From 9f729cf5c33fe9217c3bf8523273f3f7f85cda24 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 8 Jun 2022 02:20:09 +0900 Subject: [PATCH] internal/restorable: remove SetVolatile --- internal/restorable/image.go | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 1e05bfc5a..b6675d020 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -90,6 +90,11 @@ const ( ImageTypeScreen // ImageTypeVolatile indicates the image is cleared whenever a frame starts. + // + // Regular non-volatile images need to record drawing history or read its pixels from GPU if necessary so that all + // the images can be restored automatically from the context lost. However, such recording the drawing history or + // reading pixels from GPU are expensive operations. Volatile images can skip such oprations, but the image content + // is cleared every frame instead. ImageTypeVolatile ) @@ -165,29 +170,6 @@ func NewImage(width, height int, imageType ImageType) *Image { return i } -// SetVolatile sets the volatile state of the image. -// -// Regular non-volatile images need to record drawing history or read its pixels from GPU if necessary so that all -// the images can be restored automatically from the context lost. However, such recording the drawing history or -// reading pixels from GPU are expensive operations. Volatile images can skip such oprations, but the image content -// is cleared every frame instead. -func (i *Image) SetVolatile(volatile bool) { - switch i.imageType { - case ImageTypeRegular: - if volatile { - i.imageType = ImageTypeVolatile - i.makeStale() - } - case ImageTypeVolatile: - if !volatile { - i.imageType = ImageTypeRegular - i.makeStale() - } - default: - panic(fmt.Sprintf("restorable: unexpected image type: %d", i.imageType)) - } -} - // Extend extends the image by the given size. // Extend creates a new image with the given size and copies the pixels of the given source image. // Extend disposes itself after its call.