| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 using ImageKey = ImageDecodeControllerKey; | 103 using ImageKey = ImageDecodeControllerKey; |
| 104 using ImageKeyHash = ImageDecodeControllerKeyHash; | 104 using ImageKeyHash = ImageDecodeControllerKeyHash; |
| 105 | 105 |
| 106 explicit SoftwareImageDecodeController(ResourceFormat format); | 106 explicit SoftwareImageDecodeController(ResourceFormat format); |
| 107 SoftwareImageDecodeController(); | 107 SoftwareImageDecodeController(); |
| 108 ~SoftwareImageDecodeController() override; | 108 ~SoftwareImageDecodeController() override; |
| 109 | 109 |
| 110 // ImageDecodeController overrides. | 110 // ImageDecodeController overrides. |
| 111 bool GetTaskForImageAndRef(const DrawImage& image, | 111 bool GetTaskForImageAndRef(const DrawImage& image, |
| 112 uint64_t prepare_tiles_id, | 112 uint64_t prepare_tiles_id, |
| 113 scoped_refptr<ImageDecodeTask>* task) override; | 113 scoped_refptr<TileTask>* task) override; |
| 114 void UnrefImage(const DrawImage& image) override; | 114 void UnrefImage(const DrawImage& image) override; |
| 115 DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override; | 115 DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override; |
| 116 void DrawWithImageFinished(const DrawImage& image, | 116 void DrawWithImageFinished(const DrawImage& image, |
| 117 const DecodedDrawImage& decoded_image) override; | 117 const DecodedDrawImage& decoded_image) override; |
| 118 void ReduceCacheUsage() override; | 118 void ReduceCacheUsage() override; |
| 119 // Software doesn't keep outstanding images pinned, so this is a no-op. | 119 // Software doesn't keep outstanding images pinned, so this is a no-op. |
| 120 void SetShouldAggressivelyFreeResources( | 120 void SetShouldAggressivelyFreeResources( |
| 121 bool aggressively_free_resources) override {} | 121 bool aggressively_free_resources) override {} |
| 122 | 122 |
| 123 // Decode the given image and store it in the cache. This is only called by an | 123 // Decode the given image and store it in the cache. This is only called by an |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 // exception of possibly prerolling them). Over time these should return | 234 // exception of possibly prerolling them). Over time these should return |
| 235 // "false" in less cases, as the ImageDecodeController should start handling | 235 // "false" in less cases, as the ImageDecodeController should start handling |
| 236 // more of them. | 236 // more of them. |
| 237 bool CanHandleImage(const ImageKey& key); | 237 bool CanHandleImage(const ImageKey& key); |
| 238 | 238 |
| 239 // Helper function which dumps all images in a specific ImageMRUCache. | 239 // Helper function which dumps all images in a specific ImageMRUCache. |
| 240 void DumpImageMemoryForCache(const ImageMRUCache& cache, | 240 void DumpImageMemoryForCache(const ImageMRUCache& cache, |
| 241 const char* cache_name, | 241 const char* cache_name, |
| 242 base::trace_event::ProcessMemoryDump* pmd) const; | 242 base::trace_event::ProcessMemoryDump* pmd) const; |
| 243 | 243 |
| 244 std::unordered_map<ImageKey, scoped_refptr<ImageDecodeTask>, ImageKeyHash> | 244 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> |
| 245 pending_image_tasks_; | 245 pending_image_tasks_; |
| 246 | 246 |
| 247 // The members below this comment can only be accessed if the lock is held to | 247 // The members below this comment can only be accessed if the lock is held to |
| 248 // ensure that they are safe to access on multiple threads. | 248 // ensure that they are safe to access on multiple threads. |
| 249 base::Lock lock_; | 249 base::Lock lock_; |
| 250 | 250 |
| 251 // Decoded images and ref counts (predecode path). | 251 // Decoded images and ref counts (predecode path). |
| 252 ImageMRUCache decoded_images_; | 252 ImageMRUCache decoded_images_; |
| 253 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; | 253 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; |
| 254 | 254 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 266 | 266 |
| 267 ResourceFormat format_; | 267 ResourceFormat format_; |
| 268 | 268 |
| 269 // Used to uniquely identify DecodedImages for memory traces. | 269 // Used to uniquely identify DecodedImages for memory traces. |
| 270 base::AtomicSequenceNumber next_tracing_id_; | 270 base::AtomicSequenceNumber next_tracing_id_; |
| 271 }; | 271 }; |
| 272 | 272 |
| 273 } // namespace cc | 273 } // namespace cc |
| 274 | 274 |
| 275 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ | 275 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ |
| OLD | NEW |