internal/graphicsdriver/opengl: remove fnIsContextLost

As restoring from context lost doesn't happen on browsers, isContextLost
doesn't have to be called.
This commit is contained in:
Hajime Hoshi 2022-11-17 12:43:10 +09:00
parent c768860f3f
commit 8cc6fa82fd
4 changed files with 1 additions and 16 deletions

View File

@ -15,8 +15,6 @@
package graphicsdriver package graphicsdriver
import ( import (
"errors"
"github.com/hajimehoshi/ebiten/v2/internal/graphics" "github.com/hajimehoshi/ebiten/v2/internal/graphics"
"github.com/hajimehoshi/ebiten/v2/internal/shaderir" "github.com/hajimehoshi/ebiten/v2/internal/shaderir"
) )
@ -60,9 +58,6 @@ type Graphics interface {
DrawTriangles(dst ImageID, srcs [graphics.ShaderImageCount]ImageID, shader ShaderID, dstRegions []DstRegion, indexOffset int, blend Blend, uniforms [][]uint32, evenOdd bool) error DrawTriangles(dst ImageID, srcs [graphics.ShaderImageCount]ImageID, shader ShaderID, dstRegions []DstRegion, indexOffset int, blend Blend, uniforms [][]uint32, evenOdd bool) error
} }
// GraphicsNotReady represents that the graphics driver is not ready for recovering from the context lost.
var GraphicsNotReady = errors.New("graphics not ready")
type Image interface { type Image interface {
ID() ImageID ID() ImageID
Dispose() Dispose()

View File

@ -48,8 +48,6 @@ type contextImpl struct {
ctx gl.Context ctx gl.Context
canvas js.Value canvas js.Value
webGL2 bool webGL2 bool
fnIsContextLost js.Value
} }
func (c *context) reset() error { func (c *context) reset() error {
@ -60,9 +58,6 @@ func (c *context) reset() error {
c.lastViewportHeight = 0 c.lastViewportHeight = 0
c.lastBlend = graphicsdriver.Blend{} c.lastBlend = graphicsdriver.Blend{}
if c.fnIsContextLost.Invoke().Bool() {
return graphicsdriver.GraphicsNotReady
}
c.ctx.Enable(gl.BLEND) c.ctx.Enable(gl.BLEND)
c.ctx.Enable(gl.SCISSOR_TEST) c.ctx.Enable(gl.SCISSOR_TEST)
c.blend(graphicsdriver.BlendSourceOver) c.blend(graphicsdriver.BlendSourceOver)

View File

@ -62,7 +62,6 @@ func NewGraphics(canvas js.Value) (graphicsdriver.Graphics, error) {
g.context.canvas = canvas g.context.canvas = canvas
g.context.ctx = ctx g.context.ctx = ctx
g.context.webGL2 = webGL2 g.context.webGL2 = webGL2
g.context.fnIsContextLost = glContext.Get("isContextLost").Call("bind", glContext)
if !webGL2 { if !webGL2 {
glContext.Call("getExtension", "OES_standard_derivatives") glContext.Call("getExtension", "OES_standard_derivatives")

View File

@ -109,11 +109,7 @@ func RestoreIfNeeded(graphicsDriver graphicsdriver.Graphics) error {
} }
} }
err := graphicscommand.ResetGraphicsDriverState(graphicsDriver) if err := graphicscommand.ResetGraphicsDriverState(graphicsDriver); err != nil {
if err == graphicsdriver.GraphicsNotReady {
return nil
}
if err != nil {
return err return err
} }
return theImages.restore(graphicsDriver) return theImages.restore(graphicsDriver)