Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: cc/tiles/software_image_decode_controller.h

Issue 2130683002: [Experiment] purge-and-suspend Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <unordered_map> 11 #include <unordered_map>
12 #include <unordered_set> 12 #include <unordered_set>
13 13
14 #include "base/atomic_sequence_num.h" 14 #include "base/atomic_sequence_num.h"
15 #include "base/containers/mru_cache.h" 15 #include "base/containers/mru_cache.h"
16 #include "base/hash.h" 16 #include "base/hash.h"
17 #include "base/memory/discardable_memory_allocator.h" 17 #include "base/memory/discardable_memory_allocator.h"
18 #include "base/memory/memory_pressure_listener.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/numerics/safe_math.h" 20 #include "base/numerics/safe_math.h"
20 #include "base/threading/thread_checker.h" 21 #include "base/threading/thread_checker.h"
21 #include "base/trace_event/memory_dump_provider.h" 22 #include "base/trace_event/memory_dump_provider.h"
22 #include "cc/base/cc_export.h" 23 #include "cc/base/cc_export.h"
23 #include "cc/playback/decoded_draw_image.h" 24 #include "cc/playback/decoded_draw_image.h"
24 #include "cc/playback/draw_image.h" 25 #include "cc/playback/draw_image.h"
25 #include "cc/resources/resource_format.h" 26 #include "cc/resources/resource_format.h"
26 #include "cc/tiles/image_decode_controller.h" 27 #include "cc/tiles/image_decode_controller.h"
27 #include "third_party/skia/include/core/SkRefCnt.h" 28 #include "third_party/skia/include/core/SkRefCnt.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void SanityCheckState(int line, bool lock_acquired); 245 void SanityCheckState(int line, bool lock_acquired);
245 void RefImage(const ImageKey& key); 246 void RefImage(const ImageKey& key);
246 void RefAtRasterImage(const ImageKey& key); 247 void RefAtRasterImage(const ImageKey& key);
247 void UnrefAtRasterImage(const ImageKey& key); 248 void UnrefAtRasterImage(const ImageKey& key);
248 249
249 // Helper function which dumps all images in a specific ImageMRUCache. 250 // Helper function which dumps all images in a specific ImageMRUCache.
250 void DumpImageMemoryForCache(const ImageMRUCache& cache, 251 void DumpImageMemoryForCache(const ImageMRUCache& cache,
251 const char* cache_name, 252 const char* cache_name,
252 base::trace_event::ProcessMemoryDump* pmd) const; 253 base::trace_event::ProcessMemoryDump* pmd) const;
253 254
255 void OnMemoryPressure(
256 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
257
254 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash> 258 std::unordered_map<ImageKey, scoped_refptr<TileTask>, ImageKeyHash>
255 pending_image_tasks_; 259 pending_image_tasks_;
256 260
257 // The members below this comment can only be accessed if the lock is held to 261 // The members below this comment can only be accessed if the lock is held to
258 // ensure that they are safe to access on multiple threads. 262 // ensure that they are safe to access on multiple threads.
259 base::Lock lock_; 263 base::Lock lock_;
260 264
261 // Decoded images and ref counts (predecode path). 265 // Decoded images and ref counts (predecode path).
262 ImageMRUCache decoded_images_; 266 ImageMRUCache decoded_images_;
263 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_; 267 std::unordered_map<ImageKey, int, ImageKeyHash> decoded_images_ref_counts_;
264 268
265 // Decoded image and ref counts (at-raster decode path). 269 // Decoded image and ref counts (at-raster decode path).
266 ImageMRUCache at_raster_decoded_images_; 270 ImageMRUCache at_raster_decoded_images_;
267 std::unordered_map<ImageKey, int, ImageKeyHash> 271 std::unordered_map<ImageKey, int, ImageKeyHash>
268 at_raster_decoded_images_ref_counts_; 272 at_raster_decoded_images_ref_counts_;
269 273
270 MemoryBudget locked_images_budget_; 274 MemoryBudget locked_images_budget_;
271 275
272 ResourceFormat format_; 276 ResourceFormat format_;
273 277
274 // Used to uniquely identify DecodedImages for memory traces. 278 // Used to uniquely identify DecodedImages for memory traces.
275 base::AtomicSequenceNumber next_tracing_id_; 279 base::AtomicSequenceNumber next_tracing_id_;
280
281 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
276 }; 282 };
277 283
278 } // namespace cc 284 } // namespace cc
279 285
280 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 286 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698