aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/image')
-rw-r--r--src/image/draw/bench_test.go27
-rw-r--r--src/image/draw/draw.go2
-rw-r--r--src/image/draw/draw_test.go13
3 files changed, 24 insertions, 18 deletions
diff --git a/src/image/draw/bench_test.go b/src/image/draw/bench_test.go
index 2b7c6d6ac4..55d25b8596 100644
--- a/src/image/draw/bench_test.go
+++ b/src/image/draw/bench_test.go
@@ -190,8 +190,7 @@ func bench(b *testing.B, dcm, scm, mcm color.Model, op Op) {
}
}
-// The BenchmarkFoo and BenchmarkFooN functions exercise a drawFoo fast-path
-// function in draw.go.
+// The BenchmarkFoo functions exercise a drawFoo fast-path function in draw.go.
func BenchmarkFillOver(b *testing.B) {
bench(b, color.RGBAModel, nil, nil, Over)
@@ -233,12 +232,20 @@ func BenchmarkGlyphOver(b *testing.B) {
bench(b, color.RGBAModel, nil, color.AlphaModel, Over)
}
-func BenchmarkRGBA1(b *testing.B) {
- bench(b, color.RGBAModel, color.RGBA64Model, nil, Src)
+func BenchmarkRGBAMaskOver(b *testing.B) {
+ bench(b, color.RGBAModel, color.RGBAModel, color.AlphaModel, Over)
}
-func BenchmarkRGBA2(b *testing.B) {
- bench(b, color.RGBAModel, color.RGBAModel, color.AlphaModel, Over)
+func BenchmarkGrayMaskOver(b *testing.B) {
+ bench(b, color.RGBAModel, color.GrayModel, color.AlphaModel, Over)
+}
+
+func BenchmarkRGBA64ImageMaskOver(b *testing.B) {
+ bench(b, color.RGBAModel, color.RGBA64Model, color.AlphaModel, Over)
+}
+
+func BenchmarkRGBA(b *testing.B) {
+ bench(b, color.RGBAModel, color.RGBA64Model, nil, Src)
}
func BenchmarkPalettedFill(b *testing.B) {
@@ -266,11 +273,3 @@ func BenchmarkGenericSrc(b *testing.B) {
func BenchmarkGenericMaskSrc(b *testing.B) {
bench(b, color.RGBA64Model, color.RGBA64Model, color.AlphaModel, Src)
}
-
-func BenchmarkRGBA64Over(b *testing.B) {
- bench(b, color.RGBAModel, color.RGBA64Model, color.AlphaModel, Over)
-}
-
-func BenchmarkGrayOver(b *testing.B) {
- bench(b, color.RGBAModel, color.GrayModel, color.AlphaModel, Over)
-}
diff --git a/src/image/draw/draw.go b/src/image/draw/draw.go
index d3c5b29097..7dd18dfdb5 100644
--- a/src/image/draw/draw.go
+++ b/src/image/draw/draw.go
@@ -166,6 +166,8 @@ func DrawMask(dst Image, r image.Rectangle, src image.Image, sp image.Point, mas
case *image.Gray:
drawGrayMaskOver(dst0, r, src0, sp, mask0, mp)
return
+ // Case order matters. The next case (image.RGBA64Image) is an
+ // interface type that the concrete types above also implement.
case image.RGBA64Image:
drawRGBA64ImageMaskOver(dst0, r, src0, sp, mask0, mp)
return
diff --git a/src/image/draw/draw_test.go b/src/image/draw/draw_test.go
index 75a2896631..77f1c5c2c2 100644
--- a/src/image/draw/draw_test.go
+++ b/src/image/draw/draw_test.go
@@ -380,7 +380,7 @@ var drawTests = []drawTest{
{"cmykAlphaSrc", vgradMagenta(), fillAlpha(192), Src, color.RGBA{145, 67, 145, 192}},
{"cmykNil", vgradMagenta(), nil, Over, color.RGBA{192, 89, 192, 255}},
{"cmykNilSrc", vgradMagenta(), nil, Src, color.RGBA{192, 89, 192, 255}},
- // Variable mask and variable source.
+ // Variable mask and uniform source.
// At (x, y) == (8, 8):
// The destination pixel is {136, 0, 0, 255}.
// The source pixel is {0, 0, 255, 255}.
@@ -397,9 +397,14 @@ var drawTests = []drawTest{
Over, color.RGBA{81, 0, 102, 255}},
{"genericSrcSlowest", fillBlue(255), convertToSlowestRGBA(vgradAlpha(192)),
Src, color.RGBA{0, 0, 102, 102}},
- // The source pixel is {0, 48, 0, 90}.
- {"rgbaVariableMaskOver", vgradGreen(255), vgradAlpha(192), Over, color.RGBA{81, 54, 0, 255}},
- // The source pixel is {136} in Gray-space, which is {136, 136, 136, 255} in RGBA-space.
+ // Variable mask and variable source.
+ // At (x, y) == (8, 8):
+ // The destination pixel is {136, 0, 0, 255}.
+ // The source pixel is:
+ // - {0, 48, 0, 90}.
+ // - {136} in Gray-space, which is {136, 136, 136, 255} in RGBA-space.
+ // The mask pixel's alpha is 102, or 40%.
+ {"rgbaVariableMaskOver", vgradGreen(90), vgradAlpha(192), Over, color.RGBA{117, 19, 0, 255}},
{"grayVariableMaskOver", vgradGray(), vgradAlpha(192), Over, color.RGBA{136, 54, 54, 255}},
}