diff options
author | nicolasroard <nicolasroard@google.com> | 2013-09-03 08:40:42 -0700 |
---|---|---|
committer | nicolasroard <nicolasroard@google.com> | 2013-09-03 10:57:12 -0700 |
commit | c3d21101b14cdc1abf8a055e056019af57c4c7be (patch) | |
tree | 97d15ae3fac68ca61a8cd98d12889f64aacec4aa /src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java | |
parent | b178c1959c10e57b397490f1f2d882df06104366 (diff) | |
download | android_packages_apps_Gallery2-c3d21101b14cdc1abf8a055e056019af57c4c7be.tar.gz android_packages_apps_Gallery2-c3d21101b14cdc1abf8a055e056019af57c4c7be.tar.bz2 android_packages_apps_Gallery2-c3d21101b14cdc1abf8a055e056019af57c4c7be.zip |
Fix graphic pipeline cache
Some bitmaps were thrown back
into the bitmap pool while still
used in the caching pipeline...
Change-Id: I56c47b44d137f16b9a9a6cf79224c296ea6e55a0
Diffstat (limited to 'src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java')
-rw-r--r-- | src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java index 2a8321908..3d560ef5f 100644 --- a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java +++ b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java @@ -119,6 +119,8 @@ public class CacheProcessing { return environment.getBitmapCopy(originalBitmap); } + environment.getBimapCache().setCacheProcessing(this); + if (DEBUG) { displayFilters(filters); } @@ -145,9 +147,9 @@ public class CacheProcessing { if (similar) { similarUpToIndex = i; } else { - environment.cache(cacheStep.cache); mSteps.remove(i); mSteps.insertElementAt(newStep, i); + environment.cache(cacheStep.cache); } } if (DEBUG) { @@ -171,6 +173,7 @@ public class CacheProcessing { } Bitmap originalCopy = null; + int lastPositionCached = -1; for (int i = findBaseImageIndex; i < mSteps.size(); i++) { if (i == -1 || cacheBitmap == null) { cacheBitmap = environment.getBitmapCopy(originalBitmap); @@ -194,6 +197,7 @@ public class CacheProcessing { cacheBitmap = environment.getBitmapCopy(cacheBitmap); cacheBitmap = step.apply(environment, cacheBitmap); step.cache = cacheBitmap; + lastPositionCached = i; } } environment.cache(originalCopy); @@ -214,9 +218,21 @@ public class CacheProcessing { Log.v(LOGTAG, "cleanup done..."); displayNbBitmapsInCache(); } + if (lastPositionCached != -1) { + mSteps.elementAt(lastPositionCached).cache = null; + } return cacheBitmap; } + public boolean contains(Bitmap bitmap) { + for (int i = 0; i < mSteps.size(); i++) { + if (mSteps.elementAt(i).cache == bitmap) { + return true; + } + } + return false; + } + private void displayFilters(Vector<FilterRepresentation> filters) { Log.v(LOGTAG, "------>>> Filters received"); for (int i = 0; i < filters.size(); i++) { |