aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/cyanogenmod/wallpapers/photophase/shapes
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2014-08-31 16:44:41 +0200
committerJorge Ruesga <jorge@ruesga.com>2014-08-31 16:44:41 +0200
commitc8d004f3be2bc071184dd32e17b87efccb3aca38 (patch)
treea500c6260b77454bf7a07b36dc14695d3c8770f2 /src/org/cyanogenmod/wallpapers/photophase/shapes
parenta523e7f3384fbab9cc398e2fd398bda8fc13663b (diff)
downloadandroid_packages_wallpapers_PhotoPhase-c8d004f3be2bc071184dd32e17b87efccb3aca38.tar.gz
android_packages_wallpapers_PhotoPhase-c8d004f3be2bc071184dd32e17b87efccb3aca38.tar.bz2
android_packages_wallpapers_PhotoPhase-c8d004f3be2bc071184dd32e17b87efccb3aca38.zip
photophase: fix memory leaks
* Fix memory leak caused by unreleased of framebuffers new refs * pre-cache Roboto typeface * trace allocations/deallocations GL's resources Change-Id: Ib1ca22aae7ba90c4282f91dcef69a5fe274017a8 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/shapes')
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/shapes/ColorShape.java4
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java21
2 files changed, 23 insertions, 2 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/shapes/ColorShape.java b/src/org/cyanogenmod/wallpapers/photophase/shapes/ColorShape.java
index ceb7ec4..c05836f 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/shapes/ColorShape.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/shapes/ColorShape.java
@@ -18,6 +18,7 @@ package org.cyanogenmod.wallpapers.photophase.shapes;
import android.content.Context;
import android.opengl.GLES20;
+import android.util.Log;
import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil;
import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil.GLColor;
@@ -137,6 +138,9 @@ public class ColorShape implements DrawableShape {
*/
public void recycle() {
if (GLES20.glIsProgram(mProgramHandler)) {
+ if (GLESUtil.DEBUG_GL_MEMOBJS) {
+ Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteProgram: " + mProgramHandler);
+ }
GLES20.glDeleteProgram(mProgramHandler);
GLESUtil.glesCheckError("glDeleteProgram");
}
diff --git a/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java b/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java
index d7b3e89..195a1e4 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/shapes/OopsShape.java
@@ -24,6 +24,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.opengl.GLES20;
+import android.util.Log;
import org.cyanogenmod.wallpapers.photophase.Colors;
import org.cyanogenmod.wallpapers.photophase.utils.GLESUtil;
@@ -65,6 +66,8 @@ public class OopsShape implements DrawableShape {
0.5f, 0.75f
};
+ private static Typeface sRobotoFont;
+
private FloatBuffer mPositionBuffer;
private FloatBuffer mTextureBuffer;
@@ -87,6 +90,9 @@ public class OopsShape implements DrawableShape {
*/
public OopsShape(Context ctx, int resourceMessageId) {
super();
+ if (sRobotoFont == null) {
+ sRobotoFont = Typeface.createFromAsset(ctx.getAssets(), "fonts/Roboto-Bold.ttf");
+ }
int orientation = ctx.getResources().getConfiguration().orientation;
float[] vertex = VERTEX_COORDS_PORTRAIT;
@@ -233,12 +239,20 @@ public class OopsShape implements DrawableShape {
public void recycle() {
// Remove textures
if (mOopsImageTexture != null && mOopsImageTexture.handle != 0) {
+ if (GLESUtil.DEBUG_GL_MEMOBJS) {
+ Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteTextures: ["
+ + mOopsImageTexture.handle + "]");
+ }
int[] textures = new int[]{mOopsImageTexture.handle};
GLES20.glDeleteTextures(1, textures, 0);
GLESUtil.glesCheckError("glDeleteTextures");
}
mOopsImageTexture = null;
if (mOopsTextTexture != null && mOopsTextTexture.handle != 0) {
+ if (GLESUtil.DEBUG_GL_MEMOBJS) {
+ Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteTextures: ["
+ + mOopsTextTexture.handle + "]");
+ }
int[] textures = new int[]{mOopsTextTexture.handle};
GLES20.glDeleteTextures(1, textures, 0);
GLESUtil.glesCheckError("glDeleteTextures");
@@ -257,6 +271,10 @@ public class OopsShape implements DrawableShape {
for (int i = 0; i < 2; i++) {
if (GLES20.glIsProgram(mProgramHandlers[i])) {
+ if (GLESUtil.DEBUG_GL_MEMOBJS) {
+ Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteProgram: "
+ + mProgramHandlers[i]);
+ }
GLES20.glDeleteProgram(mProgramHandlers[i]);
GLESUtil.glesCheckError("glDeleteProgram(" + i + ")");
}
@@ -277,8 +295,7 @@ public class OopsShape implements DrawableShape {
*/
public Bitmap text2Bitmap(Context ctx, String text) {
Paint paint = new Paint();
- Typeface font = Typeface.createFromAsset(ctx.getAssets(), "fonts/Roboto-Bold.ttf");
- paint.setTypeface(font);
+ paint.setTypeface(sRobotoFont);
paint.setColor(Color.WHITE);
paint.setTextSize(24.0f);
paint.setAntiAlias(true);