internal/restorable: bug fix: readPixelsFromGPU might be called for a non-stale image

Actually readPixelsFromGPUIfNeeded can invoke this.

Closes #2322
This commit is contained in:
Hajime Hoshi 2022-09-13 15:34:41 +09:00
parent 4824cbc755
commit 40362aa62d

View File

@ -496,10 +496,6 @@ func (i *Image) makeStaleIfDependingOnShader(shader *Shader) {
// readPixelsFromGPU reads the pixels from GPU and resolves the image's 'stale' state.
func (i *Image) readPixelsFromGPU(graphicsDriver graphicsdriver.Graphics) error {
if !i.stale {
panic("restorable: the image must be stale at readPixelsFromGPU")
}
i.basePixels = Pixels{}
if r := i.staleRegion; !r.Empty() {
pix := make([]byte, 4*r.Dx()*r.Dy())