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 0c78d3ba..55552d7d 100644 Binary files a/gpu/internal/rendertest/refs/TestImageRGBA.png and b/gpu/internal/rendertest/refs/TestImageRGBA.png differ diff --git a/gpu/internal/rendertest/render_test.go b/gpu/internal/rendertest/render_test.go index b5bea43a..9ba14799 100644 --- a/gpu/internal/rendertest/render_test.go +++ b/gpu/internal/rendertest/render_test.go @@ -339,10 +339,10 @@ func TestImageRGBA(t *testing.T) { w := newWindow(t, 10, 10) im := image.NewRGBA(image.Rect(0, 0, 5, 5)) - im.Set(3, 3, colornames.Black) - im.Set(4, 3, colornames.Black) - im.Set(3, 4, colornames.Black) - im.Set(4, 4, colornames.Black) + im.Set(3, 3, colornames.Red) + im.Set(4, 3, colornames.Red) + im.Set(3, 4, colornames.Red) + im.Set(4, 4, colornames.Red) im = im.SubImage(image.Rect(2, 2, 5, 5)).(*image.RGBA) paint.NewImageOp(im).Add(o) paint.PaintOp{}.Add(o) @@ -350,10 +350,10 @@ func TestImageRGBA(t *testing.T) { t.Error(err) } }, func(r result) { - r.expect(1, 1, colornames.Black) - r.expect(2, 1, colornames.Black) - r.expect(1, 2, colornames.Black) - r.expect(2, 2, colornames.Black) + r.expect(1, 1, colornames.Red) + r.expect(2, 1, colornames.Red) + r.expect(1, 2, colornames.Red) + r.expect(2, 2, colornames.Red) }) }