| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // | 54 // |
| 55 // ImageFrameGenerator | 55 // ImageFrameGenerator |
| 56 // This is a direct user of this cache. Responsible for generating bitmap imag
es | 56 // This is a direct user of this cache. Responsible for generating bitmap imag
es |
| 57 // using an ImageDecoder. It contains encoded image data and is used to repres
ent | 57 // using an ImageDecoder. It contains encoded image data and is used to repres
ent |
| 58 // one image file. It is used to index image and decoder objects in the cache. | 58 // one image file. It is used to index image and decoder objects in the cache. |
| 59 // | 59 // |
| 60 // THREAD SAFETY | 60 // THREAD SAFETY |
| 61 // | 61 // |
| 62 // All public methods can be used on any thread. | 62 // All public methods can be used on any thread. |
| 63 | 63 |
| 64 class PLATFORM_EXPORT ImageDecodingStore { | 64 class PLATFORM_EXPORT ImageDecodingStore final { |
| 65 USING_FAST_MALLOC(ImageDecodingStore); |
| 66 WTF_MAKE_NONCOPYABLE(ImageDecodingStore); |
| 65 public: | 67 public: |
| 66 static PassOwnPtr<ImageDecodingStore> create() { return adoptPtr(new ImageDe
codingStore); } | 68 static PassOwnPtr<ImageDecodingStore> create() { return adoptPtr(new ImageDe
codingStore); } |
| 67 ~ImageDecodingStore(); | 69 ~ImageDecodingStore(); |
| 68 | 70 |
| 69 static ImageDecodingStore& instance(); | 71 static ImageDecodingStore& instance(); |
| 70 | 72 |
| 71 // Access a cached decoder object. A decoder is indexed by origin (ImageFram
eGenerator) | 73 // Access a cached decoder object. A decoder is indexed by origin (ImageFram
eGenerator) |
| 72 // and scaled size. Return true if the cached object is found. | 74 // and scaled size. Return true if the cached object is found. |
| 73 bool lockDecoder(const ImageFrameGenerator*, const SkISize& scaledSize, Imag
eDecoder**); | 75 bool lockDecoder(const ImageFrameGenerator*, const SkISize& scaledSize, Imag
eDecoder**); |
| 74 void unlockDecoder(const ImageFrameGenerator*, const ImageDecoder*); | 76 void unlockDecoder(const ImageFrameGenerator*, const ImageDecoder*); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 85 int decoderCacheEntries(); | 87 int decoderCacheEntries(); |
| 86 | 88 |
| 87 private: | 89 private: |
| 88 // Decoder cache entry is identified by: | 90 // Decoder cache entry is identified by: |
| 89 // 1. Pointer to ImageFrameGenerator. | 91 // 1. Pointer to ImageFrameGenerator. |
| 90 // 2. Size of the image. | 92 // 2. Size of the image. |
| 91 typedef std::pair<const ImageFrameGenerator*, SkISize> DecoderCacheKey; | 93 typedef std::pair<const ImageFrameGenerator*, SkISize> DecoderCacheKey; |
| 92 | 94 |
| 93 // Base class for all cache entries. | 95 // Base class for all cache entries. |
| 94 class CacheEntry : public DoublyLinkedListNode<CacheEntry> { | 96 class CacheEntry : public DoublyLinkedListNode<CacheEntry> { |
| 97 USING_FAST_MALLOC(CacheEntry); |
| 98 WTF_MAKE_NONCOPYABLE(CacheEntry); |
| 95 friend class WTF::DoublyLinkedListNode<CacheEntry>; | 99 friend class WTF::DoublyLinkedListNode<CacheEntry>; |
| 96 public: | 100 public: |
| 97 enum CacheType { | 101 enum CacheType { |
| 98 TypeDecoder, | 102 TypeDecoder, |
| 99 }; | 103 }; |
| 100 | 104 |
| 101 CacheEntry(const ImageFrameGenerator* generator, int useCount) | 105 CacheEntry(const ImageFrameGenerator* generator, int useCount) |
| 102 : m_generator(generator) | 106 : m_generator(generator) |
| 103 , m_useCount(useCount) | 107 , m_useCount(useCount) |
| 104 , m_prev(0) | 108 , m_prev(0) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 210 |
| 207 // Protect concurrent access to these members: | 211 // Protect concurrent access to these members: |
| 208 // m_orderedCacheList | 212 // m_orderedCacheList |
| 209 // m_decoderCacheMap and all CacheEntrys stored in it | 213 // m_decoderCacheMap and all CacheEntrys stored in it |
| 210 // m_decoderCacheKeyMap | 214 // m_decoderCacheKeyMap |
| 211 // m_heapLimitInBytes | 215 // m_heapLimitInBytes |
| 212 // m_heapMemoryUsageInBytes | 216 // m_heapMemoryUsageInBytes |
| 213 // This mutex also protects calls to underlying skBitmap's | 217 // This mutex also protects calls to underlying skBitmap's |
| 214 // lockPixels()/unlockPixels() as they are not threadsafe. | 218 // lockPixels()/unlockPixels() as they are not threadsafe. |
| 215 Mutex m_mutex; | 219 Mutex m_mutex; |
| 220 |
| 221 #if COMPILER(MSVC) |
| 222 friend struct ::WTF::OwnedPtrDeleter<CacheEntry>; |
| 223 friend struct ::WTF::OwnedPtrDeleter<DecoderCacheEntry>; |
| 224 #endif |
| 216 }; | 225 }; |
| 217 | 226 |
| 218 } // namespace blink | 227 } // namespace blink |
| 219 | 228 |
| 220 #endif | 229 #endif |
| OLD | NEW |