summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2011-10-11 21:23:22 +0800
committerYuli Huang <yuli@google.com>2011-10-12 17:02:27 +0800
commit80481cb46180021abe0f3cf959dacca2519b9c53 (patch)
treee7b9bb866f2375d1dcc303f860a3b5da00edf84f /src/com/android/gallery3d/photoeditor
parentc2c9df91a8f9b35d18d43593d75f65b78e6bfc38 (diff)
downloadandroid_packages_apps_Snap-80481cb46180021abe0f3cf959dacca2519b9c53.tar.gz
android_packages_apps_Snap-80481cb46180021abe0f3cf959dacca2519b9c53.tar.bz2
android_packages_apps_Snap-80481cb46180021abe0f3cf959dacca2519b9c53.zip
Fix b/5392171 and b/5389281.
1. Fix b/5392171 by moving effect context creation into Filter to make sure it'd be created when needed. 2. Revise the fix for b/5389281 by clearing surface background even there's no photo. Change-Id: I212a552291c7df28b75a909bf6560634ba061e9f
Diffstat (limited to 'src/com/android/gallery3d/photoeditor')
-rw-r--r--src/com/android/gallery3d/photoeditor/FilterStack.java12
-rw-r--r--src/com/android/gallery3d/photoeditor/PhotoView.java1
-rw-r--r--src/com/android/gallery3d/photoeditor/RendererUtils.java7
-rw-r--r--src/com/android/gallery3d/photoeditor/filters/Filter.java10
4 files changed, 15 insertions, 15 deletions
diff --git a/src/com/android/gallery3d/photoeditor/FilterStack.java b/src/com/android/gallery3d/photoeditor/FilterStack.java
index e84c92e12..7a155096a 100644
--- a/src/com/android/gallery3d/photoeditor/FilterStack.java
+++ b/src/com/android/gallery3d/photoeditor/FilterStack.java
@@ -238,8 +238,10 @@ public class FilterStack {
@Override
public void run() {
Filter.releaseContext();
+ // Textures will be automatically deleted when GL context is lost.
+ photoView.setPhoto(null, false);
+ source = null;
for (int i = 0; i < buffers.length; i++) {
- // Textures will be automatically deleted when GL context is lost.
buffers[i] = null;
}
}
@@ -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;
}
}
diff --git a/src/com/android/gallery3d/photoeditor/PhotoView.java b/src/com/android/gallery3d/photoeditor/PhotoView.java
index b2e510329..edb36242e 100644
--- a/src/com/android/gallery3d/photoeditor/PhotoView.java
+++ b/src/com/android/gallery3d/photoeditor/PhotoView.java
@@ -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);
}
diff --git a/src/com/android/gallery3d/photoeditor/RendererUtils.java b/src/com/android/gallery3d/photoeditor/RendererUtils.java
index a0cd5982d..ff593d4ef 100644
--- a/src/com/android/gallery3d/photoeditor/RendererUtils.java
+++ b/src/com/android/gallery3d/photoeditor/RendererUtils.java
@@ -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
@@ -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);
}
diff --git a/src/com/android/gallery3d/photoeditor/filters/Filter.java b/src/com/android/gallery3d/photoeditor/filters/Filter.java
index 1fd1f7e73..8c00dbb3f 100644
--- a/src/com/android/gallery3d/photoeditor/filters/Filter.java
+++ b/src/com/android/gallery3d/photoeditor/filters/Filter.java
@@ -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.
@@ -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);