OLD | NEW |
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 #include "skia/ext/image_operations.h" | 6 #include "skia/ext/image_operations.h" |
7 #include "third_party/skia/include/core/SkPaint.h" | 7 #include "third_party/skia/include/core/SkPaint.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 27 matching lines...) Expand all Loading... |
38 void RoundedImageView::SetCornerRadii(int top_left, | 38 void RoundedImageView::SetCornerRadii(int top_left, |
39 int top_right, | 39 int top_right, |
40 int bottom_right, | 40 int bottom_right, |
41 int bottom_left) { | 41 int bottom_left) { |
42 corner_radius_[0] = top_left; | 42 corner_radius_[0] = top_left; |
43 corner_radius_[1] = top_right; | 43 corner_radius_[1] = top_right; |
44 corner_radius_[2] = bottom_right; | 44 corner_radius_[2] = bottom_right; |
45 corner_radius_[3] = bottom_left; | 45 corner_radius_[3] = bottom_left; |
46 } | 46 } |
47 | 47 |
48 gfx::Size RoundedImageView::GetPreferredSize() { | 48 gfx::Size RoundedImageView::GetPreferredSize() const { |
49 return gfx::Size(image_size_.width() + GetInsets().width(), | 49 return gfx::Size(image_size_.width() + GetInsets().width(), |
50 image_size_.height() + GetInsets().height()); | 50 image_size_.height() + GetInsets().height()); |
51 } | 51 } |
52 | 52 |
53 void RoundedImageView::OnPaint(gfx::Canvas* canvas) { | 53 void RoundedImageView::OnPaint(gfx::Canvas* canvas) { |
54 View::OnPaint(canvas); | 54 View::OnPaint(canvas); |
55 gfx::Rect image_bounds(size()); | 55 gfx::Rect image_bounds(size()); |
56 image_bounds.ClampToCenteredSize(GetPreferredSize()); | 56 image_bounds.ClampToCenteredSize(GetPreferredSize()); |
57 image_bounds.Inset(GetInsets()); | 57 image_bounds.Inset(GetInsets()); |
58 const SkScalar kRadius[8] = { | 58 const SkScalar kRadius[8] = { |
(...skipping 11 matching lines...) Expand all Loading... |
70 SkPaint paint; | 70 SkPaint paint; |
71 paint.setAntiAlias(true); | 71 paint.setAntiAlias(true); |
72 paint.setXfermodeMode(active_user_ ? SkXfermode::kSrcOver_Mode | 72 paint.setXfermodeMode(active_user_ ? SkXfermode::kSrcOver_Mode |
73 : SkXfermode::kLuminosity_Mode); | 73 : SkXfermode::kLuminosity_Mode); |
74 canvas->DrawImageInPath( | 74 canvas->DrawImageInPath( |
75 resized_, image_bounds.x(), image_bounds.y(), path, paint); | 75 resized_, image_bounds.x(), image_bounds.y(), path, paint); |
76 } | 76 } |
77 | 77 |
78 } // namespace tray | 78 } // namespace tray |
79 } // namespace ash | 79 } // namespace ash |
OLD | NEW |