diff options
author | John Hoford <hoford@google.com> | 2012-10-15 15:51:02 -0700 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2012-10-15 16:46:38 -0700 |
commit | 92cd5e6cdb366322733dacd7b6d36d9f0ca43eac (patch) | |
tree | 27dddcadd22acdd83fd187fcad1649f3c9ab5f55 /src/com/android/gallery3d | |
parent | 7ef3d2d5af9ff5230f7275a835255907d4977303 (diff) | |
download | android_packages_apps_Snap-92cd5e6cdb366322733dacd7b6d36d9f0ca43eac.tar.gz android_packages_apps_Snap-92cd5e6cdb366322733dacd7b6d36d9f0ca43eac.tar.bz2 android_packages_apps_Snap-92cd5e6cdb366322733dacd7b6d36d9f0ca43eac.zip |
fix for the cache
Change-Id: Ib5c82aa602df961d15064e732b3701c8d6cd66ff
bug:7345592
Diffstat (limited to 'src/com/android/gallery3d')
-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); + } } |