| 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..6c3f3ea7c84076038ec248dc822d0249e0e2710d 100644
|
| --- a/ui/views/controls/button/label_button_border.cc
|
| +++ b/ui/views/controls/button/label_button_border.cc
|
| @@ -139,20 +139,28 @@ 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 =
|
| + static_cast<uint8_t>(animation->CurrentValueBetween(0, 255));
|
| +
|
| const SkRect sk_rect = gfx::RectToSkRect(rect);
|
| - canvas->sk_canvas()->saveLayer(&sk_rect, NULL);
|
| - state = native_theme_delegate->GetBackgroundThemeState(&extra);
|
| - PaintHelper(this, canvas, state, rect, extra);
|
| + SkAutoCanvasRestore auto_restore(canvas->sk_canvas(), false);
|
| + canvas->sk_canvas()->saveLayer(&sk_rect, nullptr);
|
| +
|
| + {
|
| + // First, modulate the background by 1 - alpha.
|
| + SkAutoCanvasRestore auto_restore(canvas->sk_canvas(), false);
|
| + canvas->sk_canvas()->saveLayerAlpha(&sk_rect, 255 - fg_alpha);
|
| + state = native_theme_delegate->GetBackgroundThemeState(&extra);
|
| + PaintHelper(this, canvas, state, rect, extra);
|
| + }
|
|
|
| + // 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);
|
| - canvas->sk_canvas()->restore();
|
| -
|
| - canvas->sk_canvas()->restore();
|
| } else {
|
| PaintHelper(this, canvas, state, rect, extra);
|
| }
|
|
|