graphicscommand: Bug fix: Do not assure the initial state of the image

This commit is contained in:
Hajime Hoshi 2018-12-23 01:18:05 +09:00
parent 4d0cc623fb
commit bf67998fc5

View File

@ -46,34 +46,12 @@ func TestClear(t *testing.T) {
const w, h = 1024, 1024 const w, h = 1024, 1024
src := NewImage(w/2, h/2) src := NewImage(w/2, h/2)
dst := NewImage(w, h) dst := NewImage(w, h)
pix := dst.Pixels()
for j := 0; j < h/2; j++ {
for i := 0; i < w/2; i++ {
idx := 4 * (i + w*j)
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
want := color.RGBA{}
if got != want {
t.Errorf("dst.At(%d, %d): got %v, want: %v", i, j, got, want)
}
}
}
pix = src.Pixels()
for j := 0; j < h/2; j++ {
for i := 0; i < w/2; i++ {
idx := 4 * (i + (w/2)*j)
got := color.RGBA{pix[idx], pix[idx+1], pix[idx+2], pix[idx+3]}
want := color.RGBA{}
if got != want {
t.Errorf("src.At(%d, %d): got %v, want: %v", i, j, got, want)
}
}
}
vs := graphics.QuadVertices(w/2, h/2, 0, 0, w/2, h/2, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1) vs := graphics.QuadVertices(w/2, h/2, 0, 0, w/2, h/2, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
is := graphics.QuadIndices() is := graphics.QuadIndices()
dst.DrawImage(src, vs, is, nil, graphics.CompositeModeClear, graphics.FilterNearest) dst.DrawImage(src, vs, is, nil, graphics.CompositeModeClear, graphics.FilterNearest)
pix = dst.Pixels() pix := dst.Pixels()
for j := 0; j < h/2; j++ { for j := 0; j < h/2; j++ {
for i := 0; i < w/2; i++ { for i := 0; i < w/2; i++ {
idx := 4 * (i + w*j) idx := 4 * (i + w*j)