mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/restorable: refactoring
This commit is contained in:
parent
b36160d9e7
commit
9ef9ea0469
@ -482,12 +482,12 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte
|
||||
return nil
|
||||
}
|
||||
|
||||
// makeStaleIfDependingOn makes the image stale if the image depends on target.
|
||||
func (i *Image) makeStaleIfDependingOn(target *Image) {
|
||||
// makeStaleIfDependingOn makes the image stale if the image depends on src.
|
||||
func (i *Image) makeStaleIfDependingOn(src *Image) {
|
||||
if i.stale {
|
||||
return
|
||||
}
|
||||
if i.dependsOn(target) {
|
||||
if i.dependsOn(src) {
|
||||
// There is no new region to make stale.
|
||||
i.makeStale(image.Rectangle{})
|
||||
}
|
||||
@ -573,16 +573,14 @@ func (i *Image) resolveStale(graphicsDriver graphicsdriver.Graphics) error {
|
||||
return i.readPixelsFromGPU(graphicsDriver)
|
||||
}
|
||||
|
||||
// dependsOn reports whether the image depends on target.
|
||||
func (i *Image) dependsOn(target *Image) bool {
|
||||
// dependsOn reports whether the image depends on src.
|
||||
func (i *Image) dependsOn(src *Image) bool {
|
||||
for _, c := range i.drawTrianglesHistory {
|
||||
for _, img := range c.images {
|
||||
if img == nil {
|
||||
if img != src {
|
||||
continue
|
||||
}
|
||||
if img == target {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
@ -164,16 +164,16 @@ func (i *images) resolveStaleImages(graphicsDriver graphicsdriver.Graphics) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// makeStaleIfDependingOn makes all the images stale that depend on target.
|
||||
// makeStaleIfDependingOn makes all the images stale that depend on src.
|
||||
//
|
||||
// When target is modified, all images depending on target can't be restored with target.
|
||||
// makeStaleIfDependingOn is called in such situation.
|
||||
func (i *images) makeStaleIfDependingOn(target *Image) {
|
||||
if target == nil {
|
||||
panic("restorable: target must not be nil at makeStaleIfDependingOn")
|
||||
// When src is modified, all images depending on src can't be restored with src.
|
||||
// makeStaleIfDependingOn is called in such situation.src.
|
||||
func (i *images) makeStaleIfDependingOn(src *Image) {
|
||||
if src == nil {
|
||||
panic("restorable: src must not be nil at makeStaleIfDependingOn")
|
||||
}
|
||||
for img := range i.images {
|
||||
img.makeStaleIfDependingOn(target)
|
||||
img.makeStaleIfDependingOn(src)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user