mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
graphics: Reland: Bug fix: a too old frame was rendered at least on Android
Fixes #525
This commit is contained in:
parent
1c0f5e09d5
commit
b8deabbd94
@ -16,6 +16,7 @@ package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/internal/restorable"
|
||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||
@ -97,17 +98,22 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
||||
}
|
||||
afterFrameUpdate()
|
||||
}
|
||||
if 0 < updateCount {
|
||||
// Call ClearFramebuffer instead of c.screen.Clear()
|
||||
|
||||
// Clear the screen framebuffer by DrawImage instad of Fill
|
||||
// to clear the whole region including fullscreen's padding.
|
||||
c.screen.restorable.ClearFramebuffer()
|
||||
op := &DrawImageOptions{}
|
||||
w, h := emptyImage.Size()
|
||||
// graphics.MaxImageSize should be the maximum size of framebuffer.
|
||||
op.GeoM.Scale(graphics.MaxImageSize/float64(w), graphics.MaxImageSize/float64(h))
|
||||
op.CompositeMode = CompositeModeCopy
|
||||
op.Filter = filterScreen // any filter is fine: just use the same filter as below.
|
||||
c.screen.DrawImage(emptyImage, op)
|
||||
|
||||
dw, dh := c.screen.Size()
|
||||
sw, _ := c.offscreen.Size()
|
||||
scale := float64(dw) / float64(sw)
|
||||
|
||||
op := &DrawImageOptions{}
|
||||
|
||||
op = &DrawImageOptions{}
|
||||
// c.screen is special: its Y axis is down to up,
|
||||
// and the origin point is lower left.
|
||||
op.GeoM.Scale(scale, -scale)
|
||||
@ -117,7 +123,6 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
||||
op.CompositeMode = CompositeModeCopy
|
||||
op.Filter = filterScreen
|
||||
_ = c.screen.DrawImage(c.offscreen, op)
|
||||
}
|
||||
|
||||
if err := restorable.ResolveStaleImages(); err != nil {
|
||||
return err
|
||||
|
@ -129,10 +129,6 @@ func (i *Image) clearIfVolatile() {
|
||||
if !i.volatile {
|
||||
return
|
||||
}
|
||||
i.ClearFramebuffer()
|
||||
}
|
||||
|
||||
func (i *Image) ClearFramebuffer() {
|
||||
i.basePixels = nil
|
||||
i.drawImageHistory = nil
|
||||
i.stale = false
|
||||
|
Loading…
Reference in New Issue
Block a user