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
--- 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);
}