mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphics: Add image.disposed
This commit is contained in:
parent
61ed13e322
commit
b8a062e813
7
image.go
7
image.go
@ -32,6 +32,7 @@ var imageM sync.Mutex
|
||||
type Image struct {
|
||||
framebuffer *graphics.Framebuffer
|
||||
texture *graphics.Texture
|
||||
disposed bool
|
||||
pixels []uint8
|
||||
width int
|
||||
height int
|
||||
@ -203,12 +204,8 @@ func (i *Image) Dispose() error {
|
||||
return c.Exec()
|
||||
}
|
||||
|
||||
// FIXME: This returns true when image is temporal state!
|
||||
func (i *Image) isDisposed() bool {
|
||||
// i.texture can be nil even when the image is not disposed,
|
||||
// so we need to check if both are nil.
|
||||
// See graphicsContext.setSize function.
|
||||
return i.texture == nil && i.framebuffer == nil
|
||||
return i.disposed
|
||||
}
|
||||
|
||||
// ReplacePixels replaces the pixels of the image with p.
|
||||
|
@ -109,6 +109,7 @@ func (c *disposeCommand) Exec() error {
|
||||
}
|
||||
c.image.texture = nil
|
||||
}
|
||||
c.image.disposed = true
|
||||
c.image.pixels = nil
|
||||
runtime.SetFinalizer(c.image, nil)
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user