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

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

Issue 2555743004: Delay activation/draw on GPU tile work completion (Closed)
Patch Set: rebase #2 Created 3 years, 11 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 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
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 scoped_refptr<TileTask> CreateTaskSetFinishedTask( 298 scoped_refptr<TileTask> CreateTaskSetFinishedTask(
294 void (TileManager::*callback)()); 299 void (TileManager::*callback)());
295 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); 300 PrioritizedWorkToSchedule AssignGpuMemoryToTiles();
296 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); 301 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule);
297 302
298 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 303 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
299 ScheduledTasksStateAsValue() const; 304 ScheduledTasksStateAsValue() const;
300 305
301 bool UsePartialRaster() const; 306 bool UsePartialRaster() const;
302 307
308 void CheckPendingGpuWorkTiles(bool issue_signals);
309
303 TileManagerClient* client_; 310 TileManagerClient* client_;
304 base::SequencedTaskRunner* task_runner_; 311 base::SequencedTaskRunner* task_runner_;
305 ResourcePool* resource_pool_; 312 ResourcePool* resource_pool_;
306 std::unique_ptr<TileTaskManager> tile_task_manager_; 313 std::unique_ptr<TileTaskManager> tile_task_manager_;
307 RasterBufferProvider* raster_buffer_provider_; 314 RasterBufferProvider* raster_buffer_provider_;
308 GlobalStateThatImpactsTilePriority global_state_; 315 GlobalStateThatImpactsTilePriority global_state_;
309 size_t scheduled_raster_task_limit_; 316 size_t scheduled_raster_task_limit_;
310 const bool use_partial_raster_; 317 const bool use_partial_raster_;
311 bool use_gpu_rasterization_; 318 bool use_gpu_rasterization_;
312 319
(...skipping 15 matching lines...) Expand all
328 335
329 Signals signals_; 336 Signals signals_;
330 337
331 UniqueNotifier signals_check_notifier_; 338 UniqueNotifier signals_check_notifier_;
332 339
333 bool has_scheduled_tile_tasks_; 340 bool has_scheduled_tile_tasks_;
334 341
335 uint64_t prepare_tiles_count_; 342 uint64_t prepare_tiles_count_;
336 uint64_t next_tile_id_; 343 uint64_t next_tile_id_;
337 344
345 std::unordered_set<Tile*> pending_gpu_work_tiles_;
346 uint64_t pending_required_for_activation_callback_id_ = 0;
347 uint64_t pending_required_for_draw_callback_id_ = 0;
348 // If true, we should re-compute tile requirements in
349 // CheckPendingGpuWorkTiles.
350 bool pending_tile_requirements_dirty_ = false;
351
338 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; 352 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_;
339 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; 353 std::vector<scoped_refptr<TileTask>> locked_image_tasks_;
340 const bool check_tile_priority_inversion_; 354 const bool check_tile_priority_inversion_;
341 355
356 // We need two WeakPtrFactory objects as the invalidation pattern of each is
357 // different. The |task_set_finished_weak_ptr_factory_| is invalidated any
358 // time new tasks are scheduled, preventing a race when the callback has
359 // been scheduled but not yet executed.
342 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; 360 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_;
361 // The |ready_to_draw_callback_weak_ptr_factory_| is never invalidated.
362 base::WeakPtrFactory<TileManager> ready_to_draw_callback_weak_ptr_factory_;
343 363
344 DISALLOW_COPY_AND_ASSIGN(TileManager); 364 DISALLOW_COPY_AND_ASSIGN(TileManager);
345 }; 365 };
346 366
347 } // namespace cc 367 } // namespace cc
348 368
349 #endif // CC_TILES_TILE_MANAGER_H_ 369 #endif // CC_TILES_TILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698