mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +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() {
|
||||
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 {
|
||||
// context is null when this is not initialized yet.
|
||||
i.pixels = nil
|
||||
return nil
|
||||
}
|
||||
if err := i.pixels.ResetIfNeeded(target.image, context); err != nil {
|
||||
if err := i.pixels.Reset(context); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -116,21 +116,14 @@ func (p *Pixels) Reset(context *opengl.Context) error {
|
||||
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 {
|
||||
return nil
|
||||
return false
|
||||
}
|
||||
if !p.hasHistoryWith(target) {
|
||||
return nil
|
||||
return false
|
||||
}
|
||||
var err error
|
||||
p.basePixels, err = p.image.Pixels(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.baseColor = nil
|
||||
p.drawImageHistory = nil
|
||||
return nil
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *Pixels) HasHistory() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user