v0.9.1: slightly improved android performance on warm start
This commit is contained in:
parent
9c75859126
commit
2b6de19995
|
@ -43,8 +43,10 @@ public abstract class PlatformSupport {
|
|||
//TODO should consider spinning this into its own class, rather than platform support getting ever bigger
|
||||
|
||||
public abstract void setupFontGenerators(int pageSize, boolean systemFont );
|
||||
|
||||
|
||||
public abstract void resetGenerators();
|
||||
|
||||
public abstract void reloadGenerators();
|
||||
|
||||
public abstract BitmapFont getFont(int size, String text);
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class AndroidGame extends AndroidApplication {
|
|||
config.useAccelerometer = false;
|
||||
|
||||
if (support == null) support = new AndroidPlatformSupport();
|
||||
else support.resetGenerators();
|
||||
else support.reloadGenerators();
|
||||
|
||||
support.updateSystemUI();
|
||||
|
||||
|
|
|
@ -328,7 +328,27 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||
}
|
||||
setupFontGenerators(pageSize, systemfont);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
//FIXME it would be really nice to keep the local texture data and just re-send it to the GPU
|
||||
public void reloadGenerators() {
|
||||
if (packer != null) {
|
||||
for (FreeTypeFontGenerator generator : fonts.keySet()) {
|
||||
for (BitmapFont f : fonts.get(generator).values()) {
|
||||
f.dispose();
|
||||
}
|
||||
fonts.get(generator).clear();
|
||||
}
|
||||
if (packer != null) {
|
||||
for (PixmapPacker.Page p : packer.getPages()) {
|
||||
p.getTexture().dispose();
|
||||
}
|
||||
packer.dispose();
|
||||
}
|
||||
packer = new PixmapPacker(pageSize, pageSize, Pixmap.Format.RGBA8888, 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static Pattern KRMatcher = Pattern.compile("\\p{InHangul_Syllables}");
|
||||
private static Pattern SCMatcher = Pattern.compile("\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}");
|
||||
private static Pattern JPMatcher = Pattern.compile("\\p{InHiragana}|\\p{InKatakana}");
|
||||
|
@ -358,7 +378,7 @@ public class AndroidPlatformSupport extends PlatformSupport {
|
|||
parameters.size = size;
|
||||
parameters.flip = true;
|
||||
parameters.borderWidth = parameters.size / 10f;
|
||||
parameters.renderCount = 3;
|
||||
parameters.renderCount = 1;
|
||||
parameters.hinting = FreeTypeFontGenerator.Hinting.None;
|
||||
parameters.spaceX = -(int) parameters.borderWidth;
|
||||
parameters.incremental = true;
|
||||
|
|
|
@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.desktop;
|
|||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.PixmapPacker;
|
||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||
|
@ -154,6 +155,16 @@ public class DesktopPlatformSupport extends PlatformSupport {
|
|||
}
|
||||
setupFontGenerators(pageSize, systemfont);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadGenerators() {
|
||||
if (packer != null) {
|
||||
for (PixmapPacker.Page p : packer.getPages()) {
|
||||
p.getTexture().dispose();
|
||||
p.updateTexture(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Pattern asianMatcher = Pattern.compile("\\p{InHangul_Syllables}|" +
|
||||
"\\p{InCJK_Unified_Ideographs}|\\p{InCJK_Symbols_and_Punctuation}|\\p{InHalfwidth_and_Fullwidth_Forms}|" +
|
||||
|
|
Loading…
Reference in New Issue
Block a user