mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/ui: flush the cache of the final screen after DrawScreen
The screen image might have a cache in the future. Updates #2385
This commit is contained in:
parent
daf349ab72
commit
32a2a705c0
@ -175,6 +175,11 @@ func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics) error {
|
||||
}
|
||||
|
||||
c.game.DrawScreen()
|
||||
|
||||
// The final screen is never used as the rendering source.
|
||||
// Flush its cache here just in case.
|
||||
c.screen.flushCacheIfNeeded()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -57,14 +57,14 @@ func (i *Image) MarkDisposed() {
|
||||
}
|
||||
|
||||
func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, mode graphicsdriver.CompositeMode, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageCount - 1][2]float32, shader *Shader, uniforms [][]float32, evenOdd bool, canSkipMipmap bool) {
|
||||
i.resolveDotsCacheIfNeeded()
|
||||
i.flushCacheIfNeeded()
|
||||
|
||||
var srcMipmaps [graphics.ShaderImageCount]*mipmap.Mipmap
|
||||
for i, src := range srcs {
|
||||
if src == nil {
|
||||
continue
|
||||
}
|
||||
src.resolveDotsCacheIfNeeded()
|
||||
src.flushCacheIfNeeded()
|
||||
srcMipmaps[i] = src.mipmap
|
||||
}
|
||||
|
||||
@ -83,12 +83,12 @@ func (i *Image) WritePixels(pix []byte, x, y, width, height int) {
|
||||
|
||||
// One square requires 6 indices (= 2 triangles).
|
||||
if len(i.dotsCache) >= graphics.IndicesCount/6 {
|
||||
i.resolveDotsCacheIfNeeded()
|
||||
i.flushCacheIfNeeded()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
i.resolveDotsCacheIfNeeded()
|
||||
i.flushCacheIfNeeded()
|
||||
i.mipmap.WritePixels(pix, x, y, width, height)
|
||||
}
|
||||
|
||||
@ -103,10 +103,10 @@ func (i *Image) ReadPixels(pixels []byte, x, y, width, height int) {
|
||||
copy(pixels, c[:])
|
||||
return
|
||||
}
|
||||
// Do not call resolveDotsCacheIfNeeded here. This would slow (image/draw).Draw.
|
||||
// Do not call flushCacheIfNeeded here. This would slow (image/draw).Draw.
|
||||
// See ebiten.TestImageDrawOver.
|
||||
} else {
|
||||
i.resolveDotsCacheIfNeeded()
|
||||
i.flushCacheIfNeeded()
|
||||
}
|
||||
|
||||
if err := theUI.readPixels(i.mipmap, pixels, x, y, width, height); err != nil {
|
||||
@ -121,7 +121,7 @@ func (i *Image) DumpScreenshot(name string, blackbg bool) (string, error) {
|
||||
return theUI.dumpScreenshot(i.mipmap, name, blackbg)
|
||||
}
|
||||
|
||||
func (i *Image) resolveDotsCacheIfNeeded() {
|
||||
func (i *Image) flushCacheIfNeeded() {
|
||||
if len(i.dotsCache) == 0 {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user