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

Unified Diff: ui/app_list/icon_cache.cc

Issue 10868003: chromeos: Fix pixelated icons in app list and launcher (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile Created 8 years, 3 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 | « ui/app_list/icon_cache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/icon_cache.cc
diff --git a/ui/app_list/icon_cache.cc b/ui/app_list/icon_cache.cc
deleted file mode 100644
index f69a50601f71480f35cc0d01ad1620989861fcf9..0000000000000000000000000000000000000000
--- a/ui/app_list/icon_cache.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/app_list/icon_cache.h"
-
-#include <algorithm>
-
-#include "base/logging.h"
-#include "base/md5.h"
-#include "ui/gfx/size.h"
-
-namespace {
-
-// Predicator for sorting ImageSkiaRep by scale factor.
-bool ImageRepScaleFactorCompare(const gfx::ImageSkiaRep& rep1,
- const gfx::ImageSkiaRep& rep2) {
- return rep1.scale_factor() < rep2.scale_factor();
-}
-
-// Gets cache key based on |image| contents and desired |size|.
-std::string GetKey(const gfx::ImageSkia& image, const gfx::Size& size) {
- gfx::ImageSkia::ImageSkiaReps image_reps = image.image_reps();
- DCHECK_GT(image_reps.size(), 0u);
-
- std::sort(image_reps.begin(), image_reps.end(), &ImageRepScaleFactorCompare);
-
- base::MD5Context ctx;
- base::MD5Init(&ctx);
- for (gfx::ImageSkia::ImageSkiaReps::const_iterator it = image_reps.begin();
- it != image_reps.end(); ++it) {
- const SkBitmap& bitmap = it->sk_bitmap();
- SkAutoLockPixels image_lock(bitmap);
-
- base::MD5Update(
- &ctx,
- base::StringPiece(reinterpret_cast<const char*>(bitmap.getPixels()),
- bitmap.getSize()));
- }
-
- base::MD5Digest digest;
- base::MD5Final(&digest, &ctx);
-
- return MD5DigestToBase16(digest) + "." + size.ToString();
-}
-
-} // namespace
-
-namespace app_list {
-
-// static
-IconCache* IconCache::instance_ = NULL;
-
-// static
-void IconCache::CreateInstance() {
- DCHECK(!instance_);
- instance_ = new IconCache;
-}
-
-// static
-void IconCache::DeleteInstance() {
- DCHECK(instance_);
- delete instance_;
- instance_ = NULL;
-}
-
-// static
-IconCache* IconCache::GetInstance() {
- DCHECK(instance_);
- return instance_;
-}
-
-void IconCache::MarkAllEntryUnused() {
- for (Cache::iterator i = cache_.begin(); i != cache_.end(); ++i)
- i->second.used = false;
-}
-
-void IconCache::PurgeAllUnused() {
- for (Cache::iterator i = cache_.begin(); i != cache_.end();) {
- Cache::iterator current(i);
- ++i;
- if (!current->second.used)
- cache_.erase(current);
- }
-}
-
-bool IconCache::Get(const gfx::ImageSkia& src,
- const gfx::Size& size,
- gfx::ImageSkia* processed) {
- Cache::iterator it = cache_.find(GetKey(src, size));
- if (it == cache_.end())
- return false;
-
- it->second.used = true;
-
- if (processed)
- *processed = it->second.image;
- return true;
-}
-
-void IconCache::Put(const gfx::ImageSkia& src,
- const gfx::Size& size,
- const gfx::ImageSkia& processed) {
- const std::string key = GetKey(src, size);
- cache_[key].image = processed;
- cache_[key].used = true;
-}
-
-IconCache::IconCache() {
-}
-
-IconCache::~IconCache() {
-}
-
-} // namespace app_list
« no previous file with comments | « ui/app_list/icon_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698