| 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& scaled_size, | 61 const SkISize& scaled_size, |
| 62 ImageDecoder::AlphaOption alpha_option, |
| 62 ImageDecoder** decoder) { | 63 ImageDecoder** decoder) { |
| 63 DCHECK(decoder); | 64 DCHECK(decoder); |
| 64 | 65 |
| 65 MutexLocker lock(mutex_); | 66 MutexLocker lock(mutex_); |
| 66 DecoderCacheMap::iterator iter = decoder_cache_map_.Find( | 67 DecoderCacheMap::iterator iter = decoder_cache_map_.Find( |
| 67 DecoderCacheEntry::MakeCacheKey(generator, scaled_size)); | 68 DecoderCacheEntry::MakeCacheKey(generator, scaled_size, alpha_option)); |
| 68 if (iter == decoder_cache_map_.end()) | 69 if (iter == decoder_cache_map_.end()) |
| 69 return false; | 70 return false; |
| 70 | 71 |
| 71 DecoderCacheEntry* cache_entry = iter->value.get(); | 72 DecoderCacheEntry* cache_entry = 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 DCHECK(!cache_entry->UseCount()); | 75 DCHECK(!cache_entry->UseCount()); |
| 75 cache_entry->IncrementUseCount(); | 76 cache_entry->IncrementUseCount(); |
| 76 *decoder = cache_entry->CachedDecoder(); | 77 *decoder = cache_entry->CachedDecoder(); |
| 77 return true; | 78 return true; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 299 } |
| 299 } | 300 } |
| 300 | 301 |
| 301 void ImageDecodingStore::RemoveFromCacheListInternal( | 302 void ImageDecodingStore::RemoveFromCacheListInternal( |
| 302 const Vector<std::unique_ptr<CacheEntry>>& deletion_list) { | 303 const Vector<std::unique_ptr<CacheEntry>>& deletion_list) { |
| 303 for (size_t i = 0; i < deletion_list.size(); ++i) | 304 for (size_t i = 0; i < deletion_list.size(); ++i) |
| 304 ordered_cache_list_.Remove(deletion_list[i].get()); | 305 ordered_cache_list_.Remove(deletion_list[i].get()); |
| 305 } | 306 } |
| 306 | 307 |
| 307 } // namespace blink | 308 } // namespace blink |
| OLD | NEW |