ui: let OpsReader keep track of references

Instead of exposing the entire reference slice, return the relevant
references from Next.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-01 20:48:36 +02:00
parent 5966aab77e
commit 0d2cffe196
11 changed files with 166 additions and 104 deletions
+5 -5
View File
@@ -667,7 +667,7 @@ func (d *drawOps) newPathOp() *pathOp {
func (d *drawOps) collectOps(r *ui.OpsReader, state drawState) int {
loop:
for {
data, ok := r.Decode()
data, refs, ok := r.Decode()
if !ok {
break
}
@@ -678,7 +678,7 @@ loop:
state.t = state.t.Mul(op.Transform)
case ops.TypeClip:
var op gdraw.OpClip
op.Decode(data, r.Refs)
op.Decode(data, refs)
if op.Path == nil {
state.clip = f32.Rectangle{}
continue
@@ -702,17 +702,17 @@ loop:
}
case ops.TypeColor:
var op gdraw.OpColor
op.Decode(data, r.Refs)
op.Decode(data, refs)
state.img = nil
state.color = op.Col
case ops.TypeImage:
var op gdraw.OpImage
op.Decode(data, r.Refs)
op.Decode(data, refs)
state.img = op.Img
state.imgRect = op.Rect
case ops.TypeDraw:
var op gdraw.OpDraw
op.Decode(data, r.Refs)
op.Decode(data, refs)
off := state.t.Transform(f32.Point{})
clip := state.clip.Intersect(op.Rect.Add(off))
if clip.Empty() {