• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Gallery2


Commit MetaInfo

Revisão27918e8d7dafecd9310cbb7726b2967f795b3c0b (tree)
Hora2010-01-28 07:36:53
AutorVenkat Krishnaraj <venkatkrishnaraj@venk...>
CommiterChih-Chung Chang

Mensagem de Log

Fix to prevent auto-thumbnailer to run on images whose decoding has failed (causing CPU cycles being wasted resulting in sometimes affecting performance of CPU intensive applications such as the video player)

Mudança Sumário

Diff

--- a/src/com/cooliris/cache/BootReceiver.java
+++ b/src/com/cooliris/cache/BootReceiver.java
@@ -58,6 +58,7 @@ public class BootReceiver extends BroadcastReceiver {
5858 PicasaDataSource.sThumbnailCache.close();
5959 CacheService.sAlbumCache.close();
6060 CacheService.sMetaAlbumCache.close();
61+ CacheService.sSkipThumbnailIds.flush();
6162 }
6263 }
6364 }
--- a/src/com/cooliris/cache/CacheService.java
+++ b/src/com/cooliris/cache/CacheService.java
@@ -57,6 +57,7 @@ public final class CacheService extends IntentService {
5757 public static final String ACTION_CACHE = "com.cooliris.cache.action.CACHE";
5858 public static final DiskCache sAlbumCache = new DiskCache("local-album-cache");
5959 public static final DiskCache sMetaAlbumCache = new DiskCache("local-meta-cache");
60+ public static final DiskCache sSkipThumbnailIds = new DiskCache("local-skip-cache");
6061
6162 private static final String TAG = "CacheService";
6263 private static ImageList sList = null;
@@ -603,14 +604,36 @@ public final class CacheService extends IntentService {
603604 final long id = ids[i];
604605 final long timeModifiedInSec = timestamp[i];
605606 final long thumbnailId = thumbnailIds[i];
606- if (!thumbnailCache.isDataAvailable(thumbnailId, timeModifiedInSec * 1000)) {
607- buildThumbnailForId(context, thumbnailCache, thumbnailId, id, false, DEFAULT_THUMBNAIL_WIDTH,
608- DEFAULT_THUMBNAIL_HEIGHT, timeModifiedInSec * 1000);
607+ if (!isInThumbnailerSkipList(thumbnailId)) {
608+ if (!thumbnailCache.isDataAvailable(thumbnailId, timeModifiedInSec * 1000)) {
609+ byte[] retVal = buildThumbnailForId(context, thumbnailCache, thumbnailId, id, false, DEFAULT_THUMBNAIL_WIDTH,
610+ DEFAULT_THUMBNAIL_HEIGHT, timeModifiedInSec * 1000);
611+ if (retVal == null || retVal.length == 0) {
612+ // There was an error in building the thumbnail.
613+ // We record this thumbnail id
614+ addToThumbnailerSkipList(thumbnailId);
615+ }
616+ }
609617 }
610618 }
611619 Log.i(TAG, "DiskCache ready for all thumbnails.");
612620 }
613621
622+ private static void addToThumbnailerSkipList(long thumbnailId) {
623+ sSkipThumbnailIds.put(thumbnailId, sDummyData, 0);
624+ sSkipThumbnailIds.flush();
625+ }
626+
627+ private static boolean isInThumbnailerSkipList(long thumbnailId) {
628+ if (sSkipThumbnailIds.isDataAvailable(thumbnailId, 0)) {
629+ byte[] data = sSkipThumbnailIds.get(thumbnailId, 0);
630+ if (data.length > 0) {
631+ return true;
632+ }
633+ }
634+ return false;
635+ }
636+
614637 private static final byte[] buildThumbnailForId(final Context context, final DiskCache thumbnailCache, final long thumbId,
615638 final long origId, final boolean isVideo, final int thumbnailWidth, final int thumbnailHeight, final long timestamp) {
616639 if (origId == Shared.INVALID) {
@@ -650,7 +673,8 @@ public final class CacheService extends IntentService {
650673 if (bitmap == null) {
651674 return null;
652675 }
653- final byte[] retVal = writeBitmapToCache(thumbnailCache, thumbId, origId, bitmap, thumbnailWidth, thumbnailHeight, timestamp);
676+ final byte[] retVal = writeBitmapToCache(thumbnailCache, thumbId, origId, bitmap, thumbnailWidth, thumbnailHeight,
677+ timestamp);
654678 return retVal;
655679 } catch (InterruptedException e) {
656680 return null;