internal/ui: refactoring

This commit is contained in:
Hajime Hoshi 2022-02-14 03:39:02 +09:00
parent 871121abe3
commit 4949c49cd0

View File

@ -75,13 +75,8 @@ func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeig
return nil return nil
} }
c.m.Lock()
c.outsideWidth = outsideWidth
c.outsideHeight = outsideHeight
c.m.Unlock()
// ForceUpdate can be invoked even if the context is not initialized yet (#1591). // ForceUpdate can be invoked even if the context is not initialized yet (#1591).
if w, h := c.layoutGame(deviceScaleFactor); w == 0 || h == 0 { if w, h := c.layoutGame(outsideWidth, outsideHeight, deviceScaleFactor); w == 0 || h == 0 {
return nil return nil
} }
@ -125,11 +120,13 @@ func (c *contextImpl) updateFrameImpl(updateCount int, outsideWidth, outsideHeig
}) })
} }
func (c *contextImpl) layoutGame(deviceScaleFactor float64) (int, int) { func (c *contextImpl) layoutGame(outsideWidth, outsideHeight float64, deviceScaleFactor float64) (int, int) {
c.m.Lock() c.m.Lock()
defer c.m.Unlock() defer c.m.Unlock()
w, h := c.game.Layout(c.outsideWidth, c.outsideHeight, deviceScaleFactor) c.outsideWidth = outsideWidth
c.outsideHeight = outsideHeight
w, h := c.game.Layout(outsideWidth, outsideHeight, deviceScaleFactor)
c.screenWidth = w c.screenWidth = w
c.screenHeight = h c.screenHeight = h
return w, h return w, h