OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_TILE_MANAGER_H_ | 5 #ifndef CC_TILES_TILE_MANAGER_H_ |
6 #define CC_TILES_TILE_MANAGER_H_ | 6 #define CC_TILES_TILE_MANAGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <unordered_map> | 13 #include <unordered_map> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "cc/base/unique_notifier.h" | 19 #include "cc/base/unique_notifier.h" |
20 #include "cc/playback/raster_source.h" | 20 #include "cc/playback/raster_source.h" |
21 #include "cc/raster/raster_buffer_provider.h" | 21 #include "cc/raster/raster_buffer_provider.h" |
22 #include "cc/resources/memory_history.h" | 22 #include "cc/resources/memory_history.h" |
23 #include "cc/resources/resource_pool.h" | 23 #include "cc/resources/resource_pool.h" |
| 24 #include "cc/tiles/checker_image_tracker.h" |
24 #include "cc/tiles/decoded_image_tracker.h" | 25 #include "cc/tiles/decoded_image_tracker.h" |
25 #include "cc/tiles/eviction_tile_priority_queue.h" | 26 #include "cc/tiles/eviction_tile_priority_queue.h" |
26 #include "cc/tiles/image_controller.h" | 27 #include "cc/tiles/image_controller.h" |
27 #include "cc/tiles/raster_tile_priority_queue.h" | 28 #include "cc/tiles/raster_tile_priority_queue.h" |
28 #include "cc/tiles/tile.h" | 29 #include "cc/tiles/tile.h" |
29 #include "cc/tiles/tile_draw_info.h" | 30 #include "cc/tiles/tile_draw_info.h" |
30 #include "cc/tiles/tile_task_manager.h" | 31 #include "cc/tiles/tile_task_manager.h" |
31 | 32 |
32 namespace base { | 33 namespace base { |
33 namespace trace_event { | 34 namespace trace_event { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 TreePriority tree_priority) = 0; | 73 TreePriority tree_priority) = 0; |
73 | 74 |
74 // Informs the client that due to the currently rasterizing (or scheduled to | 75 // Informs the client that due to the currently rasterizing (or scheduled to |
75 // be rasterized) tiles, we will be in a position that will likely require a | 76 // be rasterized) tiles, we will be in a position that will likely require a |
76 // draw. This can be used to preemptively start a frame. | 77 // draw. This can be used to preemptively start a frame. |
77 virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0; | 78 virtual void SetIsLikelyToRequireADraw(bool is_likely_to_require_a_draw) = 0; |
78 | 79 |
79 // Requests the color space into which tiles should be rasterized. | 80 // Requests the color space into which tiles should be rasterized. |
80 virtual gfx::ColorSpace GetTileColorSpace() const = 0; | 81 virtual gfx::ColorSpace GetTileColorSpace() const = 0; |
81 | 82 |
| 83 // Requests that a pending tree be scheduled to invalidate content on the |
| 84 // pending on active tree. This is currently used when tiles that are |
| 85 // rasterized with missing images need to be invalidated. |
| 86 virtual void RequestImplSideInvalidation() = 0; |
| 87 |
82 protected: | 88 protected: |
83 virtual ~TileManagerClient() {} | 89 virtual ~TileManagerClient() {} |
84 }; | 90 }; |
85 | 91 |
86 struct RasterTaskCompletionStats { | 92 struct RasterTaskCompletionStats { |
87 RasterTaskCompletionStats(); | 93 RasterTaskCompletionStats(); |
88 | 94 |
89 size_t completed_count; | 95 size_t completed_count; |
90 size_t canceled_count; | 96 size_t canceled_count; |
91 }; | 97 }; |
92 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 98 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
93 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); | 99 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); |
94 | 100 |
95 // This class manages tiles, deciding which should get rasterized and which | 101 // This class manages tiles, deciding which should get rasterized and which |
96 // should no longer have any memory assigned to them. Tile objects are "owned" | 102 // should no longer have any memory assigned to them. Tile objects are "owned" |
97 // by layers; they automatically register with the manager when they are | 103 // by layers; they automatically register with the manager when they are |
98 // created, and unregister from the manager when they are deleted. | 104 // created, and unregister from the manager when they are deleted. |
99 class CC_EXPORT TileManager { | 105 class CC_EXPORT TileManager : CheckerImageTrackerClient { |
100 public: | 106 public: |
101 TileManager(TileManagerClient* client, | 107 TileManager(TileManagerClient* client, |
102 base::SequencedTaskRunner* origin_task_runner, | 108 base::SequencedTaskRunner* origin_task_runner, |
103 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner, | 109 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner, |
104 size_t scheduled_raster_task_limit, | 110 size_t scheduled_raster_task_limit, |
105 bool use_partial_raster, | 111 bool use_partial_raster, |
106 bool check_tile_priority_inversion); | 112 bool check_tile_priority_inversion, |
107 virtual ~TileManager(); | 113 bool enable_checker_imaging); |
| 114 ~TileManager() override; |
108 | 115 |
109 // Assigns tile memory and schedules work to prepare tiles for drawing. | 116 // Assigns tile memory and schedules work to prepare tiles for drawing. |
110 // - Runs client_->NotifyReadyToActivate() when all tiles required for | 117 // - Runs client_->NotifyReadyToActivate() when all tiles required for |
111 // activation are prepared, or failed to prepare due to OOM. | 118 // activation are prepared, or failed to prepare due to OOM. |
112 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are | 119 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are |
113 // prepared, or failed to prepare due to OOM. | 120 // prepared, or failed to prepare due to OOM. |
114 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 121 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); |
115 | 122 |
116 // Synchronously finish any in progress work, cancel the rest, and clean up as | 123 // Synchronously finish any in progress work, cancel the rest, and clean up as |
117 // much resources as possible. Also, prevents any future work until a | 124 // much resources as possible. Also, prevents any future work until a |
(...skipping 15 matching lines...) Expand all Loading... |
133 void Flush(); | 140 void Flush(); |
134 | 141 |
135 std::unique_ptr<Tile> CreateTile(const Tile::CreateInfo& info, | 142 std::unique_ptr<Tile> CreateTile(const Tile::CreateInfo& info, |
136 int layer_id, | 143 int layer_id, |
137 int source_frame_number, | 144 int source_frame_number, |
138 int flags); | 145 int flags); |
139 | 146 |
140 bool IsReadyToActivate() const; | 147 bool IsReadyToActivate() const; |
141 bool IsReadyToDraw() const; | 148 bool IsReadyToDraw() const; |
142 | 149 |
| 150 void AddImplSideInvalidations(LayerTreeImpl* sync_tree); |
| 151 void DidActivateSyncTree(); |
| 152 |
143 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 153 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
144 BasicStateAsValue() const; | 154 BasicStateAsValue() const; |
145 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 155 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
146 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 156 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
147 return memory_stats_from_last_assign_; | 157 return memory_stats_from_last_assign_; |
148 } | 158 } |
149 | 159 |
150 // Public methods for testing. | 160 // Public methods for testing. |
151 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 161 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
152 for (size_t i = 0; i < tiles.size(); ++i) { | 162 for (size_t i = 0; i < tiles.size(); ++i) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return has_scheduled_tile_tasks_; | 215 return has_scheduled_tile_tasks_; |
206 } | 216 } |
207 | 217 |
208 void OnRasterTaskCompleted(std::unique_ptr<RasterBuffer> raster_buffer, | 218 void OnRasterTaskCompleted(std::unique_ptr<RasterBuffer> raster_buffer, |
209 Tile::Id tile_id, | 219 Tile::Id tile_id, |
210 Resource* resource, | 220 Resource* resource, |
211 bool was_canceled); | 221 bool was_canceled); |
212 | 222 |
213 void SetDecodedImageTracker(DecodedImageTracker* decoded_image_tracker); | 223 void SetDecodedImageTracker(DecodedImageTracker* decoded_image_tracker); |
214 | 224 |
| 225 // CheckerImageTrackerClient implementation. |
| 226 void NeedsInvalidationForCheckerImagedTiles() override; |
| 227 |
215 protected: | 228 protected: |
216 friend class Tile; | 229 friend class Tile; |
217 // Must be called by tile during destruction. | 230 // Must be called by tile during destruction. |
218 void Release(Tile* tile); | 231 void Release(Tile* tile); |
219 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } | 232 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } |
220 | 233 |
221 private: | 234 private: |
222 class MemoryUsage { | 235 class MemoryUsage { |
223 public: | 236 public: |
224 MemoryUsage(); | 237 MemoryUsage(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 | 327 |
315 std::unordered_map<Tile::Id, Tile*> tiles_; | 328 std::unordered_map<Tile::Id, Tile*> tiles_; |
316 | 329 |
317 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 330 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
318 MemoryHistory::Entry memory_stats_from_last_assign_; | 331 MemoryHistory::Entry memory_stats_from_last_assign_; |
319 | 332 |
320 bool did_check_for_completed_tasks_since_last_schedule_tasks_; | 333 bool did_check_for_completed_tasks_since_last_schedule_tasks_; |
321 bool did_oom_on_last_assign_; | 334 bool did_oom_on_last_assign_; |
322 | 335 |
323 ImageController image_controller_; | 336 ImageController image_controller_; |
| 337 CheckerImageTracker checker_image_tracker_; |
324 | 338 |
325 RasterTaskCompletionStats flush_stats_; | 339 RasterTaskCompletionStats flush_stats_; |
326 | 340 |
327 TaskGraph graph_; | 341 TaskGraph graph_; |
328 | 342 |
329 UniqueNotifier more_tiles_need_prepare_check_notifier_; | 343 UniqueNotifier more_tiles_need_prepare_check_notifier_; |
330 | 344 |
331 Signals signals_; | 345 Signals signals_; |
332 | 346 |
333 UniqueNotifier signals_check_notifier_; | 347 UniqueNotifier signals_check_notifier_; |
334 | 348 |
335 bool has_scheduled_tile_tasks_; | 349 bool has_scheduled_tile_tasks_; |
336 | 350 |
337 uint64_t prepare_tiles_count_; | 351 uint64_t prepare_tiles_count_; |
338 uint64_t next_tile_id_; | 352 uint64_t next_tile_id_; |
339 | 353 |
340 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 354 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
341 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; | 355 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; |
342 const bool check_tile_priority_inversion_; | 356 const bool check_tile_priority_inversion_; |
343 | 357 |
344 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 358 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
345 | 359 |
346 DISALLOW_COPY_AND_ASSIGN(TileManager); | 360 DISALLOW_COPY_AND_ASSIGN(TileManager); |
347 }; | 361 }; |
348 | 362 |
349 } // namespace cc | 363 } // namespace cc |
350 | 364 |
351 #endif // CC_TILES_TILE_MANAGER_H_ | 365 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |