mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/atlas: resolve deferred every frame instead of every tick
Resolving defferred functions doesn't have to be done every tick. Rather, this should be done every frame as this is related to rendering.
This commit is contained in:
parent
4949c49cd0
commit
f17d222a4b
@ -23,7 +23,6 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/packing"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/restorable"
|
||||
)
|
||||
@ -103,16 +102,6 @@ func min(a, b int) int {
|
||||
return b
|
||||
}
|
||||
|
||||
func init() {
|
||||
hooks.AppendHookOnBeforeUpdate(func() error {
|
||||
backendsM.Lock()
|
||||
defer backendsM.Unlock()
|
||||
|
||||
resolveDeferred()
|
||||
return putImagesOnAtlas()
|
||||
})
|
||||
}
|
||||
|
||||
func resolveDeferred() {
|
||||
deferredM.Lock()
|
||||
fs := deferred
|
||||
@ -823,6 +812,11 @@ func BeginFrame() error {
|
||||
return err
|
||||
}
|
||||
|
||||
resolveDeferred()
|
||||
if err := putImagesOnAtlas(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return restorable.RestoreIfNeeded()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user