| 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/common/system/user/rounded_image_view.h" | 5 #include "ash/common/system/user/rounded_image_view.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "skia/ext/image_operations.h" | 8 #include "skia/ext/image_operations.h" |
| 9 #include "third_party/skia/include/core/SkPaint.h" | |
| 10 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
| 11 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/image/image_skia_operations.h" | 11 #include "ui/gfx/image/image_skia_operations.h" |
| 13 #include "ui/gfx/skia_util.h" | 12 #include "ui/gfx/skia_util.h" |
| 14 | 13 |
| 15 namespace ash { | 14 namespace ash { |
| 16 namespace tray { | 15 namespace tray { |
| 17 | 16 |
| 18 RoundedImageView::RoundedImageView(int corner_radius, bool active_user) | 17 RoundedImageView::RoundedImageView(int corner_radius, bool active_user) |
| 19 : active_user_(active_user) { | 18 : active_user_(active_user) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 gfx::Rect image_bounds(size()); | 56 gfx::Rect image_bounds(size()); |
| 58 image_bounds.ClampToCenteredSize(GetPreferredSize()); | 57 image_bounds.ClampToCenteredSize(GetPreferredSize()); |
| 59 image_bounds.Inset(GetInsets()); | 58 image_bounds.Inset(GetInsets()); |
| 60 const SkScalar kRadius[8] = { | 59 const SkScalar kRadius[8] = { |
| 61 SkIntToScalar(corner_radius_[0]), SkIntToScalar(corner_radius_[0]), | 60 SkIntToScalar(corner_radius_[0]), SkIntToScalar(corner_radius_[0]), |
| 62 SkIntToScalar(corner_radius_[1]), SkIntToScalar(corner_radius_[1]), | 61 SkIntToScalar(corner_radius_[1]), SkIntToScalar(corner_radius_[1]), |
| 63 SkIntToScalar(corner_radius_[2]), SkIntToScalar(corner_radius_[2]), | 62 SkIntToScalar(corner_radius_[2]), SkIntToScalar(corner_radius_[2]), |
| 64 SkIntToScalar(corner_radius_[3]), SkIntToScalar(corner_radius_[3])}; | 63 SkIntToScalar(corner_radius_[3]), SkIntToScalar(corner_radius_[3])}; |
| 65 SkPath path; | 64 SkPath path; |
| 66 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius); | 65 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius); |
| 67 SkPaint paint; | 66 cc::PaintFlags paint; |
| 68 paint.setAntiAlias(true); | 67 paint.setAntiAlias(true); |
| 69 const bool grayscale = | 68 const bool grayscale = |
| 70 !active_user_ && !MaterialDesignController::IsSystemTrayMenuMaterial(); | 69 !active_user_ && !MaterialDesignController::IsSystemTrayMenuMaterial(); |
| 71 paint.setBlendMode(grayscale ? SkBlendMode::kLuminosity | 70 paint.setBlendMode(grayscale ? SkBlendMode::kLuminosity |
| 72 : SkBlendMode::kSrcOver); | 71 : SkBlendMode::kSrcOver); |
| 73 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(), path, | 72 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(), path, |
| 74 paint); | 73 paint); |
| 75 } | 74 } |
| 76 | 75 |
| 77 } // namespace tray | 76 } // namespace tray |
| 78 } // namespace ash | 77 } // namespace ash |
| OLD | NEW |