mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/restorble: clear pixels when possible to save memory
This commit is contained in:
parent
f04d9d6925
commit
df944fdf90
@ -267,6 +267,7 @@ func (i *Image) makeStale(rect image.Rectangle) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
origNum := len(i.staleRegions)
|
||||||
i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions)
|
i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions)
|
||||||
if !rect.Empty() {
|
if !rect.Empty() {
|
||||||
i.staleRegions = append(i.staleRegions, rect)
|
i.staleRegions = append(i.staleRegions, rect)
|
||||||
@ -274,6 +275,11 @@ func (i *Image) makeStale(rect image.Rectangle) {
|
|||||||
|
|
||||||
i.clearDrawTrianglesHistory()
|
i.clearDrawTrianglesHistory()
|
||||||
|
|
||||||
|
// Clear pixels to save memory.
|
||||||
|
for _, r := range i.staleRegions[origNum:] {
|
||||||
|
i.basePixels.Clear(r.Min.X, r.Min.Y, r.Dx(), r.Dy())
|
||||||
|
}
|
||||||
|
|
||||||
// Don't have to call makeStale recursively here.
|
// Don't have to call makeStale recursively here.
|
||||||
// Restoring is done after topological sorting is done.
|
// Restoring is done after topological sorting is done.
|
||||||
// If an image depends on another stale image, this means that
|
// If an image depends on another stale image, this means that
|
||||||
|
Loading…
Reference in New Issue
Block a user