internal/graphicscommand: bug fix: compile error, test failures

This commit is contained in:
Hajime Hoshi 2022-02-27 20:11:27 +09:00
parent b22309a0e5
commit 4ca1220671
2 changed files with 5 additions and 6 deletions

View File

@ -223,8 +223,7 @@ func (i *Image) Dump(path string, blackbg bool, rect image.Rectangle) error {
}
defer f.Close()
w, h := i.InternalSize()
pix := make([]byte, 4*w*h)
pix := make([]byte, 4*i.width*i.height)
if err := i.ReadPixels(pix); err != nil {
return err
}

View File

@ -53,8 +53,8 @@ func TestClear(t *testing.T) {
}
dst.DrawTriangles([graphics.ShaderImageNum]*graphicscommand.Image{src}, [graphics.ShaderImageNum - 1][2]float32{}, vs, is, affine.ColorMIdentity{}, graphicsdriver.CompositeModeClear, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, dr, graphicsdriver.Region{}, nil, nil, false)
pix, err := dst.Pixels()
if err != nil {
pix := make([]byte, 4*w*h)
if err := dst.ReadPixels(pix); err != nil {
t.Fatal(err)
}
for j := 0; j < h/2; j++ {
@ -107,8 +107,8 @@ func TestShader(t *testing.T) {
s := graphicscommand.NewShader(&ir)
dst.DrawTriangles([graphics.ShaderImageNum]*graphicscommand.Image{}, [graphics.ShaderImageNum - 1][2]float32{}, vs, is, affine.ColorMIdentity{}, graphicsdriver.CompositeModeSourceOver, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, dr, graphicsdriver.Region{}, s, nil, false)
pix, err := dst.Pixels()
if err != nil {
pix := make([]byte, 4*w*h)
if err := dst.ReadPixels(pix); err != nil {
t.Fatal(err)
}
for j := 0; j < h; j++ {