Significant sprite packing memory leak fixes
additional thanks to GlFolker for reporting issues with undisposed content icon pixmaps
This commit is contained in:
@@ -115,6 +115,7 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
var result = Pixmaps.outline(base, outlineColor, outlineRadius);
|
||||
Drawf.checkBleed(result);
|
||||
packer.add(page, regName, result);
|
||||
result.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +127,7 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
var result = Pixmaps.outline(base, outlineColor, outlineRadius);
|
||||
Drawf.checkBleed(result);
|
||||
packer.add(PageType.main, name, result);
|
||||
result.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,8 +97,12 @@ public class MultiPacker implements Disposable{
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
for(PixmapPacker packer : packers){
|
||||
packer.dispose();
|
||||
for(int i = 0; i < PageType.all.length; i ++){
|
||||
var packer = packers[i];
|
||||
//the UI packer's image is later used when merging with the font, don't dispose it
|
||||
if(i != PageType.ui.ordinal()){
|
||||
packer.forceDispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -969,6 +969,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
Drawf.checkBleed(outlined);
|
||||
|
||||
packer.add(PageType.main, regionName + "-outline", outlined);
|
||||
outlined.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,7 +1022,9 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
}
|
||||
|
||||
packer.add(PageType.main, name + "-treads" + r + "-" + i, frame);
|
||||
frame.dispose();
|
||||
}
|
||||
slice.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1294,6 +1294,8 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
}
|
||||
}
|
||||
|
||||
Seq<Pixmap> toDispose = new Seq<>();
|
||||
|
||||
//generate paletted team regions
|
||||
if(teamRegion != null && teamRegion.found()){
|
||||
for(Team team : Team.all){
|
||||
@@ -1318,6 +1320,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
Drawf.checkBleed(out);
|
||||
|
||||
packer.add(PageType.main, name + "-team-" + team.name, out);
|
||||
toDispose.add(out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1337,6 +1340,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
Pixmap out = last = Pixmaps.outline(region, outlineColor, outlineRadius);
|
||||
Drawf.checkBleed(out);
|
||||
packer.add(PageType.main, atlasRegion.name, out);
|
||||
toDispose.add(out);
|
||||
}
|
||||
|
||||
var toOutline = new Seq<TextureRegion>();
|
||||
@@ -1350,6 +1354,7 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
Drawf.checkBleed(outlined);
|
||||
|
||||
packer.add(PageType.main, regionName + "-outline", outlined);
|
||||
toDispose.add(outlined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1367,12 +1372,15 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
packer.add(PageType.main, "block-" + name + "-full", base);
|
||||
|
||||
editorBase = new PixmapRegion(base);
|
||||
toDispose.add(base);
|
||||
}else{
|
||||
if(gen[0] != null) packer.add(PageType.main, "block-" + name + "-full", Core.atlas.getPixmap(gen[0]));
|
||||
editorBase = gen[0] == null ? Core.atlas.getPixmap(fullIcon) : Core.atlas.getPixmap(gen[0]);
|
||||
}
|
||||
|
||||
packer.add(PageType.editor, name + "-icon-editor", editorBase);
|
||||
|
||||
toDispose.each(Pixmap::dispose);
|
||||
}
|
||||
|
||||
public int planRotation(int rot){
|
||||
|
||||
@@ -177,6 +177,7 @@ public class Floor extends Block{
|
||||
}
|
||||
|
||||
packer.add(PageType.environment, name + "-edge", result);
|
||||
result.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,6 +69,8 @@ public class OreBlock extends OverlayFloor{
|
||||
packer.add(PageType.editor, "editor-block-" + name + "-full", image);
|
||||
packer.add(PageType.main, "block-" + name + "-full", image);
|
||||
}
|
||||
|
||||
image.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user