aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-10-13 00:51:29 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-10-13 00:51:29 +0200
commit0e97904d149d2d62ac63ee359caa0856af879e33 (patch)
treedb0bca9e78a6f28e029e0189c63058c339887abd /src
parenteced5a55cdec21d4e380a57d523c30f80cec6e1b (diff)
downloadandroid_packages_wallpapers_PhotoPhase-0e97904d149d2d62ac63ee359caa0856af879e33.tar.gz
android_packages_wallpapers_PhotoPhase-0e97904d149d2d62ac63ee359caa0856af879e33.tar.bz2
android_packages_wallpapers_PhotoPhase-0e97904d149d2d62ac63ee359caa0856af879e33.zip
Remove unnecessary code
Cached bitmaps are not used, because bitmaps are recycled previously Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src')
-rw-r--r--src/com/ruesga/android/wallpapers/photophase/PhotoPhaseRenderer.java16
-rw-r--r--src/com/ruesga/android/wallpapers/photophase/PhotoPhaseWallpaperWorld.java13
-rw-r--r--src/com/ruesga/android/wallpapers/photophase/TextureManager.java60
3 files changed, 21 insertions, 68 deletions
diff --git a/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseRenderer.java b/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseRenderer.java
index cce6b3a..b703342 100644
--- a/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseRenderer.java
+++ b/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseRenderer.java
@@ -143,12 +143,16 @@ public class PhotoPhaseRenderer implements GLSurfaceView.Renderer {
mDispatcher.dispatch(new Runnable() {
@Override
public void run() {
- // Select a new transition
- mWorld.selectRandomTransition();
- mLastRunningTransition = System.currentTimeMillis();
-
- // Now force continuously render while transition is applied
- mDispatcher.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
+ try {
+ // Select a new transition
+ mWorld.selectRandomTransition();
+ mLastRunningTransition = System.currentTimeMillis();
+
+ // Now force continuously render while transition is applied
+ mDispatcher.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
+ } catch (Throwable ex) {
+ Log.e(TAG, "Something was wrong selecting the transition", ex);
+ }
}
});
}
diff --git a/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseWallpaperWorld.java b/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseWallpaperWorld.java
index f17b986..e44e250 100644
--- a/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseWallpaperWorld.java
+++ b/src/com/ruesga/android/wallpapers/photophase/PhotoPhaseWallpaperWorld.java
@@ -22,7 +22,6 @@ import android.graphics.PointF;
import android.graphics.RectF;
import android.util.Log;
-import com.ruesga.android.wallpapers.photophase.utils.GLESUtil.GLESTextureInfo;
import com.ruesga.android.wallpapers.photophase.model.Disposition;
import com.ruesga.android.wallpapers.photophase.preferences.PreferencesProvider.Preferences;
import com.ruesga.android.wallpapers.photophase.transitions.Transition;
@@ -237,18 +236,6 @@ public class PhotoPhaseWallpaperWorld {
mUnusedTransitions.remove(i);
}
}
- if (mPhotoFrames != null) {
- int cc = mPhotoFrames.size() - 1;
- for (int i = cc; i >= 0; i--) {
- PhotoFrame frame = mPhotoFrames.get(i);
- GLESTextureInfo info = frame.getTextureInfo();
- if (info != null && info.bitmap != null) {
- mTextureManager.releaseBitmap(info);
- }
- frame.recycle();
- mPhotoFrames.remove(i);
- }
- }
if (mTransitionsQueue != null) {
mTransitionsQueue.clear();
}
diff --git a/src/com/ruesga/android/wallpapers/photophase/TextureManager.java b/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
index 5224ea6..033ca6c 100644
--- a/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
+++ b/src/com/ruesga/android/wallpapers/photophase/TextureManager.java
@@ -49,8 +49,6 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
private static final int QUEUE_SIZE = 3;
- static final List<GLESTextureInfo> sRecycledBitmaps = new ArrayList<GLESTextureInfo>();
-
final Context mContext;
final Effects mEffects;
final Object mSync;
@@ -84,35 +82,16 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
@Override
public void run() {
try {
- // If we have bitmap to reused then pick up from the recycled list
Effect effect = mEffects.getNextEffect();
- if (sRecycledBitmaps.size() > 0) {
- // Bind to the GLES context
- GLESTextureInfo oldTextureInfo = sRecycledBitmaps.remove(0);
- try {
- ti = GLESUtil.loadTexture(oldTextureInfo.bitmap, effect, mDimensions);
- ti.path = oldTextureInfo.path;
- } finally {
- if (GLES20.glIsTexture(oldTextureInfo.handle)) {
- int[] textures = new int[] {oldTextureInfo.handle};
- GLES20.glDeleteTextures(1, textures, 0);
- GLESUtil.glesCheckError("glDeleteTextures");
- }
- if (oldTextureInfo.bitmap != null) {
- oldTextureInfo.bitmap.recycle();
- oldTextureInfo.bitmap = null;
- }
- }
+
+ // Load and bind to the GLES context. The effect is applied when the image
+ // is associated to the destination target (only if aspect ratio will be applied)
+ if (!Preferences.General.isFixAspectRatio()) {
+ ti = GLESUtil.loadTexture(
+ mImage, mDimensions, effect, mDimensions, false);
} else {
- // Load and bind to the GLES context. The effect is applied when the image
- // is associated to the destination target (only if aspect ratio will be applied)
- if (!Preferences.General.isFixAspectRatio()) {
- ti = GLESUtil.loadTexture(
- mImage, mDimensions, effect, mDimensions, false);
- } else {
- ti = GLESUtil.loadTexture(mImage, mDimensions, null, null, false);
- ti.effect = effect;
- }
+ ti = GLESUtil.loadTexture(mImage, mDimensions, null, null, false);
+ ti.effect = effect;
}
synchronized (mSync) {
@@ -137,8 +116,9 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
}
}
- } catch (Exception e) {
- Log.e(TAG, "Something was wrong loading the texture: " + mImage.getAbsolutePath(), e);
+ } catch (Throwable e) {
+ Log.e(TAG, "Something was wrong loading the texture: " +
+ mImage.getAbsolutePath(), e);
} finally {
// Notify that we have a new image
@@ -229,18 +209,6 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
}
/**
- * Method that returns a bitmap to be reused
- *
- * @param ti The bitmap to release
- */
- @SuppressWarnings("static-method")
- public void releaseBitmap(GLESTextureInfo ti) {
- if (ti != null && ti.bitmap != null) {
- sRecycledBitmaps.add(0, ti);
- }
- }
-
- /**
* Method that request a new picture for the {@link TextureRequestor}
*
* @param requestor The requestor of the texture
@@ -293,12 +261,6 @@ public class TextureManager implements OnMediaPictureDiscoveredListener {
} catch (EmptyQueueException eqex) {
// Ignore
}
- // Recycle the bitmaps
- for (GLESTextureInfo ti : sRecycledBitmaps) {
- ti.bitmap.recycle();
- ti.bitmap = null;
- }
- sRecycledBitmaps.clear();
// Remove all pictures in the queue
try {