gpu: fix negative intersections

Fixes a bug due to that f32.Rect.Intersect will not return the
empty rectangle for non intersecting rectangles - but instead
a swapped rectangle. By removing the .Canon() call in gpu.go we
ensure that non overlapping clipping rects and paint rects will
lead to no painting.

The Canon() call is not needed since boundsForTransformedRect()
was previously updated to always return a canonical rectangle.

Test case added.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
This commit is contained in:
Viktor Ogeman
2020-06-25 13:14:38 +02:00
committed by Elias Naur
parent 5bd0ecea5e
commit 7ff17453dd
3 changed files with 13 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

+12
View File
@@ -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)
})
}