diff options
Diffstat (limited to 'src/pkg/image/draw/bench_test.go')
-rw-r--r-- | src/pkg/image/draw/bench_test.go | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/pkg/image/draw/bench_test.go b/src/pkg/image/draw/bench_test.go index 0e5e324dc..4cd2095c4 100644 --- a/src/pkg/image/draw/bench_test.go +++ b/src/pkg/image/draw/bench_test.go @@ -6,7 +6,7 @@ package draw import ( "image" - "image/ycbcr" + "image/color" "testing" ) @@ -18,16 +18,16 @@ const ( // bench benchmarks drawing src and mask images onto a dst image with the // given op and the color models to create those images from. // The created images' pixels are initialized to non-zero values. -func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { +func bench(b *testing.B, dcm, scm, mcm color.Model, op Op) { b.StopTimer() var dst Image switch dcm { - case image.RGBAColorModel: + case color.RGBAModel: dst1 := image.NewRGBA(image.Rect(0, 0, dstw, dsth)) for y := 0; y < dsth; y++ { for x := 0; x < dstw; x++ { - dst1.SetRGBA(x, y, image.RGBAColor{ + dst1.SetRGBA(x, y, color.RGBA{ uint8(5 * x % 0x100), uint8(7 * y % 0x100), uint8((7*x + 5*y) % 0x100), @@ -36,11 +36,11 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { } } dst = dst1 - case image.RGBA64ColorModel: + case color.RGBA64Model: dst1 := image.NewRGBA64(image.Rect(0, 0, dstw, dsth)) for y := 0; y < dsth; y++ { for x := 0; x < dstw; x++ { - dst1.SetRGBA64(x, y, image.RGBA64Color{ + dst1.SetRGBA64(x, y, color.RGBA64{ uint16(53 * x % 0x10000), uint16(59 * y % 0x10000), uint16((59*x + 53*y) % 0x10000), @@ -50,18 +50,18 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { } dst = dst1 default: - panic("unreachable") + b.Fatal("unknown destination color model", dcm) } var src image.Image switch scm { case nil: - src = &image.ColorImage{image.RGBAColor{0x11, 0x22, 0x33, 0xff}} - case image.RGBAColorModel: + src = &image.Uniform{color.RGBA{0x11, 0x22, 0x33, 0xff}} + case color.RGBAModel: src1 := image.NewRGBA(image.Rect(0, 0, srcw, srch)) for y := 0; y < srch; y++ { for x := 0; x < srcw; x++ { - src1.SetRGBA(x, y, image.RGBAColor{ + src1.SetRGBA(x, y, color.RGBA{ uint8(13 * x % 0x80), uint8(11 * y % 0x80), uint8((11*x + 13*y) % 0x80), @@ -70,11 +70,11 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { } } src = src1 - case image.RGBA64ColorModel: + case color.RGBA64Model: src1 := image.NewRGBA64(image.Rect(0, 0, srcw, srch)) for y := 0; y < srch; y++ { for x := 0; x < srcw; x++ { - src1.SetRGBA64(x, y, image.RGBA64Color{ + src1.SetRGBA64(x, y, color.RGBA64{ uint16(103 * x % 0x8000), uint16(101 * y % 0x8000), uint16((101*x + 103*y) % 0x8000), @@ -83,11 +83,11 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { } } src = src1 - case image.NRGBAColorModel: + case color.NRGBAModel: src1 := image.NewNRGBA(image.Rect(0, 0, srcw, srch)) for y := 0; y < srch; y++ { for x := 0; x < srcw; x++ { - src1.SetNRGBA(x, y, image.NRGBAColor{ + src1.SetNRGBA(x, y, color.NRGBA{ uint8(13 * x % 0x100), uint8(11 * y % 0x100), uint8((11*x + 13*y) % 0x100), @@ -96,7 +96,7 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { } } src = src1 - case ycbcr.YCbCrColorModel: + case color.YCbCrModel: yy := make([]uint8, srcw*srch) cb := make([]uint8, srcw*srch) cr := make([]uint8, srcw*srch) @@ -105,24 +105,24 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { cb[i] = uint8(5 * i % 0x100) cr[i] = uint8(7 * i % 0x100) } - src = &ycbcr.YCbCr{ + src = &image.YCbCr{ Y: yy, Cb: cb, Cr: cr, YStride: srcw, CStride: srcw, - SubsampleRatio: ycbcr.SubsampleRatio444, + SubsampleRatio: image.YCbCrSubsampleRatio444, Rect: image.Rect(0, 0, srcw, srch), } default: - panic("unreachable") + b.Fatal("unknown source color model", scm) } var mask image.Image switch mcm { case nil: // No-op. - case image.AlphaColorModel: + case color.AlphaModel: mask1 := image.NewAlpha(image.Rect(0, 0, srcw, srch)) for y := 0; y < srch; y++ { for x := 0; x < srcw; x++ { @@ -130,13 +130,13 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { // Glyph masks are typically mostly zero, // so we only set a quarter of mask1's pixels. if a >= 0xc0 { - mask1.SetAlpha(x, y, image.AlphaColor{a}) + mask1.SetAlpha(x, y, color.Alpha{a}) } } } mask = mask1 default: - panic("unreachable") + b.Fatal("unknown mask color model", mcm) } b.StartTimer() @@ -152,55 +152,55 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) { // The BenchmarkFoo functions exercise a drawFoo fast-path function in draw.go. func BenchmarkFillOver(b *testing.B) { - bench(b, image.RGBAColorModel, nil, nil, Over) + bench(b, color.RGBAModel, nil, nil, Over) } func BenchmarkFillSrc(b *testing.B) { - bench(b, image.RGBAColorModel, nil, nil, Src) + bench(b, color.RGBAModel, nil, nil, Src) } func BenchmarkCopyOver(b *testing.B) { - bench(b, image.RGBAColorModel, image.RGBAColorModel, nil, Over) + bench(b, color.RGBAModel, color.RGBAModel, nil, Over) } func BenchmarkCopySrc(b *testing.B) { - bench(b, image.RGBAColorModel, image.RGBAColorModel, nil, Src) + bench(b, color.RGBAModel, color.RGBAModel, nil, Src) } func BenchmarkNRGBAOver(b *testing.B) { - bench(b, image.RGBAColorModel, image.NRGBAColorModel, nil, Over) + bench(b, color.RGBAModel, color.NRGBAModel, nil, Over) } func BenchmarkNRGBASrc(b *testing.B) { - bench(b, image.RGBAColorModel, image.NRGBAColorModel, nil, Src) + bench(b, color.RGBAModel, color.NRGBAModel, nil, Src) } func BenchmarkYCbCr(b *testing.B) { - bench(b, image.RGBAColorModel, ycbcr.YCbCrColorModel, nil, Over) + bench(b, color.RGBAModel, color.YCbCrModel, nil, Over) } func BenchmarkGlyphOver(b *testing.B) { - bench(b, image.RGBAColorModel, nil, image.AlphaColorModel, Over) + bench(b, color.RGBAModel, nil, color.AlphaModel, Over) } func BenchmarkRGBA(b *testing.B) { - bench(b, image.RGBAColorModel, image.RGBA64ColorModel, nil, Src) + bench(b, color.RGBAModel, color.RGBA64Model, nil, Src) } // The BenchmarkGenericFoo functions exercise the generic, slow-path code. func BenchmarkGenericOver(b *testing.B) { - bench(b, image.RGBA64ColorModel, image.RGBA64ColorModel, nil, Over) + bench(b, color.RGBA64Model, color.RGBA64Model, nil, Over) } func BenchmarkGenericMaskOver(b *testing.B) { - bench(b, image.RGBA64ColorModel, image.RGBA64ColorModel, image.AlphaColorModel, Over) + bench(b, color.RGBA64Model, color.RGBA64Model, color.AlphaModel, Over) } func BenchmarkGenericSrc(b *testing.B) { - bench(b, image.RGBA64ColorModel, image.RGBA64ColorModel, nil, Src) + bench(b, color.RGBA64Model, color.RGBA64Model, nil, Src) } func BenchmarkGenericMaskSrc(b *testing.B) { - bench(b, image.RGBA64ColorModel, image.RGBA64ColorModel, image.AlphaColorModel, Src) + bench(b, color.RGBA64Model, color.RGBA64Model, color.AlphaModel, Src) } |