pixels Rename s/history/dependency/

This commit is contained in:
Hajime Hoshi 2016-07-27 01:28:16 +09:00
parent eff0ec8e11
commit 5c56058d6e
3 changed files with 11 additions and 12 deletions

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}