diff --git a/gpu/gpu.go b/gpu/gpu.go index b68ca541..49c878ea 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -1055,6 +1055,7 @@ loop: } else { quads.aux, bounds, _ = d.boundsForTransformedRect(bounds, trans) quads.key = opKey{Key: encOp.Key} + quads.key = quads.key.SetTransform(trans) } d.addClipPath(&state, quads.aux, quads.key, bounds, off) quads = quadsOp{} @@ -1100,7 +1101,7 @@ loop: // The paint operation is sheared or rotated, add a clip path representing // this transformed rectangle. k := opKey{Key: encOp.Key} - k.SetTransform(t) // TODO: This call has no effect. + k = k.SetTransform(t) d.addClipPath(&state, clipData, k, bnd, off) } diff --git a/gpu/internal/rendertest/clip_test.go b/gpu/internal/rendertest/clip_test.go index 793b1397..381e9784 100644 --- a/gpu/internal/rendertest/clip_test.go +++ b/gpu/internal/rendertest/clip_test.go @@ -293,3 +293,20 @@ func TestStrokedRect(t *testing.T) { }, func(r result) { }) } + +func TestInstancedRects(t *testing.T) { + run(t, func(o *op.Ops) { + macro := op.Record(o) + clip := clip.Rect{Max: image.Pt(20, 20)}.Push(o) + paint.ColorOp{Color: color.NRGBA{R: 0x80, A: 0xFF}}.Add(o) + paint.PaintOp{}.Add(o) + clip.Pop() + c := macro.Stop() + + for i := 0; i < 2; i++ { + op.Affine(f32.Affine2D{}.Rotate(f32.Pt(0, 0), .2)).Add(o) + c.Add(o) + op.Offset(image.Pt(20, 20)).Add(o) + } + }, nil) +} diff --git a/gpu/internal/rendertest/refs/TestInstancedRects.png b/gpu/internal/rendertest/refs/TestInstancedRects.png new file mode 100644 index 00000000..e5f195a8 Binary files /dev/null and b/gpu/internal/rendertest/refs/TestInstancedRects.png differ