optimization

This commit is contained in:
Harrison Deng 2017-12-05 16:07:26 -06:00
parent 86a606c44e
commit a41923fa12
3 changed files with 8 additions and 15 deletions

View File

@ -15,11 +15,10 @@ import zero1hd.rhythmbullet.audio.MusicManager;
public class BasicVisualizer extends VisualizerCore { public class BasicVisualizer extends VisualizerCore {
private Pixmap pixmap; private Pixmap pixmap;
private Texture bar; private Texture barTexture;
private int barWidth; private int barWidth;
private int binsPerBar; private int binsPerBar;
private int spaceBetweenBars; private int spaceBetweenBars;
private Texture[] textures;
private Sprite[] bars; private Sprite[] bars;
private float[] barHeights; private float[] barHeights;
private int smoothRange; private int smoothRange;
@ -41,13 +40,11 @@ public class BasicVisualizer extends VisualizerCore {
barCount = 75; barCount = 75;
smoothRange = 2; smoothRange = 2;
angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation)); angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
textures = new Texture[barCount];
bars = new Sprite[barCount]; bars = new Sprite[barCount];
barHeights = new float[barCount]; barHeights = new float[barCount];
barTexture = new Texture(pixmap);
for (int i = 0; i < textures.length; i++) { for (int i = 0; i < bars.length; i++) {
textures[i] = new Texture(pixmap); bars[i] = new Sprite(barTexture);
bars[i] = new Sprite(textures[i]);
} }
updatePositionInfo(); updatePositionInfo();
@ -118,10 +115,7 @@ public class BasicVisualizer extends VisualizerCore {
@Override @Override
public void dispose() { public void dispose() {
bar.dispose(); barTexture.dispose();
for (int i = 0; i < textures.length; i++) {
textures[i].dispose();
}
if (mm != null) { if (mm != null) {
mm.dispose(); mm.dispose();
} }

View File

@ -131,7 +131,6 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
/** /**
* Selects this panel * Selects this panel
* @param updateGlobalSelection whether or not to tell everything that this is selected. Usually true unless you set the global somewhere else.
*/ */
public void select() { public void select() {
msp.deselectAll(); msp.deselectAll();

View File

@ -208,10 +208,10 @@ public class MusicSelectionPage extends Page implements Observer {
exec.submit(() -> { exec.submit(() -> {
for (int i = 0; i < selectables.size; i++) { for (int i = 0; i < selectables.size; i++) {
MusicSelectable info = selectables.get(i); MusicSelectable selectable = selectables.get(i);
info.getAudioInfo().loadInfo(); selectable.getAudioInfo().loadInfo();
Gdx.app.postRunnable(() -> { Gdx.app.postRunnable(() -> {
info.updateInfo(); selectable.updateInfo();
}); });
} }
extraInfoDone = true; extraInfoDone = true;