mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/ui: use sync/atomic for performance
This commit is contained in:
parent
909f2fe492
commit
4a82a109be
@ -70,7 +70,7 @@ type userInterfaceImpl struct {
|
|||||||
windowBeingClosed bool
|
windowBeingClosed bool
|
||||||
windowResizingMode WindowResizingMode
|
windowResizingMode WindowResizingMode
|
||||||
justAfterResized bool
|
justAfterResized bool
|
||||||
inFrame bool
|
inFrame uint32
|
||||||
|
|
||||||
// err must be accessed from the main thread.
|
// err must be accessed from the main thread.
|
||||||
err error
|
err error
|
||||||
@ -728,15 +728,11 @@ func (u *userInterfaceImpl) createWindow(width, height int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) beginFrame() {
|
func (u *userInterfaceImpl) beginFrame() {
|
||||||
u.t.Call(func() {
|
atomic.StoreUint32(&u.inFrame, 1)
|
||||||
u.inFrame = true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) endFrame() {
|
func (u *userInterfaceImpl) endFrame() {
|
||||||
u.t.Call(func() {
|
atomic.StoreUint32(&u.inFrame, 0)
|
||||||
u.inFrame = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerWindowSetSizeCallback must be called from the main thread.
|
// registerWindowSetSizeCallback must be called from the main thread.
|
||||||
@ -759,7 +755,7 @@ func (u *userInterfaceImpl) registerWindowSetSizeCallback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now the state is in a frame. (force)UpdateFrame cannot be called recursively.
|
// Now the state is in a frame. (force)UpdateFrame cannot be called recursively.
|
||||||
if u.inFrame {
|
if atomic.LoadUint32(&u.inFrame) != 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user