From 6b906bb8135a0f61e40ea084bd31ab9cb5a8ece2 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 13 Sep 2022 06:53:30 -0700 Subject: [PATCH] internal/restorable: extend the staleRegion when the image is already stale on WritePixels This is a kind of refactoring. There seems no case that this condition change is really needed, but this is more logical. --- internal/restorable/image.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 9e44bfb4a..d75fc0bd5 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -314,7 +314,8 @@ func (i *Image) WritePixels(pixels []byte, x, y, width, height int) { i.image.WritePixels(make([]byte, 4*width*height), x, y, width, height) } - if !needsRestoring() || !i.needsRestoring() { + // Even if the image is already stale, call makeStale to extend the stale region. + if !needsRestoring() || !i.needsRestoring() || i.stale { i.makeStale(image.Rect(x, y, x+width, y+height)) return } @@ -341,11 +342,6 @@ func (i *Image) WritePixels(pixels []byte, x, y, width, height int) { return } - if i.stale { - // TODO: panic here? - return - } - if pixels != nil { // pixels can point to a shared region. // This function is responsible to copy this.