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

Unified Diff: ui/app_list/app_list_item_view.cc

Issue 10699065: chromeos: Fix pixelated icons in app list and launcher (part 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for comments in #2 Created 8 years, 5 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: ui/app_list/app_list_item_view.cc
diff --git a/ui/app_list/app_list_item_view.cc b/ui/app_list/app_list_item_view.cc
index 714bf327055da6d1584f493bc6aa10bac00752a6..7f1bcda9a968b398bcd360ea731b9922e7edc02b 100644
--- a/ui/app_list/app_list_item_view.cc
+++ b/ui/app_list/app_list_item_view.cc
@@ -11,7 +11,6 @@
#include "base/synchronization/cancellation_flag.h"
#include "base/threading/worker_pool.h"
#include "base/utf_string_conversions.h"
-#include "skia/ext/image_operations.h"
#include "ui/app_list/app_list_item_model.h"
#include "ui/app_list/apps_grid_view.h"
#include "ui/app_list/drop_shadow_label.h"
@@ -21,7 +20,8 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
-#include "ui/gfx/skbitmap_operations.h"
+#include "ui/gfx/image/image_skia_sources.h"
+#include "ui/gfx/screen.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
@@ -85,10 +85,10 @@ const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView";
class AppListItemView::IconOperation
: public base::RefCountedThreadSafe<AppListItemView::IconOperation> {
public:
- IconOperation(const SkBitmap& bitmap,
+ IconOperation(const gfx::ImageSkia& image,
const gfx::Size& size,
const gfx::ShadowValues& shadows)
- : bitmap_(bitmap),
+ : image_(image),
size_(size),
shadows_(shadows) {
}
@@ -101,23 +101,29 @@ class AppListItemView::IconOperation
if (cancel_flag_.IsSet())
return;
- if (size_ != gfx::Size(bitmap_.width(), bitmap_.height())) {
- bitmap_ = skia::ImageOperations::Resize(bitmap_,
- skia::ImageOperations::RESIZE_BEST, size_.width(), size_.height());
- }
-
- if (cancel_flag_.IsSet())
- return;
-
- bitmap_ = SkBitmapOperations::CreateDropShadow(bitmap_, shadows_);
+ gfx::ImageSkia resized(
+ gfx::image_skia_sources::CreateResizeSource(image_, size_),
+ size_);
+
+ const gfx::Insets shadow_padding = -gfx::ShadowValue::GetMargin(shadows_);
+ gfx::Size shadow_image_size = size_;
+ shadow_image_size.Enlarge(shadow_padding.width(),
+ shadow_padding.height());
+ gfx::ImageSkia shadow(
+ gfx::image_skia_sources::CreateDropShadowSource(resized, shadows_),
+ shadow_image_size);
oshima 2012/07/10 23:51:06 ditto. (ImageSkiaOperations)
xiyuan 2012/07/11 17:39:13 Done.
+
+ // The following statement causes shadowed image being generated.
+ image_ = shadow.GetRepresentation(gfx::Screen::IsDIPEnabled() ?
+ ui::SCALE_FACTOR_200P : ui::SCALE_FACTOR_100P);
}
void Cancel() {
cancel_flag_.Set();
}
- const SkBitmap& bitmap() const {
- return bitmap_;
+ const gfx::ImageSkia& image() const {
+ return image_;
}
private:
@@ -126,7 +132,7 @@ class AppListItemView::IconOperation
base::CancellationFlag cancel_flag_;
- SkBitmap bitmap_;
+ gfx::ImageSkia image_;
const gfx::Size size_;
const gfx::ShadowValues shadows_;
@@ -180,7 +186,7 @@ void AppListItemView::UpdateIcon() {
if (icon_size_.IsEmpty())
return;
- SkBitmap icon = model_->icon();
+ gfx::ImageSkia icon = model_->icon();
// Clear icon and bail out if model icon is empty.
if (icon.empty()) {
icon_->SetImage(NULL);
@@ -189,7 +195,7 @@ void AppListItemView::UpdateIcon() {
CancelPendingIconOperation();
- SkBitmap shadow;
+ gfx::ImageSkia shadow;
if (IconCache::GetInstance()->Get(icon, icon_size_, &shadow)) {
icon_->SetImage(shadow);
} else {
@@ -215,8 +221,8 @@ void AppListItemView::CancelPendingIconOperation() {
}
void AppListItemView::ApplyShadow(scoped_refptr<IconOperation> op) {
- icon_->SetImage(op->bitmap());
- IconCache::GetInstance()->Put(model_->icon(), icon_size_, op->bitmap());
+ icon_->SetImage(op->image());
+ IconCache::GetInstance()->Put(model_->icon(), icon_size_, op->image());
DCHECK(op.get() == icon_op_.get());
icon_op_ = NULL;

Powered by Google App Engine
This is Rietveld 408576698