diff --git a/imageimpl.go b/imageimpl.go index a11b31468..2cd3fbf30 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -212,19 +212,12 @@ func (i *imageImpl) resetPixelsIfDependingOn(target *imageImpl, context *opengl. if target.isDisposed() { return errors.New("ebiten: target is already disposed") } - // target is an image begin tried to mutate. + // target is an image that is about to be tried mutating. // If pixels object is related to that image, the pixels must be reset. if !i.pixels.DependsOn(target.image) { return nil } - if context == nil || i.volatile { - // context is nil when this is not initialized yet. - i.pixels.MakeStale() - return nil - } - if err := i.pixels.ReadPixelsFromVRAM(i.image, context); err != nil { - return err - } + i.pixels.MakeStale() return nil } diff --git a/internal/pixels/pixels.go b/internal/pixels/pixels.go index c1189786d..7481f2b24 100644 --- a/internal/pixels/pixels.go +++ b/internal/pixels/pixels.go @@ -91,7 +91,7 @@ func (p *Pixels) AppendDrawImageHistory(image *graphics.Image, vertices []int16, // This means Pixels members must match with acutal state in VRAM. func (p *Pixels) At(idx int, image *graphics.Image, context *opengl.Context) (color.Color, error) { if p.basePixels == nil || p.drawImageHistory != nil || p.stale { - if err := p.ReadPixelsFromVRAM(image, context); err != nil { + if err := p.readPixelsFromVRAM(image, context); err != nil { return nil, err } } @@ -111,7 +111,7 @@ func (p *Pixels) DependsOn(target *graphics.Image) bool { return false } -func (p *Pixels) ReadPixelsFromVRAM(image *graphics.Image, context *opengl.Context) error { +func (p *Pixels) readPixelsFromVRAM(image *graphics.Image, context *opengl.Context) error { var err error p.basePixels, err = image.Pixels(context) if err != nil { @@ -127,7 +127,7 @@ func (p *Pixels) ReadPixelsFromVRAMIfStale(image *graphics.Image, context *openg if !p.stale { return nil } - return p.ReadPixelsFromVRAM(image, context) + return p.readPixelsFromVRAM(image, context) } func (p *Pixels) HasDependency() bool {