Index: ui/views/controls/button/label_button_border.cc |
diff --git a/ui/views/controls/button/label_button_border.cc b/ui/views/controls/button/label_button_border.cc |
index e8347bb9c7938f539cc00f0222c1b1b0885eac04..b911faa8ab0a1eab2d410f882c6d8037547cbe43 100644 |
--- a/ui/views/controls/button/label_button_border.cc |
+++ b/ui/views/controls/button/label_button_border.cc |
@@ -139,14 +139,22 @@ void LabelButtonAssetBorder::Paint(const View& view, gfx::Canvas* canvas) { |
if (animation && animation->is_animating()) { |
// Linearly interpolate background and foreground painters during animation. |
+ uint8_t fg_alpha = |
+ SkToU8(SkScalarRoundToInt(0xff * animation->GetCurrentValue())); |
sky
2016/09/29 16:05:17
CurrentValueBetween(0, 255)?
f(malita)
2016/09/29 16:35:28
Done.
|
+ |
const SkRect sk_rect = gfx::RectToSkRect(rect); |
- canvas->sk_canvas()->saveLayer(&sk_rect, NULL); |
+ canvas->sk_canvas()->saveLayer(&sk_rect, nullptr); |
+ |
+ // First, modulate the background by 1 - alpha. |
+ canvas->sk_canvas()->saveLayerAlpha(&sk_rect, 0xff - fg_alpha); |
state = native_theme_delegate->GetBackgroundThemeState(&extra); |
PaintHelper(this, canvas, state, rect, extra); |
+ canvas->sk_canvas()->restore(); |
sky
2016/09/29 16:05:17
All these raw save/restore make me nervous as they
f(malita)
2016/09/29 16:35:28
We have SkAutoCanvasRestore, which restores to the
|
+ // Then modulate the foreground by alpha, and blend using kPlus_Mode. |
SkPaint paint; |
- double scale = animation->GetCurrentValue(); |
- paint.setXfermode(SkArithmeticMode::Make(0.0f, scale, 1.0 - scale, 0.0)); |
+ paint.setAlpha(fg_alpha); |
+ paint.setXfermodeMode(SkXfermode::kPlus_Mode); |
canvas->sk_canvas()->saveLayer(&sk_rect, &paint); |
state = native_theme_delegate->GetForegroundThemeState(&extra); |
PaintHelper(this, canvas, state, rect, extra); |