internal/ui: rename contextImpl -> context

This commit is contained in:
Hajime Hoshi 2022-04-01 17:59:44 +09:00
parent 09a548e055
commit ea1c18d124
9 changed files with 20 additions and 20 deletions

View File

@ -35,7 +35,7 @@ type Game interface {
Draw(screenScale float64, offsetX, offsetY float64, needsClearingScreen bool, framebufferYDirection graphicsdriver.YDirection, screenClearedEveryFrame, filterEnabled bool) error
}
type contextImpl struct {
type context struct {
game Game
updateCalled bool
@ -49,18 +49,18 @@ type contextImpl struct {
m sync.Mutex
}
func newContextImpl(game Game) *contextImpl {
return &contextImpl{
func newContext(game Game) *context {
return &context{
game: game,
}
}
func (c *contextImpl) updateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
func (c *context) 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(graphicsDriver, clock.Update(theGlobalState.maxTPS()), outsideWidth, outsideHeight, deviceScaleFactor)
}
func (c *contextImpl) forceUpdateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
func (c *context) forceUpdateFrame(graphicsDriver graphicsdriver.Graphics, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
n := 1
if graphicsDriver.IsDirectX() {
// On DirectX, both framebuffers in the swap chain should be updated.
@ -75,7 +75,7 @@ func (c *contextImpl) forceUpdateFrame(graphicsDriver graphicsdriver.Graphics, o
return nil
}
func (c *contextImpl) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, updateCount int, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, updateCount int, outsideWidth, outsideHeight float64, deviceScaleFactor float64) error {
if err := theGlobalState.error(); err != nil {
return err
}
@ -135,7 +135,7 @@ func (c *contextImpl) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, up
})
}
func (c *contextImpl) layoutGame(outsideWidth, outsideHeight float64, deviceScaleFactor float64) (int, int) {
func (c *context) layoutGame(outsideWidth, outsideHeight float64, deviceScaleFactor float64) (int, int) {
c.m.Lock()
defer c.m.Unlock()
@ -147,7 +147,7 @@ func (c *contextImpl) layoutGame(outsideWidth, outsideHeight float64, deviceScal
return w, h
}
func (c *contextImpl) adjustPosition(x, y float64, deviceScaleFactor float64) (float64, float64) {
func (c *context) adjustPosition(x, y float64, deviceScaleFactor float64) (float64, float64) {
s, ox, oy := c.screenScaleAndOffsets(deviceScaleFactor)
// The scale 0 indicates that the screen is not initialized yet.
// As any cursor values don't make sense, just return NaN.
@ -157,7 +157,7 @@ func (c *contextImpl) adjustPosition(x, y float64, deviceScaleFactor float64) (f
return (x*deviceScaleFactor - ox) / s, (y*deviceScaleFactor - oy) / s
}
func (c *contextImpl) screenScaleAndOffsets(deviceScaleFactor float64) (float64, float64, float64) {
func (c *context) screenScaleAndOffsets(deviceScaleFactor float64) (float64, float64, float64) {
c.m.Lock()
defer c.m.Unlock()

View File

@ -31,7 +31,7 @@ type Input struct {
m sync.Mutex
}
func (i *Input) update(context *contextImpl) {
func (i *Input) update(context *context) {
i.m.Lock()
defer i.m.Unlock()

View File

@ -155,7 +155,7 @@ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
}
// update must be called from the main thread.
func (i *Input) update(window *glfw.Window, context *contextImpl) error {
func (i *Input) update(window *glfw.Window, context *context) error {
i.ui.m.Lock()
defer i.ui.m.Unlock()

View File

@ -23,7 +23,7 @@ import (
)
func (u *userInterfaceImpl) Run(game Game) error {
u.context = newContextImpl(game)
u.context = newContext(game)
// Initialize the main thread first so the thread is available at u.run (#809).
u.t = thread.NewOSThread()

View File

@ -23,7 +23,7 @@ import (
)
func (u *userInterfaceImpl) Run(game Game) error {
u.context = newContextImpl(game)
u.context = newContext(game)
// Initialize the main thread first so the thread is available at u.run (#809).
u.t = thread.NewNoopThread()

View File

@ -55,12 +55,12 @@ func init() {
type userInterfaceImpl struct {
graphicsDriver graphicsdriver.Graphics
context *contextImpl
context *context
input Input
}
func (u *userInterfaceImpl) Run(game Game) error {
u.context = newContextImpl(game)
u.context = newContext(game)
g, err := chooseGraphicsDriver(&graphicsDriverGetterImpl{})
if err != nil {
return err

View File

@ -50,7 +50,7 @@ func driverCursorModeToGLFWCursorMode(mode CursorMode) int {
type userInterfaceImpl struct {
graphicsDriver graphicsdriver.Graphics
context *contextImpl
context *context
title string
window *glfw.Window

View File

@ -84,7 +84,7 @@ type userInterfaceImpl struct {
lastDeviceScaleFactor float64
context *contextImpl
context *context
input Input
}
@ -330,7 +330,7 @@ func (u *userInterfaceImpl) needsUpdate() bool {
}
func (u *userInterfaceImpl) loop(game Game) <-chan error {
u.context = newContextImpl(game)
u.context = newContext(game)
errCh := make(chan error, 1)
reqStopAudioCh := make(chan struct{})

View File

@ -105,7 +105,7 @@ type userInterfaceImpl struct {
setGBuildSizeCh chan struct{}
once sync.Once
context *contextImpl
context *context
input Input
@ -269,7 +269,7 @@ func (u *userInterfaceImpl) run(game Game, mainloop bool) (err error) {
}
}()
u.context = newContextImpl(game)
u.context = newContext(game)
g, err := chooseGraphicsDriver(&graphicsDriverGetterImpl{
gomobileBuild: mainloop,
})