| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 165 |
| 166 ImageDecodingStore(); | 166 ImageDecodingStore(); |
| 167 | 167 |
| 168 void prune(); | 168 void prune(); |
| 169 | 169 |
| 170 // These helper methods are called while m_mutex is locked. | 170 // These helper methods are called while m_mutex is locked. |
| 171 template<class T, class U, class V> void insertCacheInternal(PassOwnPtr<T> c
acheEntry, U* cacheMap, V* identifierMap); | 171 template<class T, class U, class V> void insertCacheInternal(PassOwnPtr<T> c
acheEntry, U* cacheMap, V* identifierMap); |
| 172 | 172 |
| 173 // Helper method to remove a cache entry. Ownership is transferred to | 173 // Helper method to remove a cache entry. Ownership is transferred to |
| 174 // deletionList. Use of Vector<> is handy when removing multiple entries. | 174 // deletionList. Use of Vector<> is handy when removing multiple entries. |
| 175 template<class T, class U, class V> void removeFromCacheInternal(const T* ca
cheEntry, U* cacheMap, V* identifierMap, Vector<OwnPtr<CacheEntry> >* deletionLi
st); | 175 template<class T, class U, class V> void removeFromCacheInternal(const T* ca
cheEntry, U* cacheMap, V* identifierMap, Vector<OwnPtr<CacheEntry>>* deletionLis
t); |
| 176 | 176 |
| 177 // Helper method to remove a cache entry. Uses the templated version base on | 177 // Helper method to remove a cache entry. Uses the templated version base on |
| 178 // the type of cache entry. | 178 // the type of cache entry. |
| 179 void removeFromCacheInternal(const CacheEntry*, Vector<OwnPtr<CacheEntry> >*
deletionList); | 179 void removeFromCacheInternal(const CacheEntry*, Vector<OwnPtr<CacheEntry>>*
deletionList); |
| 180 | 180 |
| 181 // Helper method to remove all cache entries associated with a ImageFraneGen
erator. | 181 // Helper method to remove all cache entries associated with a ImageFraneGen
erator. |
| 182 // Ownership of cache entries is transferred to deletionList. | 182 // Ownership of cache entries is transferred to deletionList. |
| 183 template<class U, class V> void removeCacheIndexedByGeneratorInternal(U* cac
heMap, V* identifierMap, const ImageFrameGenerator*, Vector<OwnPtr<CacheEntry> >
* deletionList); | 183 template<class U, class V> void removeCacheIndexedByGeneratorInternal(U* cac
heMap, V* identifierMap, const ImageFrameGenerator*, Vector<OwnPtr<CacheEntry>>*
deletionList); |
| 184 | 184 |
| 185 // Helper method to remove cache entry pointers from the LRU list. | 185 // Helper method to remove cache entry pointers from the LRU list. |
| 186 void removeFromCacheListInternal(const Vector<OwnPtr<CacheEntry> >& deletion
List); | 186 void removeFromCacheListInternal(const Vector<OwnPtr<CacheEntry>>& deletionL
ist); |
| 187 | 187 |
| 188 // A doubly linked list that maintains usage history of cache entries. | 188 // A doubly linked list that maintains usage history of cache entries. |
| 189 // This is used for eviction of old entries. | 189 // This is used for eviction of old entries. |
| 190 // Head of this list is the least recently used cache entry. | 190 // Head of this list is the least recently used cache entry. |
| 191 // Tail of this list is the most recently used cache entry. | 191 // Tail of this list is the most recently used cache entry. |
| 192 DoublyLinkedList<CacheEntry> m_orderedCacheList; | 192 DoublyLinkedList<CacheEntry> m_orderedCacheList; |
| 193 | 193 |
| 194 // A lookup table for all decoder cache objects. Owns all decoder cache obje
cts. | 194 // A lookup table for all decoder cache objects. Owns all decoder cache obje
cts. |
| 195 typedef HashMap<DecoderCacheKey, OwnPtr<DecoderCacheEntry> > DecoderCacheMap
; | 195 typedef HashMap<DecoderCacheKey, OwnPtr<DecoderCacheEntry>> DecoderCacheMap; |
| 196 DecoderCacheMap m_decoderCacheMap; | 196 DecoderCacheMap m_decoderCacheMap; |
| 197 | 197 |
| 198 // A lookup table to map ImageFrameGenerator to all associated | 198 // A lookup table to map ImageFrameGenerator to all associated |
| 199 // decoder cache keys. | 199 // decoder cache keys. |
| 200 typedef HashSet<DecoderCacheKey> DecoderCacheKeySet; | 200 typedef HashSet<DecoderCacheKey> DecoderCacheKeySet; |
| 201 typedef HashMap<const ImageFrameGenerator*, DecoderCacheKeySet> DecoderCache
KeyMap; | 201 typedef HashMap<const ImageFrameGenerator*, DecoderCacheKeySet> DecoderCache
KeyMap; |
| 202 DecoderCacheKeyMap m_decoderCacheKeyMap; | 202 DecoderCacheKeyMap m_decoderCacheKeyMap; |
| 203 | 203 |
| 204 size_t m_heapLimitInBytes; | 204 size_t m_heapLimitInBytes; |
| 205 size_t m_heapMemoryUsageInBytes; | 205 size_t m_heapMemoryUsageInBytes; |
| 206 | 206 |
| 207 // Protect concurrent access to these members: | 207 // Protect concurrent access to these members: |
| 208 // m_orderedCacheList | 208 // m_orderedCacheList |
| 209 // m_decoderCacheMap and all CacheEntrys stored in it | 209 // m_decoderCacheMap and all CacheEntrys stored in it |
| 210 // m_decoderCacheKeyMap | 210 // m_decoderCacheKeyMap |
| 211 // m_heapLimitInBytes | 211 // m_heapLimitInBytes |
| 212 // m_heapMemoryUsageInBytes | 212 // m_heapMemoryUsageInBytes |
| 213 // This mutex also protects calls to underlying skBitmap's | 213 // This mutex also protects calls to underlying skBitmap's |
| 214 // lockPixels()/unlockPixels() as they are not threadsafe. | 214 // lockPixels()/unlockPixels() as they are not threadsafe. |
| 215 Mutex m_mutex; | 215 Mutex m_mutex; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 } // namespace blink | 218 } // namespace blink |
| 219 | 219 |
| 220 #endif | 220 #endif |
| OLD | NEW |