| 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 "cc/paint/paint_flags.h" | 8 #include "cc/paint/paint_flags.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/animation/animation.h" | 10 #include "ui/gfx/animation/animation.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 { | 148 { |
| 149 // First, modulate the background by 1 - alpha. | 149 // First, modulate the background by 1 - alpha. |
| 150 cc::PaintCanvasAutoRestore auto_restore(canvas->sk_canvas(), false); | 150 cc::PaintCanvasAutoRestore auto_restore(canvas->sk_canvas(), false); |
| 151 canvas->sk_canvas()->saveLayerAlpha(&sk_rect, 255 - fg_alpha); | 151 canvas->sk_canvas()->saveLayerAlpha(&sk_rect, 255 - fg_alpha); |
| 152 state = native_theme_delegate->GetBackgroundThemeState(&extra); | 152 state = native_theme_delegate->GetBackgroundThemeState(&extra); |
| 153 PaintHelper(this, canvas, state, rect, extra); | 153 PaintHelper(this, canvas, state, rect, extra); |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Then modulate the foreground by alpha, and blend using kPlus_Mode. | 156 // Then modulate the foreground by alpha, and blend using kPlus_Mode. |
| 157 cc::PaintFlags paint; | 157 cc::PaintFlags flags; |
| 158 paint.setAlpha(fg_alpha); | 158 flags.setAlpha(fg_alpha); |
| 159 paint.setBlendMode(SkBlendMode::kPlus); | 159 flags.setBlendMode(SkBlendMode::kPlus); |
| 160 canvas->sk_canvas()->saveLayer(&sk_rect, &paint); | 160 canvas->sk_canvas()->saveLayer(&sk_rect, &flags); |
| 161 state = native_theme_delegate->GetForegroundThemeState(&extra); | 161 state = native_theme_delegate->GetForegroundThemeState(&extra); |
| 162 PaintHelper(this, canvas, state, rect, extra); | 162 PaintHelper(this, canvas, state, rect, extra); |
| 163 } else { | 163 } else { |
| 164 PaintHelper(this, canvas, state, rect, extra); | 164 PaintHelper(this, canvas, state, rect, extra); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 gfx::Size LabelButtonAssetBorder::GetMinimumSize() const { | 168 gfx::Size LabelButtonAssetBorder::GetMinimumSize() const { |
| 169 gfx::Size minimum_size; | 169 gfx::Size minimum_size; |
| 170 for (int i = 0; i < 2; ++i) { | 170 for (int i = 0; i < 2; ++i) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 181 return painters_[focused ? 1 : 0][state].get(); | 181 return painters_[focused ? 1 : 0][state].get(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void LabelButtonAssetBorder::SetPainter(bool focused, | 184 void LabelButtonAssetBorder::SetPainter(bool focused, |
| 185 Button::ButtonState state, | 185 Button::ButtonState state, |
| 186 std::unique_ptr<Painter> painter) { | 186 std::unique_ptr<Painter> painter) { |
| 187 painters_[focused ? 1 : 0][state] = std::move(painter); | 187 painters_[focused ? 1 : 0][state] = std::move(painter); |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace views | 190 } // namespace views |
| OLD | NEW |