internal/restorable: restore a stale image at clearing pixels

This commit is contained in:
Hajime Hoshi 2024-09-08 17:42:45 +09:00
parent 26f0479f16
commit aa8e112414

View File

@ -283,8 +283,7 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl
clearImage(i.image, region) clearImage(i.image, region)
} }
// Even if the image is already stale, call makeStale to extend the stale region. if !needsRestoration() || !i.needsRestoration() {
if !needsRestoration() || !i.needsRestoration() || i.stale {
i.makeStale(region) i.makeStale(region)
return return
} }
@ -302,6 +301,12 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl
return 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. // Records for DrawTriangles cannot come before records for WritePixels.
if len(i.drawTrianglesHistory) > 0 { if len(i.drawTrianglesHistory) > 0 {
i.makeStale(region) i.makeStale(region)