mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 08:25:34 +00:00
op: change Defer to only restore transformation state
It turns out restoring all operation state from the moment Defer is executed is too much; for example, a right-click pop-up needs the transformation, but not the current clip. Change Defer to only restore the transformation, and reset all other state. Other combinations may be needed in future; we'll deal with them then, possibly by exposing the load state mask. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -107,13 +107,17 @@ func TestDeferredPaint(t *testing.T) {
|
||||
run(t, func(o *op.Ops) {
|
||||
state := op.Save(o)
|
||||
clip.Rect(image.Rect(0, 0, 80, 80)).Op().Add(o)
|
||||
paint.ColorOp{Color: color.NRGBA{A: 0xff, R: 0xff}}.Add(o)
|
||||
paint.ColorOp{Color: color.NRGBA{A: 0xff, G: 0xff}}.Add(o)
|
||||
paint.PaintOp{}.Add(o)
|
||||
|
||||
op.Affine(f32.Affine2D{}.Offset(f32.Pt(20, 20))).Add(o)
|
||||
m := op.Record(o)
|
||||
clip.Rect(image.Rect(0, 0, 80, 80)).Op().Add(o)
|
||||
paint.ColorOp{Color: color.NRGBA{A: 0xff, R: 0xff, G: 0xff}}.Add(o)
|
||||
paint.PaintOp{}.Add(o)
|
||||
paintMacro := m.Stop()
|
||||
op.Defer(o, paintMacro)
|
||||
paint.ColorOp{Color: color.NRGBA{A: 0xff, G: 0xff}}.Add(o)
|
||||
paint.PaintOp{}.Add(o)
|
||||
|
||||
state.Load()
|
||||
op.Affine(f32.Affine2D{}.Offset(f32.Pt(10, 10))).Add(o)
|
||||
clip.Rect(image.Rect(0, 0, 80, 80)).Op().Add(o)
|
||||
|
||||
Reference in New Issue
Block a user