From 0a872b342a2061591022b301eb26111ee933a77d Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 21 Sep 2019 21:16:39 +0900 Subject: [PATCH] shareable: Change the argument to color.RGBA at Fill The argument will be copied explicitly. --- image.go | 11 +++-------- internal/restorable/image.go | 4 ++-- internal/shareable/image.go | 2 +- mipmap.go | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/image.go b/image.go index b6031a10b..f59edfd68 100644 --- a/image.go +++ b/image.go @@ -135,15 +135,10 @@ func (i *Image) Clear() error { func (i *Image) Fill(clr color.Color) error { i.copyCheck() + rgba := color.RGBAModel.Convert(clr).(color.RGBA) if enqueueImageOpIfNeeded(func() func() { - r, g, b, a := clr.RGBA() return func() { - i.Fill(color.RGBA64{ - R: uint16(r), - G: uint16(g), - B: uint16(b), - A: uint16(a), - }) + i.Fill(rgba) } }) { return nil @@ -160,7 +155,7 @@ func (i *Image) Fill(clr color.Color) error { i.resolvePendingPixels(false) - i.mipmap.fill(clr) + i.mipmap.fill(rgba) return nil } diff --git a/internal/restorable/image.go b/internal/restorable/image.go index b64a98985..bacd3e89c 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -250,9 +250,9 @@ func (i *Image) clear() { } // Fill fills the specified part of the image with a solid color. -func (i *Image) Fill(clr color.Color) { +func (i *Image) Fill(clr color.RGBA) { i.basePixels = Pixels{ - baseColor: color.RGBAModel.Convert(clr).(color.RGBA), + baseColor: clr, } i.drawTrianglesHistory = nil i.stale = false diff --git a/internal/shareable/image.go b/internal/shareable/image.go index 69abdc081..61d4c4591 100644 --- a/internal/shareable/image.go +++ b/internal/shareable/image.go @@ -322,7 +322,7 @@ func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16, } } -func (i *Image) Fill(clr color.Color) { +func (i *Image) Fill(clr color.RGBA) { backendsM.Lock() defer backendsM.Unlock() diff --git a/mipmap.go b/mipmap.go index 922d681c1..ef3f8b786 100644 --- a/mipmap.go +++ b/mipmap.go @@ -59,7 +59,7 @@ func (m *mipmap) dump(name string) error { return m.orig.Dump(name) } -func (m *mipmap) fill(clr color.Color) { +func (m *mipmap) fill(clr color.RGBA) { m.orig.Fill(clr) m.disposeMipmaps() }