mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
op,internal/ops: support CallOps without macros
A recorded macro is prefixed with an internal macro op that stores
the end of the macro. The end is used to efficiently skip the macro
when not calling it. The call a macro, the CallOp stores the start
position of the macro.
To support seamless wrapping of Ops lists, this change removes the
dependency on the macro op prefix from CallOp. Internal code can
now call an Ops like this:
var ops op.Ops
var wrapper op.Ops
ops.AddCall(&wrapper.Internal, &ops.Internal, ops.PC{}, ops.PCFor(&ops.Internal))
References: https://todo.sr.ht/~eliasnaur/gio/318
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -92,8 +92,9 @@ type MacroOp struct {
|
||||
// CallOp invokes the operations recorded by Record.
|
||||
type CallOp struct {
|
||||
// Ops is the list of operations to invoke.
|
||||
ops *ops.Ops
|
||||
pc ops.PC
|
||||
ops *ops.Ops
|
||||
start ops.PC
|
||||
end ops.PC
|
||||
}
|
||||
|
||||
// InvalidateOp requests a redraw at the given time. Use
|
||||
@@ -165,7 +166,9 @@ func (m MacroOp) Stop() CallOp {
|
||||
ops.FillMacro(m.ops, m.pc)
|
||||
return CallOp{
|
||||
ops: m.ops,
|
||||
pc: m.pc,
|
||||
// Skip macro header.
|
||||
start: m.pc.Add(ops.TypeMacro),
|
||||
end: ops.PCFor(m.ops),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +179,7 @@ func (c CallOp) Add(o *Ops) {
|
||||
if c.ops == nil {
|
||||
return
|
||||
}
|
||||
ops.AddCall(&o.Internal, c.ops, c.pc)
|
||||
ops.AddCall(&o.Internal, c.ops, c.start, c.end)
|
||||
}
|
||||
|
||||
func (r InvalidateOp) Add(o *Ops) {
|
||||
|
||||
Reference in New Issue
Block a user