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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 ImageDecodingStore& ImageDecodingStore::instance() { | 54 ImageDecodingStore& ImageDecodingStore::instance() { |
55 DEFINE_THREAD_SAFE_STATIC_LOCAL(ImageDecodingStore, store, | 55 DEFINE_THREAD_SAFE_STATIC_LOCAL(ImageDecodingStore, store, |
56 ImageDecodingStore::create().release()); | 56 ImageDecodingStore::create().release()); |
57 return store; | 57 return store; |
58 } | 58 } |
59 | 59 |
60 bool ImageDecodingStore::lockDecoder(const ImageFrameGenerator* generator, | 60 bool ImageDecodingStore::lockDecoder(const ImageFrameGenerator* generator, |
61 const SkISize& scaledSize, | 61 const SkISize& scaledSize, |
| 62 ImageDecoder::AlphaOption alphaOption, |
62 ImageDecoder** decoder) { | 63 ImageDecoder** decoder) { |
63 ASSERT(decoder); | 64 ASSERT(decoder); |
64 | 65 |
65 MutexLocker lock(m_mutex); | 66 MutexLocker lock(m_mutex); |
66 DecoderCacheMap::iterator iter = m_decoderCacheMap.find( | 67 DecoderCacheMap::iterator iter = m_decoderCacheMap.find( |
67 DecoderCacheEntry::makeCacheKey(generator, scaledSize)); | 68 DecoderCacheEntry::makeCacheKey(generator, scaledSize, alphaOption)); |
68 if (iter == m_decoderCacheMap.end()) | 69 if (iter == m_decoderCacheMap.end()) |
69 return false; | 70 return false; |
70 | 71 |
71 DecoderCacheEntry* cacheEntry = iter->value.get(); | 72 DecoderCacheEntry* cacheEntry = iter->value.get(); |
72 | 73 |
73 // There can only be one user of a decoder at a time. | 74 // There can only be one user of a decoder at a time. |
74 ASSERT(!cacheEntry->useCount()); | 75 ASSERT(!cacheEntry->useCount()); |
75 cacheEntry->incrementUseCount(); | 76 cacheEntry->incrementUseCount(); |
76 *decoder = cacheEntry->cachedDecoder(); | 77 *decoder = cacheEntry->cachedDecoder(); |
77 return true; | 78 return true; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 297 } |
297 } | 298 } |
298 | 299 |
299 void ImageDecodingStore::removeFromCacheListInternal( | 300 void ImageDecodingStore::removeFromCacheListInternal( |
300 const Vector<std::unique_ptr<CacheEntry>>& deletionList) { | 301 const Vector<std::unique_ptr<CacheEntry>>& deletionList) { |
301 for (size_t i = 0; i < deletionList.size(); ++i) | 302 for (size_t i = 0; i < deletionList.size(); ++i) |
302 m_orderedCacheList.remove(deletionList[i].get()); | 303 m_orderedCacheList.remove(deletionList[i].get()); |
303 } | 304 } |
304 | 305 |
305 } // namespace blink | 306 } // namespace blink |
OLD | NEW |