graphics: Bug fix: level must be >= 0

There was a cache that level can be negative. This change fixes
this.
This commit is contained in:
Hajime Hoshi 2019-04-25 02:49:20 +09:00
parent cce41e8152
commit 6022d8856e

View File

@ -42,8 +42,8 @@ func (m *mipmap) original() *shareable.Image {
}
func (m *mipmap) level(r image.Rectangle, level int) *shareable.Image {
if level == 0 {
panic("ebiten: level must not be 0 (original image) at level")
if level <= 0 {
panic("ebiten: level must be positive at level")
}
imgs, ok := m.imgs[r]
@ -336,6 +336,11 @@ func (i *Image) drawImage(img *Image, options *DrawImageOptions) {
}
break
}
if level < 0 {
// As the render source is too small, nothing is rendered.
return
}
}
if level > 6 {
level = 6