mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/atlas: refactoring: remove ImageTypeVolatile
ImageTypeVolatile was meaningful when Ebitengine had `restorable` package, but now this doesn't make sense.
This commit is contained in:
parent
32417353d3
commit
def82fd5d3
@ -66,10 +66,6 @@ func (g *gameForUI) NewOffscreenImage(width, height int) *ui.Image {
|
||||
// An image on an atlas is surrounded by a transparent edge,
|
||||
// and the shader program unexpectedly picks the pixel on the edges.
|
||||
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)
|
||||
return g.offscreen.image
|
||||
}
|
||||
|
@ -225,7 +225,6 @@ type ImageType int
|
||||
const (
|
||||
ImageTypeRegular ImageType = iota
|
||||
ImageTypeScreen
|
||||
ImageTypeVolatile
|
||||
ImageTypeUnmanaged
|
||||
)
|
||||
|
||||
|
@ -177,8 +177,8 @@ func TestReputOnSourceBackend(t *testing.T) {
|
||||
}
|
||||
img2.WritePixels(pix, image.Rect(0, 0, size, size))
|
||||
|
||||
// Create a volatile image. This should always be on a non-source backend.
|
||||
img3 := atlas.NewImage(size, size, atlas.ImageTypeVolatile)
|
||||
// Create an unmanaged image. This should always be on a non-source backend.
|
||||
img3 := atlas.NewImage(size, size, atlas.ImageTypeUnmanaged)
|
||||
defer img3.Deallocate()
|
||||
img3.WritePixels(make([]byte, 4*size*size), image.Rect(0, 0, size, size))
|
||||
if got, want := img3.IsOnSourceBackendForTesting(), false; got != want {
|
||||
@ -688,7 +688,7 @@ func TestImageIsNotReputOnSourceBackendWithoutUsingAsSource(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImageWritePixelsModify(t *testing.T) {
|
||||
for _, typ := range []atlas.ImageType{atlas.ImageTypeRegular, atlas.ImageTypeVolatile, atlas.ImageTypeUnmanaged} {
|
||||
for _, typ := range []atlas.ImageType{atlas.ImageTypeRegular, atlas.ImageTypeRegular, atlas.ImageTypeUnmanaged} {
|
||||
const size = 16
|
||||
img := atlas.NewImage(size, size, typ)
|
||||
defer img.Deallocate()
|
||||
|
@ -178,12 +178,6 @@ func (c *context) newOffscreenImage(w, h int) *Image {
|
||||
}
|
||||
|
||||
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.
|
||||
c.isOffscreenModified = false
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"math"
|
||||
|
||||
@ -86,16 +85,7 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice
|
||||
|
||||
if antialias {
|
||||
if i.bigOffscreenBuffer == nil {
|
||||
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 = i.ui.newBigOffscreenImage(i, atlas.ImageTypeUnmanaged)
|
||||
}
|
||||
|
||||
i.bigOffscreenBuffer.drawTriangles(srcs, vertices, indices, blend, dstRegion, srcRegions, shader, uniforms, fillRule, canSkipMipmap)
|
||||
|
Loading…
Reference in New Issue
Block a user