ebiten: Remove the returning value from (*Image).Dispose

Updates #1380
This commit is contained in:
Hajime Hoshi 2020-10-06 00:13:19 +09:00
parent c2ee8e8d59
commit 525d16bec8
3 changed files with 6 additions and 11 deletions

View File

@ -678,20 +678,17 @@ func (i *Image) Set(x, y int, clr color.Color) {
// However, calling Dispose explicitly is helpful if memory usage matters.
//
// When the image is disposed, Dipose does nothing.
//
// Dipose always return nil as of 1.5.0.
func (i *Image) Dispose() error {
func (i *Image) Dispose() {
i.copyCheck()
if i.isDisposed() {
return nil
return
}
if i.isSubImage() {
return nil
return
}
i.mipmap.MarkDisposed()
i.mipmap = nil
return nil
}
// ReplacePixels replaces the pixels of the image with p.

View File

@ -383,9 +383,7 @@ func TestImageDispose(t *testing.T) {
return
}
img.Fill(color.White)
if err := img.Dispose(); err != nil {
t.Errorf("img.Dipose() returns error: %v", err)
}
img.Dispose()
// The color is transparent (color.RGBA{}).
// Note that the value's type must be color.RGBA.

View File

@ -81,13 +81,13 @@ func (c *uiContext) updateOffscreen() {
c.outsideSizeUpdated = false
if c.screen != nil {
_ = c.screen.Dispose()
c.screen.Dispose()
c.screen = nil
}
if c.offscreen != nil {
if w, h := c.offscreen.Size(); w != sw || h != sh {
_ = c.offscreen.Dispose()
c.offscreen.Dispose()
c.offscreen = nil
}
}