restorable: Bug fix: Skip the screen image to check invalidation

This commit is contained in:
Hajime Hoshi 2019-05-28 11:26:08 +09:00
parent 24822c0a10
commit ffb9871839
2 changed files with 10 additions and 0 deletions

View File

@ -154,6 +154,12 @@ func (i *Image) CopyPixels(src *Image) {
}
func (i *Image) IsInvalidated() bool {
if i.screen {
// The screen image might not have a texture, and in this case it is impossible to detect whether
// the image is invalidated or not.
panic("graphicscommand: IsInvalidated cannot be called on the screen image")
}
// i.image can be nil before initializing.
if i.image == nil {
return false

View File

@ -72,6 +72,10 @@ func RestoreIfNeeded() error {
// As isInvalidated() is expensive, call this only for one image.
// This assumes that if there is one image that is invalidated, all images are invalidated.
for img := range theImages.images {
// The screen image might not have a texture. Skip this.
if img.screen {
continue
}
r = img.isInvalidated()
break
}