diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2014-08-31 16:44:41 +0200 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2014-08-31 16:44:41 +0200 |
commit | c8d004f3be2bc071184dd32e17b87efccb3aca38 (patch) | |
tree | a500c6260b77454bf7a07b36dc14695d3c8770f2 /src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java | |
parent | a523e7f3384fbab9cc398e2fd398bda8fc13663b (diff) | |
download | android_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/utils/GLESUtil.java')
-rw-r--r-- | src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java b/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java index 0078ea6..8b34601 100644 --- a/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java +++ b/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java @@ -42,6 +42,10 @@ public final class GLESUtil { private static final boolean DEBUG = false; + public static final boolean DEBUG_GL_MEMOBJS = false; + public static final String DEBUG_GL_MEMOBJS_NEW_TAG = "MEMOBJS_NEW"; + public static final String DEBUG_GL_MEMOBJS_DEL_TAG = "MEMOBJS_DEL"; + private static final Object sSync = new Object(); /** @@ -207,6 +211,9 @@ public final class GLESUtil { int[] compiled = new int[1]; // Create, load and compile the shader int shader = GLES20.glCreateShader(type); + if (GLESUtil.DEBUG_GL_MEMOBJS) { + Log.d(GLESUtil.DEBUG_GL_MEMOBJS_NEW_TAG, "glCreateShader (" + type + "): " + shader); + } GLESUtil.glesCheckError("glCreateShader"); if (shader <= 0) { Log.e(TAG, "Cannot create a shader"); @@ -265,6 +272,9 @@ public final class GLESUtil { // Create the programa ref progid = GLES20.glCreateProgram(); + if (GLESUtil.DEBUG_GL_MEMOBJS) { + Log.d(GLESUtil.DEBUG_GL_MEMOBJS_NEW_TAG, "glCreateProgram: " + progid); + } GLESUtil.glesCheckError("glCreateProgram"); if (progid <= 0) { String msg = "Cannot create a program"; @@ -296,10 +306,16 @@ public final class GLESUtil { } finally { // Delete the shaders if (vshader != 0) { + if (GLESUtil.DEBUG_GL_MEMOBJS) { + Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteShader (v): " + vshader); + } GLES20.glDeleteShader(vshader); GLESUtil.glesCheckError("glDeleteShader"); } if (fshader != 0) { + if (GLESUtil.DEBUG_GL_MEMOBJS) { + Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteShader (f): " + fshader); + } GLES20.glDeleteShader(fshader); GLESUtil.glesCheckError("glDeleteShader"); } @@ -415,6 +431,11 @@ public final class GLESUtil { int[] textureHandles = new int[num]; GLES20.glGenTextures(num, textureHandles, 0); GLESUtil.glesCheckError("glGenTextures"); + for (int i = 0; i < num; i++) { + if (GLESUtil.DEBUG_GL_MEMOBJS) { + Log.d(GLESUtil.DEBUG_GL_MEMOBJS_NEW_TAG, "glGenTextures: " + textureHandles[i]); + } + } if (textureHandles[0] <= 0 || (effect != null && textureHandles[1] <= 0)) { Log.e(TAG, "Failed to generate a valid texture"); return new GLESTextureInfo(); @@ -455,6 +476,10 @@ public final class GLESUtil { // Delete the unused texture int[] textures = {textureHandles[0]}; + if (GLESUtil.DEBUG_GL_MEMOBJS) { + Log.d(GLESUtil.DEBUG_GL_MEMOBJS_DEL_TAG, "glDeleteTextures: [" + + textureHandles[0] + "]"); + } GLES20.glDeleteTextures(1, textures, 0); GLESUtil.glesCheckError("glDeleteTextures"); } |