bug 711136 - thumbnails on about:home are really poor quality r=mfinkle
authorBrad Lassey <blassey@mozilla.com>
Wed, 11 Jan 2012 00:09:48 -0800
changeset 85554 ba96b6a034c23ed035e9663e29877f7dfb2fd38b
parent 85553 a4abb0dd6b5643d8931928412ee437e3aec47567
child 85555 0dbdc8243364e3696e203b47ab2528229797bd6b
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs711136
milestone12.0a1
bug 711136 - thumbnails on about:home are really poor quality r=mfinkle
mobile/android/base/Tab.java
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -53,17 +53,18 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
 import org.mozilla.gecko.db.BrowserDB;
 
 public class Tab {
     public static enum AgentMode { MOBILE, DESKTOP };
     private static final String LOGTAG = "GeckoTab";
-    private static final int kThumbnailSize = 96;
+    private static final int kThumbnailWidth = 120;
+    private static final int kThumbnailHeight = 80;
 
     static int sMinDim = 0;
     static float sDensity = 1;
     private int mId;
     private String mUrl;
     private String mTitle;
     private Drawable mFavicon;
     private String mFaviconUrl;
@@ -147,23 +148,23 @@ public class Tab {
     }
 
     public void updateThumbnail(final Bitmap b) {
         GeckoAppShell.getHandler().post(new Runnable() {
             public void run() {
                 if (sMinDim == 0) {
                     DisplayMetrics metrics = new DisplayMetrics();
                     GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
-                    sMinDim = Math.min(metrics.widthPixels, metrics.heightPixels);
+                    sMinDim = Math.min(metrics.widthPixels / 3, metrics.heightPixels / 2);
                     sDensity = metrics.density;
                 }
                 if (b != null) {
                     try {
-                        Bitmap cropped = Bitmap.createBitmap(b, 0, 0, sMinDim, sMinDim);
-                        Bitmap bitmap = Bitmap.createScaledBitmap(cropped, kThumbnailSize, kThumbnailSize, false);
+                        Bitmap cropped = Bitmap.createBitmap(b, 0, 0, sMinDim * 3, sMinDim * 2);
+                        Bitmap bitmap = Bitmap.createScaledBitmap(cropped, (int) (kThumbnailWidth * sDensity), (int) (kThumbnailHeight * sDensity), false);
                         saveThumbnailToDB(new BitmapDrawable(bitmap));
                         b.recycle();
 
                         bitmap = Bitmap.createBitmap(cropped, 0, 0, (int) (138 * sDensity), (int) (78 * sDensity));
                         mThumbnail = new BitmapDrawable(bitmap);
                         cropped.recycle();
                     } catch (OutOfMemoryError oom) {
                         Log.e(LOGTAG, "Unable to create/scale bitmap", oom);