mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
pixels: Bug fix: Reset pixels correctly
This commit is contained in:
parent
0fc61ed568
commit
40427b6263
@ -226,12 +226,18 @@ func (i *imageImpl) resetPixelsIfNeeded(target *imageImpl, context *opengl.Conte
|
|||||||
if target.isDisposed() {
|
if target.isDisposed() {
|
||||||
return errors.New("ebiten: target is already disposed")
|
return errors.New("ebiten: target is already disposed")
|
||||||
}
|
}
|
||||||
|
if i.pixels == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !i.pixels.NeedsReset(target.image) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if context == nil {
|
if context == nil {
|
||||||
// context is null when this is not initialized yet.
|
// context is null when this is not initialized yet.
|
||||||
i.pixels = nil
|
i.pixels = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := i.pixels.ResetIfNeeded(target.image, context); err != nil {
|
if err := i.pixels.Reset(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -116,21 +116,14 @@ func (p *Pixels) Reset(context *opengl.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pixels) ResetIfNeeded(target *graphics.Image, context *opengl.Context) error {
|
func (p *Pixels) NeedsReset(target *graphics.Image) bool {
|
||||||
if p.drawImageHistory == nil {
|
if p.drawImageHistory == nil {
|
||||||
return nil
|
return false
|
||||||
}
|
}
|
||||||
if !p.hasHistoryWith(target) {
|
if !p.hasHistoryWith(target) {
|
||||||
return nil
|
return false
|
||||||
}
|
}
|
||||||
var err error
|
return true
|
||||||
p.basePixels, err = p.image.Pixels(context)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
p.baseColor = nil
|
|
||||||
p.drawImageHistory = nil
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pixels) HasHistory() bool {
|
func (p *Pixels) HasHistory() bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user