From 0e97904d149d2d62ac63ee359caa0856af879e33 Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Sun, 13 Oct 2013 00:51:29 +0200 Subject: Remove unnecessary code Cached bitmaps are not used, because bitmaps are recycled previously Signed-off-by: Jorge Ruesga --- .../wallpapers/photophase/PhotoPhaseRenderer.java | 16 +++--- .../photophase/PhotoPhaseWallpaperWorld.java | 13 ----- .../wallpapers/photophase/TextureManager.java | 60 ++++------------------ 3 files changed, 21 insertions(+), 68 deletions(-) (limited to 'src') 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 sRecycledBitmaps = new ArrayList(); - 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 @@ -228,18 +208,6 @@ public class TextureManager implements OnMediaPictureDiscoveredListener { mPictureDiscoverer.discover(userRequest); } - /** - * 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} * @@ -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 { -- cgit v1.2.3