~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] gpu: fix negative intersections

Details
Message ID
<20200625111438.10004-1-viktor.ogeman@gmail.com>
DKIM signature
missing
Download raw message
Patch: +13 -1
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>
---
 gpu/gpu.go                                        |   2 +-
 internal/rendertest/refs/TestNegativeOverlaps.png | Bin 0 -> 364 bytes
 internal/rendertest/render_test.go                |  12 ++++++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 internal/rendertest/refs/TestNegativeOverlaps.png

diff --git a/gpu/gpu.go b/gpu/gpu.go
index 48a6334..321b2a8 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 0000000000000000000000000000000000000000..9ed91358c5102f5423f4aee5bc3e241445ea011c
GIT binary patch
literal 364
zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1SEZ8zRh7^U^Mo0aSW-L^X6h8=K%wTqX!IM
z-T$<@=XZvmqeA*^@#ohW*Jm?aV_3r&!MuSjf%kw^gDJxZ7RUnz-2eZJSXdY~s>`MV
OISihzelF{r5}E+9Ep1l-

literal 0
HcmV?d00001

diff --git a/internal/rendertest/render_test.go b/internal/rendertest/render_test.go
index 089ab24..1078f49 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)
	})
}
-- 
2.25.2
Details
Message ID
<C3Q8FAHUBYBS.15BR1ZDCFL9GY@testmac>
In-Reply-To
<20200625111438.10004-1-viktor.ogeman@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Thanks, merged.
Review patch Export thread (mbox)