mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08: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.
|
// 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 {
|
func (c *contextImpl) forceUpdateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
|
||||||
return c.updateFrameImpl(1, outsideWidth, outsideHeight, deviceScaleFactor)
|
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 {
|
if err := theGlobalState.error(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeig
|
|||||||
|
|
||||||
debug.Logf("----\n")
|
debug.Logf("----\n")
|
||||||
|
|
||||||
if err := buffered.BeginFrame(graphicsDriver()); err != nil {
|
if err := buffered.BeginFrame(graphicsDriver); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeig
|
|||||||
|
|
||||||
// Draw the game.
|
// Draw the game.
|
||||||
screenScale, offsetX, offsetY := c.screenScaleAndOffsets(deviceScaleFactor)
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the vertices data are consumed at the end of the frame, and the data backend can be
|
// 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.
|
// available after that. Until then, lock the vertices backend.
|
||||||
return graphicspkg.LockAndResetVertices(func() error {
|
return graphicspkg.LockAndResetVertices(func() error {
|
||||||
if err := buffered.EndFrame(graphicsDriver()); err != nil {
|
if err := buffered.EndFrame(graphicsDriver); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -715,7 +715,7 @@ func (u *UserInterface) registerWindowSetSizeCallback() {
|
|||||||
// In order to call it safely, use runOnAnotherThreadFromMainThread.
|
// In order to call it safely, use runOnAnotherThreadFromMainThread.
|
||||||
var err error
|
var err error
|
||||||
u.runOnAnotherThreadFromMainThread(func() {
|
u.runOnAnotherThreadFromMainThread(func() {
|
||||||
err = u.context.forceUpdateFrame(outsideWidth, outsideHeight, deviceScaleFactor)
|
err = u.context.forceUpdateFrame(graphicsDriver(), outsideWidth, outsideHeight, deviceScaleFactor)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.err = err
|
u.err = err
|
||||||
@ -1025,7 +1025,7 @@ func (u *UserInterface) loop() error {
|
|||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,11 +284,11 @@ func (u *UserInterface) updateImpl(force bool) error {
|
|||||||
|
|
||||||
w, h := u.outsideSize()
|
w, h := u.outsideSize()
|
||||||
if force {
|
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
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ func (u *UserInterface) update() error {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
w, h := u.outsideSize()
|
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 err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user