mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 16:06:19 +00:00
op: rename StackOp/Push/Pop to StateOp/Save/Load
The semantics were relaxed in a previous commit; this change renames to operations accordingly. API change. Use gofmt to adjust your code accordingly: gofmt -r 'op.Push(a).Pop() -> op.Save(a).Load()' gofmt -r 'op.Push(a) -> op.Save(a)' gofmt -r 'v.Pop() -> v.Load()' gofmt -r 'op.StackOp -> op.StateOp' Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -82,13 +82,13 @@ func BenchmarkDrawUI(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
resetOps(gtx)
|
||||
|
||||
p := op.Push(gtx.Ops)
|
||||
p := op.Save(gtx.Ops)
|
||||
off := float32(math.Mod(float64(i)/10, 10))
|
||||
op.Offset(f32.Pt(off, off)).Add(gtx.Ops)
|
||||
|
||||
drawCore(gtx, th)
|
||||
|
||||
p.Pop()
|
||||
p.Load()
|
||||
w.Frame(gtx.Ops)
|
||||
}
|
||||
finishBenchmark(b, w)
|
||||
@@ -104,14 +104,14 @@ func BenchmarkDrawUITransformed(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
resetOps(gtx)
|
||||
|
||||
p := op.Push(gtx.Ops)
|
||||
p := op.Save(gtx.Ops)
|
||||
angle := float32(math.Mod(float64(i)/1000, 0.05))
|
||||
a := f32.Affine2D{}.Shear(f32.Point{}, angle, angle).Rotate(f32.Point{}, angle)
|
||||
op.Affine(a).Add(gtx.Ops)
|
||||
|
||||
drawCore(gtx, th)
|
||||
|
||||
p.Pop()
|
||||
p.Load()
|
||||
w.Frame(gtx.Ops)
|
||||
}
|
||||
finishBenchmark(b, w)
|
||||
@@ -153,7 +153,7 @@ func Benchmark1000CirclesInstanced(b *testing.B) {
|
||||
func draw1000Circles(gtx layout.Context) {
|
||||
ops := gtx.Ops
|
||||
for x := 0; x < 100; x++ {
|
||||
p := op.Push(ops)
|
||||
p := op.Save(ops)
|
||||
op.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
for y := 0; y < 10; y++ {
|
||||
paint.FillShape(ops,
|
||||
@@ -162,7 +162,7 @@ func draw1000Circles(gtx layout.Context) {
|
||||
)
|
||||
op.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
}
|
||||
p.Pop()
|
||||
p.Load()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,16 +175,16 @@ func draw1000CirclesInstanced(gtx layout.Context) {
|
||||
c := r.Stop()
|
||||
|
||||
for x := 0; x < 100; x++ {
|
||||
p := op.Push(ops)
|
||||
p := op.Save(ops)
|
||||
op.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
for y := 0; y < 10; y++ {
|
||||
pi := op.Push(ops)
|
||||
pi := op.Save(ops)
|
||||
paint.ColorOp{Color: color.NRGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120}}.Add(ops)
|
||||
c.Add(ops)
|
||||
pi.Pop()
|
||||
pi.Load()
|
||||
op.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
}
|
||||
p.Pop()
|
||||
p.Load()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ func drawIndividualShapes(gtx layout.Context, th *material.Theme) chan op.CallOp
|
||||
ops := &op1
|
||||
c := op.Record(ops)
|
||||
for x := 0; x < 9; x++ {
|
||||
p := op.Push(ops)
|
||||
p := op.Save(ops)
|
||||
op.Offset(f32.Pt(float32(x*50), 0)).Add(ops)
|
||||
for y := 0; y < 9; y++ {
|
||||
paint.FillShape(ops,
|
||||
@@ -213,7 +213,7 @@ func drawIndividualShapes(gtx layout.Context, th *material.Theme) chan op.CallOp
|
||||
)
|
||||
op.Offset(f32.Pt(0, float32(50))).Add(ops)
|
||||
}
|
||||
p.Pop()
|
||||
p.Load()
|
||||
}
|
||||
c1 <- c.Stop()
|
||||
}()
|
||||
@@ -235,10 +235,10 @@ func drawShapeInstances(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
rad := float32(0)
|
||||
for x := 0; x < 20; x++ {
|
||||
for y := 0; y < 20; y++ {
|
||||
p := op.Push(ops)
|
||||
p := op.Save(ops)
|
||||
op.Offset(f32.Pt(float32(x*50+25), float32(y*50+25))).Add(ops)
|
||||
c.Add(ops)
|
||||
p.Pop()
|
||||
p.Load()
|
||||
rad += math.Pi * 2 / 400
|
||||
}
|
||||
}
|
||||
@@ -256,11 +256,11 @@ func drawText(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
txt := material.H6(th, "")
|
||||
for x := 0; x < 40; x++ {
|
||||
txt.Text = textRows[x]
|
||||
p := op.Push(ops)
|
||||
p := op.Save(ops)
|
||||
op.Offset(f32.Pt(float32(0), float32(24*x))).Add(ops)
|
||||
gtx.Ops = ops
|
||||
txt.Layout(gtx)
|
||||
p.Pop()
|
||||
p.Load()
|
||||
}
|
||||
c3 <- c.Stop()
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user