Bug 1290014 - ResizingProcessor: Do not resize icons loaded from memory. r?ahunt,grisha draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Thu, 18 Aug 2016 15:52:20 +0200
changeset 408656 30eed2a8c1341677779057af0d59ef95812bd04b
parent 408655 e749080784ebc97f244120dc94b597d0d9783a09
child 408657 c69a7157a9694009dc8e2df46129b13c954655b4
push id28266
push users.kaspari@gmail.com
push dateThu, 01 Sep 2016 13:51:54 +0000
reviewersahunt, grisha
bugs1290014
milestone51.0a1
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
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
@@ -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 {
     @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;
+        }
+
         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.
             return;