ebiten: Remove IsDrawingSkipped

Fixes #1127
This commit is contained in:
Hajime Hoshi 2020-10-04 17:21:09 +09:00
parent ec6e4a16ce
commit 81f336ac46
3 changed files with 2 additions and 46 deletions

View File

@ -154,10 +154,7 @@ func (i *imageDumper) update(screen *Image) error {
}
}
if IsDrawingSkipped() {
return nil
}
// TODO: As the screen will be available only from Draw, move this to a drawing function.
return i.dump(screen)
}

39
run.go
View File

@ -78,19 +78,10 @@ func CurrentFPS() float64 {
}
var (
isDrawingSkipped = int32(0)
isScreenClearedEveryFrame = int32(1)
currentMaxTPS = int32(DefaultTPS)
)
func setDrawingSkipped(skipped bool) {
v := int32(0)
if skipped {
v = 1
}
atomic.StoreInt32(&isDrawingSkipped, v)
}
// SetScreenClearedEveryFrame enables or disables the clearing of the screen at the beginning of each frame.
// The default value is false and the screen is cleared each frame by default.
//
@ -111,36 +102,6 @@ func IsScreenClearedEveryFrame() bool {
return atomic.LoadInt32(&isScreenClearedEveryFrame) != 0
}
// IsDrawingSkipped returns true if rendering result is not adopted.
// It is recommended to skip drawing images or screen
// when IsDrawingSkipped is true.
//
// The typical code with IsDrawingSkipped is this:
//
// func update(screen *ebiten.Image) error {
//
// // Update the state.
//
// // When IsDrawingSkipped is true, the rendered result is not adopted.
// // Skip rendering then.
// if ebiten.IsDrawingSkipped() {
// return nil
// }
//
// // Draw something to the screen.
//
// return nil
// }
//
// IsDrawingSkipped is useful if you use Run function or RunGame function without implementing Game's Draw.
// Otherwise, i.e., if you use RunGame function with implementing Game's Draw, IsDrawingSkipped should not be used.
// If you use RunGame and Draw, IsDrawingSkipped always returns true.
//
// IsDrawingSkipped is concurrent-safe.
func IsDrawingSkipped() bool {
return atomic.LoadInt32(&isDrawingSkipped) != 0
}
type imageDumperGame struct {
game Game
d *imageDumper

View File

@ -179,6 +179,7 @@ func (c *uiContext) Draw() error {
}
func (c *uiContext) update() error {
// TODO: Move the clock usage to the UI driver side.
updateCount := clock.Update(MaxTPS())
// Ensure that Update is called once before Draw so that Update can be used for initialization.
@ -190,9 +191,6 @@ func (c *uiContext) update() error {
for i := 0; i < updateCount; i++ {
c.updateOffscreen()
// TODO: Move the clock usage to the UI driver side.
setDrawingSkipped(i < updateCount-1)
if err := hooks.RunBeforeUpdateHooks(); err != nil {
return err
}