summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/photoeditor/FilterStack.java
diff options
context:
space:
mode:
authorYuli Huang <yuli@google.com>2011-10-10 00:55:26 +0800
committerYuli Huang <yuli@google.com>2011-10-10 02:57:08 +0800
commit566f653e477d8d594e6c69e394a52f616100bd31 (patch)
treed033d299a75fc355d33b7b66829d96b50ca1b0f8 /src/com/android/gallery3d/photoeditor/FilterStack.java
parent9d62da7986aef9d89356f6b169fafecd8936d9f6 (diff)
downloadandroid_packages_apps_Snap-566f653e477d8d594e6c69e394a52f616100bd31.tar.gz
android_packages_apps_Snap-566f653e477d8d594e6c69e394a52f616100bd31.tar.bz2
android_packages_apps_Snap-566f653e477d8d594e6c69e394a52f616100bd31.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.java27
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);