mipmap: Bug fix: Wrong maximum size of the negative-level mipmap image

This commit is contained in:
Hajime Hoshi 2020-07-15 22:59:27 +09:00
parent 7f70797a6d
commit 48b192dbe9

View File

@ -108,7 +108,7 @@ func (m *Mipmap) DrawImage(src *Mipmap, bounds image.Rectangle, geom GeoM, color
return return
} }
level := src.mipmapLevel(geom, bounds.Dx(), bounds.Dy(), filter) level := src.mipmapLevel(geom, filter)
if level > 0 { if level > 0 {
// If the image can be scaled into 0 size, adjust the level. (#839) // If the image can be scaled into 0 size, adjust the level. (#839)
@ -312,7 +312,7 @@ func (m *Mipmap) disposeMipmaps() {
// mipmapLevel returns an appropriate mipmap level for the given determinant of a geometry matrix. // mipmapLevel returns an appropriate mipmap level for the given determinant of a geometry matrix.
// //
// mipmapLevel panics if det is NaN or 0. // mipmapLevel panics if det is NaN or 0.
func (m *Mipmap) mipmapLevel(geom GeoM, width, height int, filter driver.Filter) int { func (m *Mipmap) mipmapLevel(geom GeoM, filter driver.Filter) int {
det := geom.det() det := geom.det()
if math.IsNaN(float64(det)) { if math.IsNaN(float64(det)) {
panic("ebiten: det must be finite at mipmapLevel") panic("ebiten: det must be finite at mipmapLevel")
@ -338,7 +338,7 @@ func (m *Mipmap) mipmapLevel(geom GeoM, width, height int, filter driver.Filter)
} }
const mipmapMaxSize = 1024 const mipmapMaxSize = 1024
w, h := width, height w, h := m.width, m.height
if w >= mipmapMaxSize || h >= mipmapMaxSize { if w >= mipmapMaxSize || h >= mipmapMaxSize {
return 0 return 0
} }