driver: Refactoring: Rename functions

This commit is contained in:
Hajime Hoshi 2021-08-05 01:29:45 +09:00
parent 60b8f82bfd
commit 0bc5166a36
5 changed files with 17 additions and 16 deletions

View File

@ -20,8 +20,8 @@ import (
)
type UIContext interface {
Update() error
ForceUpdate() error
UpdateFrame() error
ForceUpdateFrame() error
Layout(outsideWidth, outsideHeight float64)
// AdjustPosition can be called from a different goroutine from Update's or Layout's.

View File

@ -795,7 +795,7 @@ func (u *UserInterface) registerWindowSetSizeCallback() {
if outsideSizeChanged {
u.context.Layout(outsideWidth, outsideHeight)
}
if err := u.context.ForceUpdate(); err != nil {
if err := u.context.ForceUpdateFrame(); err != nil {
return err
}
if u.Graphics().IsGL() {
@ -1033,7 +1033,7 @@ func (u *UserInterface) loop() error {
u.context.Layout(outsideWidth, outsideHeight)
}
if err := u.context.Update(); err != nil {
if err := u.context.UpdateFrame(); err != nil {
return err
}
@ -1192,8 +1192,9 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
u.swapBuffers()
// Disable the callback of SetSize. This callback can be invoked by SetMonitor or SetSize.
// ForceUpdate is called from the callback.
// While setWindowSize can be called from Update, calling ForceUpdate inside Update is illegal (#1505).
// ForceUpdateFrame is called from the callback.
// While setWindowSize can be called from UpdateFrame,
// calling ForceUpdateFrame inside UpdateFrame is illegal (#1505).
if u.setSizeCallbackEnabled {
u.setSizeCallbackEnabled = false
defer func() {

View File

@ -276,11 +276,11 @@ func (u *UserInterface) updateImpl(force bool) error {
u.input.updateForGo2Cpp()
u.updateSize()
if force {
if err := u.context.ForceUpdate(); err != nil {
if err := u.context.ForceUpdateFrame(); err != nil {
return err
}
} else {
if err := u.context.Update(); err != nil {
if err := u.context.UpdateFrame(); err != nil {
return err
}
}

View File

@ -329,7 +329,7 @@ func (u *UserInterface) update() error {
renderEndCh <- struct{}{}
}()
if err := u.context.Update(); err != nil {
if err := u.context.UpdateFrame(); err != nil {
return err
}
return nil

View File

@ -142,20 +142,20 @@ func (c *uiContext) offsets(deviceScaleFactor float64) (float64, float64) {
return x, y
}
func (c *uiContext) Update() error {
func (c *uiContext) UpdateFrame() error {
// TODO: If updateCount is 0 and vsync is disabled, swapping buffers can be skipped.
return c.update(clock.Update(MaxTPS()))
return c.updateFrame(clock.Update(MaxTPS()))
}
func (c *uiContext) ForceUpdate() error {
func (c *uiContext) ForceUpdateFrame() error {
// ForceUpdate can be invoked even if uiContext it not initialized yet (#1591).
if c.outsideWidth == 0 || c.outsideHeight == 0 {
return nil
}
return c.update(1)
return c.updateFrame(1)
}
func (c *uiContext) update(updateCount int) error {
func (c *uiContext) updateFrame(updateCount int) error {
if err, ok := c.err.Load().(error); ok && err != nil {
return err
}
@ -165,7 +165,7 @@ func (c *uiContext) update(updateCount int) error {
if err := buffered.BeginFrame(); err != nil {
return err
}
if err := c.updateImpl(updateCount); err != nil {
if err := c.updateFrameImpl(updateCount); err != nil {
return err
}
@ -179,7 +179,7 @@ func (c *uiContext) update(updateCount int) error {
})
}
func (c *uiContext) updateImpl(updateCount int) error {
func (c *uiContext) updateFrameImpl(updateCount int) error {
c.updateOffscreen()
// Ensure that Update is called once before Draw so that Update can be used for initialization.