diff --git a/image.go b/image.go index c5c0c28a1..2074c2081 100644 --- a/image.go +++ b/image.go @@ -99,23 +99,22 @@ func (i *images) restore(context *opengl.Context) error { return err } } - imagesWithoutHistory := []*imageImpl{} - imagesWithHistory := []*imageImpl{} + imagesWithoutDependency := []*imageImpl{} + imagesWithDependency := []*imageImpl{} for img := range i.images { - if img.hasHistory() { - imagesWithHistory = append(imagesWithHistory, img) + if img.hasDependency() { + imagesWithDependency = append(imagesWithDependency, img) } else { - imagesWithoutHistory = append(imagesWithoutHistory, img) + imagesWithoutDependency = append(imagesWithoutDependency, img) } } - // Images with history can depend on other images. Let's process images without history - // first. - for _, img := range imagesWithoutHistory { + // Images depending on other images should be processed first. + for _, img := range imagesWithoutDependency { if err := img.restore(context); err != nil { return err } } - for _, img := range imagesWithHistory { + for _, img := range imagesWithDependency { if err := img.restore(context); err != nil { return err } diff --git a/imageimpl.go b/imageimpl.go index eee49ca56..2c66a344d 100644 --- a/imageimpl.go +++ b/imageimpl.go @@ -243,13 +243,13 @@ func (i *imageImpl) resetPixelsIfDependingOn(target *imageImpl, context *opengl. return nil } -func (i *imageImpl) hasHistory() bool { +func (i *imageImpl) hasDependency() bool { i.m.Lock() defer i.m.Unlock() if i.pixels == nil { return false } - return i.pixels.HasHistory() + return i.pixels.HasDependency() } func (i *imageImpl) restore(context *opengl.Context) error { diff --git a/internal/pixels/pixels.go b/internal/pixels/pixels.go index 1e1bec0ad..b9198912c 100644 --- a/internal/pixels/pixels.go +++ b/internal/pixels/pixels.go @@ -116,7 +116,7 @@ func (p *Pixels) Reset(context *opengl.Context) error { return nil } -func (p *Pixels) HasHistory() bool { +func (p *Pixels) HasDependency() bool { return p.drawImageHistory != nil }