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. // 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.

View File

@ -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.

View File

@ -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
} }
} }