mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
restorable: Remove Image()
This commit is contained in:
parent
82febc9c6e
commit
02151e48ea
2
image.go
2
image.go
@ -95,7 +95,7 @@ func (i *images) restore(context *opengl.Context) error {
|
||||
if img.isDisposed() {
|
||||
continue
|
||||
}
|
||||
if err := img.restorable.Image().Dispose(); err != nil {
|
||||
if err := img.restorable.DisposeOnlyImage(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
13
imageimpl.go
13
imageimpl.go
@ -256,11 +256,6 @@ func (i *imageImpl) Dispose() error {
|
||||
if i.disposed {
|
||||
return errors.New("ebiten: image is already disposed")
|
||||
}
|
||||
if !i.screen {
|
||||
if err := i.restorable.Image().Dispose(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := i.restorable.Dispose(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -275,11 +270,13 @@ func (i *imageImpl) ReplacePixels(p []uint8) error {
|
||||
}
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
i.restorable.ReplacePixels(p)
|
||||
if i.disposed {
|
||||
return errors.New("ebiten: image is already disposed")
|
||||
}
|
||||
return i.restorable.Image().ReplacePixels(p)
|
||||
if err := i.restorable.ReplacePixels(p); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *imageImpl) isDisposed() bool {
|
||||
@ -291,5 +288,5 @@ func (i *imageImpl) isDisposed() bool {
|
||||
func (i *imageImpl) isInvalidated(context *opengl.Context) bool {
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
return i.restorable.Image().IsInvalidated(context)
|
||||
return i.restorable.IsInvalidated(context)
|
||||
}
|
||||
|
@ -105,7 +105,10 @@ func (p *Image) Fill(clr color.RGBA) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) ReplacePixels(pixels []uint8) {
|
||||
func (p *Image) ReplacePixels(pixels []uint8) error {
|
||||
if err := p.image.ReplacePixels(pixels); err != nil {
|
||||
return err
|
||||
}
|
||||
if p.basePixels == nil {
|
||||
p.basePixels = make([]uint8, len(pixels))
|
||||
}
|
||||
@ -113,6 +116,7 @@ func (p *Image) ReplacePixels(pixels []uint8) {
|
||||
p.baseColor = color.RGBA{}
|
||||
p.drawImageHistory = nil
|
||||
p.stale = false
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) DrawImage(img *Image, vertices []int16, geom graphics.Matrix, colorm graphics.Matrix, mode opengl.CompositeMode) error {
|
||||
@ -127,11 +131,6 @@ func (p *Image) DrawImage(img *Image, vertices []int16, geom graphics.Matrix, co
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) Image() *graphics.Image {
|
||||
// TODO: This function is temporary. Remove this.
|
||||
return p.image
|
||||
}
|
||||
|
||||
func (p *Image) appendDrawImageHistory(image *graphics.Image, vertices []int16, geom graphics.Matrix, colorm graphics.Matrix, mode opengl.CompositeMode) {
|
||||
if p.stale {
|
||||
return
|
||||
@ -279,3 +278,14 @@ func (p *Image) Dispose() error {
|
||||
p.stale = false
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) DisposeOnlyImage() error {
|
||||
if err := p.image.Dispose(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Image) IsInvalidated(context *opengl.Context) bool {
|
||||
return p.image.IsInvalidated(context)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user