mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
gpu: move drawState.rect to pathOp
The rect field tracks whether the clip stack can be represented by a pixel-aligned rectangle. It is easier to track as part of pathOp instead of the global drawState. Remove an obsolete comment while here. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+22
-24
@@ -73,18 +73,15 @@ type renderer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type drawOps struct {
|
type drawOps struct {
|
||||||
profile bool
|
profile bool
|
||||||
reader ops.Reader
|
reader ops.Reader
|
||||||
states []drawState
|
states []drawState
|
||||||
cache *resourceCache
|
cache *resourceCache
|
||||||
vertCache []byte
|
vertCache []byte
|
||||||
viewport image.Point
|
viewport image.Point
|
||||||
clear bool
|
clear bool
|
||||||
clearColor f32color.RGBA
|
clearColor f32color.RGBA
|
||||||
imageOps []imageOp
|
imageOps []imageOp
|
||||||
// zimageOps are the rectangle clipped opaque images
|
|
||||||
// that can use fast front-to-back rendering with z-test
|
|
||||||
// and no blending.
|
|
||||||
pathOps []*pathOp
|
pathOps []*pathOp
|
||||||
pathOpCache []pathOp
|
pathOpCache []pathOp
|
||||||
qs quadSplitter
|
qs quadSplitter
|
||||||
@@ -95,7 +92,6 @@ type drawState struct {
|
|||||||
clip f32.Rectangle
|
clip f32.Rectangle
|
||||||
t f32.Affine2D
|
t f32.Affine2D
|
||||||
cpath *pathOp
|
cpath *pathOp
|
||||||
rect bool
|
|
||||||
|
|
||||||
matType materialType
|
matType materialType
|
||||||
// Current paint.ImageOp
|
// Current paint.ImageOp
|
||||||
@@ -112,6 +108,9 @@ type drawState struct {
|
|||||||
|
|
||||||
type pathOp struct {
|
type pathOp struct {
|
||||||
off f32.Point
|
off f32.Point
|
||||||
|
// rect tracks whether the clip stack can be represented by a
|
||||||
|
// pixel-aligned rectangle.
|
||||||
|
rect bool
|
||||||
// clip is the union of all
|
// clip is the union of all
|
||||||
// later clip rectangles.
|
// later clip rectangles.
|
||||||
clip image.Rectangle
|
clip image.Rectangle
|
||||||
@@ -830,7 +829,6 @@ func (d *drawOps) collect(root *op.Ops, viewport image.Point) {
|
|||||||
d.reader.Reset(root)
|
d.reader.Reset(root)
|
||||||
state := drawState{
|
state := drawState{
|
||||||
clip: clip,
|
clip: clip,
|
||||||
rect: true,
|
|
||||||
color: color.NRGBA{A: 0xff},
|
color: color.NRGBA{A: 0xff},
|
||||||
}
|
}
|
||||||
d.collectOps(&d.reader, state)
|
d.collectOps(&d.reader, state)
|
||||||
@@ -860,15 +858,16 @@ func (d *drawOps) addClipPath(state *drawState, aux []byte, auxKey opKey, bounds
|
|||||||
parent: state.cpath,
|
parent: state.cpath,
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
off: off,
|
off: off,
|
||||||
|
rect: npath.parent == nil || npath.parent.rect,
|
||||||
|
}
|
||||||
|
if len(aux) > 0 {
|
||||||
|
npath.rect = false
|
||||||
|
npath.pathKey = auxKey
|
||||||
|
npath.path = true
|
||||||
|
npath.pathVerts = aux
|
||||||
|
d.pathOps = append(d.pathOps, npath)
|
||||||
}
|
}
|
||||||
state.cpath = npath
|
state.cpath = npath
|
||||||
if len(aux) > 0 {
|
|
||||||
state.rect = false
|
|
||||||
state.cpath.pathKey = auxKey
|
|
||||||
state.cpath.path = true
|
|
||||||
state.cpath.pathVerts = aux
|
|
||||||
d.pathOps = append(d.pathOps, state.cpath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// split a transform into two parts, one which is pure offset and the
|
// split a transform into two parts, one which is pure offset and the
|
||||||
@@ -987,7 +986,6 @@ loop:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
wasrect := state.rect
|
|
||||||
if clipData != nil {
|
if clipData != nil {
|
||||||
// The paint operation is sheared or rotated, add a clip path representing
|
// The paint operation is sheared or rotated, add a clip path representing
|
||||||
// this transformed rectangle.
|
// this transformed rectangle.
|
||||||
@@ -999,7 +997,8 @@ loop:
|
|||||||
bounds := boundRectF(cl)
|
bounds := boundRectF(cl)
|
||||||
mat := state.materialFor(bnd, off, partialTrans, bounds)
|
mat := state.materialFor(bnd, off, partialTrans, bounds)
|
||||||
|
|
||||||
if bounds.Min == (image.Point{}) && bounds.Max == d.viewport && state.rect && mat.opaque && (mat.material == materialColor) {
|
rect := state.cpath == nil || state.cpath.rect
|
||||||
|
if bounds.Min == (image.Point{}) && bounds.Max == d.viewport && rect && mat.opaque && (mat.material == materialColor) {
|
||||||
// The image is a uniform opaque color and takes up the whole screen.
|
// The image is a uniform opaque color and takes up the whole screen.
|
||||||
// Scrap images up to and including this image and set clear color.
|
// Scrap images up to and including this image and set clear color.
|
||||||
d.imageOps = d.imageOps[:0]
|
d.imageOps = d.imageOps[:0]
|
||||||
@@ -1017,7 +1016,6 @@ loop:
|
|||||||
if clipData != nil {
|
if clipData != nil {
|
||||||
// we added a clip path that should not remain
|
// we added a clip path that should not remain
|
||||||
state.cpath = state.cpath.parent
|
state.cpath = state.cpath.parent
|
||||||
state.rect = wasrect
|
|
||||||
}
|
}
|
||||||
case opconst.TypeSave:
|
case opconst.TypeSave:
|
||||||
id := ops.DecodeSave(encOp.Data)
|
id := ops.DecodeSave(encOp.Data)
|
||||||
|
|||||||
Reference in New Issue
Block a user