mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
restorable: Add NewImage
This commit is contained in:
parent
9c079917f1
commit
438afdac5b
33
imageimpl.go
33
imageimpl.go
@ -34,7 +34,7 @@ type imageImpl struct {
|
||||
width int
|
||||
height int
|
||||
filter Filter
|
||||
restorable restorable.Image
|
||||
restorable *restorable.Image
|
||||
volatile bool
|
||||
screen bool
|
||||
m sync.Mutex
|
||||
@ -46,11 +46,12 @@ func newImageImpl(width, height int, filter Filter, volatile bool) (*imageImpl,
|
||||
return nil, err
|
||||
}
|
||||
i := &imageImpl{
|
||||
image: img,
|
||||
width: width,
|
||||
height: height,
|
||||
filter: filter,
|
||||
volatile: volatile,
|
||||
image: img,
|
||||
width: width,
|
||||
height: height,
|
||||
filter: filter,
|
||||
restorable: restorable.NewImage(),
|
||||
volatile: volatile,
|
||||
}
|
||||
runtime.SetFinalizer(i, (*imageImpl).Dispose)
|
||||
return i, nil
|
||||
@ -79,10 +80,11 @@ func newImageImplFromImage(source image.Image, filter Filter) (*imageImpl, error
|
||||
return nil, err
|
||||
}
|
||||
i := &imageImpl{
|
||||
image: img,
|
||||
width: w,
|
||||
height: h,
|
||||
filter: filter,
|
||||
image: img,
|
||||
width: w,
|
||||
height: h,
|
||||
filter: filter,
|
||||
restorable: restorable.NewImage(),
|
||||
}
|
||||
i.restorable.ReplacePixels(p)
|
||||
runtime.SetFinalizer(i, (*imageImpl).Dispose)
|
||||
@ -95,11 +97,12 @@ func newScreenImageImpl(width, height int) (*imageImpl, error) {
|
||||
return nil, err
|
||||
}
|
||||
i := &imageImpl{
|
||||
image: img,
|
||||
width: width,
|
||||
height: height,
|
||||
volatile: true,
|
||||
screen: true,
|
||||
image: img,
|
||||
width: width,
|
||||
height: height,
|
||||
restorable: restorable.NewImage(),
|
||||
volatile: true,
|
||||
screen: true,
|
||||
}
|
||||
runtime.SetFinalizer(i, (*imageImpl).Dispose)
|
||||
return i, nil
|
||||
|
@ -40,6 +40,10 @@ type Image struct {
|
||||
stale bool
|
||||
}
|
||||
|
||||
func NewImage() *Image {
|
||||
return &Image{}
|
||||
}
|
||||
|
||||
func (p *Image) IsStale() bool {
|
||||
return p.stale
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user