graphics: Don't call IsTexture on browsers

This commit is contained in:
Hajime Hoshi 2017-05-28 00:49:01 +09:00
parent e53262bfac
commit 8614599c5c
3 changed files with 56 additions and 12 deletions

View File

@ -37,7 +37,7 @@ type graphicsContext struct {
screen *Image
screenScale float64
initialized int32
invalidated bool
invalidated bool // browser only
}
func (c *graphicsContext) GLContext() *opengl.Context {
@ -100,17 +100,6 @@ func (c *graphicsContext) SetSize(screenWidth, screenHeight int, screenScale flo
return nil
}
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
if c.invalidated {
return true, nil
}
// FlushCommands is required because c.offscreen.impl might not have an actual texture.
if err := graphics.FlushCommands(context); err != nil {
return false, err
}
return c.offscreen.restorable.IsInvalidated(context), nil
}
func (c *graphicsContext) initializeIfNeeded(context *opengl.Context) error {
if atomic.LoadInt32(&c.initialized) == 0 {
if err := graphics.Reset(context); err != nil {

25
graphicscontext_js.go Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2017 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build js
package ebiten
import (
"github.com/hajimehoshi/ebiten/internal/opengl"
)
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
return c.invalidated, nil
}

30
graphicscontext_notjs.go Normal file
View File

@ -0,0 +1,30 @@
// Copyright 2017 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build !js
package ebiten
import (
"github.com/hajimehoshi/ebiten/internal/graphics"
"github.com/hajimehoshi/ebiten/internal/opengl"
)
func (c *graphicsContext) needsRestoring(context *opengl.Context) (bool, error) {
// FlushCommands is required because c.offscreen.impl might not have an actual texture.
if err := graphics.FlushCommands(context); err != nil {
return false, err
}
return c.offscreen.restorable.IsInvalidated(context), nil
}