summaryrefslogtreecommitdiff
path: root/libgo/go/image/draw/bench_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/image/draw/bench_test.go')
-rw-r--r--libgo/go/image/draw/bench_test.go67
1 files changed, 34 insertions, 33 deletions
diff --git a/libgo/go/image/draw/bench_test.go b/libgo/go/image/draw/bench_test.go
index a99b408141e..2be91185af2 100644
--- a/libgo/go/image/draw/bench_test.go
+++ b/libgo/go/image/draw/bench_test.go
@@ -6,6 +6,7 @@ package draw
import (
"image"
+ "image/color"
"image/ycbcr"
"testing"
)
@@ -18,16 +19,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:
- dst1 := image.NewRGBA(dstw, dsth)
+ 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 +37,11 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) {
}
}
dst = dst1
- case image.RGBA64ColorModel:
- dst1 := image.NewRGBA64(dstw, dsth)
+ 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),
@@ -56,12 +57,12 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) {
var src image.Image
switch scm {
case nil:
- src = &image.ColorImage{image.RGBAColor{0x11, 0x22, 0x33, 0xff}}
- case image.RGBAColorModel:
- src1 := image.NewRGBA(srcw, srch)
+ 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 +71,11 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) {
}
}
src = src1
- case image.RGBA64ColorModel:
- src1 := image.NewRGBA64(srcw, srch)
+ 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 +84,11 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) {
}
}
src = src1
- case image.NRGBAColorModel:
- src1 := image.NewNRGBA(srcw, srch)
+ 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),
@@ -122,15 +123,15 @@ func bench(b *testing.B, dcm, scm, mcm image.ColorModel, op Op) {
switch mcm {
case nil:
// No-op.
- case image.AlphaColorModel:
- mask1 := image.NewAlpha(srcw, srch)
+ case color.AlphaModel:
+ mask1 := image.NewAlpha(image.Rect(0, 0, srcw, srch))
for y := 0; y < srch; y++ {
for x := 0; x < srcw; x++ {
a := uint8((23*x + 29*y) % 0x100)
// 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})
}
}
}
@@ -152,55 +153,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, ycbcr.YCbCrColorModel, 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)
}