mipmap, shareable: Refactoring: Remove SetGraphicsDriver

This commit is contained in:
Hajime Hoshi 2020-10-13 01:36:40 +09:00
parent 4c42a26464
commit b2d618c2be
5 changed files with 11 additions and 17 deletions

View File

@ -16,14 +16,10 @@ package ebiten
import ( import (
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand" "github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/v2/internal/mipmap"
"github.com/hajimehoshi/ebiten/v2/internal/shareable"
) )
var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__ var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__
func init() { func init() {
mipmap.SetGraphicsDriver(uiDriver().Graphics())
shareable.SetGraphicsDriver(uiDriver().Graphics())
graphicscommand.SetGraphicsDriver(uiDriver().Graphics()) graphicscommand.SetGraphicsDriver(uiDriver().Graphics())
} }

View File

@ -718,3 +718,8 @@ func (c *newShaderCommand) CanMergeWithDrawTrianglesCommand(dst *Image, src [gra
func ResetGraphicsDriverState() error { func ResetGraphicsDriverState() error {
return theGraphicsDriver.Reset() return theGraphicsDriver.Reset()
} }
// MaxImageSize returns the maximum size of an image.
func MaxImageSize() int {
return theGraphicsDriver.MaxImageSize()
}

View File

@ -26,12 +26,6 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/shaderir" "github.com/hajimehoshi/ebiten/v2/internal/shaderir"
) )
var graphicsDriver driver.Graphics
func SetGraphicsDriver(graphics driver.Graphics) {
graphicsDriver = graphics
}
func BeginFrame() error { func BeginFrame() error {
return buffered.BeginFrame() return buffered.BeginFrame()
} }

View File

@ -275,6 +275,11 @@ func InitializeGraphicsDriverState() error {
return graphicscommand.ResetGraphicsDriverState() return graphicscommand.ResetGraphicsDriverState()
} }
// MaxImageSize returns the maximum size of an image.
func MaxImageSize() int {
return graphicscommand.MaxImageSize()
}
// OnContextLost is called when the context lost is detected in an explicit way. // OnContextLost is called when the context lost is detected in an explicit way.
func OnContextLost() { func OnContextLost() {
if !canDetectContextLostExplicitly { if !canDetectContextLostExplicitly {

View File

@ -34,12 +34,6 @@ const (
paddingSize = 1 paddingSize = 1
) )
var graphicsDriver driver.Graphics
func SetGraphicsDriver(graphics driver.Graphics) {
graphicsDriver = graphics
}
var ( var (
minSize = 0 minSize = 0
maxSize = 0 maxSize = 0
@ -673,7 +667,7 @@ func BeginFrame() error {
panic("shareable: all the images must be not-shared before the game starts") panic("shareable: all the images must be not-shared before the game starts")
} }
minSize = 1024 minSize = 1024
maxSize = max(minSize, graphicsDriver.MaxImageSize()) maxSize = max(minSize, restorable.MaxImageSize())
}) })
if err != nil { if err != nil {
return err return err