mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
internal/stroke, gpu: reuse slice when splitting cubics
When building GPU vertices from paths, we call stroke.SplitCubic once per OpCubic. Before this change, each call to stroke.SplitCubic would allocate a slice, which we would only use to iterate over. This allocation can be easily avoided by reusing the slice. We can conveniently store it in gpu.quadSplitter. In a real application that renders hundreds of paths with tens of rounded rectangles per path, this saved roughly 4500 allocations (or 1 MB worth) per frame. Signed-off-by: Dominik Honnef <dominik@honnef.co>
This commit is contained in:
committed by
Elias Naur
parent
90e57c2b18
commit
b183774063
@@ -12,6 +12,9 @@ type quadSplitter struct {
|
||||
bounds f32.Rectangle
|
||||
contour uint32
|
||||
d *drawOps
|
||||
|
||||
// scratch space used by calls to stroke.SplitCubic
|
||||
scratch []stroke.QuadSegment
|
||||
}
|
||||
|
||||
func encodeQuadTo(data []byte, meta uint32, from, ctrl, to f32.Point) {
|
||||
|
||||
Reference in New Issue
Block a user