From c6c8ff22d703628b8cc4f911a020afb2e545622b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 30 May 2017 00:56:01 +0900 Subject: [PATCH] graphics: Panic first when drawing the same image --- image.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/image.go b/image.go index 17d417b4e..fa6f43f6f 100644 --- a/image.go +++ b/image.go @@ -90,10 +90,13 @@ func (i *Image) Fill(clr color.Color) error { // // When the image is disposed, DrawImage does nothing. // -// When image is as same as i, DrawImage panics. +// When the given image is as same as i, DrawImage panics. // // DrawImage always returns nil as of 1.5.0-alpha. func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error { + if i == img { + panic("ebiten: Image.DrawImage: img must be different from the receiver") + } if i.restorable == nil { return nil } @@ -137,9 +140,6 @@ func (i *Image) DrawImage(img *Image, options *DrawImageOptions) error { sy1 = r.Max.Y } vs := vertices(sx0, sy0, sx1, sy1, w, h, &options.GeoM.impl) - if i == img { - panic("ebiten: Image.DrawImage: img must be different from the receiver") - } mode := opengl.CompositeMode(options.CompositeMode) i.restorable.DrawImage(img.restorable, vs, &options.ColorM.impl, mode) return nil