From 4ca1220671add047bfa047bd71fc1a6df8764ac8 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 27 Feb 2022 20:11:27 +0900 Subject: [PATCH] internal/graphicscommand: bug fix: compile error, test failures --- internal/graphicscommand/image.go | 3 +-- internal/graphicscommand/image_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/graphicscommand/image.go b/internal/graphicscommand/image.go index 450c5674f..33c9bbdc4 100644 --- a/internal/graphicscommand/image.go +++ b/internal/graphicscommand/image.go @@ -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 } diff --git a/internal/graphicscommand/image_test.go b/internal/graphicscommand/image_test.go index 6069579be..22e2a50c9 100644 --- a/internal/graphicscommand/image_test.go +++ b/internal/graphicscommand/image_test.go @@ -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++ {