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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 1062813004: views: Use ClipTransformRecorder to access canvas in ProfileChooserView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: profilechooser-recorder: explicit Created 5 years, 8 months 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 | « no previous file | ui/compositor/clip_transform_recorder.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 25 matching lines...) Expand all
36 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" 36 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h"
37 #include "components/signin/core/browser/profile_oauth2_token_service.h" 37 #include "components/signin/core/browser/profile_oauth2_token_service.h"
38 #include "components/signin/core/browser/signin_error_controller.h" 38 #include "components/signin/core/browser/signin_error_controller.h"
39 #include "components/signin/core/browser/signin_manager.h" 39 #include "components/signin/core/browser/signin_manager.h"
40 #include "components/signin/core/common/profile_management_switches.h" 40 #include "components/signin/core/common/profile_management_switches.h"
41 #include "content/public/browser/render_widget_host_view.h" 41 #include "content/public/browser/render_widget_host_view.h"
42 #include "grit/theme_resources.h" 42 #include "grit/theme_resources.h"
43 #include "third_party/skia/include/core/SkColor.h" 43 #include "third_party/skia/include/core/SkColor.h"
44 #include "ui/base/l10n/l10n_util.h" 44 #include "ui/base/l10n/l10n_util.h"
45 #include "ui/base/resource/resource_bundle.h" 45 #include "ui/base/resource/resource_bundle.h"
46 #include "ui/compositor/clip_transform_recorder.h"
46 #include "ui/compositor/paint_context.h" 47 #include "ui/compositor/paint_context.h"
47 #include "ui/gfx/canvas.h" 48 #include "ui/gfx/canvas.h"
48 #include "ui/gfx/image/image.h" 49 #include "ui/gfx/image/image.h"
49 #include "ui/gfx/image/image_skia.h" 50 #include "ui/gfx/image/image_skia.h"
50 #include "ui/gfx/path.h" 51 #include "ui/gfx/path.h"
51 #include "ui/gfx/skia_util.h" 52 #include "ui/gfx/skia_util.h"
52 #include "ui/gfx/text_elider.h" 53 #include "ui/gfx/text_elider.h"
53 #include "ui/native_theme/native_theme.h" 54 #include "ui/native_theme/native_theme.h"
54 #include "ui/views/controls/button/blue_button.h" 55 #include "ui/views/controls/button/blue_button.h"
55 #include "ui/views/controls/button/image_button.h" 56 #include "ui/views/controls/button/image_button.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 254 }
254 255
255 void OnPaint(gfx::Canvas* canvas) override { 256 void OnPaint(gfx::Canvas* canvas) override {
256 // Display the profile picture as a circle. 257 // Display the profile picture as a circle.
257 canvas->ClipPath(circular_mask_, true); 258 canvas->ClipPath(circular_mask_, true);
258 views::LabelButton::OnPaint(canvas); 259 views::LabelButton::OnPaint(canvas);
259 } 260 }
260 261
261 void PaintChildren(const ui::PaintContext& context) override { 262 void PaintChildren(const ui::PaintContext& context) override {
262 // Display any children (the "change photo" overlay) as a circle. 263 // Display any children (the "change photo" overlay) as a circle.
263 context.canvas()->ClipPath(circular_mask_, true); 264 ui::ClipTransformRecorder clip_transform_recorder(context);
265 clip_transform_recorder.ClipPathWithAntiAliasing(circular_mask_);
264 View::PaintChildren(context); 266 View::PaintChildren(context);
265 } 267 }
266 268
267 private: 269 private:
268 // views::CustomButton: 270 // views::CustomButton:
269 void StateChanged() override { 271 void StateChanged() override {
270 bool show_overlay = 272 bool show_overlay =
271 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); 273 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus());
272 if (photo_overlay_) 274 if (photo_overlay_)
273 photo_overlay_->SetVisible(show_overlay); 275 photo_overlay_->SetVisible(show_overlay);
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1721 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1720 IncognitoModePrefs::DISABLED; 1722 IncognitoModePrefs::DISABLED;
1721 return incognito_available && !browser_->profile()->IsGuestSession(); 1723 return incognito_available && !browser_->profile()->IsGuestSession();
1722 } 1724 }
1723 1725
1724 void ProfileChooserView::PostActionPerformed( 1726 void ProfileChooserView::PostActionPerformed(
1725 ProfileMetrics::ProfileDesktopMenu action_performed) { 1727 ProfileMetrics::ProfileDesktopMenu action_performed) {
1726 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1728 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1727 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1729 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1728 } 1730 }
OLDNEW
« no previous file with comments | « no previous file | ui/compositor/clip_transform_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698