diff options
author | John Hoford <hoford@google.com> | 2012-10-15 16:54:21 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-15 16:54:21 -0700 |
commit | 2d4b782a5e1289e736771cd01566858fd0a20dd1 (patch) | |
tree | e3206fa6f41a9903bd52e625268dbd9ff7921e02 /src | |
parent | 0cd81d768c23d9499209994571138d4f62892aa8 (diff) | |
parent | 2ef2d71edf822f0462fb312342f89f80ff271564 (diff) | |
download | android_packages_apps_Snap-2d4b782a5e1289e736771cd01566858fd0a20dd1.tar.gz android_packages_apps_Snap-2d4b782a5e1289e736771cd01566858fd0a20dd1.tar.bz2 android_packages_apps_Snap-2d4b782a5e1289e736771cd01566858fd0a20dd1.zip |
am 80789c08: Merge "fix for the cache" into gb-ub-photos-arches
* commit '80789c089e8795968426838ff9c1e71c84cfee6f':
fix for the cache
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java b/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java index 67bd49b1c..25d1db414 100644 --- a/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java +++ b/src/com/android/gallery3d/filtershow/cache/DirectPresetCache.java @@ -62,7 +62,7 @@ public class DirectPresetCache implements Cache { private CachedPreset getCachedPreset(ImagePreset preset) { for (int i = 0; i < mCache.size(); i++) { CachedPreset cache = mCache.elementAt(i); - if (cache.mPreset == preset && !cache.mBusy) { + if (cache.mPreset == preset) { return cache; } } @@ -73,7 +73,7 @@ public class DirectPresetCache implements Cache { public Bitmap get(ImagePreset preset) { // Log.v(LOGTAG, "get preset " + preset.name() + " : " + preset); CachedPreset cache = getCachedPreset(preset); - if (cache != null) { + if (cache != null && !cache.mBusy) { return cache.mBitmap; } // Log.v(LOGTAG, "didn't find preset " + preset.name() + " : " + preset @@ -138,18 +138,21 @@ public class DirectPresetCache implements Cache { public void prepare(ImagePreset preset) { // Log.v(LOGTAG, "prepare preset " + preset.name() + " : " + preset); CachedPreset cache = getCachedPreset(preset); - if (cache == null) { - if (mCache.size() < mCacheSize) { - cache = new CachedPreset(); - mCache.add(cache); - } else { - cache = getOldestCachedPreset(); + if (cache == null || (cache.mBitmap == null && !cache.mBusy)) { + if (cache == null) { + if (mCache.size() < mCacheSize) { + cache = new CachedPreset(); + mCache.add(cache); + } else { + cache = getOldestCachedPreset(); + } } if (cache != null) { cache.mPreset = preset; + willCompute(cache); } } - willCompute(cache); + } } |