Bug 1290014 - ResizingProcessor: Do not resize icons loaded from memory. r=ahunt,Grisha
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 18 Aug 2016 15:52:20 +0200
changeset 312473 f11ee12c87bbfeab4b25b4b30c9aa0f7aefc982c
parent 312472 a87ed908d84b5d3a6d3a8dbed171608ff4d6b33c
child 312474 ef83714d122603b428cede37fd3341375f61c6ed
push id20447
push userkwierso@gmail.com
push dateFri, 02 Sep 2016 20:36:44 +0000
treeherderfx-team@969397f22187 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahunt, Grisha
Bug 1290014 - ResizingProcessor: Do not resize icons loaded from memory. r=ahunt,Grisha Icons loaded from memory have already gone through the resizing process and have either the requested size or are resized up to a limit. Without this check a small icon could be resized multiple times until it matches the target size; even though the icon is too small. In addition to that we would recycle a bitmap that might still be in use. MozReview-Commit-ID: K51aBhBcAnj
--- a/mobile/android/base/java/org/mozilla/gecko/icons/processing/ResizingProcessor.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/processing/ResizingProcessor.java
@@ -12,16 +12,22 @@ import org.mozilla.gecko.icons.IconReque
 import org.mozilla.gecko.icons.IconResponse;
  * Processor implementation for resizing the loaded icon based on the target size.
 public class ResizingProcessor implements Processor {
     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;
+        }
         final Bitmap originalBitmap = response.getBitmap();
         final int size = originalBitmap.getWidth();
         final int targetSize = request.getTargetSize();
         if (size == targetSize) {
             // The bitmap has exactly the size we are looking for.