From c6b37e9809bb85e5a60b82aab9c532702719aa83 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 6 Oct 2022 15:08:59 +0900 Subject: [PATCH] internal/restorable: use pixelsForRestore only when restoring is needed Updates #2375 --- internal/restorable/image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index c9051012c..c2d3349da 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -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())