internal/graphicsdriver: remove NeedsRestoring()

Updates #805
This commit is contained in:
Hajime Hoshi 2024-01-08 22:08:42 +09:00
parent a30f075896
commit 771e5685f8
6 changed files with 1 additions and 32 deletions

View File

@ -463,10 +463,6 @@ func (g *graphics11) SetVsyncEnabled(enabled bool) {
g.vsyncEnabled = enabled g.vsyncEnabled = enabled
} }
func (g *graphics11) NeedsRestoring() bool {
return false
}
func (g *graphics11) NeedsClearingScreen() bool { func (g *graphics11) NeedsClearingScreen() bool {
// TODO: Confirm this is really true. // TODO: Confirm this is really true.
return true return true

View File

@ -1054,10 +1054,6 @@ func (g *graphics12) SetVsyncEnabled(enabled bool) {
g.vsyncEnabled = enabled g.vsyncEnabled = enabled
} }
func (g *graphics12) NeedsRestoring() bool {
return false
}
func (g *graphics12) NeedsClearingScreen() bool { func (g *graphics12) NeedsClearingScreen() bool {
// TODO: Confirm this is really true. // TODO: Confirm this is really true.
return true return true

View File

@ -62,7 +62,6 @@ type Graphics interface {
NewImage(width, height int) (Image, error) NewImage(width, height int) (Image, error)
NewScreenFramebufferImage(width, height int) (Image, error) NewScreenFramebufferImage(width, height int) (Image, error)
SetVsyncEnabled(enabled bool) SetVsyncEnabled(enabled bool)
NeedsRestoring() bool
NeedsClearingScreen() bool NeedsClearingScreen() bool
MaxImageSize() int MaxImageSize() int

View File

@ -708,10 +708,6 @@ func (g *Graphics) SetVsyncEnabled(enabled bool) {
g.view.setDisplaySyncEnabled(enabled) g.view.setDisplaySyncEnabled(enabled)
} }
func (g *Graphics) NeedsRestoring() bool {
return false
}
func (g *Graphics) NeedsClearingScreen() bool { func (g *Graphics) NeedsClearingScreen() bool {
return false return false
} }

View File

@ -18,7 +18,6 @@ package opengl
import ( import (
"fmt" "fmt"
"runtime"
"unsafe" "unsafe"
"github.com/hajimehoshi/ebiten/v2/internal/graphics" "github.com/hajimehoshi/ebiten/v2/internal/graphics"
@ -310,20 +309,6 @@ func (g *Graphics) SetVsyncEnabled(enabled bool) {
g.vsync = enabled g.vsync = enabled
} }
func (g *Graphics) NeedsRestoring() bool {
// Though it is possible to have a logic to restore the graphics data for GPU, do not use it for performance (#1603).
if runtime.GOOS == "js" {
return false
}
// On Android, `setPreserveEGLContextOnPause(true)` is called and then context loss unlikely happens.
// If this happens, Ebitengine tries to relaunch the app (#805).
if runtime.GOOS == "android" {
return false
}
// TODO: Remove the entire logic of the restoring (#805).
return g.context.ctx.IsES()
}
func (g *Graphics) NeedsClearingScreen() bool { func (g *Graphics) NeedsClearingScreen() bool {
return true return true
} }

View File

@ -23,11 +23,9 @@ import (
// forceRestoring reports whether restoring forcely happens or not. // forceRestoring reports whether restoring forcely happens or not.
var forceRestoring = false var forceRestoring = false
var needsRestoringByGraphicsDriver bool
// needsRestoring reports whether restoring process works or not. // needsRestoring reports whether restoring process works or not.
func needsRestoring() bool { func needsRestoring() bool {
return forceRestoring || needsRestoringByGraphicsDriver return forceRestoring
} }
// AlwaysReadPixelsFromGPU reports whether ReadPixels always reads pixels from GPU or not. // AlwaysReadPixelsFromGPU reports whether ReadPixels always reads pixels from GPU or not.
@ -266,7 +264,6 @@ var graphicsDriverInitialized bool
// InitializeGraphicsDriverState initializes the graphics driver state. // InitializeGraphicsDriverState initializes the graphics driver state.
func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) error { func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) error {
graphicsDriverInitialized = true graphicsDriverInitialized = true
needsRestoringByGraphicsDriver = graphicsDriver.NeedsRestoring()
return graphicscommand.InitializeGraphicsDriverState(graphicsDriver) return graphicscommand.InitializeGraphicsDriverState(graphicsDriver)
} }