restorable: Bug fix: Calling At must resolve the image's stale state

This commit is contained in:
Hajime Hoshi 2018-04-28 21:50:30 +09:00
parent 245dde9bc1
commit eb357f61b5

View File

@ -238,13 +238,15 @@ func (i *Image) At(x, y int) (color.RGBA, error) {
return color.RGBA{}, nil return color.RGBA{}, nil
} }
if err := graphics.FlushCommands(); err != nil {
return color.RGBA{}, err
}
if i.basePixels == nil || i.drawImageHistory != nil || i.stale { if i.basePixels == nil || i.drawImageHistory != nil || i.stale {
if err := graphics.FlushCommands(); err != nil {
return color.RGBA{}, err
}
if err := i.readPixelsFromGPU(); err != nil { if err := i.readPixelsFromGPU(); err != nil {
return color.RGBA{}, err return color.RGBA{}, err
} }
i.drawImageHistory = nil
i.stale = false
} }
idx := 4*x + 4*y*w idx := 4*x + 4*y*w
r, g, b, a := i.basePixels[idx], i.basePixels[idx+1], i.basePixels[idx+2], i.basePixels[idx+3] r, g, b, a := i.basePixels[idx], i.basePixels[idx+1], i.basePixels[idx+2], i.basePixels[idx+3]