internal/restorable: remove SetVolatile

This commit is contained in:
Hajime Hoshi 2022-06-08 02:20:09 +09:00
parent 81f91658ff
commit 9f729cf5c3

View File

@ -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.