| 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 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 ImageDecodeCache* image_decode_cache, | 125 ImageDecodeCache* image_decode_cache, |
| 126 TaskGraphRunner* task_graph_runner, | 126 TaskGraphRunner* task_graph_runner, |
| 127 RasterBufferProvider* raster_buffer_provider, | 127 RasterBufferProvider* raster_buffer_provider, |
| 128 size_t scheduled_raster_task_limit, | 128 size_t scheduled_raster_task_limit, |
| 129 bool use_gpu_rasterization); | 129 bool use_gpu_rasterization); |
| 130 | 130 |
| 131 // This causes any completed raster work to finalize, so that tiles get up to | 131 // This causes any completed raster work to finalize, so that tiles get up to |
| 132 // date draw information. | 132 // date draw information. |
| 133 void Flush(); | 133 void Flush(); |
| 134 | 134 |
| 135 // Called when the required-for-activation/required-for-draw state of tiles |
| 136 // may have changed. |
| 137 void DidModifyTilePriorities(); |
| 138 |
| 135 std::unique_ptr<Tile> CreateTile(const Tile::CreateInfo& info, | 139 std::unique_ptr<Tile> CreateTile(const Tile::CreateInfo& info, |
| 136 int layer_id, | 140 int layer_id, |
| 137 int source_frame_number, | 141 int source_frame_number, |
| 138 int flags); | 142 int flags); |
| 139 | 143 |
| 140 bool IsReadyToActivate() const; | 144 bool IsReadyToActivate() const; |
| 141 bool IsReadyToDraw() const; | 145 bool IsReadyToDraw() const; |
| 142 | 146 |
| 143 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 147 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 144 BasicStateAsValue() const; | 148 BasicStateAsValue() const; |
| 145 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 149 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
| 146 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 150 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 147 return memory_stats_from_last_assign_; | 151 return memory_stats_from_last_assign_; |
| 148 } | 152 } |
| 149 | 153 |
| 150 // Public methods for testing. | 154 // Public methods for testing. |
| 151 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 155 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
| 152 for (size_t i = 0; i < tiles.size(); ++i) { | 156 for (size_t i = 0; i < tiles.size(); ++i) { |
| 153 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 157 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
| 154 draw_info.resource_ = resource_pool_->AcquireResource( | 158 draw_info.set_resource(resource_pool_->AcquireResource( |
| 155 tiles[i]->desired_texture_size(), | 159 tiles[i]->desired_texture_size(), |
| 156 raster_buffer_provider_->GetResourceFormat(false), | 160 raster_buffer_provider_->GetResourceFormat(false), |
| 157 client_->GetTileColorSpace()); | 161 client_->GetTileColorSpace())); |
| 162 draw_info.set_resource_ready_for_draw(); |
| 158 } | 163 } |
| 159 } | 164 } |
| 160 | 165 |
| 161 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 166 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
| 162 for (size_t i = 0; i < tiles.size(); ++i) { | 167 for (size_t i = 0; i < tiles.size(); ++i) { |
| 163 Tile* tile = tiles[i]; | 168 Tile* tile = tiles[i]; |
| 164 FreeResourcesForTile(tile); | 169 FreeResourcesForTile(tile); |
| 165 } | 170 } |
| 166 } | 171 } |
| 167 | 172 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 scoped_refptr<TileTask> CreateTaskSetFinishedTask( | 300 scoped_refptr<TileTask> CreateTaskSetFinishedTask( |
| 296 void (TileManager::*callback)()); | 301 void (TileManager::*callback)()); |
| 297 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); | 302 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); |
| 298 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); | 303 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); |
| 299 | 304 |
| 300 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 305 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 301 ScheduledTasksStateAsValue() const; | 306 ScheduledTasksStateAsValue() const; |
| 302 | 307 |
| 303 bool UsePartialRaster() const; | 308 bool UsePartialRaster() const; |
| 304 | 309 |
| 310 void CheckPendingGpuWorkTiles(bool issue_signals); |
| 311 |
| 305 TileManagerClient* client_; | 312 TileManagerClient* client_; |
| 306 base::SequencedTaskRunner* task_runner_; | 313 base::SequencedTaskRunner* task_runner_; |
| 307 ResourcePool* resource_pool_; | 314 ResourcePool* resource_pool_; |
| 308 std::unique_ptr<TileTaskManager> tile_task_manager_; | 315 std::unique_ptr<TileTaskManager> tile_task_manager_; |
| 309 RasterBufferProvider* raster_buffer_provider_; | 316 RasterBufferProvider* raster_buffer_provider_; |
| 310 GlobalStateThatImpactsTilePriority global_state_; | 317 GlobalStateThatImpactsTilePriority global_state_; |
| 311 size_t scheduled_raster_task_limit_; | 318 size_t scheduled_raster_task_limit_; |
| 312 const bool use_partial_raster_; | 319 const bool use_partial_raster_; |
| 313 bool use_gpu_rasterization_; | 320 bool use_gpu_rasterization_; |
| 314 | 321 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 330 | 337 |
| 331 Signals signals_; | 338 Signals signals_; |
| 332 | 339 |
| 333 UniqueNotifier signals_check_notifier_; | 340 UniqueNotifier signals_check_notifier_; |
| 334 | 341 |
| 335 bool has_scheduled_tile_tasks_; | 342 bool has_scheduled_tile_tasks_; |
| 336 | 343 |
| 337 uint64_t prepare_tiles_count_; | 344 uint64_t prepare_tiles_count_; |
| 338 uint64_t next_tile_id_; | 345 uint64_t next_tile_id_; |
| 339 | 346 |
| 347 std::unordered_set<Tile*> pending_gpu_work_tiles_; |
| 348 uint64_t pending_required_for_activation_callback_id_ = 0; |
| 349 uint64_t pending_required_for_draw_callback_id_ = 0; |
| 350 // If true, we should re-compute tile requirements in |
| 351 // CheckPendingGpuWorkTiles. |
| 352 bool pending_tile_requirements_dirty_ = false; |
| 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 |
| 358 // We need two WeakPtrFactory objects as the invalidation pattern of each is |
| 359 // different. The |task_set_finished_weak_ptr_factory_| is invalidated any |
| 360 // time new tasks are scheduled, preventing a race when the callback has |
| 361 // been scheduled but not yet executed. |
| 344 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 362 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
| 363 // The |ready_to_draw_callback_weak_ptr_factory_| is never invalidated. |
| 364 base::WeakPtrFactory<TileManager> ready_to_draw_callback_weak_ptr_factory_; |
| 345 | 365 |
| 346 DISALLOW_COPY_AND_ASSIGN(TileManager); | 366 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 347 }; | 367 }; |
| 348 | 368 |
| 349 } // namespace cc | 369 } // namespace cc |
| 350 | 370 |
| 351 #endif // CC_TILES_TILE_MANAGER_H_ | 371 #endif // CC_TILES_TILE_MANAGER_H_ |
| OLD | NEW |