mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
graphics: Bug fix: Copy variables out of the closures
This commit is contained in:
parent
d2312f1450
commit
fc939fabb8
8
image.go
8
image.go
@ -113,8 +113,8 @@ func (i *Image) Fill(clr color.Color) error {
|
||||
i.copyCheck()
|
||||
|
||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||
enqueueImageOp(func() {
|
||||
r, g, b, a := clr.RGBA()
|
||||
enqueueImageOp(func() {
|
||||
i.Fill(color.RGBA64{
|
||||
R: uint16(r),
|
||||
G: uint16(g),
|
||||
@ -189,8 +189,8 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error {
|
||||
i.copyCheck()
|
||||
|
||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||
enqueueImageOp(func() {
|
||||
op := *options
|
||||
enqueueImageOp(func() {
|
||||
i.DrawImage(img, &op)
|
||||
})
|
||||
return nil
|
||||
@ -408,12 +408,12 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o
|
||||
i.copyCheck()
|
||||
|
||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||
enqueueImageOp(func() {
|
||||
vs := make([]Vertex, len(vertices))
|
||||
copy(vs, vertices)
|
||||
is := make([]uint16, len(indices))
|
||||
copy(is, indices)
|
||||
op := *options
|
||||
enqueueImageOp(func() {
|
||||
i.DrawTriangles(vs, is, img, &op)
|
||||
})
|
||||
return
|
||||
@ -652,9 +652,9 @@ func (i *Image) ReplacePixels(p []byte) error {
|
||||
i.copyCheck()
|
||||
|
||||
if atomic.LoadInt32(&isImageAvailable) == 0 {
|
||||
enqueueImageOp(func() {
|
||||
px := make([]byte, len(p))
|
||||
copy(px, p)
|
||||
enqueueImageOp(func() {
|
||||
i.ReplacePixels(px)
|
||||
})
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user