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

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

Issue 1910213005: cc: Refactor TileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_states
Patch Set: feedback Created 4 years, 7 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
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "cc/tiles/tile_manager.h" 5 #include "cc/tiles/tile_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 for (TileTask::Vector::const_iterator it = decode_tasks.begin(); 203 for (TileTask::Vector::const_iterator it = decode_tasks.begin();
204 it != decode_tasks.end(); ++it) { 204 it != decode_tasks.end(); ++it) {
205 TileTask* decode_task = it->get(); 205 TileTask* decode_task = it->get();
206 206
207 // Skip if already decoded. 207 // Skip if already decoded.
208 if (decode_task->HasCompleted()) 208 if (decode_task->HasCompleted())
209 continue; 209 continue;
210 210
211 dependencies++; 211 dependencies++;
212 212
213 // Add decode task if it doesn't already exists in graph. 213 // Add decode task if it doesn't already exist in graph.
214 TaskGraph::Node::Vector::iterator decode_it = 214 TaskGraph::Node::Vector::iterator decode_it =
215 std::find_if(graph->nodes.begin(), graph->nodes.end(), 215 std::find_if(graph->nodes.begin(), graph->nodes.end(),
216 [decode_task](const TaskGraph::Node& node) { 216 [decode_task](const TaskGraph::Node& node) {
217 return node.task == decode_task; 217 return node.task == decode_task;
218 }); 218 });
219 219
220 // In rare circumstances, a low priority task may come in before a high 220 // In rare circumstances, a low priority task may come in before a high
221 // priority task. In these cases, upgrade any low-priority dependencies of 221 // priority task. In these cases, upgrade any low-priority dependencies of
222 // the current task. 222 // the current task.
223 // TODO(ericrk): Task iterators should be updated to avoid this. 223 // TODO(ericrk): Task iterators should be updated to avoid this.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 client, task_runner, scheduled_raster_task_limit, use_partial_raster)); 301 client, task_runner, scheduled_raster_task_limit, use_partial_raster));
302 } 302 }
303 303
304 TileManager::TileManager(TileManagerClient* client, 304 TileManager::TileManager(TileManagerClient* client,
305 scoped_refptr<base::SequencedTaskRunner> task_runner, 305 scoped_refptr<base::SequencedTaskRunner> task_runner,
306 size_t scheduled_raster_task_limit, 306 size_t scheduled_raster_task_limit,
307 bool use_partial_raster) 307 bool use_partial_raster)
308 : client_(client), 308 : client_(client),
309 task_runner_(std::move(task_runner)), 309 task_runner_(std::move(task_runner)),
310 resource_pool_(nullptr), 310 resource_pool_(nullptr),
311 tile_task_worker_pool_(nullptr), 311 tile_task_manager_(nullptr),
312 scheduled_raster_task_limit_(scheduled_raster_task_limit), 312 scheduled_raster_task_limit_(scheduled_raster_task_limit),
313 use_partial_raster_(use_partial_raster), 313 use_partial_raster_(use_partial_raster),
314 use_gpu_rasterization_(false), 314 use_gpu_rasterization_(false),
315 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 315 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
316 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 316 did_check_for_completed_tasks_since_last_schedule_tasks_(true),
317 did_oom_on_last_assign_(false), 317 did_oom_on_last_assign_(false),
318 more_tiles_need_prepare_check_notifier_( 318 more_tiles_need_prepare_check_notifier_(
319 task_runner_.get(), 319 task_runner_.get(),
320 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, 320 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared,
321 base::Unretained(this))), 321 base::Unretained(this))),
322 signals_check_notifier_(task_runner_.get(), 322 signals_check_notifier_(task_runner_.get(),
323 base::Bind(&TileManager::CheckAndIssueSignals, 323 base::Bind(&TileManager::CheckAndIssueSignals,
324 base::Unretained(this))), 324 base::Unretained(this))),
325 has_scheduled_tile_tasks_(false), 325 has_scheduled_tile_tasks_(false),
326 prepare_tiles_count_(0u), 326 prepare_tiles_count_(0u),
327 next_tile_id_(0u), 327 next_tile_id_(0u),
328 task_set_finished_weak_ptr_factory_(this) {} 328 task_set_finished_weak_ptr_factory_(this) {}
329 329
330 TileManager::~TileManager() { 330 TileManager::~TileManager() {
331 FinishTasksAndCleanUp(); 331 FinishTasksAndCleanUp();
332 } 332 }
333 333
334 void TileManager::FinishTasksAndCleanUp() { 334 void TileManager::FinishTasksAndCleanUp() {
335 if (!tile_task_worker_pool_) 335 if (!tile_task_manager_)
336 return; 336 return;
337 337
338 global_state_ = GlobalStateThatImpactsTilePriority(); 338 global_state_ = GlobalStateThatImpactsTilePriority();
339 339
340 // This cancels tasks if possible, finishes pending tasks, and release any 340 // This cancels tasks if possible, finishes pending tasks, and release any
341 // uninitialized resources. 341 // uninitialized resources.
342 tile_task_worker_pool_->Shutdown(); 342 tile_task_manager_->Shutdown();
343 343
344 // Now that all tasks have been finished, we can clear any 344 // Now that all tasks have been finished, we can clear any
345 // |orphan_tasks_|. 345 // |orphan_tasks_|.
346 orphan_tasks_.clear(); 346 orphan_tasks_.clear();
347 347
348 tile_task_worker_pool_->CheckForCompletedTasks(); 348 tile_task_manager_->CheckForCompletedTasks();
349 349
350 FreeResourcesForReleasedTiles(); 350 FreeResourcesForReleasedTiles();
351 CleanUpReleasedTiles(); 351 CleanUpReleasedTiles();
352 352
353 tile_task_worker_pool_ = nullptr; 353 tile_task_manager_ = nullptr;
354 resource_pool_ = nullptr; 354 resource_pool_ = nullptr;
355 more_tiles_need_prepare_check_notifier_.Cancel(); 355 more_tiles_need_prepare_check_notifier_.Cancel();
356 signals_check_notifier_.Cancel(); 356 signals_check_notifier_.Cancel();
357 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); 357 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs();
358 } 358 }
359 359
360 void TileManager::SetResources(ResourcePool* resource_pool, 360 void TileManager::SetResources(ResourcePool* resource_pool,
361 TileTaskWorkerPool* tile_task_worker_pool,
362 ImageDecodeController* image_decode_controller, 361 ImageDecodeController* image_decode_controller,
362 TileTaskManager* tile_task_manager,
363 size_t scheduled_raster_task_limit, 363 size_t scheduled_raster_task_limit,
364 bool use_gpu_rasterization) { 364 bool use_gpu_rasterization) {
365 DCHECK(!tile_task_worker_pool_); 365 DCHECK(!tile_task_manager_);
366 DCHECK(tile_task_worker_pool); 366 DCHECK(tile_task_manager);
367 367
368 use_gpu_rasterization_ = use_gpu_rasterization; 368 use_gpu_rasterization_ = use_gpu_rasterization;
369 scheduled_raster_task_limit_ = scheduled_raster_task_limit; 369 scheduled_raster_task_limit_ = scheduled_raster_task_limit;
370 resource_pool_ = resource_pool; 370 resource_pool_ = resource_pool;
371 tile_task_worker_pool_ = tile_task_worker_pool;
372 image_decode_controller_ = image_decode_controller; 371 image_decode_controller_ = image_decode_controller;
372 tile_task_manager_ = tile_task_manager;
373 } 373 }
374 374
375 void TileManager::Release(Tile* tile) { 375 void TileManager::Release(Tile* tile) {
376 released_tiles_.push_back(tile); 376 released_tiles_.push_back(tile);
377 } 377 }
378 378
379 void TileManager::FreeResourcesForReleasedTiles() { 379 void TileManager::FreeResourcesForReleasedTiles() {
380 for (auto* tile : released_tiles_) 380 for (auto* tile : released_tiles_)
381 FreeResourcesForTile(tile); 381 FreeResourcesForTile(tile);
382 } 382 }
(...skipping 29 matching lines...) Expand all
412 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", 412 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state",
413 ScheduledTasksStateAsValue()); 413 ScheduledTasksStateAsValue());
414 signals_.ready_to_draw = true; 414 signals_.ready_to_draw = true;
415 signals_check_notifier_.Schedule(); 415 signals_check_notifier_.Schedule();
416 } 416 }
417 417
418 void TileManager::DidFinishRunningAllTileTasks() { 418 void TileManager::DidFinishRunningAllTileTasks() {
419 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); 419 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks");
420 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); 420 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this);
421 DCHECK(resource_pool_); 421 DCHECK(resource_pool_);
422 DCHECK(tile_task_worker_pool_); 422 DCHECK(tile_task_manager_);
423 423
424 has_scheduled_tile_tasks_ = false; 424 has_scheduled_tile_tasks_ = false;
425 425
426 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() > 426 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() >
427 global_state_.soft_memory_limit_in_bytes; 427 global_state_.soft_memory_limit_in_bytes;
428 428
429 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && 429 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ &&
430 !memory_usage_above_limit) { 430 !memory_usage_above_limit) {
431 // TODO(ericrk): We should find a better way to safely handle re-entrant 431 // TODO(ericrk): We should find a better way to safely handle re-entrant
432 // notifications than always having to schedule a new task. 432 // notifications than always having to schedule a new task.
433 // http://crbug.com/498439 433 // http://crbug.com/498439
434 signals_.all_tile_tasks_completed = true; 434 signals_.all_tile_tasks_completed = true;
435 signals_check_notifier_.Schedule(); 435 signals_check_notifier_.Schedule();
436 return; 436 return;
437 } 437 }
438 438
439 more_tiles_need_prepare_check_notifier_.Schedule(); 439 more_tiles_need_prepare_check_notifier_.Schedule();
440 } 440 }
441 441
442 bool TileManager::PrepareTiles( 442 bool TileManager::PrepareTiles(
443 const GlobalStateThatImpactsTilePriority& state) { 443 const GlobalStateThatImpactsTilePriority& state) {
444 ++prepare_tiles_count_; 444 ++prepare_tiles_count_;
445 445
446 TRACE_EVENT1("cc", "TileManager::PrepareTiles", "prepare_tiles_id", 446 TRACE_EVENT1("cc", "TileManager::PrepareTiles", "prepare_tiles_id",
447 prepare_tiles_count_); 447 prepare_tiles_count_);
448 448
449 if (!tile_task_worker_pool_) { 449 if (!tile_task_manager_) {
450 TRACE_EVENT_INSTANT0("cc", "PrepareTiles aborted", 450 TRACE_EVENT_INSTANT0("cc", "PrepareTiles aborted",
451 TRACE_EVENT_SCOPE_THREAD); 451 TRACE_EVENT_SCOPE_THREAD);
452 return false; 452 return false;
453 } 453 }
454 454
455 signals_.reset(); 455 signals_.reset();
456 global_state_ = state; 456 global_state_ = state;
457 457
458 // We need to call CheckForCompletedTasks() once in-between each call 458 // We need to call CheckForCompletedTasks() once in-between each call
459 // to ScheduleTasks() to prevent canceled tasks from being scheduled. 459 // to ScheduleTasks() to prevent canceled tasks from being scheduled.
460 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { 460 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) {
461 tile_task_worker_pool_->CheckForCompletedTasks(); 461 tile_task_manager_->CheckForCompletedTasks();
462 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 462 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
463 } 463 }
464 464
465 FreeResourcesForReleasedTiles(); 465 FreeResourcesForReleasedTiles();
466 CleanUpReleasedTiles(); 466 CleanUpReleasedTiles();
467 467
468 PrioritizedTileVector tiles_that_need_to_be_rasterized; 468 PrioritizedTileVector tiles_that_need_to_be_rasterized;
469 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 469 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
470 client_->BuildRasterQueue(global_state_.tree_priority, 470 client_->BuildRasterQueue(global_state_.tree_priority,
471 RasterTilePriorityQueue::Type::ALL)); 471 RasterTilePriorityQueue::Type::ALL));
(...skipping 11 matching lines...) Expand all
483 ScheduleTasks(tiles_that_need_to_be_rasterized); 483 ScheduleTasks(tiles_that_need_to_be_rasterized);
484 484
485 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD, 485 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD,
486 "state", BasicStateAsValue()); 486 "state", BasicStateAsValue());
487 return true; 487 return true;
488 } 488 }
489 489
490 void TileManager::Flush() { 490 void TileManager::Flush() {
491 TRACE_EVENT0("cc", "TileManager::Flush"); 491 TRACE_EVENT0("cc", "TileManager::Flush");
492 492
493 if (!tile_task_worker_pool_) { 493 if (!tile_task_manager_) {
494 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); 494 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD);
495 return; 495 return;
496 } 496 }
497 497
498 tile_task_worker_pool_->CheckForCompletedTasks(); 498 tile_task_manager_->CheckForCompletedTasks();
499 499
500 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 500 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
501 501
502 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", 502 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats",
503 RasterTaskCompletionStatsAsValue(flush_stats_)); 503 RasterTaskCompletionStatsAsValue(flush_stats_));
504 flush_stats_ = RasterTaskCompletionStats(); 504 flush_stats_ = RasterTaskCompletionStats();
505 } 505 }
506 506
507 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 507 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
508 TileManager::BasicStateAsValue() const { 508 TileManager::BasicStateAsValue() const {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 return true; 585 return true;
586 } 586 }
587 587
588 void TileManager::AssignGpuMemoryToTiles( 588 void TileManager::AssignGpuMemoryToTiles(
589 RasterTilePriorityQueue* raster_priority_queue, 589 RasterTilePriorityQueue* raster_priority_queue,
590 size_t scheduled_raster_task_limit, 590 size_t scheduled_raster_task_limit,
591 PrioritizedTileVector* tiles_that_need_to_be_rasterized) { 591 PrioritizedTileVector* tiles_that_need_to_be_rasterized) {
592 TRACE_EVENT_BEGIN0("cc", "TileManager::AssignGpuMemoryToTiles"); 592 TRACE_EVENT_BEGIN0("cc", "TileManager::AssignGpuMemoryToTiles");
593 593
594 DCHECK(resource_pool_); 594 DCHECK(resource_pool_);
595 DCHECK(tile_task_worker_pool_); 595 DCHECK(tile_task_manager_);
596 596
597 // Maintain the list of released resources that can potentially be re-used 597 // Maintain the list of released resources that can potentially be re-used
598 // or deleted. If this operation becomes expensive too, only do this after 598 // or deleted. If this operation becomes expensive too, only do this after
599 // some resource(s) was returned. Note that in that case, one also need to 599 // some resource(s) was returned. Note that in that case, one also need to
600 // invalidate when releasing some resource from the pool. 600 // invalidate when releasing some resource from the pool.
601 resource_pool_->CheckBusyResources(); 601 resource_pool_->CheckBusyResources();
602 602
603 // Now give memory out to the tiles until we're out, and build 603 // Now give memory out to the tiles until we're out, and build
604 // the needs-to-be-rasterized queue. 604 // the needs-to-be-rasterized queue.
605 unsigned schedule_priority = 1u; 605 unsigned schedule_priority = 1u;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 kAllDoneTaskPriority, all_count); 823 kAllDoneTaskPriority, all_count);
824 824
825 // We must reduce the amount of unused resoruces before calling 825 // We must reduce the amount of unused resoruces before calling
826 // ScheduleTasks to prevent usage from rising above limits. 826 // ScheduleTasks to prevent usage from rising above limits.
827 resource_pool_->ReduceResourceUsage(); 827 resource_pool_->ReduceResourceUsage();
828 image_decode_controller_->ReduceCacheUsage(); 828 image_decode_controller_->ReduceCacheUsage();
829 829
830 // Schedule running of |raster_queue_|. This replaces any previously 830 // Schedule running of |raster_queue_|. This replaces any previously
831 // scheduled tasks and effectively cancels all tasks not present 831 // scheduled tasks and effectively cancels all tasks not present
832 // in |raster_queue_|. 832 // in |raster_queue_|.
833 tile_task_worker_pool_->ScheduleTasks(&graph_); 833 tile_task_manager_->ScheduleTasks(&graph_);
834 834
835 // It's now safe to clean up orphan tasks as raster worker pool is not 835 // It's now safe to clean up orphan tasks as raster worker pool is not
836 // allowed to keep around unreferenced raster tasks after ScheduleTasks() has 836 // allowed to keep around unreferenced raster tasks after ScheduleTasks() has
837 // been called. 837 // been called.
838 orphan_tasks_.clear(); 838 orphan_tasks_.clear();
839 839
840 // It's also now safe to replace our *_done_task_ tasks. 840 // It's also now safe to replace our *_done_task_ tasks.
841 required_for_activation_done_task_ = 841 required_for_activation_done_task_ =
842 std::move(required_for_activation_done_task); 842 std::move(required_for_activation_done_task);
843 required_for_draw_done_task_ = std::move(required_for_draw_done_task); 843 required_for_draw_done_task_ = std::move(required_for_draw_done_task);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 954
955 client_->NotifyTileStateChanged(tile); 955 client_->NotifyTileStateChanged(tile);
956 } 956 }
957 957
958 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, 958 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info,
959 int layer_id, 959 int layer_id,
960 int source_frame_number, 960 int source_frame_number,
961 int flags) { 961 int flags) {
962 // We need to have a tile task worker pool to do anything meaningful with 962 // We need to have a tile task worker pool to do anything meaningful with
963 // tiles. 963 // tiles.
964 DCHECK(tile_task_worker_pool_); 964 DCHECK(tile_task_manager_);
965 ScopedTilePtr tile( 965 ScopedTilePtr tile(
966 new Tile(this, info, layer_id, source_frame_number, flags)); 966 new Tile(this, info, layer_id, source_frame_number, flags));
967 DCHECK(tiles_.find(tile->id()) == tiles_.end()); 967 DCHECK(tiles_.find(tile->id()) == tiles_.end());
968 968
969 tiles_[tile->id()] = tile.get(); 969 tiles_[tile->id()] = tile.get();
970 return tile; 970 return tile;
971 } 971 }
972 972
973 void TileManager::SetTileTaskWorkerPoolForTesting( 973 void TileManager::SetTileTaskManagerForTesting(
974 TileTaskWorkerPool* tile_task_worker_pool) { 974 TileTaskManager* tile_task_manager) {
975 tile_task_worker_pool_ = tile_task_worker_pool; 975 tile_task_manager_ = tile_task_manager;
976 } 976 }
977 977
978 bool TileManager::AreRequiredTilesReadyToDraw( 978 bool TileManager::AreRequiredTilesReadyToDraw(
979 RasterTilePriorityQueue::Type type) const { 979 RasterTilePriorityQueue::Type type) const {
980 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 980 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
981 client_->BuildRasterQueue(global_state_.tree_priority, type)); 981 client_->BuildRasterQueue(global_state_.tree_priority, type));
982 // It is insufficient to check whether the raster queue we constructed is 982 // It is insufficient to check whether the raster queue we constructed is
983 // empty. The reason for this is that there are situations (rasterize on 983 // empty. The reason for this is that there are situations (rasterize on
984 // demand) when the tile both needs raster and it's ready to draw. Hence, we 984 // demand) when the tile both needs raster and it's ready to draw. Hence, we
985 // have to iterate the queue to check whether the required tiles are ready to 985 // have to iterate the queue to check whether the required tiles are ready to
(...skipping 22 matching lines...) Expand all
1008 } 1008 }
1009 1009
1010 bool TileManager::IsReadyToDraw() const { 1010 bool TileManager::IsReadyToDraw() const {
1011 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); 1011 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw");
1012 return AreRequiredTilesReadyToDraw( 1012 return AreRequiredTilesReadyToDraw(
1013 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); 1013 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW);
1014 } 1014 }
1015 1015
1016 void TileManager::CheckAndIssueSignals() { 1016 void TileManager::CheckAndIssueSignals() {
1017 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); 1017 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals");
1018 tile_task_worker_pool_->CheckForCompletedTasks(); 1018 tile_task_manager_->CheckForCompletedTasks();
1019 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 1019 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
1020 1020
1021 // Ready to activate. 1021 // Ready to activate.
1022 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { 1022 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) {
1023 signals_.ready_to_activate = false; 1023 signals_.ready_to_activate = false;
1024 if (IsReadyToActivate()) { 1024 if (IsReadyToActivate()) {
1025 TRACE_EVENT0("disabled-by-default-cc.debug", 1025 TRACE_EVENT0("disabled-by-default-cc.debug",
1026 "TileManager::CheckAndIssueSignals - ready to activate"); 1026 "TileManager::CheckAndIssueSignals - ready to activate");
1027 signals_.did_notify_ready_to_activate = true; 1027 signals_.did_notify_ready_to_activate = true;
1028 client_->NotifyReadyToActivate(); 1028 client_->NotifyReadyToActivate();
(...skipping 19 matching lines...) Expand all
1048 TRACE_EVENT0( 1048 TRACE_EVENT0(
1049 "disabled-by-default-cc.debug", 1049 "disabled-by-default-cc.debug",
1050 "TileManager::CheckAndIssueSignals - all tile tasks completed"); 1050 "TileManager::CheckAndIssueSignals - all tile tasks completed");
1051 signals_.did_notify_all_tile_tasks_completed = true; 1051 signals_.did_notify_all_tile_tasks_completed = true;
1052 client_->NotifyAllTileTasksCompleted(); 1052 client_->NotifyAllTileTasksCompleted();
1053 } 1053 }
1054 } 1054 }
1055 } 1055 }
1056 1056
1057 void TileManager::CheckIfMoreTilesNeedToBePrepared() { 1057 void TileManager::CheckIfMoreTilesNeedToBePrepared() {
1058 tile_task_worker_pool_->CheckForCompletedTasks(); 1058 tile_task_manager_->CheckForCompletedTasks();
1059 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; 1059 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
1060 1060
1061 // When OOM, keep re-assigning memory until we reach a steady state 1061 // When OOM, keep re-assigning memory until we reach a steady state
1062 // where top-priority tiles are initialized. 1062 // where top-priority tiles are initialized.
1063 PrioritizedTileVector tiles_that_need_to_be_rasterized; 1063 PrioritizedTileVector tiles_that_need_to_be_rasterized;
1064 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 1064 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
1065 client_->BuildRasterQueue(global_state_.tree_priority, 1065 client_->BuildRasterQueue(global_state_.tree_priority,
1066 RasterTilePriorityQueue::Type::ALL)); 1066 RasterTilePriorityQueue::Type::ALL));
1067 AssignGpuMemoryToTiles(raster_priority_queue.get(), 1067 AssignGpuMemoryToTiles(raster_priority_queue.get(),
1068 scheduled_raster_task_limit_, 1068 scheduled_raster_task_limit_,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 Tile* tile = queue->Top().tile(); 1135 Tile* tile = queue->Top().tile();
1136 if (tile->draw_info().IsReadyToDraw()) 1136 if (tile->draw_info().IsReadyToDraw())
1137 continue; 1137 continue;
1138 tile->draw_info().set_oom(); 1138 tile->draw_info().set_oom();
1139 client_->NotifyTileStateChanged(tile); 1139 client_->NotifyTileStateChanged(tile);
1140 } 1140 }
1141 return true; 1141 return true;
1142 } 1142 }
1143 1143
1144 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { 1144 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const {
1145 return tile_task_worker_pool_->GetResourceFormat(!tile->is_opaque()); 1145 return tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat(
1146 !tile->is_opaque());
1146 } 1147 }
1147 1148
1148 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { 1149 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const {
1149 return tile_task_worker_pool_->GetResourceRequiresSwizzle(!tile->is_opaque()); 1150 return tile_task_manager_->GetRasterBufferProvider()
1151 ->GetResourceRequiresSwizzle(!tile->is_opaque());
1150 } 1152 }
1151 1153
1152 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1154 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1153 TileManager::ScheduledTasksStateAsValue() const { 1155 TileManager::ScheduledTasksStateAsValue() const {
1154 std::unique_ptr<base::trace_event::TracedValue> state( 1156 std::unique_ptr<base::trace_event::TracedValue> state(
1155 new base::trace_event::TracedValue()); 1157 new base::trace_event::TracedValue());
1156 state->BeginDictionary("tasks_pending"); 1158 state->BeginDictionary("tasks_pending");
1157 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); 1159 state->SetBoolean("ready_to_activate", signals_.ready_to_activate);
1158 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); 1160 state->SetBoolean("ready_to_draw", signals_.ready_to_draw);
1159 state->SetBoolean("all_tile_tasks_completed", 1161 state->SetBoolean("all_tile_tasks_completed",
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 void TileManager::Signals::reset() { 1243 void TileManager::Signals::reset() {
1242 ready_to_activate = false; 1244 ready_to_activate = false;
1243 did_notify_ready_to_activate = false; 1245 did_notify_ready_to_activate = false;
1244 ready_to_draw = false; 1246 ready_to_draw = false;
1245 did_notify_ready_to_draw = false; 1247 did_notify_ready_to_draw = false;
1246 all_tile_tasks_completed = false; 1248 all_tile_tasks_completed = false;
1247 did_notify_all_tile_tasks_completed = false; 1249 did_notify_all_tile_tasks_completed = false;
1248 } 1250 }
1249 1251
1250 } // namespace cc 1252 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698