mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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
|
||||
}
|
||||
|
||||
origNum := len(i.staleRegions)
|
||||
i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions)
|
||||
if !rect.Empty() {
|
||||
i.staleRegions = append(i.staleRegions, rect)
|
||||
@ -274,6 +275,11 @@ func (i *Image) makeStale(rect image.Rectangle) {
|
||||
|
||||
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.
|
||||
// Restoring is done after topological sorting is done.
|
||||
// If an image depends on another stale image, this means that
|
||||
|
Loading…
Reference in New Issue
Block a user