mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
graphics: Refactoring
This commit is contained in:
parent
302f5a5437
commit
11e67d0eed
7
image.go
7
image.go
@ -20,7 +20,6 @@ import (
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics/opengl"
|
||||
)
|
||||
|
||||
@ -195,11 +194,7 @@ type DrawImageOptions struct {
|
||||
//
|
||||
// This function is concurrent-safe.
|
||||
func NewImage(width, height int, filter Filter) (*Image, error) {
|
||||
i, err := graphics.NewImage(width, height, glFilter(filter))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
img, err := newImageImpl(i, filter)
|
||||
img, err := newImageImpl(width, height, filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
27
imageimpl.go
27
imageimpl.go
@ -41,12 +41,15 @@ type imageImpl struct {
|
||||
m sync.Mutex
|
||||
}
|
||||
|
||||
func newImageImpl(image *graphics.Image, filter Filter) (*imageImpl, error) {
|
||||
w, h := image.Size()
|
||||
func newImageImpl(width, height int, filter Filter) (*imageImpl, error) {
|
||||
img, err := graphics.NewImage(width, height, glFilter(filter))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
i := &imageImpl{
|
||||
image: image,
|
||||
width: w,
|
||||
height: h,
|
||||
image: img,
|
||||
width: width,
|
||||
height: height,
|
||||
filter: filter,
|
||||
}
|
||||
runtime.SetFinalizer(i, (*imageImpl).Dispose)
|
||||
@ -86,16 +89,18 @@ func newImageImplFromImage(source image.Image, filter Filter) (*imageImpl, error
|
||||
}
|
||||
|
||||
func newScreenImageImpl(width, height int) (*imageImpl, error) {
|
||||
i, err := graphics.NewScreenFramebufferImage(width, height)
|
||||
img, err := graphics.NewScreenFramebufferImage(width, height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
img, err := newImageImpl(i, FilterNearest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
i := &imageImpl{
|
||||
image: img,
|
||||
width: width,
|
||||
height: height,
|
||||
screen: true,
|
||||
}
|
||||
img.screen = true
|
||||
return img, nil
|
||||
runtime.SetFinalizer(i, (*imageImpl).Dispose)
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (i *imageImpl) Fill(clr color.Color) error {
|
||||
|
Loading…
Reference in New Issue
Block a user