diff options
author | Yuli Huang <yuli@google.com> | 2011-10-10 00:55:26 +0800 |
---|---|---|
committer | Yuli Huang <yuli@google.com> | 2011-10-10 02:57:08 +0800 |
commit | e0e82f1de7396645244e475e1423e2f5fe518630 (patch) | |
tree | accf94952cc577887ea50e3f1945b1a649bc4677 /src/com/android/gallery3d/photoeditor/FilterStack.java | |
parent | 57cbaa1ef40d2215c6400f5ae4af3a09e67abb2d (diff) | |
download | android_packages_apps_Gallery2-e0e82f1de7396645244e475e1423e2f5fe518630.tar.gz android_packages_apps_Gallery2-e0e82f1de7396645244e475e1423e2f5fe518630.tar.bz2 android_packages_apps_Gallery2-e0e82f1de7396645244e475e1423e2f5fe518630.zip |
Fix b/5433856 and b/5433907.
1. Make PhotoView restore rotation after the device awakes or
the orientation changes.
2. Avoid outputting top filter until the active effect requests its
output to fix incorrect Crop/Rotate/Doodle effects after device awakes.
3. Speed up rotation speed by removing queued outdated rotation.
Change-Id: I5b82ccfe4e27ad5f1d2505bdd7a7540e0a77b55d
Diffstat (limited to 'src/com/android/gallery3d/photoeditor/FilterStack.java')
-rw-r--r-- | src/com/android/gallery3d/photoeditor/FilterStack.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/com/android/gallery3d/photoeditor/FilterStack.java b/src/com/android/gallery3d/photoeditor/FilterStack.java index 67b904d55..e84c92e12 100644 --- a/src/com/android/gallery3d/photoeditor/FilterStack.java +++ b/src/com/android/gallery3d/photoeditor/FilterStack.java @@ -45,6 +45,7 @@ public class FilterStack { private Photo source; private Runnable queuedTopFilterChange; + private boolean topFilterOutputted; private volatile boolean paused; public FilterStack(PhotoView photoView, StackListener stackListener) { @@ -69,18 +70,20 @@ public class FilterStack { buffers[0] = Photo.create(source.width(), source.height()); reallocateBuffer(1); + // Source photo will be displayed if there is no filter stacked. Photo photo = source; - for (int i = 0; i < appliedStack.size() && !paused; i++) { + int size = topFilterOutputted ? appliedStack.size() : appliedStack.size() - 1; + for (int i = 0; i < size && !paused; i++) { photo = runFilter(i); } - // Source photo will be displayed if there is no filter stacked. - photoView.setPhoto(photo); + photoView.setPhoto(photo, topFilterOutputted); } } private void invalidateTopFilter() { if (!appliedStack.empty()) { - photoView.setPhoto(runFilter(appliedStack.size() - 1)); + photoView.setPhoto(runFilter(appliedStack.size() - 1), true); + topFilterOutputted = true; } } @@ -135,8 +138,8 @@ public class FilterStack { @Override public void run() { - Photo photo = appliedStack.empty() ? - null : buffers[getOutBufferIndex(appliedStack.size() - 1)]; + int filterIndex = appliedStack.size() - (topFilterOutputted ? 1 : 2); + Photo photo = (filterIndex < 0) ? source : buffers[getOutBufferIndex(filterIndex)]; final Bitmap bitmap = (photo != null) ? photo.save() : null; photoView.post(new Runnable() { @@ -161,6 +164,12 @@ public class FilterStack { }); } + private void pushFilterInternal(Filter filter) { + appliedStack.push(filter); + topFilterOutputted = false; + stackChanged(); + } + public void pushFilter(final Filter filter) { photoView.queue(new Runnable() { @@ -169,8 +178,7 @@ public class FilterStack { while (!redoStack.empty()) { redoStack.pop().release(); } - appliedStack.push(filter); - stackChanged(); + pushFilterInternal(filter); } }); } @@ -196,8 +204,7 @@ public class FilterStack { @Override public void run() { if (!redoStack.empty()) { - appliedStack.push(redoStack.pop()); - stackChanged(); + pushFilterInternal(redoStack.pop()); invalidateTopFilter(); } callbackDone(callback); |