From aa8e11241446df1d53f5ab4ebd8a2a542e60f8ae Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 8 Sep 2024 17:42:45 +0900 Subject: [PATCH] internal/restorable: restore a stale image at clearing pixels --- internal/restorable/image.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 1312c2733..85e5a0a7a 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -283,8 +283,7 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl clearImage(i.image, region) } - // Even if the image is already stale, call makeStale to extend the stale region. - if !needsRestoration() || !i.needsRestoration() || i.stale { + if !needsRestoration() || !i.needsRestoration() { i.makeStale(region) return } @@ -302,6 +301,12 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl return } + if i.stale { + // Even if the image is already stale, call makeStale to extend the stale region. + i.makeStale(region) + return + } + // Records for DrawTriangles cannot come before records for WritePixels. if len(i.drawTrianglesHistory) > 0 { i.makeStale(region)