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

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

Issue 2780963002: ash: Fix system tray avatar not updated regression (Closed)
Patch Set: resized_ -> resized_image_ Created 3 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 | « ash/common/system/user/rounded_image_view.h ('k') | ash/common/system/user/tray_user.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 "ash/common/system/user/rounded_image_view.h" 5 #include "ash/common/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"
11 #include "ui/gfx/skia_util.h" 11 #include "ui/gfx/skia_util.h"
12 12
13 namespace ash { 13 namespace ash {
14 namespace tray { 14 namespace tray {
15 15
16 RoundedImageView::RoundedImageView(int corner_radius) { 16 RoundedImageView::RoundedImageView(int corner_radius) {
17 for (int i = 0; i < 4; ++i) 17 for (int i = 0; i < 4; ++i)
18 corner_radius_[i] = corner_radius; 18 corner_radius_[i] = corner_radius;
19 } 19 }
20 20
21 RoundedImageView::~RoundedImageView() {} 21 RoundedImageView::~RoundedImageView() {}
22 22
23 void RoundedImageView::SetImage(const gfx::ImageSkia& img, 23 void RoundedImageView::SetImage(const gfx::ImageSkia& image,
24 const gfx::Size& size) { 24 const gfx::Size& size) {
25 image_ = img;
26 image_size_ = size; 25 image_size_ = size;
27 26
28 // Try to get the best image quality for the avatar. 27 // Try to get the best image quality for the avatar.
29 resized_ = gfx::ImageSkiaOperations::CreateResizedImage( 28 resized_image_ = gfx::ImageSkiaOperations::CreateResizedImage(
30 image_, skia::ImageOperations::RESIZE_BEST, size); 29 image, skia::ImageOperations::RESIZE_BEST, size);
31 if (GetWidget() && visible()) { 30 if (GetWidget() && visible()) {
32 PreferredSizeChanged(); 31 PreferredSizeChanged();
33 SchedulePaint(); 32 SchedulePaint();
34 } 33 }
35 } 34 }
36 35
37 void RoundedImageView::SetCornerRadii(int top_left, 36 void RoundedImageView::SetCornerRadii(int top_left,
38 int top_right, 37 int top_right,
39 int bottom_right, 38 int bottom_right,
40 int bottom_left) { 39 int bottom_left) {
(...skipping 15 matching lines...) Expand all
56 image_bounds.Inset(GetInsets()); 55 image_bounds.Inset(GetInsets());
57 const SkScalar kRadius[8] = { 56 const SkScalar kRadius[8] = {
58 SkIntToScalar(corner_radius_[0]), SkIntToScalar(corner_radius_[0]), 57 SkIntToScalar(corner_radius_[0]), SkIntToScalar(corner_radius_[0]),
59 SkIntToScalar(corner_radius_[1]), SkIntToScalar(corner_radius_[1]), 58 SkIntToScalar(corner_radius_[1]), SkIntToScalar(corner_radius_[1]),
60 SkIntToScalar(corner_radius_[2]), SkIntToScalar(corner_radius_[2]), 59 SkIntToScalar(corner_radius_[2]), SkIntToScalar(corner_radius_[2]),
61 SkIntToScalar(corner_radius_[3]), SkIntToScalar(corner_radius_[3])}; 60 SkIntToScalar(corner_radius_[3]), SkIntToScalar(corner_radius_[3])};
62 SkPath path; 61 SkPath path;
63 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius); 62 path.addRoundRect(gfx::RectToSkRect(image_bounds), kRadius);
64 cc::PaintFlags flags; 63 cc::PaintFlags flags;
65 flags.setAntiAlias(true); 64 flags.setAntiAlias(true);
66 canvas->DrawImageInPath(resized_, image_bounds.x(), image_bounds.y(), path, 65 canvas->DrawImageInPath(resized_image_, image_bounds.x(), image_bounds.y(),
67 flags); 66 path, flags);
68 } 67 }
69 68
70 } // namespace tray 69 } // namespace tray
71 } // namespace ash 70 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/user/rounded_image_view.h ('k') | ash/common/system/user/tray_user.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698