Unintuitive Optimization: Speeding Up Path Unions in Skia
2025-01-01
The author encountered performance bottlenecks when performing path union operations on a large number of vector graphics paths using Skia. The initial naive approach of iteratively uniting paths was slow, and while Skia's path builder offered optimization, it wasn't fast enough. Deep diving into Skia's path operation internals revealed that the number of curves in each path significantly impacted performance. By dividing the path union into smaller intervals and recursively applying a divide-and-conquer strategy, the author achieved a significant speedup, ultimately surpassing Skia's default method. Surprisingly, increasing the number of union operations through this method resulted in faster processing.