diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-14 15:41:54 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-14 15:41:54 +0000 |
commit | d5363590597572228d4e0d0ae13f3469176ceb14 (patch) | |
tree | e3de46cbc89d82ca1f49843fe2e1e670db67795e /libgo/go/image | |
parent | ef0d4c4d9937276c8ff818ecb0b92925d322d3bd (diff) | |
download | gcc-d5363590597572228d4e0d0ae13f3469176ceb14.zip gcc-d5363590597572228d4e0d0ae13f3469176ceb14.tar.gz gcc-d5363590597572228d4e0d0ae13f3469176ceb14.tar.bz2 |
libgo: Update to weekly.2011-12-06.
From-SVN: r182338
Diffstat (limited to 'libgo/go/image')
-rw-r--r-- | libgo/go/image/color/color.go | 21 | ||||
-rw-r--r-- | libgo/go/image/names.go | 8 | ||||
-rw-r--r-- | libgo/go/image/png/writer.go | 2 |
3 files changed, 22 insertions, 9 deletions
diff --git a/libgo/go/image/color/color.go b/libgo/go/image/color/color.go index 4a0fae5..2948db7 100644 --- a/libgo/go/image/color/color.go +++ b/libgo/go/image/color/color.go @@ -134,13 +134,22 @@ type Model interface { Convert(c Color) Color } -// ModelFunc is an adapter type to allow the use of a color conversion -// function as a Model. If f is such a function, ModelFunc(f) is a Model that -// invokes f to implement the conversion. -type ModelFunc func(Color) Color +// ModelFunc returns a Model that invokes f to implement the conversion. +func ModelFunc(f func(Color) Color) Model { + // Note: using *modelFunc as the implementation + // means that callers can still use comparisons + // like m == RGBAModel. This is not possible if + // we use the func value directly, because funcs + // are no longer comparable. + return &modelFunc{f} +} + +type modelFunc struct { + f func(Color) Color +} -func (f ModelFunc) Convert(c Color) Color { - return f(c) +func (m *modelFunc) Convert(c Color) Color { + return m.f(c) } // RGBAModel is the Model for RGBA colors. diff --git a/libgo/go/image/names.go b/libgo/go/image/names.go index a7ad51d..a7d1a57 100644 --- a/libgo/go/image/names.go +++ b/libgo/go/image/names.go @@ -20,7 +20,7 @@ var ( ) // Uniform is an infinite-sized Image of uniform color. -// It implements both the color.Color and Image interfaces. +// It implements the color.Color, color.ColorModel, and Image interfaces. type Uniform struct { C color.Color } @@ -30,7 +30,11 @@ func (c *Uniform) RGBA() (r, g, b, a uint32) { } func (c *Uniform) ColorModel() color.Model { - return color.ModelFunc(func(color.Color) color.Color { return c.C }) + return c +} + +func (c *Uniform) Convert(color.Color) color.Color { + return c.C } func (c *Uniform) Bounds() Rectangle { return Rectangle{Point{-1e9, -1e9}, Point{1e9, 1e9}} } diff --git a/libgo/go/image/png/writer.go b/libgo/go/image/png/writer.go index 48089ff..641eae1 100644 --- a/libgo/go/image/png/writer.go +++ b/libgo/go/image/png/writer.go @@ -429,7 +429,7 @@ func Encode(w io.Writer, m image.Image) error { // also rejected. mw, mh := int64(m.Bounds().Dx()), int64(m.Bounds().Dy()) if mw <= 0 || mh <= 0 || mw >= 1<<32 || mh >= 1<<32 { - return FormatError("invalid image size: " + strconv.Itoa64(mw) + "x" + strconv.Itoa64(mw)) + return FormatError("invalid image size: " + strconv.FormatInt(mw, 10) + "x" + strconv.FormatInt(mw, 10)) } var e encoder |