From ea1c18d124a23caf999df5d1d2f9dc60ee33ddc0 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 1 Apr 2022 17:59:44 +0900 Subject: [PATCH] internal/ui: rename contextImpl -> context --- internal/ui/context.go | 18 +++++++++--------- internal/ui/input_cbackend.go | 2 +- internal/ui/input_glfw.go | 2 +- internal/ui/run_notsinglethread.go | 2 +- internal/ui/run_singlethread.go | 2 +- internal/ui/ui_cbackend.go | 4 ++-- internal/ui/ui_glfw.go | 2 +- internal/ui/ui_js.go | 4 ++-- internal/ui/ui_mobile.go | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/internal/ui/context.go b/internal/ui/context.go index 1f0c0a7ae..a497eee20 100644 --- a/internal/ui/context.go +++ b/internal/ui/context.go @@ -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() diff --git a/internal/ui/input_cbackend.go b/internal/ui/input_cbackend.go index 56a10793d..e911f0c44 100644 --- a/internal/ui/input_cbackend.go +++ b/internal/ui/input_cbackend.go @@ -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() diff --git a/internal/ui/input_glfw.go b/internal/ui/input_glfw.go index e0f99ce09..32e13b9b5 100644 --- a/internal/ui/input_glfw.go +++ b/internal/ui/input_glfw.go @@ -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() diff --git a/internal/ui/run_notsinglethread.go b/internal/ui/run_notsinglethread.go index 42c0f8fcd..1bedfbb59 100644 --- a/internal/ui/run_notsinglethread.go +++ b/internal/ui/run_notsinglethread.go @@ -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() diff --git a/internal/ui/run_singlethread.go b/internal/ui/run_singlethread.go index dc640799f..c5ab2a6a0 100644 --- a/internal/ui/run_singlethread.go +++ b/internal/ui/run_singlethread.go @@ -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() diff --git a/internal/ui/ui_cbackend.go b/internal/ui/ui_cbackend.go index 8dbe3c784..96fe972ea 100644 --- a/internal/ui/ui_cbackend.go +++ b/internal/ui/ui_cbackend.go @@ -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 diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index c7ecb53a9..8431a2956 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -50,7 +50,7 @@ func driverCursorModeToGLFWCursorMode(mode CursorMode) int { type userInterfaceImpl struct { graphicsDriver graphicsdriver.Graphics - context *contextImpl + context *context title string window *glfw.Window diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 33d0734c7..c757602c0 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -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{}) diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index 2839c960a..4d066fdd5 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -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, })