mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
shareable: Refactoring
This commit is contained in:
parent
464713f19d
commit
76330c492c
@ -139,6 +139,14 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// Lock the mutex before a frame begins.
|
||||||
|
//
|
||||||
|
// In each frame, restoring images and resolving images happen respectively:
|
||||||
|
//
|
||||||
|
// [Restore -> Resolve] -> [Restore -> Resolve] -> ...
|
||||||
|
//
|
||||||
|
// Between each frame, any image operations are not permitted, or stale images would remain when restoring
|
||||||
|
// (#913).
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,20 +572,13 @@ func NewScreenFramebufferImage(width, height int) *Image {
|
|||||||
|
|
||||||
func EndFrame() error {
|
func EndFrame() error {
|
||||||
backendsM.Lock()
|
backendsM.Lock()
|
||||||
|
|
||||||
restorable.ResolveStaleImages()
|
restorable.ResolveStaleImages()
|
||||||
return restorable.Error()
|
return restorable.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func BeginFrame() error {
|
func BeginFrame() error {
|
||||||
// In each frame, restoring images and resolving images happen respectively:
|
defer backendsM.Unlock()
|
||||||
//
|
|
||||||
// [Restore -> Resolve] -> [Restore -> Resolve] -> ...
|
|
||||||
//
|
|
||||||
// Between each frame, any image operations are not permitted, or stale images would remain when restoring
|
|
||||||
// (#913).
|
|
||||||
defer func() {
|
|
||||||
backendsM.Unlock()
|
|
||||||
}()
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
initOnce.Do(func() {
|
initOnce.Do(func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user