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

Side by Side Diff: chrome/browser/ui/webui/app_launcher_login_handler.cc

Issue 2764163002: Use SkCanvas::SkCanvas(SkBitmap) instead of going thru SkSurface (Closed)
Patch Set: Created 3 years, 9 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
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/ui/webui/app_launcher_login_handler.h" 5 #include "chrome/browser/ui/webui/app_launcher_login_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 using content::Referrer; 52 using content::Referrer;
53 53
54 namespace { 54 namespace {
55 55
56 SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) { 56 SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) {
57 // This value must match the width and height value of login-status-icon 57 // This value must match the width and height value of login-status-icon
58 // in new_tab.css. 58 // in new_tab.css.
59 const int kLength = 27; 59 const int kLength = 27;
60 SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(), 60 SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(),
61 skia::ImageOperations::RESIZE_BEST, kLength, kLength); 61 skia::ImageOperations::RESIZE_BEST, kLength, kLength);
62 SkCanvas canvas(bmp);
62 63
63 // Draw a gray border on the inside of the icon. 64 // Draw a gray border on the inside of the icon.
64 sk_sp<SkSurface> surface =
65 SkSurface::MakeRasterDirect(bmp.info(), bmp.getPixels(), bmp.rowBytes());
66 SkPaint paint; 65 SkPaint paint;
67 paint.setColor(SkColorSetARGB(83, 0, 0, 0)); 66 paint.setColor(SkColorSetARGB(83, 0, 0, 0));
68 paint.setStyle(SkPaint::kStroke_Style); 67 paint.setStyle(SkPaint::kStroke_Style);
69 surface->getCanvas()->drawRect( 68 canvas.drawRect(gfx::RectToSkRect(gfx::Rect(kLength - 1, kLength - 1)),
70 gfx::RectToSkRect(gfx::Rect(kLength - 1, kLength - 1)), paint); 69 paint);
71 return bmp; 70 return bmp;
72 } 71 }
73 72
74 // Puts the |content| into an element with the given CSS class. 73 // Puts the |content| into an element with the given CSS class.
75 base::string16 CreateElementWithClass(const base::string16& content, 74 base::string16 CreateElementWithClass(const base::string16& content,
76 const std::string& tag_name, 75 const std::string& tag_name,
77 const std::string& css_class, 76 const std::string& css_class,
78 const std::string& extends_tag) { 77 const std::string& extends_tag) {
79 base::string16 start_tag = base::ASCIIToUTF16("<" + tag_name + 78 base::string16 start_tag = base::ASCIIToUTF16("<" + tag_name +
80 " class='" + css_class + "' is='" + extends_tag + "'>"); 79 " class='" + css_class + "' is='" + extends_tag + "'>");
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 values->SetString("login_status_message", message); 255 values->SetString("login_status_message", message);
257 values->SetString("login_status_url", 256 values->SetString("login_status_url",
258 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 257 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
259 values->SetString("login_status_advanced", 258 values->SetString("login_status_advanced",
260 hide_sync ? base::string16() : 259 hide_sync ? base::string16() :
261 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 260 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
262 values->SetString("login_status_dismiss", 261 values->SetString("login_status_dismiss",
263 hide_sync ? base::string16() : 262 hide_sync ? base::string16() :
264 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 263 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
265 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/extension_app_item.cc ('k') | ui/message_center/message_center_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698