mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/ui: remove the call of graphicsDriver() from the context
This commit is contained in:
parent
fc96eb30a1
commit
12ce5ae83a
@ -55,16 +55,16 @@ func newContextImpl(game Game) *contextImpl {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *contextImpl) updateFrame(outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||
func (c *contextImpl) updateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||
// TODO: If updateCount is 0 and vsync is disabled, swapping buffers can be skipped.
|
||||
return c.updateFrameImpl(clock.Update(theGlobalState.maxTPS()), outsideWidth, outsideHeight, deviceScaleFactor)
|
||||
return c.updateFrameImpl(graphicsDriver, clock.Update(theGlobalState.maxTPS()), outsideWidth, outsideHeight, deviceScaleFactor)
|
||||
}
|
||||
|
||||
func (c *contextImpl) forceUpdateFrame(outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||
return c.updateFrameImpl(1, outsideWidth, outsideHeight, deviceScaleFactor)
|
||||
func (c *contextImpl) forceUpdateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||
return c.updateFrameImpl(graphicsDriver, 1, outsideWidth, outsideHeight, deviceScaleFactor)
|
||||
}
|
||||
|
||||
func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||
func (c *contextImpl) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, updateCount int, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||
if err := theGlobalState.error(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -82,7 +82,7 @@ func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeig
|
||||
|
||||
debug.Logf("----\n")
|
||||
|
||||
if err := buffered.BeginFrame(graphicsDriver()); err != nil {
|
||||
if err := buffered.BeginFrame(graphicsDriver); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -110,14 +110,14 @@ func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeig
|
||||
|
||||
// Draw the game.
|
||||
screenScale, offsetX, offsetY := c.screenScaleAndOffsets(deviceScaleFactor)
|
||||
if err := c.game.Draw(screenScale, offsetX, offsetY, graphicsDriver().NeedsClearingScreen(), graphicsDriver().FramebufferYDirection(), theGlobalState.isScreenClearedEveryFrame(), theGlobalState.isScreenFilterEnabled()); err != nil {
|
||||
if err := c.game.Draw(screenScale, offsetX, offsetY, graphicsDriver.NeedsClearingScreen(), graphicsDriver.FramebufferYDirection(), theGlobalState.isScreenClearedEveryFrame(), theGlobalState.isScreenFilterEnabled()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// All the vertices data are consumed at the end of the frame, and the data backend can be
|
||||
// available after that. Until then, lock the vertices backend.
|
||||
return graphicspkg.LockAndResetVertices(func() error {
|
||||
if err := buffered.EndFrame(graphicsDriver()); err != nil {
|
||||
if err := buffered.EndFrame(graphicsDriver); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -715,7 +715,7 @@ func (u *UserInterface) registerWindowSetSizeCallback() {
|
||||
// In order to call it safely, use runOnAnotherThreadFromMainThread.
|
||||
var err error
|
||||
u.runOnAnotherThreadFromMainThread(func() {
|
||||
err = u.context.forceUpdateFrame(outsideWidth, outsideHeight, deviceScaleFactor)
|
||||
err = u.context.forceUpdateFrame(graphicsDriver(), outsideWidth, outsideHeight, deviceScaleFactor)
|
||||
})
|
||||
if err != nil {
|
||||
u.err = err
|
||||
@ -1025,7 +1025,7 @@ func (u *UserInterface) loop() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := u.context.updateFrame(outsideWidth, outsideHeight, deviceScaleFactor); err != nil {
|
||||
if err := u.context.updateFrame(graphicsDriver(), outsideWidth, outsideHeight, deviceScaleFactor); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -284,11 +284,11 @@ func (u *UserInterface) updateImpl(force bool) error {
|
||||
|
||||
w, h := u.outsideSize()
|
||||
if force {
|
||||
if err := u.context.forceUpdateFrame(w, h, u.DeviceScaleFactor()); err != nil {
|
||||
if err := u.context.forceUpdateFrame(graphicsDriver(), w, h, u.DeviceScaleFactor()); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := u.context.updateFrame(w, h, u.DeviceScaleFactor()); err != nil {
|
||||
if err := u.context.updateFrame(graphicsDriver(), w, h, u.DeviceScaleFactor()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ func (u *UserInterface) update() error {
|
||||
}()
|
||||
|
||||
w, h := u.outsideSize()
|
||||
if err := u.context.updateFrame(w, h, deviceScale()); err != nil {
|
||||
if err := u.context.updateFrame(graphicsDriver(), w, h, deviceScale()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user