From 652cd169b2febe0abe3ae61c59702215b3735030 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 17 Aug 2022 00:56:15 +0900 Subject: [PATCH] ebiten: revert the changes for DrawRectShader This reverts these commits: - 9bd46cb2b51882576808c7b2318a55aed3fe5c08. - f8c46340174859df21935a07ef1b363f1f67fbf4. This causes test failures on the Steam bot. See #2246. Updates #2166 Closes #2246 --- image.go | 5 ---- shader_test.go | 67 -------------------------------------------------- 2 files changed, 72 deletions(-) diff --git a/image.go b/image.go index dc136f650..22e19f0f7 100644 --- a/image.go +++ b/image.go @@ -701,11 +701,6 @@ func (i *Image) DrawRectShader(width, height int, shader *Shader, options *DrawR b := img.Bounds() sx, sy = img.adjustPosition(b.Min.X, b.Min.Y) sr = img.adjustedRegion() - } else { - sr = graphicsdriver.Region{ - Width: float32(width), - Height: float32(height), - } } if offsetX, offsetY := i.adjustPosition(0, 0); offsetX != 0 || offsetY != 0 { diff --git a/shader_test.go b/shader_test.go index c27f16b95..b081fdd39 100644 --- a/shader_test.go +++ b/shader_test.go @@ -1181,70 +1181,3 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { } } } - -// Issue #2166 -func TestShaderDrawRect(t *testing.T) { - const ( - dstW = 16 - dstH = 16 - srcW = 8 - srcH = 8 - ) - - dst := ebiten.NewImage(dstW, dstH) - src := ebiten.NewImage(srcW, srcH) - - s, err := ebiten.NewShader([]byte(`package main - -func Fragment(position vec4, texCoord vec2, color vec4) vec4 { - // Adjust texCoord into [0, 1]. - t := texCoord - origin, size := imageSrcRegionOnTexture() - t -= origin - t /= size - if t.x >= 0.5 && t.y >= 0.5 { - return vec4(1, 0, 0, 1) - } - return vec4(0, 1, 0, 1) -} -`)) - if err != nil { - t.Fatal(err) - } - - for _, withSrc := range []bool{false, true} { - withSrc := withSrc - title := "WithSrc" - if !withSrc { - title = "WithoutSrc" - } - t.Run(title, func(t *testing.T) { - const ( - offsetX = (dstW - srcW) / 2 - offsetY = (dstH - srcH) / 2 - ) - op := &ebiten.DrawRectShaderOptions{} - op.GeoM.Translate(offsetX, offsetY) - if withSrc { - op.Images[0] = src - } - dst.DrawRectShader(srcW, srcH, s, op) - for j := 0; j < dstH; j++ { - for i := 0; i < dstW; i++ { - got := dst.At(i, j).(color.RGBA) - var want color.RGBA - if offsetX <= i && i < offsetX+srcW && offsetY <= j && j < offsetY+srcH { - if offsetX+srcW/2 <= i && offsetY+srcH/2 <= j { - want = color.RGBA{0xff, 0, 0, 0xff} - } else { - want = color.RGBA{0, 0xff, 0, 0xff} - } - } - if got != want { - t.Errorf("dst.At(%d, %d): got: %v, want: %v", i, j, got, want) - } - } - } - }) - } -}