| 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/SkArithmeticMode.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" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 if (animation && animation->is_animating()) { | 140 if (animation && animation->is_animating()) { |
| 141 // Linearly interpolate background and foreground painters during animation. | 141 // Linearly interpolate background and foreground painters during animation. |
| 142 const SkRect sk_rect = gfx::RectToSkRect(rect); | 142 const SkRect sk_rect = gfx::RectToSkRect(rect); |
| 143 canvas->sk_canvas()->saveLayer(&sk_rect, NULL); | 143 canvas->sk_canvas()->saveLayer(&sk_rect, NULL); |
| 144 state = native_theme_delegate->GetBackgroundThemeState(&extra); | 144 state = native_theme_delegate->GetBackgroundThemeState(&extra); |
| 145 PaintHelper(this, canvas, state, rect, extra); | 145 PaintHelper(this, canvas, state, rect, extra); |
| 146 | 146 |
| 147 SkPaint paint; | 147 SkPaint paint; |
| 148 double scale = animation->GetCurrentValue(); | 148 double scale = animation->GetCurrentValue(); |
| 149 skia::RefPtr<SkXfermode> sk_arith_xfer = | 149 paint.setXfermode(SkArithmeticMode::Make(0.0f, scale, 1.0 - scale, 0.0)); |
| 150 skia::AdoptRef(SkArithmeticMode::Create(0.0f, scale, 1.0 - scale, 0.0)); | |
| 151 paint.setXfermode(sk_arith_xfer.get()); | |
| 152 canvas->sk_canvas()->saveLayer(&sk_rect, &paint); | 150 canvas->sk_canvas()->saveLayer(&sk_rect, &paint); |
| 153 state = native_theme_delegate->GetForegroundThemeState(&extra); | 151 state = native_theme_delegate->GetForegroundThemeState(&extra); |
| 154 PaintHelper(this, canvas, state, rect, extra); | 152 PaintHelper(this, canvas, state, rect, extra); |
| 155 canvas->sk_canvas()->restore(); | 153 canvas->sk_canvas()->restore(); |
| 156 | 154 |
| 157 canvas->sk_canvas()->restore(); | 155 canvas->sk_canvas()->restore(); |
| 158 } else { | 156 } else { |
| 159 PaintHelper(this, canvas, state, rect, extra); | 157 PaintHelper(this, canvas, state, rect, extra); |
| 160 } | 158 } |
| 161 } | 159 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 176 return painters_[focused ? 1 : 0][state].get(); | 174 return painters_[focused ? 1 : 0][state].get(); |
| 177 } | 175 } |
| 178 | 176 |
| 179 void LabelButtonAssetBorder::SetPainter(bool focused, | 177 void LabelButtonAssetBorder::SetPainter(bool focused, |
| 180 Button::ButtonState state, | 178 Button::ButtonState state, |
| 181 Painter* painter) { | 179 Painter* painter) { |
| 182 painters_[focused ? 1 : 0][state].reset(painter); | 180 painters_[focused ? 1 : 0][state].reset(painter); |
| 183 } | 181 } |
| 184 | 182 |
| 185 } // namespace views | 183 } // namespace views |
| OLD | NEW |