Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: ui/views/controls/button/label_button_border.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/checkbox.cc ('k') | ui/views/controls/button/radio_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ui::NativeTheme::ExtraParams extra; 136 ui::NativeTheme::ExtraParams extra;
137 const gfx::Animation* animation = native_theme_delegate->GetThemeAnimation(); 137 const gfx::Animation* animation = native_theme_delegate->GetThemeAnimation();
138 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); 138 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra);
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 uint8_t fg_alpha = 142 uint8_t fg_alpha =
143 static_cast<uint8_t>(animation->CurrentValueBetween(0, 255)); 143 static_cast<uint8_t>(animation->CurrentValueBetween(0, 255));
144 144
145 const SkRect sk_rect = gfx::RectToSkRect(rect); 145 const SkRect sk_rect = gfx::RectToSkRect(rect);
146 SkAutoCanvasRestore auto_restore(canvas->sk_canvas(), false); 146 CdlAutoCanvasRestore auto_restore(canvas->sk_canvas(), false);
147 canvas->sk_canvas()->saveLayer(&sk_rect, nullptr); 147 canvas->sk_canvas()->saveLayer(&sk_rect, nullptr);
148 148
149 { 149 {
150 // First, modulate the background by 1 - alpha. 150 // First, modulate the background by 1 - alpha.
151 SkAutoCanvasRestore auto_restore(canvas->sk_canvas(), false); 151 CdlAutoCanvasRestore auto_restore(canvas->sk_canvas(), false);
152 canvas->sk_canvas()->saveLayerAlpha(&sk_rect, 255 - fg_alpha); 152 canvas->sk_canvas()->saveLayerAlpha(&sk_rect, 255 - fg_alpha);
153 state = native_theme_delegate->GetBackgroundThemeState(&extra); 153 state = native_theme_delegate->GetBackgroundThemeState(&extra);
154 PaintHelper(this, canvas, state, rect, extra); 154 PaintHelper(this, canvas, state, rect, extra);
155 } 155 }
156 156
157 // Then modulate the foreground by alpha, and blend using kPlus_Mode. 157 // Then modulate the foreground by alpha, and blend using kPlus_Mode.
158 SkPaint paint; 158 CdlPaint paint;
159 paint.setAlpha(fg_alpha); 159 paint.setAlpha(fg_alpha);
160 paint.setBlendMode(SkBlendMode::kPlus); 160 paint.setBlendMode(SkBlendMode::kPlus);
161 canvas->sk_canvas()->saveLayer(&sk_rect, &paint); 161 canvas->sk_canvas()->saveLayer(&sk_rect, &paint);
162 state = native_theme_delegate->GetForegroundThemeState(&extra); 162 state = native_theme_delegate->GetForegroundThemeState(&extra);
163 PaintHelper(this, canvas, state, rect, extra); 163 PaintHelper(this, canvas, state, rect, extra);
164 } else { 164 } else {
165 PaintHelper(this, canvas, state, rect, extra); 165 PaintHelper(this, canvas, state, rect, extra);
166 } 166 }
167 } 167 }
168 168
(...skipping 13 matching lines...) Expand all
182 return painters_[focused ? 1 : 0][state].get(); 182 return painters_[focused ? 1 : 0][state].get();
183 } 183 }
184 184
185 void LabelButtonAssetBorder::SetPainter(bool focused, 185 void LabelButtonAssetBorder::SetPainter(bool focused,
186 Button::ButtonState state, 186 Button::ButtonState state,
187 Painter* painter) { 187 Painter* painter) {
188 painters_[focused ? 1 : 0][state].reset(painter); 188 painters_[focused ? 1 : 0][state].reset(painter);
189 } 189 }
190 190
191 } // namespace views 191 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/checkbox.cc ('k') | ui/views/controls/button/radio_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698