summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/pipeline
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-10-10 15:46:44 -0700
committernicolasroard <nicolasroard@google.com>2013-10-10 15:48:30 -0700
commit1ebeed45d206ed306eb149e4e63242b1b55558ef (patch)
tree10d1f8dc8f3a7ca4c958cdd1f160c091f9d81a6d /src/com/android/gallery3d/filtershow/pipeline
parent96e6ddb24dd149aa991ef007a394ea9592066d14 (diff)
downloadandroid_packages_apps_Gallery2-1ebeed45d206ed306eb149e4e63242b1b55558ef.tar.gz
android_packages_apps_Gallery2-1ebeed45d206ed306eb149e4e63242b1b55558ef.tar.bz2
android_packages_apps_Gallery2-1ebeed45d206ed306eb149e4e63242b1b55558ef.zip
Fix edge case cache issues
Also add additional debugging information. bug:10856175 Change-Id: Ie352e2dd6a86511abea97b622ed7c3b3cccd8479
Diffstat (limited to 'src/com/android/gallery3d/filtershow/pipeline')
-rw-r--r--src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java
index 4dad73630..c2912ed78 100644
--- a/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java
+++ b/src/com/android/gallery3d/filtershow/pipeline/CacheProcessing.java
@@ -29,6 +29,7 @@ import java.util.Vector;
public class CacheProcessing {
private static final String LOGTAG = "CacheProcessing";
private static final boolean DEBUG = false;
+ private static final boolean NO_CACHING = false;
private Vector<CacheStep> mSteps = new Vector<CacheStep>();
static class CacheStep {
@@ -104,15 +105,25 @@ public class CacheProcessing {
for (FilterRepresentation representation : representations) {
geometry.add(representation);
}
+ if (DEBUG) {
+ Log.v(LOGTAG, "Apply geometry to bitmap " + cacheBitmap);
+ }
cacheBitmap = GeometryMathUtils.applyGeometryRepresentations(geometry, cacheBitmap);
} else {
for (FilterRepresentation representation : representations) {
+ if (DEBUG) {
+ Log.v(LOGTAG, "Apply " + representation.getSerializationName()
+ + " to bitmap " + cacheBitmap);
+ }
cacheBitmap = environment.applyRepresentation(representation, cacheBitmap);
}
}
if (cacheBitmap != source) {
environment.cache(source);
}
+ if (DEBUG) {
+ Log.v(LOGTAG, "Apply returns bitmap " + cacheBitmap);
+ }
return cacheBitmap;
}
}
@@ -178,6 +189,20 @@ public class CacheProcessing {
+ mSteps.size() + " cacheBitmap: " + cacheBitmap);
}
+ if (NO_CACHING) {
+ cacheBitmap = environment.getBitmapCopy(originalBitmap,
+ BitmapCache.PREVIEW_CACHE_NO_ROOT);
+ for (int i = 0; i < mSteps.size(); i++) {
+ CacheStep step = mSteps.elementAt(i);
+ Bitmap prev = cacheBitmap;
+ cacheBitmap = step.apply(environment, cacheBitmap);
+ if (prev != cacheBitmap) {
+ environment.cache(prev);
+ }
+ }
+ return cacheBitmap;
+ }
+
Bitmap originalCopy = null;
int lastPositionCached = -1;
for (int i = findBaseImageIndex; i < mSteps.size(); i++) {
@@ -227,9 +252,8 @@ public class CacheProcessing {
displayNbBitmapsInCache();
}
if (lastPositionCached != -1) {
- Bitmap bitmap = mSteps.elementAt(lastPositionCached).cache;
+ // The last element will never be reused, remove it from the cache.
mSteps.elementAt(lastPositionCached).cache = null;
- environment.cache(bitmap);
}
if (contains(cacheBitmap)) {
return environment.getBitmapCopy(cacheBitmap, BitmapCache.PREVIEW_CACHE_NO_APPLY);