mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42:02 +01:00
internal/restorable: remove SetVolatile
This commit is contained in:
parent
81f91658ff
commit
9f729cf5c3
@ -90,6 +90,11 @@ const (
|
|||||||
ImageTypeScreen
|
ImageTypeScreen
|
||||||
|
|
||||||
// ImageTypeVolatile indicates the image is cleared whenever a frame starts.
|
// 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
|
ImageTypeVolatile
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -165,29 +170,6 @@ func NewImage(width, height int, imageType ImageType) *Image {
|
|||||||
return i
|
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 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 creates a new image with the given size and copies the pixels of the given source image.
|
||||||
// Extend disposes itself after its call.
|
// Extend disposes itself after its call.
|
||||||
|
Loading…
Reference in New Issue
Block a user