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 {
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
}

View File

@ -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

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

View File

@ -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()
}