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

Side by Side Diff: chrome/browser/profiles/profile_info_util.cc

Issue 9477016: Remove all |gfx::Image(new SkBitmap(...))| antipatterns. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/icon_loader_mac.mm ('k') | chrome/browser/themes/browser_theme_pack.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/profile_info_util.h" 5 #include "chrome/browser/profiles/profile_info_util.h"
6 6
7 #include "skia/ext/image_operations.h" 7 #include "skia/ext/image_operations.h"
8 #include "ui/gfx/canvas_skia.h" 8 #include "ui/gfx/canvas_skia.h"
9 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 // Draw the icon centered on the canvas. 26 // Draw the icon centered on the canvas.
27 int x = (kAvatarIconWidth - length) / 2; 27 int x = (kAvatarIconWidth - length) / 2;
28 int y = (kAvatarIconHeight - length) / 2; 28 int y = (kAvatarIconHeight - length) / 2;
29 canvas.DrawBitmapInt(bmp, x, y); 29 canvas.DrawBitmapInt(bmp, x, y);
30 30
31 // Draw a gray border on the inside of the icon. 31 // Draw a gray border on the inside of the icon.
32 SkColor color = SkColorSetARGB(83, 0, 0, 0); 32 SkColor color = SkColorSetARGB(83, 0, 0, 0);
33 canvas.DrawRect(gfx::Rect(x, y, length - 1, length - 1), color); 33 canvas.DrawRect(gfx::Rect(x, y, length - 1, length - 1), color);
34 34
35 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); 35 return gfx::Image(canvas.ExtractBitmap());
36 } 36 }
37 37
38 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image, 38 gfx::Image GetAvatarIconForWebUI(const gfx::Image& image,
39 bool is_gaia_picture) { 39 bool is_gaia_picture) {
40 if (!is_gaia_picture) 40 if (!is_gaia_picture)
41 return image; 41 return image;
42 42
43 int length = std::min(kAvatarIconWidth, kAvatarIconHeight) - 2; 43 int length = std::min(kAvatarIconWidth, kAvatarIconHeight) - 2;
44 SkBitmap bmp = skia::ImageOperations::Resize( 44 SkBitmap bmp = skia::ImageOperations::Resize(
45 image, skia::ImageOperations::RESIZE_BEST, length, length); 45 image, skia::ImageOperations::RESIZE_BEST, length, length);
46 gfx::CanvasSkia canvas(gfx::Size(kAvatarIconWidth, kAvatarIconHeight), false); 46 gfx::CanvasSkia canvas(gfx::Size(kAvatarIconWidth, kAvatarIconHeight), false);
47 47
48 // Draw the icon centered on the canvas. 48 // Draw the icon centered on the canvas.
49 int x = (kAvatarIconWidth - length) / 2; 49 int x = (kAvatarIconWidth - length) / 2;
50 int y = (kAvatarIconHeight - length) / 2; 50 int y = (kAvatarIconHeight - length) / 2;
51 canvas.DrawBitmapInt(bmp, x, y); 51 canvas.DrawBitmapInt(bmp, x, y);
52 52
53 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); 53 return gfx::Image(canvas.ExtractBitmap());
54 } 54 }
55 55
56 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, 56 gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
57 bool is_gaia_picture, 57 bool is_gaia_picture,
58 int dst_width, 58 int dst_width,
59 int dst_height) { 59 int dst_height) {
60 if (!is_gaia_picture) 60 if (!is_gaia_picture)
61 return image; 61 return image;
62 62
63 int length = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight), 63 int length = std::min(std::min(kAvatarIconWidth, kAvatarIconHeight),
(...skipping 17 matching lines...) Expand all
81 canvas.DrawLine(gfx::Point(x1, y2 - 1), gfx::Point(x2, y2 - 1), 81 canvas.DrawLine(gfx::Point(x1, y2 - 1), gfx::Point(x2, y2 - 1),
82 highlight_color); 82 highlight_color);
83 // Top shadow. 83 // Top shadow.
84 canvas.DrawLine(gfx::Point(x1, y1), gfx::Point(x2, y1), shadow_color); 84 canvas.DrawLine(gfx::Point(x1, y1), gfx::Point(x2, y1), shadow_color);
85 // Left shadow. 85 // Left shadow.
86 canvas.DrawLine(gfx::Point(x1, y1 + 1), gfx::Point(x1, y2 - 1), shadow_color); 86 canvas.DrawLine(gfx::Point(x1, y1 + 1), gfx::Point(x1, y2 - 1), shadow_color);
87 // Right shadow. 87 // Right shadow.
88 canvas.DrawLine(gfx::Point(x2 - 1, y1 + 1), gfx::Point(x2 - 1, y2 - 1), 88 canvas.DrawLine(gfx::Point(x2 - 1, y1 + 1), gfx::Point(x2 - 1, y2 - 1),
89 shadow_color); 89 shadow_color);
90 90
91 return gfx::Image(new SkBitmap(canvas.ExtractBitmap())); 91 return gfx::Image(canvas.ExtractBitmap());
92 } 92 }
93 93
94 } // namespace 94 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/icon_loader_mac.mm ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698