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

Unified Diff: ash/launcher/launcher_button.cc

Issue 9837065: Use shadows on launcher icons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extraneous canvas Created 8 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
« no previous file with comments | « ash/launcher/launcher_button.h ('k') | ui/resources/aura/launcher_browser.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/launcher/launcher_button.cc
diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc
index 2bebe0be9d68ca5469a16435545f09bbbe225fc9..0ee04891cda218e13cbf63891a6d20ec22c8f69d 100644
--- a/ash/launcher/launcher_button.cc
+++ b/ash/launcher/launcher_button.cc
@@ -13,6 +13,7 @@
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/skbitmap_operations.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/image_view.h"
@@ -79,6 +80,32 @@ LauncherButton::LauncherButton(views::ButtonListener* listener,
LauncherButton::~LauncherButton() {
}
+void LauncherButton::SetShadowedImage(const SkBitmap& bitmap) {
+ const SkColor kShadowColor[] = {
+ SkColorSetARGB(0x1A, 0, 0, 0),
+ SkColorSetARGB(0x1A, 0, 0, 0),
+ SkColorSetARGB(0x54, 0, 0, 0),
+ };
+ const gfx::Point kShadowOffset[] = {
+ gfx::Point(0, 2),
+ gfx::Point(0, 3),
+ gfx::Point(0, 0),
+ };
+ const SkScalar kShadowRadius[] = {
+ SkIntToScalar(0),
+ SkIntToScalar(1),
+ SkIntToScalar(1),
+ };
+
+ SkBitmap shadowed_bitmap = SkBitmapOperations::CreateDropShadow(
+ bitmap,
+ arraysize(kShadowColor) - 1,
+ kShadowColor,
+ kShadowOffset,
+ kShadowRadius);
+ icon_view_->SetImage(shadowed_bitmap);
+}
+
void LauncherButton::SetImage(const SkBitmap& image) {
if (image.empty()) {
// TODO: need an empty image.
@@ -87,7 +114,7 @@ void LauncherButton::SetImage(const SkBitmap& image) {
}
if (icon_view_->icon_size() == 0) {
- icon_view_->SetImage(&image);
+ SetShadowedImage(image);
return;
}
@@ -101,15 +128,15 @@ void LauncherButton::SetImage(const SkBitmap& image) {
width = pref;
height = static_cast<int>(width / aspect_ratio);
}
+
if (width == image.width() && height == image.height()) {
- icon_view_->SetImage(&image);
+ SetShadowedImage(image);
return;
}
- gfx::Canvas canvas(gfx::Size(width, height), false);
- canvas.DrawBitmapInt(image, 0, 0, image.width(), image.height(),
- 0, 0, width, height, false);
- SkBitmap resized_image(canvas.ExtractBitmap());
- icon_view_->SetImage(&resized_image);
+
+ SkBitmap resized_image = SkBitmapOperations::CreateResizedBitmap(
+ image, gfx::Size(width, height));
+ SetShadowedImage(resized_image);
}
void LauncherButton::AddState(State state) {
« no previous file with comments | « ash/launcher/launcher_button.h ('k') | ui/resources/aura/launcher_browser.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698