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

Unified Diff: ui/app_list/icon_cache.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: fix ash_shell compile 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/icon_cache.cc
diff --git a/ui/app_list/icon_cache.cc b/ui/app_list/icon_cache.cc
index b0b9997e6aebc9113232521827a3a0c956fc6e43..360b967728138c8239d0e5e7bfd5d398c0c12b4a 100644
--- a/ui/app_list/icon_cache.cc
+++ b/ui/app_list/icon_cache.cc
@@ -7,14 +7,21 @@
#include "base/logging.h"
#include "base/md5.h"
#include "ui/gfx/size.h"
+#include "ui/gfx/screen.h"
namespace {
// Gets cache key based on |image| contents and desired |size|.
-std::string GetKey(const SkBitmap& image, const gfx::Size& size) {
- SkAutoLockPixels image_lock(image);
+std::string GetKey(const gfx::ImageSkia& image, const gfx::Size& size) {
+ // TODO(xiyuan): Revisit this after ImageLoadingTracker DIP support is done.
+ ui::ScaleFactor scale_factor = gfx::Screen::IsDIPEnabled() ?
+ ui::SCALE_FACTOR_200P : ui::SCALE_FACTOR_100P;
sky 2012/07/16 16:49:39 How come if dip is enabled this always scales by 2
xiyuan 2012/07/16 17:08:02 This is because we have not yet decided what is th
+ const gfx::ImageSkiaRep& image_rep = image.GetRepresentation(scale_factor);
+ DCHECK(!image_rep.is_null());
+ const SkBitmap& bitmap = image_rep.sk_bitmap();
+ SkAutoLockPixels image_lock(bitmap);
base::MD5Digest digest;
- MD5Sum(image.getPixels(), image.getSize(), &digest);
+ MD5Sum(bitmap.getPixels(), bitmap.getSize(), &digest);
return MD5DigestToBase16(digest) + "." + size.ToString();
}
@@ -59,9 +66,9 @@ void IconCache::PurgeAllUnused() {
}
}
-bool IconCache::Get(const SkBitmap& src,
+bool IconCache::Get(const gfx::ImageSkia& src,
const gfx::Size& size,
- SkBitmap* processed) {
+ gfx::ImageSkia* processed) {
Cache::iterator it = cache_.find(GetKey(src, size));
if (it == cache_.end())
return false;
@@ -73,9 +80,9 @@ bool IconCache::Get(const SkBitmap& src,
return true;
}
-void IconCache::Put(const SkBitmap& src,
+void IconCache::Put(const gfx::ImageSkia& src,
const gfx::Size& size,
- const SkBitmap& processed) {
+ const gfx::ImageSkia& processed) {
const std::string key = GetKey(src, size);
cache_[key].image = processed;
cache_[key].used = true;

Powered by Google App Engine
This is Rietveld 408576698