draw: disable the image.Rectangle DstMask fast path until Go 1.5 is
released. Change-Id: Ie5d6766d53952d3a81dfbd19a9f4022aaad6af5a Reviewed-on: https://go-review.googlesource.com/9463 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
b2f48f3f51
commit
918b3735c3
|
@ -410,9 +410,11 @@ func clipAffectedDestRect(adr image.Rectangle, dstMask image.Image, dstMaskP ima
|
|||
if dstMask == nil {
|
||||
return adr, nil
|
||||
}
|
||||
if r, ok := dstMask.(image.Rectangle); ok {
|
||||
return adr.Intersect(r.Sub(dstMaskP)), nil
|
||||
}
|
||||
// TODO: enable this fast path once Go 1.5 is released, where an
|
||||
// image.Rectangle implements image.Image.
|
||||
// if r, ok := dstMask.(image.Rectangle); ok {
|
||||
// return adr.Intersect(r.Sub(dstMaskP)), nil
|
||||
// }
|
||||
// TODO: clip to dstMask.Bounds() if the color model implies that out-of-bounds means 0 alpha?
|
||||
return adr, dstMask
|
||||
}
|
||||
|
|
|
@ -433,7 +433,9 @@ func TestRectDstMask(t *testing.T) {
|
|||
for _, dstMaskP := range dstMaskPs {
|
||||
dstInside := mk(q, nil, image.Point{})
|
||||
for _, wrap := range []bool{false, true} {
|
||||
dstMask := image.Image(rect)
|
||||
// TODO: replace "rectImage(rect)" with "rect" once Go 1.5 is
|
||||
// released, where an image.Rectangle implements image.Image.
|
||||
dstMask := image.Image(rectImage(rect))
|
||||
if wrap {
|
||||
dstMask = srcWrapper{dstMask}
|
||||
}
|
||||
|
@ -463,6 +465,19 @@ func TestRectDstMask(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: delete this wrapper type once Go 1.5 is released, where an
|
||||
// image.Rectangle implements image.Image.
|
||||
type rectImage image.Rectangle
|
||||
|
||||
func (r rectImage) ColorModel() color.Model { return color.Alpha16Model }
|
||||
func (r rectImage) Bounds() image.Rectangle { return image.Rectangle(r) }
|
||||
func (r rectImage) At(x, y int) color.Color {
|
||||
if (image.Point{x, y}).In(image.Rectangle(r)) {
|
||||
return color.Opaque
|
||||
}
|
||||
return color.Transparent
|
||||
}
|
||||
|
||||
// The fooWrapper types wrap the dst or src image to avoid triggering the
|
||||
// type-specific fast path implementations.
|
||||
type (
|
||||
|
|
Loading…
Reference in New Issue
Block a user