mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
restorable: Bug fix: Fill didn't invalidate its dependencies
Fixes #1170
This commit is contained in:
parent
982a68e5a2
commit
ca73f17dd4
@ -215,6 +215,7 @@ func quadVertices(dx0, dy0, dx1, dy1, sx0, sy0, sx1, sy1, cr, cg, cb, ca float32
|
||||
|
||||
// Fill fills the specified part of the image with a solid color.
|
||||
func (i *Image) Fill(clr color.RGBA) {
|
||||
theImages.makeStaleIfDependingOn(i)
|
||||
i.basePixels = Pixels{
|
||||
baseColor: clr,
|
||||
}
|
||||
|
@ -819,6 +819,38 @@ func TestFill(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #1170
|
||||
func TestFill2(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
src := NewImage(w, h, false)
|
||||
src.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
||||
|
||||
dst := NewImage(w, h, false)
|
||||
vs := quadVertices(w, h, 0, 0)
|
||||
is := graphics.QuadIndices()
|
||||
dst.DrawTriangles(src, vs, is, nil, driver.CompositeModeCopy, driver.FilterNearest, driver.AddressClampToZero, nil, nil)
|
||||
|
||||
// Fill src with a different color. This should not affect dst.
|
||||
src.Fill(color.RGBA{0, 0xff, 0, 0xff})
|
||||
|
||||
if err := ResolveStaleImages(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := RestoreIfNeeded(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
got := pixelsToColor(dst.BasePixelsForTesting(), i, j)
|
||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
||||
if got != want {
|
||||
t.Errorf("img.At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMutateSlices(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
dst := NewImage(w, h, false)
|
||||
|
Loading…
Reference in New Issue
Block a user