| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/app_list/icon_cache.h" | 5 #include "ui/app_list/icon_cache.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "ui/gfx/size.h" | 9 #include "ui/gfx/size.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 // Gets cache key based on |image| contents and desired |size|. | 13 // Gets cache key based on |image| contents and desired |size|. |
| 14 std::string GetKey(const SkBitmap& image, const gfx::Size& size) { | 14 std::string GetKey(const SkBitmap& image, const gfx::Size& size) { |
| 15 SkAutoLockPixels image_lock(image); | 15 SkAutoLockPixels image_lock(image); |
| 16 base::MD5Digest digest; | 16 base::MD5Digest digest; |
| 17 MD5Sum(image.getPixels(), image.getSize(), &digest); | 17 MD5Sum(image.getPixels(), image.getSize(), &digest); |
| 18 | 18 |
| 19 return MD5DigestToBase16(digest) + "." + size.ToString(); | 19 return MD5DigestToBase16(digest) + "." + size.ToString(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 namespace ash { | 24 namespace app_list { |
| 25 | 25 |
| 26 // static | 26 // static |
| 27 IconCache* IconCache::instance_ = NULL; | 27 IconCache* IconCache::instance_ = NULL; |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 void IconCache::CreateInstance() { | 30 void IconCache::CreateInstance() { |
| 31 DCHECK(!instance_); | 31 DCHECK(!instance_); |
| 32 instance_ = new IconCache; | 32 instance_ = new IconCache; |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 cache_[key].image = processed; | 80 cache_[key].image = processed; |
| 81 cache_[key].used = true; | 81 cache_[key].used = true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 IconCache::IconCache() { | 84 IconCache::IconCache() { |
| 85 } | 85 } |
| 86 | 86 |
| 87 IconCache::~IconCache() { | 87 IconCache::~IconCache() { |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace ash | 90 } // namespace app_list |
| OLD | NEW |