buffered: Bug fix: Pixel data was not invalidated after DrawImage/Triangles

This commit is contained in:
Hajime Hoshi 2020-06-25 13:11:19 +09:00
parent 4a7929cf71
commit 198621404f
2 changed files with 26 additions and 0 deletions

View File

@ -2172,3 +2172,27 @@ func TestImageFloatTranslate(t *testing.T) {
})
}
}
// Issue #1213
func TestImageColorMCopy(t *testing.T) {
const w, h = 16, 16
dst, _ := NewImage(w, h, FilterDefault)
src, _ := NewImage(w, h, FilterDefault)
for k := 0; k < 256; k++ {
op := &DrawImageOptions{}
op.ColorM.Translate(float64(k)/0xff, 1, 1, 1)
op.CompositeMode = CompositeModeCopy
dst.DrawImage(src, op)
for j := 0; j < h; j++ {
for i := 0; i < w; i++ {
got := dst.At(i, j).(color.RGBA)
want := color.RGBA{byte(k), 0xff, 0xff, 0xff}
if !sameColors(got, want, 1) {
t.Fatalf("dst.At(%d, %d), k: %d: got %v, want %v", i, j, k, got, want)
}
}
}
}
}

View File

@ -275,6 +275,7 @@ func (i *Image) drawImage(src *Image, bounds image.Rectangle, g mipmap.GeoM, col
src.resolvePendingPixels(true)
i.resolvePendingPixels(false)
i.img.DrawImage(src.img, bounds, g, colorm, mode, filter)
i.invalidatePendingPixels()
}
// DrawTriangles draws the src image with the given vertices.
@ -329,6 +330,7 @@ func (i *Image) DrawTriangles(src *Image, vertices []float32, indices []uint16,
srcImg = src.img
}
i.img.DrawTriangles(srcImg, vertices, indices, colorm, mode, filter, address, s, us)
i.invalidatePendingPixels()
}
type Shader struct {