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

Side by Side Diff: ash/system/user/rounded_image_view.cc

Issue 2901503003: Rename GetPreferredSize to CalculatePreferredSize in ash/ (Closed)
Patch Set: improvements Created 3 years, 7 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 | « ash/system/user/rounded_image_view.h ('k') | ash/system/user/user_card_view.cc » ('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 "ash/system/user/rounded_image_view.h" 5 #include "ash/system/user/rounded_image_view.h"
6 6
7 #include "skia/ext/image_operations.h" 7 #include "skia/ext/image_operations.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/image/image_skia_operations.h" 10 #include "ui/gfx/image/image_skia_operations.h"
(...skipping 25 matching lines...) Expand all
36 void RoundedImageView::SetCornerRadii(int top_left, 36 void RoundedImageView::SetCornerRadii(int top_left,
37 int top_right, 37 int top_right,
38 int bottom_right, 38 int bottom_right,
39 int bottom_left) { 39 int bottom_left) {
40 corner_radius_[0] = top_left; 40 corner_radius_[0] = top_left;
41 corner_radius_[1] = top_right; 41 corner_radius_[1] = top_right;
42 corner_radius_[2] = bottom_right; 42 corner_radius_[2] = bottom_right;
43 corner_radius_[3] = bottom_left; 43 corner_radius_[3] = bottom_left;
44 } 44 }
45 45
46 gfx::Size RoundedImageView::GetPreferredSize() const { 46 gfx::Size RoundedImageView::CalculatePreferredSize() const {
47 return gfx::Size(image_size_.width() + GetInsets().width(), 47 return gfx::Size(image_size_.width() + GetInsets().width(),
48 image_size_.height() + GetInsets().height()); 48 image_size_.height() + GetInsets().height());
49 } 49 }
50 50
51 void RoundedImageView::OnPaint(gfx::Canvas* canvas) { 51 void RoundedImageView::OnPaint(gfx::Canvas* canvas) {
52 View::OnPaint(canvas); 52 View::OnPaint(canvas);
53 gfx::Rect image_bounds(size()); 53 gfx::Rect image_bounds(size());
54 image_bounds.ClampToCenteredSize(GetPreferredSize()); 54 image_bounds.ClampToCenteredSize(GetPreferredSize());
55 image_bounds.Inset(GetInsets()); 55 image_bounds.Inset(GetInsets());
56 const SkScalar kRadius[8] = { 56 const SkScalar kRadius[8] = {
57 SkIntToScalar(corner_radius_[0]), SkIntToScalar(corner_radius_[0]), 57 SkIntToScalar(corner_radius_[0]), SkIntToScalar(corner_radius_[0]),
58 SkIntToScalar(corner_radius_[1]), SkIntToScalar(corner_radius_[1]), 58 SkIntToScalar(corner_radius_[1]), SkIntToScalar(corner_radius_[1]),
59 SkIntToScalar(corner_radius_[2]), SkIntToScalar(corner_radius_[2]), 59 SkIntToScalar(corner_radius_[2]), SkIntToScalar(corner_radius_[2]),
60 SkIntToScalar(corner_radius_[3]), SkIntToScalar(corner_radius_[3])}; 60 SkIntToScalar(corner_radius_[3]), SkIntToScalar(corner_radius_[3])};
61 SkPath path; 61 SkPath path;
62 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius); 62 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius);
63 cc::PaintFlags flags; 63 cc::PaintFlags flags;
64 flags.setAntiAlias(true); 64 flags.setAntiAlias(true);
65 canvas->DrawImageInPath(resized_image_, image_bounds.x(), image_bounds.y(), 65 canvas->DrawImageInPath(resized_image_, image_bounds.x(), image_bounds.y(),
66 path, flags); 66 path, flags);
67 } 67 }
68 68
69 } // namespace tray 69 } // namespace tray
70 } // namespace ash 70 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/rounded_image_view.h ('k') | ash/system/user/user_card_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698