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
import (
"errors"
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
"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
}
// 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 {
ID() ImageID
Dispose()

View File

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

View File

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

View File

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