Bug 1320775 - Pre: move favicon colour fading to color generator r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Wed, 08 Feb 2017 10:12:24 -0800
changeset 343130 04d7cacd46f957f7185ca27edb142a8b989fdeec
parent 343129 e4ab837ee587dcb5fe353cf29886d92112beee95
child 343131 aeab7252c1165587c58d42e5cb835650129a1df7
push id31371
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:15:11 +0000
treeherdermozilla-central@8c8b54b13be7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1320775
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1320775 - Pre: move favicon colour fading to color generator r=sebastian In order to allow for a background which merges into a favicon, we need to allow for solid (non faded) colours. It is simplest to do this by letting the colour generator (i.e. either the colour extractor, or the favicon generator) fade the dominant colour as it wishes. That also means the colour generator can in future choose to not fade the colour if appropriate. MozReview-Commit-ID: LsI8PlZsaGn
mobile/android/base/java/org/mozilla/gecko/icons/loader/IconGenerator.java
mobile/android/base/java/org/mozilla/gecko/icons/processing/ColorProcessor.java
mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
mobile/android/tests/background/junit4/src/org/mozilla/gecko/icons/processing/TestColorProcessor.java
--- a/mobile/android/base/java/org/mozilla/gecko/icons/loader/IconGenerator.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/loader/IconGenerator.java
@@ -84,17 +84,17 @@ public class IconGenerator implements Ic
         paint.setTextSize(textSize);
         paint.setAntiAlias(true);
 
         canvas.drawText(character,
                 canvas.getWidth() / 2,
                 (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2)),
                 paint);
 
-        return IconResponse.createGenerated(favicon, color);
+        return IconResponse.createGenerated(favicon, color & 0x7FFFFFFF);
     }
 
     /**
      * Get a representative character for the given URL.
      *
      * For example this method will return "f" for "http://m.facebook.com/foobar".
      */
     @VisibleForTesting static String getRepresentativeCharacter(String url) {
--- a/mobile/android/base/java/org/mozilla/gecko/icons/processing/ColorProcessor.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/processing/ColorProcessor.java
@@ -37,17 +37,17 @@ public class ColorProcessor implements P
         } else {
             extractColorUsingPaletteSupportLibrary(response);
         }
     }
 
     private void extractColorUsingPaletteSupportLibrary(final IconResponse response) {
         try {
             final Palette palette = Palette.from(response.getBitmap()).generate();
-            response.updateColor(palette.getVibrantColor(DEFAULT_COLOR));
+            response.updateColor(palette.getVibrantColor(DEFAULT_COLOR) & 0x7FFFFFFF);
         } catch (ArrayIndexOutOfBoundsException e) {
             // We saw the palette library fail with an ArrayIndexOutOfBoundsException intermittently
             // in automation. In this case lets just swallow the exception and move on without a
             // color. This is a valid condition and callers should handle this gracefully (Bug 1318560).
             Log.e(LOGTAG, "Palette generation failed with ArrayIndexOutOfBoundsException", e);
 
             response.updateColor(DEFAULT_COLOR);
         }
--- a/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/FaviconView.java
@@ -112,17 +112,17 @@ public class FaviconView extends ImageVi
         mBackgroundRect.bottom = h;
 
         formatImage();
     }
 
     @Override
     public void onDraw(Canvas canvas) {
         if (isDominantBorderEnabled) {
-            sBackgroundPaint.setColor(mDominantColor & 0x7FFFFFFF);
+            sBackgroundPaint.setColor(mDominantColor);
 
             if (areRoundCornersEnabled) {
                 canvas.drawRoundRect(mBackgroundRect, mBackgroundCornerRadius, mBackgroundCornerRadius, sBackgroundPaint);
             } else {
                 canvas.drawRect(mBackgroundRect, sBackgroundPaint);
             }
         }
 
--- a/mobile/android/tests/background/junit4/src/org/mozilla/gecko/icons/processing/TestColorProcessor.java
+++ b/mobile/android/tests/background/junit4/src/org/mozilla/gecko/icons/processing/TestColorProcessor.java
@@ -28,17 +28,17 @@ public class TestColorProcessor {
 
         Assert.assertFalse(response.hasColor());
         Assert.assertEquals(0, response.getColor());
 
         final Processor processor = new ColorProcessor();
         processor.process(null, response);
 
         Assert.assertTrue(response.hasColor());
-        Assert.assertEquals(Color.RED, response.getColor());
+        Assert.assertEquals(Color.RED & 0x7FFFFFFF, response.getColor());
     }
 
     private Bitmap createRedBitmapMock() {
         final Bitmap bitmap = mock(Bitmap.class);
 
         doReturn(1).when(bitmap).getWidth();
         doReturn(1).when(bitmap).getHeight();