summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPin Ting <pinting@google.com>2012-10-04 06:54:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-04 06:54:48 -0700
commit25ab25343c04ed845717b7d25d67be66c247e48d (patch)
treecedcd353293bbe4c69e1a7cf316d786d5826a0f1
parent5a7157733bb2229642866a3bb4cbc6850c995a9d (diff)
parent82d95838d891057b56fd43780e2424e04f1e291b (diff)
downloadandroid_packages_apps_Snap-25ab25343c04ed845717b7d25d67be66c247e48d.tar.gz
android_packages_apps_Snap-25ab25343c04ed845717b7d25d67be66c247e48d.tar.bz2
android_packages_apps_Snap-25ab25343c04ed845717b7d25d67be66c247e48d.zip
Merge "Accelerate PNG image rendering." into gb-ub-photos-arches
-rw-r--r--src/com/android/gallery3d/ui/TileImageView.java22
-rw-r--r--src/com/android/gallery3d/ui/TileImageViewAdapter.java1
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java8
3 files changed, 24 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index 9eb4f4787..5ce06bec4 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -29,6 +29,7 @@ import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.DecodeUtils;
import com.android.gallery3d.util.Future;
+import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.ThreadPool;
import com.android.gallery3d.util.ThreadPool.CancelListener;
import com.android.gallery3d.util.ThreadPool.JobContext;
@@ -43,15 +44,12 @@ public class TileImageView extends GLView {
// TILE_SIZE must be 2^N - 2. We put one pixel border in each side of the
// texture to avoid seams between tiles.
- private static final int TILE_SIZE = 254;
+ private static int TILE_SIZE;
private static final int TILE_BORDER = 1;
- private static final int BITMAP_SIZE = TILE_SIZE + TILE_BORDER * 2;
+ private static int BITMAP_SIZE;
private static final int UPLOAD_LIMIT = 1;
- private static final BitmapPool sTilePool =
- ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER
- ? new BitmapPool(BITMAP_SIZE, BITMAP_SIZE, 128)
- : null;
+ private static BitmapPool sTilePool;
/*
* This is the tile state in the CPU side.
@@ -152,6 +150,18 @@ public class TileImageView extends GLView {
public TileImageView(GalleryContext context) {
mThreadPool = context.getThreadPool();
mTileDecoder = mThreadPool.submit(new TileDecoder());
+ if (TILE_SIZE == 0) {
+ if (GalleryUtils.isHighResolution(context.getAndroidContext())) {
+ TILE_SIZE = 510 ;
+ } else {
+ TILE_SIZE = 254;
+ }
+ BITMAP_SIZE = TILE_SIZE + TILE_BORDER * 2;
+ sTilePool =
+ ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER
+ ? new BitmapPool(BITMAP_SIZE, BITMAP_SIZE, 128)
+ : null;
+ }
}
public void setModel(Model model) {
diff --git a/src/com/android/gallery3d/ui/TileImageViewAdapter.java b/src/com/android/gallery3d/ui/TileImageViewAdapter.java
index a14df754a..08d337921 100644
--- a/src/com/android/gallery3d/ui/TileImageViewAdapter.java
+++ b/src/com/android/gallery3d/ui/TileImageViewAdapter.java
@@ -112,7 +112,6 @@ public class TileImageViewAdapter implements TileImageView.Model {
@Override
public Bitmap getTile(int level, int x, int y, int tileSize,
int borderSize, BitmapPool pool) {
-
if (!ApiHelper.HAS_REUSING_BITMAP_IN_BITMAP_REGION_DECODER) {
return getTileWithoutReusingBitmap(level, x, y, tileSize, borderSize);
}
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index a3eccb89b..efa06149f 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -87,6 +87,14 @@ public class GalleryUtils {
R.color.bitmap_screennail_placeholder));
}
+ public static boolean isHighResolution(Context context) {
+ DisplayMetrics metrics = new DisplayMetrics();
+ WindowManager wm = (WindowManager)
+ context.getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getMetrics(metrics);
+ return metrics.heightPixels > 2048 || metrics.widthPixels > 2048;
+ }
+
public static float[] intColorToFloatARGBArray(int from) {
return new float[] {
Color.alpha(from) / 255f,