mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
op/paint: fix subimage rendering by ImageOp
This change is a follow-up to bcf3ff77ff, fixing the two renderers to
properly render images with non-zero origins.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
+3
-2
@@ -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() {
|
||||
|
||||
+2
-1
@@ -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))
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 394 B After Width: | Height: | Size: 395 B |
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user