From 9d05f353418235331f9a1b8d48a2187449e2ecaf Mon Sep 17 00:00:00 2001 From: Pierre Curto Date: Wed, 10 Nov 2021 22:18:59 +0100 Subject: [PATCH] op/paint: fix subimage rendering by ImageOp This change is a follow-up to bcf3ff77ff15, fixing the two renderers to properly render images with non-zero origins. Signed-off-by: Pierre Curto --- gpu/compute.go | 5 +++-- gpu/gpu.go | 3 ++- gpu/internal/rendertest/refs/TestImageRGBA.png | Bin 394 -> 395 bytes gpu/internal/rendertest/render_test.go | 16 ++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gpu/compute.go b/gpu/compute.go index 03265220..ce06add5 100644 --- a/gpu/compute.go +++ b/gpu/compute.go @@ -1802,8 +1802,9 @@ func (c *collector) collect(root *op.Ops, viewport image.Point, texOps *[]textur paintState := state if paintState.matType == materialTexture { // Clip to the bounds of the image, to hide other images in the atlas. - bounds := paintState.image.src.Bounds() - c.addClip(&paintState, fview, layout.FRect(bounds), nil, ops.Key{}, 0, 0, false) + sz := state.image.src.Rect.Size() + bounds := f32.Rectangle{Max: layout.FPt(sz)} + c.addClip(&paintState, fview, bounds, nil, ops.Key{}, 0, 0, false) } intersect := paintState.clip.intersect if intersect.Empty() { diff --git a/gpu/gpu.go b/gpu/gpu.go index 3179fd8e..c07e3f8c 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -955,7 +955,8 @@ loop: inf := float32(1e6) dst := f32.Rect(-inf, -inf, inf, inf) if state.matType == materialTexture { - dst = layout.FRect(state.image.src.Rect) + sz := state.image.src.Rect.Size() + dst = f32.Rectangle{Max: layout.FPt(sz)} } clipData, bnd, partialTrans := d.boundsForTransformedRect(dst, t) cl := viewport.Intersect(bnd.Add(off)) diff --git a/gpu/internal/rendertest/refs/TestImageRGBA.png b/gpu/internal/rendertest/refs/TestImageRGBA.png index 0c78d3ba724acbaeea1bb32b6f22a6b4ce072cbc..55552d7d53d4200ad11daeb19230fc96d3c49679 100644 GIT binary patch delta 80 zcmV-W0I&aw1B(NYBq&lzL_t(|ob1#=2>>t*1i?`Mo>Pd8o%x)B<=&8X0qo4~4K*GB m$~=*v(2<{28n_<-0RR7Q76ki+^e=e;0000