diff options
author | nicolasroard <nicolasroard@google.com> | 2013-07-31 16:22:59 -0700 |
---|---|---|
committer | nicolasroard <nicolasroard@google.com> | 2013-07-31 17:39:52 -0700 |
commit | 8f442fae60e0154867d2a6927eb9a35bcb7014e6 (patch) | |
tree | 5dbfc8c459e127bd3c05341f867a17972316ae7f /src/com/android/gallery3d/filtershow/pipeline | |
parent | 086b60315ff84c7551cc45af395a4f09f509b5c5 (diff) | |
download | android_packages_apps_Gallery2-8f442fae60e0154867d2a6927eb9a35bcb7014e6.tar.gz android_packages_apps_Gallery2-8f442fae60e0154867d2a6927eb9a35bcb7014e6.tar.bz2 android_packages_apps_Gallery2-8f442fae60e0154867d2a6927eb9a35bcb7014e6.zip |
Fix problem with N-1 caching when no filters / one filter
- also fix equals() for geometry
Change-Id: I6f6f21d1e274b3b95ac4b5189b2fa7f419912864
Diffstat (limited to 'src/com/android/gallery3d/filtershow/pipeline')
-rw-r--r-- | src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java index e358ebaa3..10b6c4923 100644 --- a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java +++ b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java @@ -35,7 +35,10 @@ public class CacheProcessing { public Bitmap process(Bitmap originalBitmap, Vector<FilterRepresentation> filters, FilterEnvironment environment) { - Bitmap cacheBitmap = originalBitmap; + + if (filters.size() == 0) { + return originalBitmap; + } // New set of filters, let's clear the cache and rebuild it. if (filters.size() != mSteps.size()) { @@ -54,7 +57,7 @@ public class CacheProcessing { // First, let's find how similar we are in our cache // compared to the current list of filters - int similarUpToIndex = 0; + int similarUpToIndex = -1; for (int i = 0; i < filters.size(); i++) { FilterRepresentation representation = filters.elementAt(i); CacheStep step = mSteps.elementAt(i); @@ -70,18 +73,27 @@ public class CacheProcessing { } // Now, let's get the earliest cached result in our pipeline + Bitmap cacheBitmap = null; int findBaseImageIndex = similarUpToIndex; - while (findBaseImageIndex > 0 - && mSteps.elementAt(findBaseImageIndex).cache == null) { - findBaseImageIndex--; + if (findBaseImageIndex > -1) { + while (findBaseImageIndex > 0 + && mSteps.elementAt(findBaseImageIndex).cache == null) { + findBaseImageIndex--; + } + cacheBitmap = mSteps.elementAt(findBaseImageIndex).cache; } - cacheBitmap = mSteps.elementAt(findBaseImageIndex).cache; boolean emptyStack = false; if (cacheBitmap == null) { emptyStack = true; // Damn, it's an empty stack, we have to start from scratch // TODO: use a bitmap cache + RS allocation instead of Bitmap.copy() cacheBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true); + if (findBaseImageIndex > -1) { + FilterRepresentation representation = filters.elementAt(findBaseImageIndex); + cacheBitmap = environment.applyRepresentation(representation, cacheBitmap); + mSteps.elementAt(findBaseImageIndex).representation = representation.copy(); + mSteps.elementAt(findBaseImageIndex).cache = cacheBitmap; + } if (DEBUG) { Log.v(LOGTAG, "empty stack"); } @@ -97,6 +109,9 @@ public class CacheProcessing { // rebuild the cache image for this step if (!emptyStack) { cacheBitmap = cacheBitmap.copy(Bitmap.Config.ARGB_8888, true); + } else { + // if it was an empty stack, we already applied it + findBaseImageIndex ++; } for (int i = findBaseImageIndex; i <= similarUpToIndex; i++) { FilterRepresentation representation = filters.elementAt(i); |