From 34639d0028c1778916977fca5fda5a7c8d23b47c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 6 Sep 2024 15:27:24 +0900 Subject: [PATCH] Revert "internal/restorable: remove ImageTypeRestorable" This reverts commit 8c2d4e1408dcba09af72a524b32d92e155b954fa. Updates #3083 --- internal/atlas/image.go | 14 +++++++++++--- internal/restorable/image.go | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/atlas/image.go b/internal/atlas/image.go index 8be47441a..d1eea954d 100644 --- a/internal/atlas/image.go +++ b/internal/atlas/image.go @@ -677,9 +677,13 @@ func (i *Image) allocate(forbiddenBackends []*backend, asSource bool) { panic(fmt.Sprintf("atlas: the image being put on an atlas is too big: width: %d, height: %d", i.width, i.height)) } + typ := restorable.ImageTypeRegular + if i.imageType == ImageTypeVolatile { + typ = restorable.ImageTypeVolatile + } i.backend = &backend{ - restorable: restorable.NewImage(wp, hp, restorable.ImageTypeRegular), - source: asSource && i.imageType == ImageTypeRegular, + restorable: restorable.NewImage(wp, hp, typ), + source: asSource && typ == restorable.ImageTypeRegular, } theBackends = append(theBackends, i.backend) return @@ -723,8 +727,12 @@ loop: height *= 2 } + typ := restorable.ImageTypeRegular + if i.imageType == ImageTypeVolatile { + typ = restorable.ImageTypeVolatile + } b := &backend{ - restorable: restorable.NewImage(width, height, restorable.ImageTypeRegular), + restorable: restorable.NewImage(width, height, typ), page: packing.NewPage(width, height, maxSize), source: asSource, } diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 3323a6c5d..73d689ff2 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -31,6 +31,9 @@ const ( // ImageTypeScreen indicates the image is used as an actual screen. ImageTypeScreen + + // ImageTypeVolatile indicates the image is cleared whenever a frame starts. + ImageTypeVolatile ) // Image represents an image.