| Index: chrome/browser/profiles/profile_avatar_icon_util.cc
|
| diff --git a/chrome/browser/profiles/profile_avatar_icon_util.cc b/chrome/browser/profiles/profile_avatar_icon_util.cc
|
| index 6a3e613c32db248382f69d8de46a1fd7377d683d..4db5c04324682c34fc024d02cd4ed97b56620ab7 100644
|
| --- a/chrome/browser/profiles/profile_avatar_icon_util.cc
|
| +++ b/chrome/browser/profiles/profile_avatar_icon_util.cc
|
| @@ -13,6 +13,7 @@
|
| #include "chrome/common/chrome_paths.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/theme_resources.h"
|
| +#include "skia/ext/image_operations.h"
|
| #include "third_party/skia/include/core/SkPaint.h"
|
| #include "third_party/skia/include/core/SkPath.h"
|
| #include "third_party/skia/include/core/SkScalar.h"
|
| @@ -22,6 +23,8 @@
|
| #include "ui/gfx/image/canvas_image_source.h"
|
| #include "ui/gfx/image/image.h"
|
| #include "ui/gfx/image/image_skia_operations.h"
|
| +#include "ui/gfx/rect.h"
|
| +#include "ui/gfx/skia_util.h"
|
|
|
| // Helper methods for transforming and drawing avatar icons.
|
| namespace {
|
| @@ -184,7 +187,7 @@ struct IconResourceInfo {
|
| };
|
|
|
| const int kAvatarIconWidth = 38;
|
| -const int kAvatarIconHeight = 38;
|
| +const int kAvatarIconHeight = 31;
|
| const SkColor kAvatarTutorialBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xf4);
|
| const SkColor kAvatarTutorialContentTextColor = SkColorSetRGB(0xc6, 0xda, 0xfc);
|
| const SkColor kAvatarBubbleAccountsBackgroundColor =
|
| @@ -264,6 +267,24 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image,
|
| return gfx::Image(gfx::ImageSkia(source.release(), dst_size));
|
| }
|
|
|
| +SkBitmap GetAvatarIconAsSquare(const SkBitmap& bitmap, int scale_factor) {
|
| + if ((bitmap.width() == scale_factor * profiles::kAvatarIconWidth) &&
|
| + (bitmap.height() == scale_factor * profiles::kAvatarIconHeight)) {
|
| + // Shave a couple of columns so the bitmap is more square. So when
|
| + // resized to a square aspect ratio it looks pretty.
|
| + SkBitmap cropped_bitmap;
|
| + gfx::Rect frame(scale_factor * profiles::kAvatarIconWidth,
|
| + scale_factor * profiles::kAvatarIconHeight);
|
| + frame.Inset(scale_factor * 2, 0, scale_factor * 2, 0);
|
| + bitmap.extractSubset(&cropped_bitmap, gfx::RectToSkIRect(frame));
|
| + return cropped_bitmap;
|
| + } else {
|
| + // If not the avatar icon's aspect ratio, the image should be square.
|
| + DCHECK(bitmap.width() == bitmap.height());
|
| + return bitmap;
|
| + }
|
| +}
|
| +
|
| // Helper methods for accessing, transforming and drawing avatar icons.
|
| size_t GetDefaultAvatarIconCount() {
|
| return kDefaultAvatarIconsCount;
|
|
|