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

Unified Diff: chrome/browser/ui/webui/app_launcher_login_handler.cc

Issue 2760133002: ui: Remove a bunch of uses of gfx::Canvas::ExtractImageRep() (Closed)
Patch Set: canvasbounds: . 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/app_launcher_login_handler.cc
diff --git a/chrome/browser/ui/webui/app_launcher_login_handler.cc b/chrome/browser/ui/webui/app_launcher_login_handler.cc
index ee7a3f257a2c6f19ea0c0e43c99bffcb34116c36..8f83077e378baca1efe18bfe8cd898e311f5d331 100644
--- a/chrome/browser/ui/webui/app_launcher_login_handler.cc
+++ b/chrome/browser/ui/webui/app_launcher_login_handler.cc
@@ -46,6 +46,7 @@
#include "ui/base/webui/web_ui_util.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/skia_util.h"
using content::OpenURLParams;
using content::Referrer;
@@ -59,14 +60,15 @@ SkBitmap GetGAIAPictureForNTP(const gfx::Image& image) {
SkBitmap bmp = skia::ImageOperations::Resize(*image.ToSkBitmap(),
skia::ImageOperations::RESIZE_BEST, kLength, kLength);
- gfx::Canvas canvas(gfx::Size(kLength, kLength), 1.0f, false);
- canvas.DrawImageInt(gfx::ImageSkia::CreateFrom1xBitmap(bmp), 0, 0);
-
// Draw a gray border on the inside of the icon.
- SkColor color = SkColorSetARGB(83, 0, 0, 0);
- canvas.DrawRect(gfx::Rect(0, 0, kLength - 1, kLength - 1), color);
-
- return canvas.ExtractImageRep().sk_bitmap();
+ sk_sp<SkSurface> surface =
+ SkSurface::MakeRasterDirect(bmp.info(), bmp.getPixels(), bmp.rowBytes());
+ SkPaint paint;
+ paint.setColor(SkColorSetARGB(83, 0, 0, 0));
+ paint.setStyle(SkPaint::kStroke_Style);
+ surface->getCanvas()->drawRect(
+ gfx::RectToSkRect(gfx::Rect(kLength - 1, kLength - 1)), paint);
+ return bmp;
}
// Puts the |content| into an element with the given CSS class.
@@ -176,7 +178,8 @@ void AppLauncherLoginHandler::UpdateLogin() {
ProfileAttributesStorage& storage =
g_browser_process->profile_manager()->GetProfileAttributesStorage();
ProfileAttributesEntry* entry;
- if (storage.GetProfileAttributesWithPath(profile->GetPath(), &entry)) {
+ bool b = storage.GetProfileAttributesWithPath(profile->GetPath(), &entry);
+ if (b) {
Peter Kasting 2017/03/20 22:49:21 Why this change? |b| doesn't add any clarity, and
danakj 2017/03/21 15:25:56 Oops this was me debug printing stuff, thanks.
// Only show the profile picture and full name for the single profile
// case. In the multi-profile case the profile picture is visible in the
// title bar and the full name can be ambiguous.

Powered by Google App Engine
This is Rietveld 408576698