| 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_CACHE_H_ | 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ |
| 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ | 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 void SanityCheckState(int line, bool lock_acquired); | 264 void SanityCheckState(int line, bool lock_acquired); |
| 265 void RefImage(const ImageKey& key); | 265 void RefImage(const ImageKey& key); |
| 266 void RefAtRasterImage(const ImageKey& key); | 266 void RefAtRasterImage(const ImageKey& key); |
| 267 void UnrefAtRasterImage(const ImageKey& key); | 267 void UnrefAtRasterImage(const ImageKey& key); |
| 268 | 268 |
| 269 // Helper function which dumps all images in a specific ImageMRUCache. | 269 // Helper function which dumps all images in a specific ImageMRUCache. |
| 270 void DumpImageMemoryForCache(const ImageMRUCache& cache, | 270 void DumpImageMemoryForCache(const ImageMRUCache& cache, |
| 271 const char* cache_name, | 271 const char* cache_name, |
| 272 base::trace_event::ProcessMemoryDump* pmd) const; | 272 base::trace_event::ProcessMemoryDump* pmd) const; |
| 273 | 273 |
| 274 // Removes unlocked decoded images until the number of decoded images is |
| 275 // reduced within the given limit. |
| 276 void ReduceCacheUsageUntilWithinLimit(size_t limit); |
| 277 |
| 274 // Overriden from base::MemoryCoordinatorClient. | 278 // Overriden from base::MemoryCoordinatorClient. |
| 275 void OnMemoryStateChange(base::MemoryState state) override; | 279 void OnMemoryStateChange(base::MemoryState state) override; |
| 280 void OnPurgeMemory() override; |
| 276 | 281 |
| 277 // Helper method to get the different tasks. Note that this should be used as | 282 // Helper method to get the different tasks. Note that this should be used as |
| 278 // if it was public (ie, all of the locks need to be properly acquired). | 283 // if it was public (ie, all of the locks need to be properly acquired). |
| 279 bool GetTaskForImageAndRefInternal(const DrawImage& image, | 284 bool GetTaskForImageAndRefInternal(const DrawImage& image, |
| 280 const TracingInfo& tracing_info, | 285 const TracingInfo& tracing_info, |
| 281 DecodeTaskType type, | 286 DecodeTaskType type, |
| 282 scoped_refptr<TileTask>* task); | 287 scoped_refptr<TileTask>* task); |
| 283 | 288 |
| 284 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> | 289 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> |
| 285 pending_in_raster_image_tasks_; | 290 pending_in_raster_image_tasks_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 304 ResourceFormat format_; | 309 ResourceFormat format_; |
| 305 size_t max_items_in_cache_; | 310 size_t max_items_in_cache_; |
| 306 | 311 |
| 307 // Used to uniquely identify DecodedImages for memory traces. | 312 // Used to uniquely identify DecodedImages for memory traces. |
| 308 base::AtomicSequenceNumber next_tracing_id_; | 313 base::AtomicSequenceNumber next_tracing_id_; |
| 309 }; | 314 }; |
| 310 | 315 |
| 311 } // namespace cc | 316 } // namespace cc |
| 312 | 317 |
| 313 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ | 318 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ |
| OLD | NEW |