mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-08 10:55:35 +00:00
ui/app/internal/gpu: add pathOp cache
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user