ui/app/internal/gpu: add pathOp cache

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-05-16 21:16:36 +02:00
parent 4513d109b1
commit 642318842c
+10 -1
View File
@@ -65,6 +65,7 @@ type drawOps struct {
// and no blending. // and no blending.
zimageOps []imageOp zimageOps []imageOp
pathOps []*pathOp pathOps []*pathOp
pathOpCache []pathOp
} }
type drawState struct { type drawState struct {
@@ -633,6 +634,7 @@ func (d *drawOps) reset(cache *resourceCache, viewport image.Point) {
d.imageOps = d.imageOps[:0] d.imageOps = d.imageOps[:0]
d.zimageOps = d.zimageOps[:0] d.zimageOps = d.zimageOps[:0]
d.pathOps = d.pathOps[:0] d.pathOps = d.pathOps[:0]
d.pathOpCache = d.pathOpCache[:0]
} }
func (d *drawOps) collect(cache *resourceCache, root *ui.Ops, viewport image.Point) { 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) 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 { func (d *drawOps) collectOps(r *ops.Reader, clip f32.Rectangle, t ui.Transform, cpath *pathOp, rect bool, z int) int {
loop: loop:
for { for {
@@ -669,10 +676,12 @@ loop:
if clip.Empty() { if clip.Empty() {
continue continue
} }
cpath = &pathOp{ npath := d.newPathOp()
*npath = pathOp{
parent: cpath, parent: cpath,
off: off, off: off,
} }
cpath = npath
if len(data.Vertices) > 0 { if len(data.Vertices) > 0 {
rect = false rect = false
cpath.path = data cpath.path = data