mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/ui: recreate an offscreen image when isScreenClearedEveryFrame is toggled
This is a preparation to remove SetVolatile and SetIsolated in the atlas package.
This commit is contained in:
parent
b30700ac31
commit
d3e3df812a
@ -145,7 +145,18 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
|
||||
}
|
||||
|
||||
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics) {
|
||||
c.offscreen.mipmap.SetVolatile(theGlobalState.isScreenClearedEveryFrame())
|
||||
if c.offscreen.volatile != theGlobalState.isScreenClearedEveryFrame() {
|
||||
w, h := c.offscreen.width, c.offscreen.height
|
||||
c.offscreen.MarkDisposed()
|
||||
c.offscreen = c.game.NewOffscreenImage(w, h)
|
||||
|
||||
// TODO: Give volatile/isolated property to the constructor.
|
||||
if theGlobalState.isScreenClearedEveryFrame() {
|
||||
c.offscreen.setVolatile(true)
|
||||
} else {
|
||||
c.offscreen.mipmap.SetIsolated(true)
|
||||
}
|
||||
}
|
||||
|
||||
// Even though updateCount == 0, the offscreen is cleared and Draw is called.
|
||||
// Draw should not update the game state and then the screen should not be updated without Update, but
|
||||
@ -245,11 +256,16 @@ func (c *context) layoutGame(outsideWidth, outsideHeight float64, deviceScaleFac
|
||||
if c.offscreen == nil {
|
||||
c.offscreen = c.game.NewOffscreenImage(ow, oh)
|
||||
|
||||
// Keep the offscreen an isolated image from an atlas (#1938).
|
||||
// The shader program for the screen is special and doesn't work well with an image on an atlas.
|
||||
// An image on an atlas is surrounded by a transparent edge,
|
||||
// and the shader program unexpectedly picks the pixel on the edges.
|
||||
c.offscreen.mipmap.SetIsolated(true)
|
||||
// TODO: Give volatile/isolated property to the constructor.
|
||||
if theGlobalState.isScreenClearedEveryFrame() {
|
||||
c.offscreen.setVolatile(true)
|
||||
} else {
|
||||
// Keep the offscreen an isolated image from an atlas (#1938).
|
||||
// The shader program for the screen is special and doesn't work well with an image on an atlas.
|
||||
// An image on an atlas is surrounded by a transparent edge,
|
||||
// and the shader program unexpectedly picks the pixel on the edges.
|
||||
c.offscreen.mipmap.SetIsolated(true)
|
||||
}
|
||||
}
|
||||
|
||||
return ow, oh
|
||||
|
@ -30,9 +30,10 @@ func SetPanicOnErrorOnReadingPixelsForTesting(value bool) {
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
mipmap *mipmap.Mipmap
|
||||
width int
|
||||
height int
|
||||
mipmap *mipmap.Mipmap
|
||||
width int
|
||||
height int
|
||||
volatile bool
|
||||
}
|
||||
|
||||
func NewImage(width, height int) *Image {
|
||||
@ -51,6 +52,11 @@ func newScreenFramebufferImage(width, height int) *Image {
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Image) setVolatile(volatile bool) {
|
||||
i.volatile = volatile
|
||||
i.mipmap.SetVolatile(volatile)
|
||||
}
|
||||
|
||||
func (i *Image) MarkDisposed() {
|
||||
if i.mipmap == nil {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user