mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
gpu: build gpu data also when outside window
This commit fixes a bug where a shape first drawn off-screen and later moved into screen would not display properly. Since we cache CPU operations (vertex transform / construction) we need to upload the constructed data to the GPU after it was build, or a later frame will use non-initialized memory for it's draw call. Note that this fix removes the optimization of not processing clip paths outside the screen - but this is assumed to be uncommon except when it is first drawn off screen to later be moved in (e.g. in a scrolling list) in which case we do want to upload the data and prepare for that later call. This commit also does a few minor clean ups and adds a test case. Signed-off-by: Viktor <viktor.ogeman@gmail.com>
This commit is contained in:
+3
-2
@@ -28,8 +28,9 @@ type opCache struct {
|
||||
type opCacheValue struct {
|
||||
data pathData
|
||||
bounds f32.Rectangle
|
||||
key ops.Key
|
||||
keep bool
|
||||
// the fields below are handled by opCache
|
||||
key ops.Key
|
||||
keep bool
|
||||
}
|
||||
|
||||
func newResourceCache() *resourceCache {
|
||||
|
||||
+2
-5
@@ -706,9 +706,9 @@ func (d *drawOps) addClipPath(state *drawState, aux []byte, auxKey ops.Key, boun
|
||||
// split a transform into two parts, one which is pur offset and the
|
||||
// other representing the scaling, shearing and rotation part
|
||||
func splitTransform(t f32.Affine2D) (srs f32.Affine2D, offset f32.Point) {
|
||||
sx, hx, ox, sy, hy, oy := t.Elems()
|
||||
sx, hx, ox, hy, sy, oy := t.Elems()
|
||||
offset = f32.Point{X: ox, Y: oy}
|
||||
srs = f32.NewAffine2D(sx, hx, 0, sy, hy, 0)
|
||||
srs = f32.NewAffine2D(sx, hx, 0, hy, sy, 0)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -752,9 +752,6 @@ loop:
|
||||
auxKey.SetTransform(trans)
|
||||
}
|
||||
state.clip = state.clip.Intersect(op.bounds.Add(off))
|
||||
if state.clip.Empty() {
|
||||
continue
|
||||
}
|
||||
d.addClipPath(&state, aux, auxKey, op.bounds, off)
|
||||
aux = nil
|
||||
auxKey = ops.Key{}
|
||||
|
||||
Reference in New Issue
Block a user