mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/restorable: integrate some functions into internal/atlas
Updates #805
This commit is contained in:
parent
21ef462c37
commit
c5d0ec3de7
@ -385,7 +385,7 @@ func (i *Image) drawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices [
|
|||||||
vertices[i+3] += oyf
|
vertices[i+3] += oyf
|
||||||
}
|
}
|
||||||
if shader.ir.Unit == shaderir.Texels {
|
if shader.ir.Unit == shaderir.Texels {
|
||||||
sw, sh := srcs[0].backend.restorable.InternalSize()
|
sw, sh := srcs[0].backend.restorable.Image.InternalSize()
|
||||||
swf, shf := float32(sw), float32(sh)
|
swf, shf := float32(sw), float32(sh)
|
||||||
for i := 0; i < n; i += graphics.VertexFloatCount {
|
for i := 0; i < n; i += graphics.VertexFloatCount {
|
||||||
vertices[i+2] /= swf
|
vertices[i+2] /= swf
|
||||||
@ -584,7 +584,8 @@ func (i *Image) deallocate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !i.isOnAtlas() {
|
if !i.isOnAtlas() {
|
||||||
i.backend.restorable.Dispose()
|
i.backend.restorable.Image.Dispose()
|
||||||
|
i.backend.restorable.Image = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +597,8 @@ func (i *Image) deallocate() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
i.backend.restorable.Dispose()
|
i.backend.restorable.Image.Dispose()
|
||||||
|
i.backend.restorable.Image = nil
|
||||||
|
|
||||||
for idx, sh := range theBackends {
|
for idx, sh := range theBackends {
|
||||||
if sh == i.backend {
|
if sh == i.backend {
|
||||||
@ -736,7 +738,7 @@ func (i *Image) DumpScreenshot(graphicsDriver graphicsdriver.Graphics, path stri
|
|||||||
panic("atlas: DumpScreenshots must be called in between BeginFrame and EndFrame")
|
panic("atlas: DumpScreenshots must be called in between BeginFrame and EndFrame")
|
||||||
}
|
}
|
||||||
|
|
||||||
return i.backend.restorable.Dump(graphicsDriver, path, blackbg, image.Rect(0, 0, i.width, i.height))
|
return i.backend.restorable.Image.Dump(graphicsDriver, path, blackbg, image.Rect(0, 0, i.width, i.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
func EndFrame() error {
|
func EndFrame() error {
|
||||||
|
@ -72,7 +72,8 @@ func (i *Image) Extend(width, height int) *Image {
|
|||||||
is := graphics.QuadIndices()
|
is := graphics.QuadIndices()
|
||||||
dr := image.Rect(0, 0, sw, sh)
|
dr := image.Rect(0, 0, sw, sh)
|
||||||
newImg.DrawTriangles(srcs, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillAll)
|
newImg.DrawTriangles(srcs, vs, is, graphicsdriver.BlendCopy, dr, [graphics.ShaderImageCount]image.Rectangle{}, NearestFilterShader, nil, graphicsdriver.FillAll)
|
||||||
i.Dispose()
|
i.Image.Dispose()
|
||||||
|
i.Image = nil
|
||||||
|
|
||||||
return newImg
|
return newImg
|
||||||
}
|
}
|
||||||
@ -155,19 +156,3 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose disposes the image.
|
|
||||||
//
|
|
||||||
// After disposing, calling the function of the image causes unexpected results.
|
|
||||||
func (i *Image) Dispose() {
|
|
||||||
i.Image.Dispose()
|
|
||||||
i.Image = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackbg bool, rect image.Rectangle) (string, error) {
|
|
||||||
return i.Image.Dump(graphicsDriver, path, blackbg, rect)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *Image) InternalSize() (int, int) {
|
|
||||||
return i.Image.InternalSize()
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user