shareable: Change the argument to color.RGBA at Fill

The argument will be copied explicitly.
This commit is contained in:
Hajime Hoshi 2019-09-21 21:16:39 +09:00
parent 9d867850dc
commit 0a872b342a
4 changed files with 7 additions and 12 deletions

View File

@ -135,15 +135,10 @@ func (i *Image) Clear() error {
func (i *Image) Fill(clr color.Color) error { func (i *Image) Fill(clr color.Color) error {
i.copyCheck() i.copyCheck()
rgba := color.RGBAModel.Convert(clr).(color.RGBA)
if enqueueImageOpIfNeeded(func() func() { if enqueueImageOpIfNeeded(func() func() {
r, g, b, a := clr.RGBA()
return func() { return func() {
i.Fill(color.RGBA64{ i.Fill(rgba)
R: uint16(r),
G: uint16(g),
B: uint16(b),
A: uint16(a),
})
} }
}) { }) {
return nil return nil
@ -160,7 +155,7 @@ func (i *Image) Fill(clr color.Color) error {
i.resolvePendingPixels(false) i.resolvePendingPixels(false)
i.mipmap.fill(clr) i.mipmap.fill(rgba)
return nil return nil
} }

View File

@ -250,9 +250,9 @@ func (i *Image) clear() {
} }
// Fill fills the specified part of the image with a solid color. // 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{ i.basePixels = Pixels{
baseColor: color.RGBAModel.Convert(clr).(color.RGBA), baseColor: clr,
} }
i.drawTrianglesHistory = nil i.drawTrianglesHistory = nil
i.stale = false i.stale = false

View File

@ -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() backendsM.Lock()
defer backendsM.Unlock() defer backendsM.Unlock()

View File

@ -59,7 +59,7 @@ func (m *mipmap) dump(name string) error {
return m.orig.Dump(name) return m.orig.Dump(name)
} }
func (m *mipmap) fill(clr color.Color) { func (m *mipmap) fill(clr color.RGBA) {
m.orig.Fill(clr) m.orig.Fill(clr)
m.disposeMipmaps() m.disposeMipmaps()
} }