Bug 1255335 - Ensure we can and should scale image before scaling. r=sebastian, a=ritu
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 10 Mar 2016 22:50:20 -0800
changeset 310165 303576fae3933ed817545e5beb3d92128fe6caea
parent 310164 a5ddf55a5f6c884b9f44c999bded4d8505f26e00
child 310166 2e108bca503d3fafb31ffc0b2cb58f6f5ec35da2
push id9282
push userryanvm@gmail.com
push dateSat, 19 Mar 2016 20:08:00 +0000
treeherdermozilla-aurora@303576fae393 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, ritu
bugs1255335, 1238656
milestone47.0a2
Bug 1255335 - Ensure we can and should scale image before scaling. r=sebastian, a=ritu We introduced the "if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0)" check, and direct Bitmap scaling in Bug 1238656 to avoid getting the cached icon (which results in downscaling) for apple-touch-icons (or just any icon that we're using for homescreen shortcuts). However we need to make sure we can actually scale the icon before performing scaling, hence this check should have been within our pre-existing "if (image_params_are_valid)" clause. MozReview-Commit-ID: 4RdHmEia5FR
mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
--- a/mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
+++ b/mobile/android/base/java/org/mozilla/gecko/favicons/LoadFaviconTask.java
@@ -570,20 +570,22 @@ public class LoadFaviconTask {
         }
     }
 
     private void processResult(Bitmap image) {
         Favicons.removeLoadTask(id);
         final Bitmap scaled;
 
         // Notify listeners, scaling if required.
-        if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0) {
-            scaled = Bitmap.createScaledBitmap(image, targetWidth, targetWidth, true);
-        } else if (targetWidth != -1 && image != null &&  image.getWidth() != targetWidth) {
-            scaled = Favicons.getSizedFaviconFromCache(faviconURL, targetWidth);
+        if (targetWidth != -1 && image != null && image.getWidth() != targetWidth) {
+            if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0) {
+                scaled = Bitmap.createScaledBitmap(image, targetWidth, targetWidth, true);
+            } else {
+                scaled = Favicons.getSizedFaviconFromCache(faviconURL, targetWidth);
+            }
         } else {
             scaled = image;
         }
 
         Favicons.dispatchResult(pageUrl, faviconURL, scaled, listener);
     }
 
     void onCancelled() {