diff --git a/image.go b/image.go index c51ca2b2c..92a8cc0c8 100644 --- a/image.go +++ b/image.go @@ -23,7 +23,6 @@ import ( "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/shareable" ) var ( @@ -748,9 +747,8 @@ type DrawImageOptions struct { // // Error returned by NewImage is always nil as of 1.5.0-alpha. func NewImage(width, height int, filter Filter) (*Image, error) { - s := shareable.NewImage(width, height) i := &Image{ - mipmap: newMipmap(s), + mipmap: newMipmap(width, height), filter: filter, } i.addr = i @@ -780,7 +778,7 @@ func (i *Image) makeVolatile() { if i.isDisposed() { return } - i.mipmap.orig.MakeVolatile() + i.mipmap.makeVolatile() i.disposeMipmaps() } @@ -797,9 +795,8 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) { width, height := size.X, size.Y - s := shareable.NewImage(width, height) i := &Image{ - mipmap: newMipmap(s), + mipmap: newMipmap(width, height), filter: filter, } i.addr = i @@ -810,7 +807,7 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) { func newScreenFramebufferImage(width, height int) *Image { i := &Image{ - mipmap: newMipmap(shareable.NewScreenFramebufferImage(width, height)), + mipmap: newScreenFramebufferMipmap(width, height), filter: FilterDefault, } i.addr = i diff --git a/imagedumper_desktop.go b/imagedumper_desktop.go index 5d90b5733..94e4012ee 100644 --- a/imagedumper_desktop.go +++ b/imagedumper_desktop.go @@ -52,7 +52,7 @@ func takeScreenshot(screen *Image) error { return err } - if err := screen.mipmap.orig.Dump(newname); err != nil { + if err := screen.mipmap.dump(newname); err != nil { return err } diff --git a/mipmap.go b/mipmap.go index 3448fdfb3..7b4d8d29a 100644 --- a/mipmap.go +++ b/mipmap.go @@ -31,9 +31,16 @@ type mipmap struct { imgs map[image.Rectangle]levelToImage } -func newMipmap(s *shareable.Image) *mipmap { +func newMipmap(width, height int) *mipmap { return &mipmap{ - orig: s, + orig: shareable.NewImage(width, height), + imgs: map[image.Rectangle]levelToImage{}, + } +} + +func newScreenFramebufferMipmap(width, height int) *mipmap { + return &mipmap{ + orig: shareable.NewScreenFramebufferImage(width, height), imgs: map[image.Rectangle]levelToImage{}, } } @@ -42,6 +49,14 @@ func (m *mipmap) original() *shareable.Image { return m.orig } +func (m *mipmap) makeVolatile() { + m.orig.MakeVolatile() +} + +func (m *mipmap) dump(name string) error { + return m.orig.Dump(name) +} + func (m *mipmap) level(r image.Rectangle, level int) *shareable.Image { if level == 0 { panic("ebiten: level must be non-zero at level")