OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/controls/button/label_button_border.h" | 5 #include "ui/views/controls/button/label_button_border.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
9 #include "third_party/skia/include/effects/SkLerpXfermode.h" | 9 #include "third_party/skia/include/effects/SkArithmeticMode.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/gfx/animation/animation.h" | 11 #include "ui/gfx/animation/animation.h" |
12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
15 #include "ui/gfx/sys_color_change_listener.h" | 15 #include "ui/gfx/sys_color_change_listener.h" |
16 #include "ui/native_theme/native_theme.h" | 16 #include "ui/native_theme/native_theme.h" |
17 #include "ui/resources/grit/ui_resources.h" | 17 #include "ui/resources/grit/ui_resources.h" |
18 #include "ui/views/border.h" | 18 #include "ui/views/border.h" |
19 #include "ui/views/controls/button/label_button.h" | 19 #include "ui/views/controls/button/label_button.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); | 141 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); |
142 | 142 |
143 if (animation && animation->is_animating()) { | 143 if (animation && animation->is_animating()) { |
144 // Linearly interpolate background and foreground painters during animation. | 144 // Linearly interpolate background and foreground painters during animation. |
145 const SkRect sk_rect = gfx::RectToSkRect(rect); | 145 const SkRect sk_rect = gfx::RectToSkRect(rect); |
146 canvas->sk_canvas()->saveLayer(&sk_rect, NULL); | 146 canvas->sk_canvas()->saveLayer(&sk_rect, NULL); |
147 state = native_theme_delegate->GetBackgroundThemeState(&extra); | 147 state = native_theme_delegate->GetBackgroundThemeState(&extra); |
148 PaintHelper(this, canvas, state, rect, extra); | 148 PaintHelper(this, canvas, state, rect, extra); |
149 | 149 |
150 SkPaint paint; | 150 SkPaint paint; |
151 skia::RefPtr<SkXfermode> sk_lerp_xfer = | 151 double scale = animation->GetCurrentValue(); |
152 skia::AdoptRef(SkLerpXfermode::Create(animation->GetCurrentValue())); | 152 skia::RefPtr<SkXfermode> sk_arith_xfer = |
153 paint.setXfermode(sk_lerp_xfer.get()); | 153 skia::AdoptRef(SkArithmeticMode::Create(0.0f, scale, 1.0 - scale, 0.0)); |
| 154 paint.setXfermode(sk_arith_xfer.get()); |
154 canvas->sk_canvas()->saveLayer(&sk_rect, &paint); | 155 canvas->sk_canvas()->saveLayer(&sk_rect, &paint); |
155 state = native_theme_delegate->GetForegroundThemeState(&extra); | 156 state = native_theme_delegate->GetForegroundThemeState(&extra); |
156 PaintHelper(this, canvas, state, rect, extra); | 157 PaintHelper(this, canvas, state, rect, extra); |
157 canvas->sk_canvas()->restore(); | 158 canvas->sk_canvas()->restore(); |
158 | 159 |
159 canvas->sk_canvas()->restore(); | 160 canvas->sk_canvas()->restore(); |
160 } else { | 161 } else { |
161 PaintHelper(this, canvas, state, rect, extra); | 162 PaintHelper(this, canvas, state, rect, extra); |
162 } | 163 } |
163 } | 164 } |
(...skipping 14 matching lines...) Expand all Loading... |
178 return painters_[focused ? 1 : 0][state].get(); | 179 return painters_[focused ? 1 : 0][state].get(); |
179 } | 180 } |
180 | 181 |
181 void LabelButtonAssetBorder::SetPainter(bool focused, | 182 void LabelButtonAssetBorder::SetPainter(bool focused, |
182 Button::ButtonState state, | 183 Button::ButtonState state, |
183 Painter* painter) { | 184 Painter* painter) { |
184 painters_[focused ? 1 : 0][state].reset(painter); | 185 painters_[focused ? 1 : 0][state].reset(painter); |
185 } | 186 } |
186 | 187 |
187 } // namespace views | 188 } // namespace views |
OLD | NEW |