Bug 1388396: Increase max favicon scale factor to 3. r=sebastian draft
authorMichael Comella <michael.l.comella@gmail.com>
Mon, 11 Sep 2017 17:13:07 -0700
changeset 664259 995262e4975a4ebd713cc81f29bc9e84ee2b8d9f
parent 664258 ba147e1000b65cd7bc07f3f59c0ea646d671e8fc
child 664260 46dadbeed206e7cf8666c1c6e97300a3f6c40c23
push id79654
push usermichael.l.comella@gmail.com
push dateWed, 13 Sep 2017 20:23:12 +0000
reviewerssebastian
bugs1388396
milestone57.0a1
Bug 1388396: Increase max favicon scale factor to 3. r=sebastian This is part 1 of the good-enough approach: see the MAX_SCALE_FACTOR comment as to what we're aiming for. The next changeset will discard any icons that do not look good being scaled so much. The MAX_SCALE_FACTOR field is non-private because it's used in the next changeset. MozReview-Commit-ID: HGzdQBEuMAy
mobile/android/base/java/org/mozilla/gecko/icons/processing/ResizingProcessor.java
--- a/mobile/android/base/java/org/mozilla/gecko/icons/processing/ResizingProcessor.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/processing/ResizingProcessor.java
@@ -10,16 +10,23 @@ import android.support.annotation.Visibl
 
 import org.mozilla.gecko.icons.IconRequest;
 import org.mozilla.gecko.icons.IconResponse;
 
 /**
  * Processor implementation for resizing the loaded icon based on the target size.
  */
 public class ResizingProcessor implements Processor {
+    // This is the largest factor we'll scale up an image by: the goal is an image
+    // that both fills the top site space well but does not have extreme resizing
+    // artifacts. This number was chosen anecdotally by comparing variously-sized
+    // favicons across devices to see which factor(s) looked the best. bug 1398970
+    // is filed to take a more comprehensive approach to favicons.
+    public static final int MAX_SCALE_FACTOR = 3;
+
     @Override
     public void process(IconRequest request, IconResponse response) {
         if (response.isFromMemory()) {
             // This bitmap has been loaded from memory, so it has already gone through the resizing
             // process. We do not want to resize the image every time we hit the memory cache.
             return;
         }
 
@@ -33,19 +40,19 @@ public class ResizingProcessor implement
             return;
         }
 
         final Bitmap resizedBitmap;
 
         if (size > targetSize) {
             resizedBitmap = resize(originalBitmap, targetSize);
         } else {
-            // Our largest primary is smaller than the desired size. Upscale by a maximum of 2x.
+            // Our largest primary is smaller than the desired size. Upscale it (to a limit)!
             // 'largestSize' now reflects the maximum size we can upscale to.
-            final int largestSize = size * 2;
+            final int largestSize = size * MAX_SCALE_FACTOR;
 
             if (largestSize > targetSize) {
                 // Perfect! We can upscale by less than 2x and reach the needed size. Do it.
                 resizedBitmap = resize(originalBitmap, targetSize);
             } else {
                 // We don't have enough information to make the target size look non terrible. Best effort:
                 resizedBitmap = resize(originalBitmap, largestSize);
             }