diff options
author | Yuli Huang <yuli@google.com> | 2011-10-05 16:22:10 +0800 |
---|---|---|
committer | Yuli Huang <yuli@google.com> | 2011-10-05 17:15:25 +0800 |
commit | c7e39d12860adf99a12c6b47e9aaa9d7ae098307 (patch) | |
tree | 2c48e280d4c80ef4f2e75e5b408043b0fe1a448e /src/com/android/gallery3d/photoeditor/FilterStack.java | |
parent | a7bbb047782014cf794c6386df2ef20c57f3a164 (diff) | |
download | android_packages_apps_Gallery2-c7e39d12860adf99a12c6b47e9aaa9d7ae098307.tar.gz android_packages_apps_Gallery2-c7e39d12860adf99a12c6b47e9aaa9d7ae098307.tar.bz2 android_packages_apps_Gallery2-c7e39d12860adf99a12c6b47e9aaa9d7ae098307.zip |
Fix b/5413887 and b/5389281.
1. Fix b/5413887 by releasing MFF effects as well as release
MFF effect-context.
2. Fix b/5389281 by removing photoView.setPhoto(null).
Change-Id: I1b848f6c87b03ba2539432fd6d6f13f4ac3a2907
Diffstat (limited to 'src/com/android/gallery3d/photoeditor/FilterStack.java')
-rw-r--r-- | src/com/android/gallery3d/photoeditor/FilterStack.java | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/com/android/gallery3d/photoeditor/FilterStack.java b/src/com/android/gallery3d/photoeditor/FilterStack.java index 5b8d0d743..67b904d55 100644 --- a/src/com/android/gallery3d/photoeditor/FilterStack.java +++ b/src/com/android/gallery3d/photoeditor/FilterStack.java @@ -17,7 +17,6 @@ package com.android.gallery3d.photoeditor; import android.graphics.Bitmap; -import android.media.effect.EffectContext; import com.android.gallery3d.photoeditor.filters.Filter; @@ -44,7 +43,6 @@ public class FilterStack { private final PhotoView photoView; private final StackListener stackListener; - private EffectContext effectContext; private Photo source; private Runnable queuedTopFilterChange; private volatile boolean paused; @@ -54,15 +52,6 @@ public class FilterStack { this.stackListener = stackListener; } - private void clearBuffers() { - for (int i = 0; i < buffers.length; i++) { - if (buffers[i] != null) { - buffers[i].clear(); - buffers[i] = null; - } - } - } - private void reallocateBuffer(int target) { int other = target ^ 1; buffers[target] = Photo.create(buffers[other].width(), buffers[other].height()); @@ -70,7 +59,12 @@ public class FilterStack { private void invalidate() { // In/out buffers need redrawn by re-applying filters on source photo. - clearBuffers(); + for (int i = 0; i < buffers.length; i++) { + if (buffers[i] != null) { + buffers[i].clear(); + buffers[i] = null; + } + } if (source != null) { buffers[0] = Photo.create(source.width(), source.height()); reallocateBuffer(1); @@ -98,7 +92,7 @@ public class FilterStack { buffers[out].clear(); reallocateBuffer(out); } - appliedStack.get(filterIndex).process(effectContext, input, buffers[out]); + appliedStack.get(filterIndex).process(input, buffers[out]); return buffers[out]; } return null; @@ -229,19 +223,18 @@ public class FilterStack { public void onPause() { // Flush pending queued operations and release effect-context before GL context is lost. - // Use pause-flag to avoid lengthy runnable in GL thread blocking onPause(). + // Use the flag to break from lengthy invalidate() in GL thread for not blocking onPause(). paused = true; photoView.flush(); photoView.queueEvent(new Runnable() { @Override public void run() { - if (effectContext != null) { - effectContext.release(); - effectContext = null; + Filter.releaseContext(); + for (int i = 0; i < buffers.length; i++) { + // Textures will be automatically deleted when GL context is lost. + buffers[i] = null; } - photoView.setPhoto(null); - clearBuffers(); } }); photoView.onPause(); @@ -254,7 +247,7 @@ public class FilterStack { @Override public void run() { // Create effect context after GL context is created or recreated. - effectContext = EffectContext.createWithCurrentGlContext(); + Filter.createContextWithCurrentGlContext(); } }); paused = false; |