mirror of
https://github.com/golang/go
synced 2024-11-17 23:44:48 -07:00
image/draw: rename and reorder some benchmarks
The intention is for BenchmarkFooBar functions to map 1:1 to drawFooBar functions. Recent draw.go changes have added more drawFooBar functions and have further modified the mapping, as fallback drawFooBar functions aren't invoked as often as they used to. This commit restores the 1:1 mapping and reorganizes the BenchmarkFooBar functions in the same order as the matching drawFooBar functions appear. Also modify a TestDraw test case from vgradGreen(255) = {0, 136, 0, 255} to vgradGreen(90) = {0, 48, 0, 90}. Doing so matches the existing "The source pixel is {0, 48, 0, 90}" comment but also makes for a more interesting test case, as the source pixel is no longer fully opaque. Fully opaque is already covered by the vgradGray() test case on the next line. Also fix a "variable source" comment copy-pasto when the source image is actually uniform, not variable. Also add a func DrawMask type switch comment about interface types. Change-Id: I828e71f2ee8ec617f523c8aafb118fb7ba166876 Reviewed-on: https://go-review.googlesource.com/c/go/+/358974 Trust: Nigel Tao <nigeltao@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Nigel Tao <nigeltao@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
0bef30d28a
commit
8e3d5f0bb3
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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}},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user