From 642318842c7027349594eefb450fdd112404ce9a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 16 May 2019 21:16:36 +0200 Subject: [PATCH] ui/app/internal/gpu: add pathOp cache Signed-off-by: Elias Naur --- ui/app/internal/gpu/gpu.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/app/internal/gpu/gpu.go b/ui/app/internal/gpu/gpu.go index 847c0f74..63d754e7 100644 --- a/ui/app/internal/gpu/gpu.go +++ b/ui/app/internal/gpu/gpu.go @@ -63,8 +63,9 @@ type drawOps struct { // zimageOps are the rectangle clipped opaque images // that can use fast front-to-back rendering with z-test // and no blending. - zimageOps []imageOp - pathOps []*pathOp + zimageOps []imageOp + pathOps []*pathOp + pathOpCache []pathOp } type drawState struct { @@ -633,6 +634,7 @@ func (d *drawOps) reset(cache *resourceCache, viewport image.Point) { d.imageOps = d.imageOps[:0] d.zimageOps = d.zimageOps[:0] d.pathOps = d.pathOps[:0] + d.pathOpCache = d.pathOpCache[:0] } func (d *drawOps) collect(cache *resourceCache, root *ui.Ops, viewport image.Point) { @@ -644,6 +646,11 @@ func (d *drawOps) collect(cache *resourceCache, root *ui.Ops, viewport image.Poi d.collectOps(&d.reader, clip, ui.Transform{}, nil, true, 0) } +func (d *drawOps) newPathOp() *pathOp { + d.pathOpCache = append(d.pathOpCache, pathOp{}) + return &d.pathOpCache[len(d.pathOpCache)-1] +} + func (d *drawOps) collectOps(r *ops.Reader, clip f32.Rectangle, t ui.Transform, cpath *pathOp, rect bool, z int) int { loop: for { @@ -669,10 +676,12 @@ loop: if clip.Empty() { continue } - cpath = &pathOp{ + npath := d.newPathOp() + *npath = pathOp{ parent: cpath, off: off, } + cpath = npath if len(data.Vertices) > 0 { rect = false cpath.path = data