diff --git a/gpu/gpu.go b/gpu/gpu.go index 48a6334d..321b2a89 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -768,7 +768,7 @@ loop: // the new bounding rectangle and the transformed original paint rectangle. trans, off := splitTransform(state.t) clipData, bnd, partialTrans := d.boundsForTransformedRect(op.Rect, trans) - clip := state.clip.Intersect(bnd.Add(off)).Canon() + clip := state.clip.Intersect(bnd.Add(off)) if clip.Empty() { continue } diff --git a/internal/rendertest/refs/TestNegativeOverlaps.png b/internal/rendertest/refs/TestNegativeOverlaps.png new file mode 100644 index 00000000..9ed91358 Binary files /dev/null and b/internal/rendertest/refs/TestNegativeOverlaps.png differ diff --git a/internal/rendertest/render_test.go b/internal/rendertest/render_test.go index 089ab24c..1078f492 100644 --- a/internal/rendertest/render_test.go +++ b/internal/rendertest/render_test.go @@ -182,3 +182,15 @@ func TestBuildOffscreen(t *testing.T) { r.expect(38, 38, colornames.White) })) } + +func TestNegativeOverlaps(t *testing.T) { + run(t, func(ops *op.Ops) { + clip.Rect{Rect: f32.Rect(50, 50, 100, 100)}.Add(ops) + paint.PaintOp{Rect: f32.Rect(0, 120, 100, 122)}.Add(ops) + }, func(r result) { + r.expect(60, 60, colornames.White) + r.expect(60, 110, colornames.White) + r.expect(60, 120, colornames.White) + r.expect(60, 122, colornames.White) + }) +}