op: change CallOp to be a return value from MacroOp.Stop

Converting

	macro := op.Record(ops)
	...
	macro.Stop()

	macro.Add()

to

	macro := op.Record(ops)
	...
	call := macro.Stop()

	call.Add(ops)

Which is more general (call.Add can take a different ops than the op.Record
that started it), and enforced the order between Stop and the subsequent Add.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-02 12:07:20 +02:00
parent ce0cc706ad
commit c19ed05342
10 changed files with 69 additions and 110 deletions
+4 -4
View File
@@ -35,12 +35,12 @@ type Path struct {
// If you need to reset the clip to its previous values after
// applying a Op, use op.StackOp.
type Op struct {
macro op.MacroOp
call op.CallOp
bounds f32.Rectangle
}
func (p Op) Add(o *op.Ops) {
p.macro.Add()
p.call.Add(o)
data := o.Write(opconst.TypeClipLen)
data[0] = byte(opconst.TypeClip)
bo := binary.LittleEndian
@@ -281,9 +281,9 @@ func (p *Path) simpleQuadTo(ctrl, to f32.Point) {
// End the path and return a clip operation that represents it.
func (p *Path) End() Op {
p.end()
p.macro.Stop()
c := p.macro.Stop()
return Op{
macro: p.macro,
call: c,
bounds: p.bounds,
}
}