summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/app_list/app_list.cc7
-rw-r--r--ash/app_list/app_list_item_view.cc25
-rw-r--r--ash/app_list/icon_cache.cc87
-rw-r--r--ash/app_list/icon_cache.h57
-rw-r--r--ash/ash.gyp2
5 files changed, 9 insertions, 169 deletions
diff --git a/ash/app_list/app_list.cc b/ash/app_list/app_list.cc
index b8b4741..6972eb0 100644
--- a/ash/app_list/app_list.cc
+++ b/ash/app_list/app_list.cc
@@ -5,7 +5,6 @@
#include "ash/app_list/app_list.h"
#include "ash/app_list/app_list_view.h"
-#include "ash/app_list/icon_cache.h"
#include "ash/shell_delegate.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
@@ -47,12 +46,10 @@ ui::Layer* GetLayer(views::Widget* widget) {
// AppList, public:
AppList::AppList() : is_visible_(false), view_(NULL) {
- IconCache::CreateInstance();
}
AppList::~AppList() {
ResetView();
- IconCache::DeleteInstance();
}
void AppList::SetVisible(bool visible) {
@@ -83,8 +80,6 @@ void AppList::SetView(AppListView* view) {
DCHECK(view_ == NULL);
if (is_visible_) {
- IconCache::GetInstance()->MarkAllEntryUnused();
-
view_ = view;
views::Widget* widget = view_->GetWidget();
widget->AddObserver(this);
@@ -110,8 +105,6 @@ void AppList::ResetView() {
Shell::GetInstance()->RemoveRootWindowEventFilter(this);
widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this);
view_ = NULL;
-
- IconCache::GetInstance()->PurgeAllUnused();
}
void AppList::ScheduleAnimation() {
diff --git a/ash/app_list/app_list_item_view.cc b/ash/app_list/app_list_item_view.cc
index 5addda1..ec7594b 100644
--- a/ash/app_list/app_list_item_view.cc
+++ b/ash/app_list/app_list_item_view.cc
@@ -7,7 +7,6 @@
#include "ash/app_list/app_list_item_model.h"
#include "ash/app_list/app_list_model_view.h"
#include "ash/app_list/drop_shadow_label.h"
-#include "ash/app_list/icon_cache.h"
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/synchronization/cancellation_flag.h"
@@ -261,20 +260,15 @@ void AppListItemView::UpdateIcon() {
CancelPendingIconOperation();
- SkBitmap shadow;
- if (IconCache::GetInstance()->Get(icon, icon_size_, &shadow)) {
- icon_->SetImage(shadow);
- } else {
- // Schedule resize and shadow generation.
- icon_op_ = new IconOperation(icon, icon_size_);
- base::WorkerPool::PostTaskAndReply(
- FROM_HERE,
- base::Bind(&IconOperation::Run, icon_op_),
- base::Bind(&AppListItemView::ApplyShadow,
- apply_shadow_factory_.GetWeakPtr(),
- icon_op_),
- true /* task_is_slow */);
- }
+ // Schedule resize and shadow generation.
+ icon_op_ = new IconOperation(icon, icon_size_);
+ base::WorkerPool::PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&IconOperation::Run, icon_op_),
+ base::Bind(&AppListItemView::ApplyShadow,
+ apply_shadow_factory_.GetWeakPtr(),
+ icon_op_),
+ true /* task_is_slow */);
}
void AppListItemView::CancelPendingIconOperation() {
@@ -288,7 +282,6 @@ void AppListItemView::CancelPendingIconOperation() {
void AppListItemView::ApplyShadow(scoped_refptr<IconOperation> op) {
icon_->SetImage(op->bitmap());
- IconCache::GetInstance()->Put(model_->icon(), icon_size_, op->bitmap());
DCHECK(op.get() == icon_op_.get());
icon_op_ = NULL;
diff --git a/ash/app_list/icon_cache.cc b/ash/app_list/icon_cache.cc
deleted file mode 100644
index dcd295c..0000000
--- a/ash/app_list/icon_cache.cc
+++ /dev/null
@@ -1,87 +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 "ash/app_list/icon_cache.h"
-
-#include "base/logging.h"
-#include "base/md5.h"
-#include "ui/gfx/size.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);
- base::MD5Digest digest;
- MD5Sum(image.getPixels(), image.getSize(), &digest);
-
- return MD5DigestToBase16(digest) + "." + size.ToString();
-}
-
-} // namespace
-
-namespace ash {
-
-// 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 SkBitmap& src,
- const gfx::Size& size,
- SkBitmap* 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 SkBitmap& src,
- const gfx::Size& size,
- const SkBitmap& processed) {
- const std::string key = GetKey(src, size);
- cache_[key].image = processed;
- cache_[key].used = true;
-}
-
-IconCache::IconCache() {
-}
-
-} // namespace ash
diff --git a/ash/app_list/icon_cache.h b/ash/app_list/icon_cache.h
deleted file mode 100644
index e0af324..0000000
--- a/ash/app_list/icon_cache.h
+++ /dev/null
@@ -1,57 +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.
-
-#ifndef ASH_APP_LIST_ICON_CACHE_H_
-#define ASH_APP_LIST_ICON_CACHE_H_
-#pragma once
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace gfx {
-class Size;
-}
-
-namespace ash {
-
-// IconCache stores processed image, keyed by the source image and desired size.
-class IconCache {
- public:
- static void CreateInstance();
- static void DeleteInstance();
-
- static IconCache* GetInstance();
-
- void MarkAllEntryUnused();
- void PurgeAllUnused();
-
- bool Get(const SkBitmap& src,
- const gfx::Size& size,
- SkBitmap* processed);
- void Put(const SkBitmap& src,
- const gfx::Size& size,
- const SkBitmap& processed);
-
- private:
- struct Item {
- SkBitmap image;
- bool used;
- };
- typedef std::map<std::string, Item> Cache;
-
- IconCache();
-
- static IconCache* instance_;
-
- Cache cache_;
-
- DISALLOW_COPY_AND_ASSIGN(IconCache);
-};
-
-} // namespace ash
-
-#endif // ASH_APP_LIST_ICON_CACHE_H_
diff --git a/ash/ash.gyp b/ash/ash.gyp
index dd146eb..26b4a88 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -64,8 +64,6 @@
'app_list/app_list_view_delegate.h',
'app_list/drop_shadow_label.cc',
'app_list/drop_shadow_label.h',
- 'app_list/icon_cache.cc',
- 'app_list/icon_cache.h',
'ash_switches.cc',
'ash_switches.h',
'caps_lock_delegate.h',