Bug 1255335 - Ensure we can and should scale image before scaling r?sebastian draft
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 10 Mar 2016 22:50:20 -0800
changeset 340721 7c4b62454cb42b63ac00e98fa5476cfcf95e2ee6
parent 340219 49091802cb61e99f00481a030b1ee4bb7acad87c
child 516256 eff4785323123bf8f8b88c2b2bdfb9e25190695a
push id13042
push userahunt@mozilla.com
push dateTue, 15 Mar 2016 21:59:08 +0000
reviewerssebastian
bugs1255335, 1238656
milestone48.0a1
Bug 1255335 - Ensure we can and should scale image before scaling r?sebastian 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
@@ -544,20 +544,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, targetWidthAndHeight, targetWidthAndHeight, true);
-        } else if (targetWidthAndHeight != -1 && image != null &&  image.getWidth() != targetWidthAndHeight) {
-            scaled = Favicons.getSizedFaviconFromCache(faviconURL, targetWidthAndHeight);
+        if (targetWidthAndHeight != -1 && image != null && image.getWidth() != targetWidthAndHeight) {
+            if ((flags & FLAG_BYPASS_CACHE_WHEN_DOWNLOADING_ICONS) != 0) {
+                scaled = Bitmap.createScaledBitmap(image, targetWidthAndHeight, targetWidthAndHeight, true);
+            } else {
+                scaled = Favicons.getSizedFaviconFromCache(faviconURL, targetWidthAndHeight);
+            }
         } else {
             scaled = image;
         }
 
         Favicons.dispatchResult(pageUrl, faviconURL, scaled, listener);
     }
 
     void onCancelled() {