Loading src/com/android/gallery3d/photoeditor/FilterStack.java +3 −9 Original line number Diff line number Diff line Loading @@ -238,8 +238,10 @@ public class FilterStack { @Override public void run() { Filter.releaseContext(); for (int i = 0; i < buffers.length; i++) { // Textures will be automatically deleted when GL context is lost. photoView.setPhoto(null, false); source = null; for (int i = 0; i < buffers.length; i++) { buffers[i] = null; } } Loading @@ -249,14 +251,6 @@ public class FilterStack { public void onResume() { photoView.onResume(); photoView.queue(new Runnable() { @Override public void run() { // Create effect context after GL context is created or recreated. Filter.createContextWithCurrentGlContext(); } }); paused = false; } } src/com/android/gallery3d/photoeditor/PhotoView.java +1 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,7 @@ public class PhotoView extends GLSurfaceView { if (!queue.isEmpty()) { requestRender(); } RendererUtils.renderBackground(); if (photo != null) { RendererUtils.renderTexture(renderContext, photo.texture(), viewWidth, viewHeight); } Loading src/com/android/gallery3d/photoeditor/RendererUtils.java +5 −2 Original line number Diff line number Diff line Loading @@ -174,6 +174,11 @@ public class RendererUtils { context.posVertices = createVerticesBuffer(vertices); } public static void renderBackground() { GLES20.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); } public static void renderTexture( RenderContext context, int texture, int viewWidth, int viewHeight) { // Use our shader program Loading Loading @@ -204,8 +209,6 @@ public class RendererUtils { GLES20.glUniform1i(context.texSamplerHandle, 0); // Draw! GLES20.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); } Loading src/com/android/gallery3d/photoeditor/filters/Filter.java +6 −4 Original line number Diff line number Diff line Loading @@ -37,10 +37,9 @@ public abstract class Filter { private boolean isValid; public static void createContextWithCurrentGlContext() { context = EffectContext.createWithCurrentGlContext(); } /** * Filter context should be released before the current GL context is lost. */ public static void releaseContext() { if (context != null) { // Release all effects created with the releasing context. Loading @@ -63,6 +62,9 @@ public abstract class Filter { protected Effect getEffect(String name) { Effect effect = effects.get(this); if (effect == null) { if (context == null) { context = EffectContext.createWithCurrentGlContext(); } effect = context.getFactory().createEffect(name); effect.setParameter("tile_size", DEFAULT_TILE_SIZE); effects.put(this, effect); Loading Loading
src/com/android/gallery3d/photoeditor/FilterStack.java +3 −9 Original line number Diff line number Diff line Loading @@ -238,8 +238,10 @@ public class FilterStack { @Override public void run() { Filter.releaseContext(); for (int i = 0; i < buffers.length; i++) { // Textures will be automatically deleted when GL context is lost. photoView.setPhoto(null, false); source = null; for (int i = 0; i < buffers.length; i++) { buffers[i] = null; } } Loading @@ -249,14 +251,6 @@ public class FilterStack { public void onResume() { photoView.onResume(); photoView.queue(new Runnable() { @Override public void run() { // Create effect context after GL context is created or recreated. Filter.createContextWithCurrentGlContext(); } }); paused = false; } }
src/com/android/gallery3d/photoeditor/PhotoView.java +1 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,7 @@ public class PhotoView extends GLSurfaceView { if (!queue.isEmpty()) { requestRender(); } RendererUtils.renderBackground(); if (photo != null) { RendererUtils.renderTexture(renderContext, photo.texture(), viewWidth, viewHeight); } Loading
src/com/android/gallery3d/photoeditor/RendererUtils.java +5 −2 Original line number Diff line number Diff line Loading @@ -174,6 +174,11 @@ public class RendererUtils { context.posVertices = createVerticesBuffer(vertices); } public static void renderBackground() { GLES20.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); } public static void renderTexture( RenderContext context, int texture, int viewWidth, int viewHeight) { // Use our shader program Loading Loading @@ -204,8 +209,6 @@ public class RendererUtils { GLES20.glUniform1i(context.texSamplerHandle, 0); // Draw! GLES20.glClearColor(0, 0, 0, 1); GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); } Loading
src/com/android/gallery3d/photoeditor/filters/Filter.java +6 −4 Original line number Diff line number Diff line Loading @@ -37,10 +37,9 @@ public abstract class Filter { private boolean isValid; public static void createContextWithCurrentGlContext() { context = EffectContext.createWithCurrentGlContext(); } /** * Filter context should be released before the current GL context is lost. */ public static void releaseContext() { if (context != null) { // Release all effects created with the releasing context. Loading @@ -63,6 +62,9 @@ public abstract class Filter { protected Effect getEffect(String name) { Effect effect = effects.get(this); if (effect == null) { if (context == null) { context = EffectContext.createWithCurrentGlContext(); } effect = context.getFactory().createEffect(name); effect.setParameter("tile_size", DEFAULT_TILE_SIZE); effects.put(this, effect); Loading