internal/restorable: use pixelsForRestore only when restoring is needed

Updates #2375
This commit is contained in:
Hajime Hoshi 2022-10-06 15:08:59 +09:00
parent 34562c3337
commit c6b37e9809

View File

@ -493,7 +493,7 @@ func (i *Image) readPixelsFromGPU(graphicsDriver graphicsdriver.Graphics) error
}
if !r.Empty() {
var pix []byte
if r == image.Rect(0, 0, i.width, i.height) {
if needsRestoring() && i.needsRestoring() && r == image.Rect(0, 0, i.width, i.height) {
// pixelsForRestore can be reused as basePixels was invalidated.
if i.pixelsForRestore == nil {
i.pixelsForRestore = make([]byte, 4*r.Dx()*r.Dy())