summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/data/ImageCacheService.java2
-rw-r--r--src/com/android/gallery3d/data/MediaItem.java36
-rw-r--r--src/com/android/gallery3d/ui/BitmapScreenNail.java12
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java23
4 files changed, 50 insertions, 23 deletions
diff --git a/src/com/android/gallery3d/data/ImageCacheService.java b/src/com/android/gallery3d/data/ImageCacheService.java
index 0e7931389..f10a7b3e6 100644
--- a/src/com/android/gallery3d/data/ImageCacheService.java
+++ b/src/com/android/gallery3d/data/ImageCacheService.java
@@ -35,7 +35,7 @@ public class ImageCacheService {
private static final String IMAGE_CACHE_FILE = "imgcache";
private static final int IMAGE_CACHE_MAX_ENTRIES = 5000;
private static final int IMAGE_CACHE_MAX_BYTES = 200 * 1024 * 1024;
- private static final int IMAGE_CACHE_VERSION = 4;
+ private static final int IMAGE_CACHE_VERSION = 5;
private BlobCache mCache;
diff --git a/src/com/android/gallery3d/data/MediaItem.java b/src/com/android/gallery3d/data/MediaItem.java
index 9d2040aad..77b86b847 100644
--- a/src/com/android/gallery3d/data/MediaItem.java
+++ b/src/com/android/gallery3d/data/MediaItem.java
@@ -30,8 +30,6 @@ public abstract class MediaItem extends MediaObject {
public static final int TYPE_THUMBNAIL = 1;
public static final int TYPE_MICROTHUMBNAIL = 2;
- public static final int THUMBNAIL_TARGET_SIZE = 640;
- public static final int MICROTHUMBNAIL_TARGET_SIZE = 200;
public static final int CACHED_IMAGE_QUALITY = 95;
public static final int IMAGE_READY = 0;
@@ -43,19 +41,17 @@ public abstract class MediaItem extends MediaObject {
private static final int BYTESBUFFE_POOL_SIZE = 4;
private static final int BYTESBUFFER_SIZE = 200 * 1024;
- private static final BitmapPool sMicroThumbPool =
- ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_FACTORY
- ? new BitmapPool(MICROTHUMBNAIL_TARGET_SIZE, MICROTHUMBNAIL_TARGET_SIZE, 16)
- : null;
+ private static int sMicrothumbnailTargetSize = 200;
+ private static BitmapPool sMicroThumbPool;
+ private static final BytesBufferPool sMicroThumbBufferPool =
+ new BytesBufferPool(BYTESBUFFE_POOL_SIZE, BYTESBUFFER_SIZE);
+ private static int sThumbnailTargetSize = 640;
private static final BitmapPool sThumbPool =
ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_FACTORY
? new BitmapPool(4)
: null;
- private static final BytesBufferPool sMicroThumbBufferPool =
- new BytesBufferPool(BYTESBUFFE_POOL_SIZE, BYTESBUFFER_SIZE);
-
// TODO: fix default value for latlng and change this.
public static final double INVALID_LATLNG = 0f;
@@ -125,9 +121,9 @@ public abstract class MediaItem extends MediaObject {
public static int getTargetSize(int type) {
switch (type) {
case TYPE_THUMBNAIL:
- return THUMBNAIL_TARGET_SIZE;
+ return sThumbnailTargetSize;
case TYPE_MICROTHUMBNAIL:
- return MICROTHUMBNAIL_TARGET_SIZE;
+ return sMicrothumbnailTargetSize;
default:
throw new RuntimeException(
"should only request thumb/microthumb from cache");
@@ -135,6 +131,9 @@ public abstract class MediaItem extends MediaObject {
}
public static BitmapPool getMicroThumbPool() {
+ if (ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_FACTORY && sMicroThumbPool == null) {
+ initializeMicroThumbPool();
+ }
return sMicroThumbPool;
}
@@ -145,4 +144,19 @@ public abstract class MediaItem extends MediaObject {
public static BytesBufferPool getBytesBufferPool() {
return sMicroThumbBufferPool;
}
+
+ private static void initializeMicroThumbPool() {
+ sMicroThumbPool =
+ ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_FACTORY
+ ? new BitmapPool(sMicrothumbnailTargetSize, sMicrothumbnailTargetSize, 16)
+ : null;
+ }
+
+ public static void setThumbnailSizes(int size, int microSize) {
+ sThumbnailTargetSize = size;
+ if (sMicrothumbnailTargetSize != microSize) {
+ sMicrothumbnailTargetSize = microSize;
+ initializeMicroThumbPool();
+ }
+ }
}
diff --git a/src/com/android/gallery3d/ui/BitmapScreenNail.java b/src/com/android/gallery3d/ui/BitmapScreenNail.java
index 25f88a1e4..9b629160c 100644
--- a/src/com/android/gallery3d/ui/BitmapScreenNail.java
+++ b/src/com/android/gallery3d/ui/BitmapScreenNail.java
@@ -37,7 +37,7 @@ public class BitmapScreenNail implements ScreenNail {
// The duration of the fading animation in milliseconds
private static final int DURATION = 180;
- private static final int MAX_SIDE = 640;
+ private static int sMaxSide = 640;
// These are special values for mAnimationStartTime
private static final long ANIMATION_NOT_NEEDED = -1;
@@ -73,10 +73,10 @@ public class BitmapScreenNail implements ScreenNail {
private void setSize(int width, int height) {
if (width == 0 || height == 0) {
- width = 640;
- height = 480;
+ width = sMaxSide;
+ height = sMaxSide * 3 / 4;
}
- float scale = Math.min(1, (float) MAX_SIDE / Math.max(width, height));
+ float scale = Math.min(1, (float) sMaxSide / Math.max(width, height));
mWidth = Math.round(scale * width);
mHeight = Math.round(scale * height);
}
@@ -209,4 +209,8 @@ public class BitmapScreenNail implements ScreenNail {
public TiledTexture getTexture() {
return mTexture;
}
+
+ public static void setMaxSide(int size) {
+ sMaxSide = size;
+ }
}
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index efa06149f..05bd3dea6 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -75,16 +75,25 @@ public class GalleryUtils {
private static boolean sCameraAvailable;
public static void initialize(Context context) {
- if (sPixelDensity < 0) {
- DisplayMetrics metrics = new DisplayMetrics();
- WindowManager wm = (WindowManager)
- context.getSystemService(Context.WINDOW_SERVICE);
- wm.getDefaultDisplay().getMetrics(metrics);
- sPixelDensity = metrics.density;
- }
+ DisplayMetrics metrics = new DisplayMetrics();
+ WindowManager wm = (WindowManager)
+ context.getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getMetrics(metrics);
+ sPixelDensity = metrics.density;
Resources r = context.getResources();
BitmapScreenNail.setPlaceholderColor(r.getColor(
R.color.bitmap_screennail_placeholder));
+ initializeThumbnailSizes(metrics, r);
+ }
+
+ private static void initializeThumbnailSizes(DisplayMetrics metrics, Resources r) {
+ int minRows = Math.min(r.getInteger(R.integer.album_rows_land),
+ r.getInteger(R.integer.albumset_rows_land));
+ int maxDimensionPixels = Math.max(metrics.heightPixels, metrics.widthPixels);
+ // Never need to completely fill the screen
+ maxDimensionPixels = maxDimensionPixels * 3/4;
+ MediaItem.setThumbnailSizes(maxDimensionPixels, maxDimensionPixels / minRows);
+ BitmapScreenNail.setMaxSide(maxDimensionPixels);
}
public static boolean isHighResolution(Context context) {