internal/restorable: skip adding stale regions when the image doesn't need to be restored

This commit is contained in:
Hajime Hoshi 2024-09-08 17:48:59 +09:00
parent aa8e112414
commit f32648b144

View File

@ -233,6 +233,10 @@ func (i *Image) makeStale(rect image.Rectangle) {
return return
} }
if !i.needsRestoration() {
return
}
origSize := len(i.staleRegions) origSize := len(i.staleRegions)
i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions) i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions)
if !rect.Empty() { if !rect.Empty() {
@ -465,7 +469,7 @@ func (i *Image) readPixelsFromGPUIfNeeded(graphicsDriver graphicsdriver.Graphics
} }
func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte, region image.Rectangle) error { func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte, region image.Rectangle) error {
if AlwaysReadPixelsFromGPU() { if AlwaysReadPixelsFromGPU() || !i.needsRestoration() {
if err := i.image.ReadPixels(graphicsDriver, []graphicsdriver.PixelsArgs{ if err := i.image.ReadPixels(graphicsDriver, []graphicsdriver.PixelsArgs{
{ {
Pixels: pixels, Pixels: pixels,