Bug 1109001 - Only set alpha on non-transparent colors in shaped drawable. r=mcomella, a=sledru
authorLucas Rocha <lucasr@lucasr.org>
Tue, 09 Dec 2014 23:45:31 +0000
changeset 242779 069c6e7bb97d423181f7838b84d8c1cb5a6279ff
parent 242778 ce0ae0d141e3589d23ab4448e760b3e285781452
child 242780 31516786a389cb8bd5df22bb7af4a8f7e9710a8c
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcomella, sledru
bugs1109001
milestone36.0a2
Bug 1109001 - Only set alpha on non-transparent colors in shaped drawable. r=mcomella, a=sledru
mobile/android/base/widget/ResizablePathDrawable.java
--- a/mobile/android/base/widget/ResizablePathDrawable.java
+++ b/mobile/android/base/widget/ResizablePathDrawable.java
@@ -52,21 +52,25 @@ public class ResizablePathDrawable exten
     public boolean isStateful() {
         return true;
     }
 
     @Override
     protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
         paint.setColor(currentColor);
         // setAlpha overrides the alpha value in set color. Since we just set the color,
-        // the alpha value is reset: override the alpha value with the old value.
+        // the alpha value is reset: override the alpha value with the old value. We don't
+        // set alpha if the color is transparent.
         //
         // Note: We *should* be able to call Shape.setAlpha, rather than Paint.setAlpha, but
         // then the opacity doesn't change - dunno why but probably not worth the time.
-        paint.setAlpha(alpha);
+        if (currentColor != Color.TRANSPARENT) {
+            paint.setAlpha(alpha);
+        }
+
         super.onDraw(shape, canvas, paint);
     }
 
     @Override
     public void setAlpha(final int alpha) {
         super.setAlpha(alpha);
         this.alpha = alpha;
     }