| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // scaling failed. | 224 // scaling failed. |
| 225 std::unique_ptr<DecodedImage> GetScaledImageDecode( | 225 std::unique_ptr<DecodedImage> GetScaledImageDecode( |
| 226 const ImageKey& key, | 226 const ImageKey& key, |
| 227 sk_sp<const SkImage> image); | 227 sk_sp<const SkImage> image); |
| 228 | 228 |
| 229 void SanityCheckState(int line, bool lock_acquired); | 229 void SanityCheckState(int line, bool lock_acquired); |
| 230 void RefImage(const ImageKey& key); | 230 void RefImage(const ImageKey& key); |
| 231 void RefAtRasterImage(const ImageKey& key); | 231 void RefAtRasterImage(const ImageKey& key); |
| 232 void UnrefAtRasterImage(const ImageKey& key); | 232 void UnrefAtRasterImage(const ImageKey& key); |
| 233 | 233 |
| 234 // These functions indicate whether the images can be handled and cached by | |
| 235 // ImageDecodeController or whether they will fall through to Skia (with | |
| 236 // exception of possibly prerolling them). Over time these should return | |
| 237 // "false" in less cases, as the ImageDecodeController should start handling | |
| 238 // more of them. | |
| 239 bool CanHandleImage(const ImageKey& key); | |
| 240 | |
| 241 // Helper function which dumps all images in a specific ImageMRUCache. | 234 // Helper function which dumps all images in a specific ImageMRUCache. |
| 242 void DumpImageMemoryForCache(const ImageMRUCache& cache, | 235 void DumpImageMemoryForCache(const ImageMRUCache& cache, |
| 243 const char* cache_name, | 236 const char* cache_name, |
| 244 base::trace_event::ProcessMemoryDump* pmd) const; | 237 base::trace_event::ProcessMemoryDump* pmd) const; |
| 245 | 238 |
| 246 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> | 239 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> |
| 247 pending_image_tasks_; | 240 pending_image_tasks_; |
| 248 | 241 |
| 249 // The members below this comment can only be accessed if the lock is held to | 242 // The members below this comment can only be accessed if the lock is held to |
| 250 // ensure that they are safe to access on multiple threads. | 243 // ensure that they are safe to access on multiple threads. |
| 251 base::Lock lock_; | 244 base::Lock lock_; |
| 252 | 245 |
| 253 // Decoded images and ref counts (predecode path). | 246 // Decoded images and ref counts (predecode path). |
| 254 ImageMRUCache decoded_images_; | 247 ImageMRUCache decoded_images_; |
| 255 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; | 248 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; |
| 256 | 249 |
| 257 // Decoded image and ref counts (at-raster decode path). | 250 // Decoded image and ref counts (at-raster decode path). |
| 258 ImageMRUCache at_raster_decoded_images_; | 251 ImageMRUCache at_raster_decoded_images_; |
| 259 std::unordered_map<ImageKey, int, ImageKeyHash> | 252 std::unordered_map<ImageKey, int, ImageKeyHash> |
| 260 at_raster_decoded_images_ref_counts_; | 253 at_raster_decoded_images_ref_counts_; |
| 261 | 254 |
| 262 MemoryBudget locked_images_budget_; | 255 MemoryBudget locked_images_budget_; |
| 263 | 256 |
| 264 // Note that this is used for cases where the only thing we do is preroll the | |
| 265 // image the first time we see it. This mimics the previous behavior and | |
| 266 // should over time change as the compositor starts to handle more cases. | |
| 267 std::unordered_set<uint32_t> prerolled_images_; | |
| 268 | |
| 269 ResourceFormat format_; | 257 ResourceFormat format_; |
| 270 | 258 |
| 271 // Used to uniquely identify DecodedImages for memory traces. | 259 // Used to uniquely identify DecodedImages for memory traces. |
| 272 base::AtomicSequenceNumber next_tracing_id_; | 260 base::AtomicSequenceNumber next_tracing_id_; |
| 273 }; | 261 }; |
| 274 | 262 |
| 275 } // namespace cc | 263 } // namespace cc |
| 276 | 264 |
| 277 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 265 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| OLD | NEW |