From 80a7315c3400b011a0f89e63aca73031a9073c9a Mon Sep 17 00:00:00 2001 From: ryomak Date: Wed, 28 Jun 2023 22:06:38 +0900 Subject: [PATCH] image/draw: replace deprecated image.ZP and image.ZR in xx_test.go Change-Id: I87545a46e5871452075152b4c99ba85089ef86b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/506735 TryBot-Result: Gopher Robot Reviewed-by: Heschi Kreinick Run-TryBot: Bryan Mills Auto-Submit: Ian Lance Taylor Reviewed-by: Bryan Mills --- src/image/draw/bench_test.go | 2 +- src/image/draw/clip_test.go | 64 +++++++++++++++++----------------- src/image/draw/draw_test.go | 18 +++++----- src/image/draw/example_test.go | 2 +- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/image/draw/bench_test.go b/src/image/draw/bench_test.go index 55d25b8596..956f4ef971 100644 --- a/src/image/draw/bench_test.go +++ b/src/image/draw/bench_test.go @@ -186,7 +186,7 @@ func bench(b *testing.B, dcm, scm, mcm color.Model, op Op) { x := 3 * i % (dstw - srcw) y := 7 * i % (dsth - srch) - DrawMask(dst, dst.Bounds().Add(image.Pt(x, y)), src, image.ZP, mask, image.ZP, op) + DrawMask(dst, dst.Bounds().Add(image.Pt(x, y)), src, image.Point{}, mask, image.Point{}, op) } } diff --git a/src/image/draw/clip_test.go b/src/image/draw/clip_test.go index 0abf53e5c7..7bbbf7e9f9 100644 --- a/src/image/draw/clip_test.go +++ b/src/image/draw/clip_test.go @@ -25,104 +25,104 @@ var clipTests = []clipTest{ image.Rect(0, 0, 100, 100), image.Rect(0, 0, 100, 100), image.Rect(0, 0, 100, 100), - image.ZR, - image.ZP, - image.ZP, + image.Rectangle{}, + image.Point{}, + image.Point{}, true, image.Rect(0, 0, 100, 100), - image.ZP, - image.ZP, + image.Point{}, + image.Point{}, }, { "clip dr", image.Rect(0, 0, 100, 100), image.Rect(40, 40, 60, 60), image.Rect(0, 0, 100, 100), - image.ZR, - image.ZP, - image.ZP, + image.Rectangle{}, + image.Point{}, + image.Point{}, true, image.Rect(40, 40, 60, 60), image.Pt(40, 40), - image.ZP, + image.Point{}, }, { "clip sr", image.Rect(0, 0, 100, 100), image.Rect(0, 0, 100, 100), image.Rect(20, 20, 80, 80), - image.ZR, - image.ZP, - image.ZP, + image.Rectangle{}, + image.Point{}, + image.Point{}, true, image.Rect(20, 20, 80, 80), image.Pt(20, 20), - image.ZP, + image.Point{}, }, { "clip dr and sr", image.Rect(0, 0, 100, 100), image.Rect(0, 0, 50, 100), image.Rect(20, 20, 80, 80), - image.ZR, - image.ZP, - image.ZP, + image.Rectangle{}, + image.Point{}, + image.Point{}, true, image.Rect(20, 20, 50, 80), image.Pt(20, 20), - image.ZP, + image.Point{}, }, { "clip dr and sr, sp outside sr (top-left)", image.Rect(0, 0, 100, 100), image.Rect(0, 0, 50, 100), image.Rect(20, 20, 80, 80), - image.ZR, + image.Rectangle{}, image.Pt(15, 8), - image.ZP, + image.Point{}, true, image.Rect(5, 12, 50, 72), image.Pt(20, 20), - image.ZP, + image.Point{}, }, { "clip dr and sr, sp outside sr (middle-left)", image.Rect(0, 0, 100, 100), image.Rect(0, 0, 50, 100), image.Rect(20, 20, 80, 80), - image.ZR, + image.Rectangle{}, image.Pt(15, 66), - image.ZP, + image.Point{}, true, image.Rect(5, 0, 50, 14), image.Pt(20, 66), - image.ZP, + image.Point{}, }, { "clip dr and sr, sp outside sr (bottom-left)", image.Rect(0, 0, 100, 100), image.Rect(0, 0, 50, 100), image.Rect(20, 20, 80, 80), - image.ZR, + image.Rectangle{}, image.Pt(15, 91), - image.ZP, + image.Point{}, true, - image.ZR, + image.Rectangle{}, image.Pt(15, 91), - image.ZP, + image.Point{}, }, { "clip dr and sr, sp inside sr", image.Rect(0, 0, 100, 100), image.Rect(0, 0, 50, 100), image.Rect(20, 20, 80, 80), - image.ZR, + image.Rectangle{}, image.Pt(44, 33), - image.ZP, + image.Point{}, true, image.Rect(0, 0, 36, 47), image.Pt(44, 33), - image.ZP, + image.Point{}, }, // The following tests all have a non-nil mask. @@ -132,8 +132,8 @@ var clipTests = []clipTest{ image.Rect(20, 0, 100, 80), image.Rect(0, 0, 50, 49), image.Rect(0, 0, 46, 47), - image.ZP, - image.ZP, + image.Point{}, + image.Point{}, false, image.Rect(20, 0, 46, 47), image.Pt(20, 0), diff --git a/src/image/draw/draw_test.go b/src/image/draw/draw_test.go index a34d1c3e6e..ff9e71daab 100644 --- a/src/image/draw/draw_test.go +++ b/src/image/draw/draw_test.go @@ -13,7 +13,7 @@ import ( "testing/quick" ) -// slowestRGBA is a draw.Image like image.RGBA but it is a different type and +// slowestRGBA is a draw.Image like image.RGBA, but it is a different type and // therefore does not trigger the draw.go fastest code paths. // // Unlike slowerRGBA, it does not implement the draw.RGBA64Image interface. @@ -484,7 +484,7 @@ func TestDraw(t *testing.T) { } // Draw the (src, mask, op) onto a copy of dst using a slow but obviously correct implementation. - golden := makeGolden(dst, image.Rect(0, 0, 16, 16), test.src, image.ZP, test.mask, image.ZP, test.op) + golden := makeGolden(dst, image.Rect(0, 0, 16, 16), test.src, image.Point{}, test.mask, image.Point{}, test.op) b := dst.Bounds() if !b.Eq(golden.Bounds()) { t.Errorf("draw %v %s on %T: bounds %v versus %v", @@ -492,7 +492,7 @@ func TestDraw(t *testing.T) { continue } // Draw the same combination onto the actual dst using the optimized DrawMask implementation. - DrawMask(dst, image.Rect(0, 0, 16, 16), test.src, image.ZP, test.mask, image.ZP, test.op) + DrawMask(dst, image.Rect(0, 0, 16, 16), test.src, image.Point{}, test.mask, image.Point{}, test.op) if image.Pt(8, 8).In(r) { // Check that the resultant pixel at (8, 8) matches what we expect // (the expected value can be verified by hand). @@ -527,13 +527,13 @@ func TestDrawOverlap(t *testing.T) { src := m.SubImage(image.Rect(5+xoff, 5+yoff, 10+xoff, 10+yoff)).(*image.RGBA) b := dst.Bounds() // Draw the (src, mask, op) onto a copy of dst using a slow but obviously correct implementation. - golden := makeGolden(dst, b, src, src.Bounds().Min, nil, image.ZP, op) + golden := makeGolden(dst, b, src, src.Bounds().Min, nil, image.Point{}, op) if !b.Eq(golden.Bounds()) { t.Errorf("drawOverlap xoff=%d,yoff=%d: bounds %v versus %v", xoff, yoff, dst.Bounds(), golden.Bounds()) continue } // Draw the same combination onto the actual dst using the optimized DrawMask implementation. - DrawMask(dst, b, src, src.Bounds().Min, nil, image.ZP, op) + DrawMask(dst, b, src, src.Bounds().Min, nil, image.Point{}, op) // Check that the resultant dst image matches the golden output. for y := b.Min.Y; y < b.Max.Y; y++ { for x := b.Min.X; x < b.Max.X; x++ { @@ -596,7 +596,7 @@ func TestFill(t *testing.T) { // Draw 1 pixel at a time. for y := b.Min.Y; y < b.Max.Y; y++ { for x := b.Min.X; x < b.Max.X; x++ { - DrawMask(m, image.Rect(x, y, x+1, y+1), src, image.ZP, nil, image.ZP, Src) + DrawMask(m, image.Rect(x, y, x+1, y+1), src, image.Point{}, nil, image.Point{}, Src) } } check("pixel") @@ -604,20 +604,20 @@ func TestFill(t *testing.T) { c = color.RGBA{0, 22, 0, 255} src = &image.Uniform{C: c} for y := b.Min.Y; y < b.Max.Y; y++ { - DrawMask(m, image.Rect(b.Min.X, y, b.Max.X, y+1), src, image.ZP, nil, image.ZP, Src) + DrawMask(m, image.Rect(b.Min.X, y, b.Max.X, y+1), src, image.Point{}, nil, image.Point{}, Src) } check("row") // Draw 1 column at a time. c = color.RGBA{0, 0, 33, 255} src = &image.Uniform{C: c} for x := b.Min.X; x < b.Max.X; x++ { - DrawMask(m, image.Rect(x, b.Min.Y, x+1, b.Max.Y), src, image.ZP, nil, image.ZP, Src) + DrawMask(m, image.Rect(x, b.Min.Y, x+1, b.Max.Y), src, image.Point{}, nil, image.Point{}, Src) } check("column") // Draw the whole image at once. c = color.RGBA{44, 55, 66, 77} src = &image.Uniform{C: c} - DrawMask(m, b, src, image.ZP, nil, image.ZP, Src) + DrawMask(m, b, src, image.Point{}, nil, image.Point{}, Src) check("whole") } } diff --git a/src/image/draw/example_test.go b/src/image/draw/example_test.go index 2ccc2f4acd..bfa6355fe3 100644 --- a/src/image/draw/example_test.go +++ b/src/image/draw/example_test.go @@ -37,7 +37,7 @@ func ExampleDrawer_floydSteinberg() { color.Gray{Y: 0}, }) - draw.FloydSteinberg.Draw(pi, im.Bounds(), im, image.ZP) + draw.FloydSteinberg.Draw(pi, im.Bounds(), im, image.Point{}) shade := []string{" ", "░", "▒", "▓", "█"} for i, p := range pi.Pix { fmt.Print(shade[p]) -- 2.48.1