| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkScaledImageCache.h" | 8 #include "SkScaledImageCache.h" |
| 9 #include "SkMipMap.h" | 9 #include "SkMipMap.h" |
| 10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 namespace { // can't use static functions w/ template parameters | 138 namespace { // can't use static functions w/ template parameters |
| 139 const SkScaledImageCache::Key& key_from_rec(const SkScaledImageCache::Rec& rec)
{ | 139 const SkScaledImageCache::Key& key_from_rec(const SkScaledImageCache::Rec& rec)
{ |
| 140 return rec.fKey; | 140 return rec.fKey; |
| 141 } | 141 } |
| 142 | 142 |
| 143 uint32_t hash_from_key(const SkScaledImageCache::Key& key) { | 143 uint32_t hash_from_key(const SkScaledImageCache::Key& key) { |
| 144 return key.fHash; | 144 return key.fHash; |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool eq_rec_key(const SkScaledImageCache::Rec& rec, const SkScaledImageCache::Ke
y& key) { | 147 } // namespace |
| 148 return rec.fKey == key; | |
| 149 } | |
| 150 } | |
| 151 | 148 |
| 152 class SkScaledImageCache::Hash : public SkTDynamicHash<SkScaledImageCache::Rec, | 149 class SkScaledImageCache::Hash : public SkTDynamicHash<SkScaledImageCache::Rec, |
| 153 SkScaledImageCache::Key, | 150 SkScaledImageCache::Key, |
| 154 key_from_rec, | 151 key_from_rec, |
| 155 hash_from_key, | 152 hash_from_key> {}; |
| 156 eq_rec_key> {}; | 153 |
| 157 | 154 |
| 158 /////////////////////////////////////////////////////////////////////////////// | 155 /////////////////////////////////////////////////////////////////////////////// |
| 159 | 156 |
| 160 // experimental hash to speed things up | 157 // experimental hash to speed things up |
| 161 #define USE_HASH | 158 #define USE_HASH |
| 162 | 159 |
| 163 #if !defined(USE_HASH) | 160 #if !defined(USE_HASH) |
| 164 static inline SkScaledImageCache::Rec* find_rec_in_list( | 161 static inline SkScaledImageCache::Rec* find_rec_in_list( |
| 165 SkScaledImageCache::Rec* head, const Key & key) { | 162 SkScaledImageCache::Rec* head, const Key & key) { |
| 166 SkScaledImageCache::Rec* rec = head; | 163 SkScaledImageCache::Rec* rec = head; |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 return SkScaledImageCache::GetBytesUsed(); | 786 return SkScaledImageCache::GetBytesUsed(); |
| 790 } | 787 } |
| 791 | 788 |
| 792 size_t SkGraphics::GetImageCacheByteLimit() { | 789 size_t SkGraphics::GetImageCacheByteLimit() { |
| 793 return SkScaledImageCache::GetByteLimit(); | 790 return SkScaledImageCache::GetByteLimit(); |
| 794 } | 791 } |
| 795 | 792 |
| 796 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { | 793 size_t SkGraphics::SetImageCacheByteLimit(size_t newLimit) { |
| 797 return SkScaledImageCache::SetByteLimit(newLimit); | 794 return SkScaledImageCache::SetByteLimit(newLimit); |
| 798 } | 795 } |
| OLD | NEW |