mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
gpu: [compute] move encoderState.intersect to clip state
We're about to split state into a clip stack and a transform stack. The intersect fields belongs to clip state. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+11
-7
@@ -222,9 +222,8 @@ type clipCmd struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type encoderState struct {
|
type encoderState struct {
|
||||||
relTrans f32.Affine2D
|
relTrans f32.Affine2D
|
||||||
clip *clipState
|
clip *clipState
|
||||||
intersect f32.Rectangle
|
|
||||||
|
|
||||||
paintKey
|
paintKey
|
||||||
}
|
}
|
||||||
@@ -260,6 +259,7 @@ type clipState struct {
|
|||||||
parent *clipState
|
parent *clipState
|
||||||
path []byte
|
path []byte
|
||||||
pathKey ops.Key
|
pathKey ops.Key
|
||||||
|
intersect f32.Rectangle
|
||||||
|
|
||||||
clipKey
|
clipKey
|
||||||
}
|
}
|
||||||
@@ -1694,11 +1694,16 @@ func (c *collector) addClip(state *encoderState, viewport, bounds f32.Rectangle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
absBounds := transformBounds(state.t, bounds).Bounds()
|
absBounds := transformBounds(state.t, bounds).Bounds()
|
||||||
|
intersect := absBounds
|
||||||
|
if state.clip != nil {
|
||||||
|
intersect = state.clip.intersect.Intersect(intersect)
|
||||||
|
}
|
||||||
c.clipStates = append(c.clipStates, clipState{
|
c.clipStates = append(c.clipStates, clipState{
|
||||||
parent: state.clip,
|
parent: state.clip,
|
||||||
absBounds: absBounds,
|
absBounds: absBounds,
|
||||||
path: path,
|
path: path,
|
||||||
pathKey: key,
|
pathKey: key,
|
||||||
|
intersect: intersect,
|
||||||
clipKey: clipKey{
|
clipKey: clipKey{
|
||||||
bounds: bounds,
|
bounds: bounds,
|
||||||
relTrans: state.relTrans,
|
relTrans: state.relTrans,
|
||||||
@@ -1706,7 +1711,6 @@ func (c *collector) addClip(state *encoderState, viewport, bounds f32.Rectangle,
|
|||||||
pathHash: hash,
|
pathHash: hash,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
state.intersect = state.intersect.Intersect(absBounds)
|
|
||||||
state.clip = &c.clipStates[len(c.clipStates)-1]
|
state.clip = &c.clipStates[len(c.clipStates)-1]
|
||||||
state.relTrans = f32.Affine2D{}
|
state.relTrans = f32.Affine2D{}
|
||||||
}
|
}
|
||||||
@@ -1715,7 +1719,6 @@ func (c *collector) collect(root *op.Ops, viewport image.Point, texOps *[]textur
|
|||||||
fview := f32.Rectangle{Max: layout.FPt(viewport)}
|
fview := f32.Rectangle{Max: layout.FPt(viewport)}
|
||||||
c.reader.Reset(root)
|
c.reader.Reset(root)
|
||||||
state := encoderState{
|
state := encoderState{
|
||||||
intersect: fview,
|
|
||||||
paintKey: paintKey{
|
paintKey: paintKey{
|
||||||
color: color.NRGBA{A: 0xff},
|
color: color.NRGBA{A: 0xff},
|
||||||
},
|
},
|
||||||
@@ -1776,7 +1779,8 @@ func (c *collector) collect(root *op.Ops, viewport image.Point, texOps *[]textur
|
|||||||
bounds := paintState.image.src.Bounds()
|
bounds := paintState.image.src.Bounds()
|
||||||
c.addClip(&paintState, fview, layout.FRect(bounds), nil, ops.Key{}, 0, clip.StrokeStyle{})
|
c.addClip(&paintState, fview, layout.FRect(bounds), nil, ops.Key{}, 0, clip.StrokeStyle{})
|
||||||
}
|
}
|
||||||
if paintState.intersect.Empty() {
|
intersect := paintState.clip.intersect
|
||||||
|
if intersect.Empty() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1810,7 +1814,7 @@ func (c *collector) collect(root *op.Ops, viewport image.Point, texOps *[]textur
|
|||||||
c.frame.ops = append(c.frame.ops, paintOp{
|
c.frame.ops = append(c.frame.ops, paintOp{
|
||||||
clipStack: clipStack,
|
clipStack: clipStack,
|
||||||
state: paintState.paintKey,
|
state: paintState.paintKey,
|
||||||
intersect: paintState.intersect,
|
intersect: intersect,
|
||||||
})
|
})
|
||||||
case opconst.TypeSave:
|
case opconst.TypeSave:
|
||||||
id := ops.DecodeSave(encOp.Data)
|
id := ops.DecodeSave(encOp.Data)
|
||||||
|
|||||||
Reference in New Issue
Block a user