Bug 1109001 - Only set alpha on non-transparent colors in shaped drawable (r=mcomella)

This commit is contained in:
Lucas Rocha 2014-12-09 23:45:31 +00:00
parent ceba17c93e
commit b6033299b6

View File

@ -56,11 +56,15 @@ public class ResizablePathDrawable extends ShapeDrawable {
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);
}