mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Refactoring: Remove imports
This commit is contained in:
parent
e0790ee950
commit
95bc445fea
11
image.go
11
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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
19
mipmap.go
19
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")
|
||||
|
Loading…
Reference in New Issue
Block a user