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

Unified Diff: chrome/browser/ui/views/frame/taskbar_decorator_win.cc

Issue 268073005: Bring back support for 38x31 avatars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits and refactor GetAvatarIconAsSquare to have a return value. Created 6 years, 7 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
« no previous file with comments | « chrome/browser/resources/options/manage_profile_overlay.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/taskbar_decorator_win.cc
diff --git a/chrome/browser/ui/views/frame/taskbar_decorator_win.cc b/chrome/browser/ui/views/frame/taskbar_decorator_win.cc
index e9a5ad883b99f1bd435042a06d3c3824fb16805b..0d3748c3875db5bd6cece72b6d6fe75503259ab5 100644
--- a/chrome/browser/ui/views/frame/taskbar_decorator_win.cc
+++ b/chrome/browser/ui/views/frame/taskbar_decorator_win.cc
@@ -16,7 +16,6 @@
#include "content/public/browser/browser_thread.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/platform_canvas.h"
-#include "third_party/skia/include/core/SkRect.h"
#include "ui/gfx/icon_util.h"
#include "ui/gfx/image/image.h"
#include "ui/views/win/hwnd_util.h"
@@ -41,15 +40,17 @@ void SetOverlayIcon(HWND hwnd, scoped_ptr<SkBitmap> bitmap) {
base::win::ScopedGDIObject<HICON> icon;
if (bitmap.get()) {
- const size_t kOverlayIconSize = 16;
- const SkBitmap* source_bitmap = bitmap.get();
-
- // Maintain aspect ratio on resize. Image is assumed to be square.
+ DCHECK_GE(bitmap.get()->width(), bitmap.get()->height());
+ // Maintain aspect ratio on resize.
+ const int kOverlayIconSize = 16;
+ int resized_height =
+ bitmap.get()->height() * kOverlayIconSize / bitmap.get()->width();
+ DCHECK_GE(kOverlayIconSize, resized_height);
// Since the target size is so small, we use our best resizer.
SkBitmap sk_icon = skia::ImageOperations::Resize(
- *source_bitmap,
+ *bitmap.get(),
skia::ImageOperations::RESIZE_LANCZOS3,
- kOverlayIconSize, kOverlayIconSize);
+ kOverlayIconSize, resized_height);
// Paint the resized icon onto a 16x16 canvas otherwise Windows will badly
// hammer it to 16x16.
@@ -57,8 +58,7 @@ void SetOverlayIcon(HWND hwnd, scoped_ptr<SkBitmap> bitmap) {
offscreen_bitmap.allocN32Pixels(kOverlayIconSize, kOverlayIconSize);
SkCanvas offscreen_canvas(offscreen_bitmap);
offscreen_canvas.clear(SK_ColorTRANSPARENT);
- offscreen_canvas.drawBitmap(sk_icon, 0, 0);
-
+ offscreen_canvas.drawBitmap(sk_icon, 0, kOverlayIconSize - resized_height);
icon.Set(IconUtil::CreateHICONFromSkBitmap(offscreen_bitmap));
if (!icon.Get())
return;
@@ -84,8 +84,11 @@ void DrawTaskbarDecoration(gfx::NativeWindow window, const gfx::Image* image) {
// Copy the image since we're going to use it on a separate thread and
// gfx::Image isn't thread safe.
- scoped_ptr<SkBitmap> bitmap(
- image ? new SkBitmap(*image->ToSkBitmap()) : NULL);
+ scoped_ptr<SkBitmap> bitmap;
+ if (image) {
+ bitmap.reset(new SkBitmap(
+ profiles::GetAvatarIconAsSquare(*image->ToSkBitmap(), 1)));
+ }
content::BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
FROM_HERE, base::Bind(&SetOverlayIcon, hwnd, Passed(&bitmap)),
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
« no previous file with comments | « chrome/browser/resources/options/manage_profile_overlay.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698