mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
c2ee8e8d59
commit
525d16bec8
9
image.go
9
image.go
@ -678,20 +678,17 @@ func (i *Image) Set(x, y int, clr color.Color) {
|
|||||||
// However, calling Dispose explicitly is helpful if memory usage matters.
|
// However, calling Dispose explicitly is helpful if memory usage matters.
|
||||||
//
|
//
|
||||||
// When the image is disposed, Dipose does nothing.
|
// When the image is disposed, Dipose does nothing.
|
||||||
//
|
func (i *Image) Dispose() {
|
||||||
// Dipose always return nil as of 1.5.0.
|
|
||||||
func (i *Image) Dispose() error {
|
|
||||||
i.copyCheck()
|
i.copyCheck()
|
||||||
|
|
||||||
if i.isDisposed() {
|
if i.isDisposed() {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
if i.isSubImage() {
|
if i.isSubImage() {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
i.mipmap.MarkDisposed()
|
i.mipmap.MarkDisposed()
|
||||||
i.mipmap = nil
|
i.mipmap = nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplacePixels replaces the pixels of the image with p.
|
// ReplacePixels replaces the pixels of the image with p.
|
||||||
|
@ -383,9 +383,7 @@ func TestImageDispose(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
img.Fill(color.White)
|
img.Fill(color.White)
|
||||||
if err := img.Dispose(); err != nil {
|
img.Dispose()
|
||||||
t.Errorf("img.Dipose() returns error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The color is transparent (color.RGBA{}).
|
// The color is transparent (color.RGBA{}).
|
||||||
// Note that the value's type must be color.RGBA.
|
// Note that the value's type must be color.RGBA.
|
||||||
|
@ -81,13 +81,13 @@ func (c *uiContext) updateOffscreen() {
|
|||||||
c.outsideSizeUpdated = false
|
c.outsideSizeUpdated = false
|
||||||
|
|
||||||
if c.screen != nil {
|
if c.screen != nil {
|
||||||
_ = c.screen.Dispose()
|
c.screen.Dispose()
|
||||||
c.screen = nil
|
c.screen = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.offscreen != nil {
|
if c.offscreen != nil {
|
||||||
if w, h := c.offscreen.Size(); w != sw || h != sh {
|
if w, h := c.offscreen.Size(); w != sw || h != sh {
|
||||||
_ = c.offscreen.Dispose()
|
c.offscreen.Dispose()
|
||||||
c.offscreen = nil
|
c.offscreen = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user