mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Revert "internal/atlas: refactoring: remove ImageTypeVolatile"
This reverts commit def82fd5d3
.
Updates #3083
This commit is contained in:
parent
cb63f1e56b
commit
81c75e1b0a
@ -66,6 +66,10 @@ func (g *gameForUI) NewOffscreenImage(width, height int) *ui.Image {
|
|||||||
// An image on an atlas is surrounded by a transparent edge,
|
// An image on an atlas is surrounded by a transparent edge,
|
||||||
// and the shader program unexpectedly picks the pixel on the edges.
|
// and the shader program unexpectedly picks the pixel on the edges.
|
||||||
imageType := atlas.ImageTypeUnmanaged
|
imageType := atlas.ImageTypeUnmanaged
|
||||||
|
if ui.Get().IsScreenClearedEveryFrame() {
|
||||||
|
// A volatile image is also always isolated.
|
||||||
|
imageType = atlas.ImageTypeVolatile
|
||||||
|
}
|
||||||
g.offscreen = newImage(image.Rect(0, 0, width, height), imageType)
|
g.offscreen = newImage(image.Rect(0, 0, width, height), imageType)
|
||||||
return g.offscreen.image
|
return g.offscreen.image
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,8 @@ const (
|
|||||||
// A screen image is also unmanaged.
|
// A screen image is also unmanaged.
|
||||||
ImageTypeScreen
|
ImageTypeScreen
|
||||||
|
|
||||||
|
ImageTypeVolatile
|
||||||
|
|
||||||
// ImageTypeUnmanaged is an unmanaged image that is not on an atlas.
|
// ImageTypeUnmanaged is an unmanaged image that is not on an atlas.
|
||||||
ImageTypeUnmanaged
|
ImageTypeUnmanaged
|
||||||
)
|
)
|
||||||
|
@ -174,8 +174,8 @@ func TestReputOnSourceBackend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
img2.WritePixels(pix, image.Rect(0, 0, size, size))
|
img2.WritePixels(pix, image.Rect(0, 0, size, size))
|
||||||
|
|
||||||
// Create an unmanaged image. This should always be on a non-source backend.
|
// Create a volatile image. This should always be on a non-source backend.
|
||||||
img3 := atlas.NewImage(size, size, atlas.ImageTypeUnmanaged)
|
img3 := atlas.NewImage(size, size, atlas.ImageTypeVolatile)
|
||||||
defer img3.Deallocate()
|
defer img3.Deallocate()
|
||||||
img3.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
img3.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
||||||
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
||||||
@ -685,7 +685,7 @@ func TestImageIsNotReputOnSourceBackendWithoutUsingAsSource(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestImageWritePixelsModify(t *testing.T) {
|
func TestImageWritePixelsModify(t *testing.T) {
|
||||||
for _, typ := range []atlas.ImageType{atlas.ImageTypeRegular, atlas.ImageTypeRegular, atlas.ImageTypeUnmanaged} {
|
for _, typ := range []atlas.ImageType{atlas.ImageTypeRegular, atlas.ImageTypeVolatile, atlas.ImageTypeUnmanaged} {
|
||||||
const size = 16
|
const size = 16
|
||||||
img := atlas.NewImage(size, size, typ)
|
img := atlas.NewImage(size, size, typ)
|
||||||
defer img.Deallocate()
|
defer img.Deallocate()
|
||||||
|
@ -180,6 +180,12 @@ func (c *context) newOffscreenImage(w, h int) *Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, ui *UserInterface, forceDraw bool) error {
|
func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics, ui *UserInterface, forceDraw bool) error {
|
||||||
|
if (c.offscreen.imageType == atlas.ImageTypeVolatile) != ui.IsScreenClearedEveryFrame() {
|
||||||
|
w, h := c.offscreen.width, c.offscreen.height
|
||||||
|
c.offscreen.Deallocate()
|
||||||
|
c.offscreen = c.newOffscreenImage(w, h)
|
||||||
|
}
|
||||||
|
|
||||||
// isOffscreenModified is updated when an offscreen's modifyCallback.
|
// isOffscreenModified is updated when an offscreen's modifyCallback.
|
||||||
c.isOffscreenModified = false
|
c.isOffscreenModified = false
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
@ -85,7 +86,16 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
|
|||||||
|
|
||||||
if antialias {
|
if antialias {
|
||||||
if i.bigOffscreenBuffer == nil {
|
if i.bigOffscreenBuffer == nil {
|
||||||
i.bigOffscreenBuffer = i.ui.newBigOffscreenImage(i, atlas.ImageTypeUnmanaged)
|
var imageType atlas.ImageType
|
||||||
|
switch i.imageType {
|
||||||
|
case atlas.ImageTypeRegular, atlas.ImageTypeUnmanaged:
|
||||||
|
imageType = atlas.ImageTypeUnmanaged
|
||||||
|
case atlas.ImageTypeScreen, atlas.ImageTypeVolatile:
|
||||||
|
imageType = atlas.ImageTypeVolatile
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("ui: unexpected image type: %d", imageType))
|
||||||
|
}
|
||||||
|
i.bigOffscreenBuffer = i.ui.newBigOffscreenImage(i, imageType)
|
||||||
}
|
}
|
||||||
|
|
||||||
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule, canSkipMipmap)
|
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule, canSkipMipmap)
|
||||||
|
Loading…
Reference in New Issue
Block a user