Chromium Code Reviews| 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 #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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 : client_(client), | 330 : client_(client), | 
| 331 task_runner_(std::move(task_runner)), | 331 task_runner_(std::move(task_runner)), | 
| 332 resource_pool_(nullptr), | 332 resource_pool_(nullptr), | 
| 333 tile_task_manager_(nullptr), | 333 tile_task_manager_(nullptr), | 
| 334 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 334 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 
| 335 use_partial_raster_(use_partial_raster), | 335 use_partial_raster_(use_partial_raster), | 
| 336 use_gpu_rasterization_(false), | 336 use_gpu_rasterization_(false), | 
| 337 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 337 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 
| 338 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 338 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 
| 339 did_oom_on_last_assign_(false), | 339 did_oom_on_last_assign_(false), | 
| 340 more_tiles_need_prepare_check_notifier_( | |
| 341 task_runner_.get(), | |
| 342 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, | |
| 343 base::Unretained(this))), | |
| 344 signals_check_notifier_(task_runner_.get(), | |
| 345 base::Bind(&TileManager::CheckAndIssueSignals, | |
| 346 base::Unretained(this))), | |
| 347 has_scheduled_tile_tasks_(false), | 340 has_scheduled_tile_tasks_(false), | 
| 348 prepare_tiles_count_(0u), | 341 prepare_tiles_count_(0u), | 
| 349 next_tile_id_(0u), | 342 next_tile_id_(0u), | 
| 350 task_set_finished_weak_ptr_factory_(this) {} | 343 task_set_finished_weak_ptr_factory_(this) {} | 
| 351 | 344 | 
| 352 TileManager::~TileManager() { | 345 TileManager::~TileManager() { | 
| 353 FinishTasksAndCleanUp(); | 346 FinishTasksAndCleanUp(); | 
| 354 } | 347 } | 
| 355 | 348 | 
| 356 void TileManager::FinishTasksAndCleanUp() { | 349 void TileManager::FinishTasksAndCleanUp() { | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 367 // |orphan_tasks_|. | 360 // |orphan_tasks_|. | 
| 368 orphan_tasks_.clear(); | 361 orphan_tasks_.clear(); | 
| 369 | 362 | 
| 370 tile_task_manager_->CheckForCompletedTasks(); | 363 tile_task_manager_->CheckForCompletedTasks(); | 
| 371 | 364 | 
| 372 FreeResourcesForReleasedTiles(); | 365 FreeResourcesForReleasedTiles(); | 
| 373 CleanUpReleasedTiles(); | 366 CleanUpReleasedTiles(); | 
| 374 | 367 | 
| 375 tile_task_manager_ = nullptr; | 368 tile_task_manager_ = nullptr; | 
| 376 resource_pool_ = nullptr; | 369 resource_pool_ = nullptr; | 
| 377 more_tiles_need_prepare_check_notifier_.Cancel(); | |
| 378 signals_check_notifier_.Cancel(); | |
| 379 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 370 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 
| 380 } | 371 } | 
| 381 | 372 | 
| 382 void TileManager::SetResources(ResourcePool* resource_pool, | 373 void TileManager::SetResources(ResourcePool* resource_pool, | 
| 383 ImageDecodeController* image_decode_controller, | 374 ImageDecodeController* image_decode_controller, | 
| 384 TileTaskManager* tile_task_manager, | 375 TileTaskManager* tile_task_manager, | 
| 385 size_t scheduled_raster_task_limit, | 376 size_t scheduled_raster_task_limit, | 
| 386 bool use_gpu_rasterization) { | 377 bool use_gpu_rasterization) { | 
| 387 DCHECK(!tile_task_manager_); | 378 DCHECK(!tile_task_manager_); | 
| 388 DCHECK(tile_task_manager); | 379 DCHECK(tile_task_manager); | 
| (...skipping 29 matching lines...) Expand all Loading... | |
| 418 delete tile; | 409 delete tile; | 
| 419 } | 410 } | 
| 420 released_tiles_.swap(tiles_to_retain); | 411 released_tiles_.swap(tiles_to_retain); | 
| 421 } | 412 } | 
| 422 | 413 | 
| 423 void TileManager::DidFinishRunningTileTasksRequiredForActivation() { | 414 void TileManager::DidFinishRunningTileTasksRequiredForActivation() { | 
| 424 TRACE_EVENT0("cc", | 415 TRACE_EVENT0("cc", | 
| 425 "TileManager::DidFinishRunningTileTasksRequiredForActivation"); | 416 "TileManager::DidFinishRunningTileTasksRequiredForActivation"); | 
| 426 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 417 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 
| 427 ScheduledTasksStateAsValue()); | 418 ScheduledTasksStateAsValue()); | 
| 428 signals_.ready_to_activate = true; | 419 DCHECK(tile_task_manager_); | 
| 
 
ericrk
2016/05/26 22:53:37
Why are we DCHECKing this here? if this is used in
 
 | |
| 429 signals_check_notifier_.Schedule(); | 420 CheckAndNotifyReadyToActivate(); | 
| 430 } | 421 } | 
| 431 | 422 | 
| 432 void TileManager::DidFinishRunningTileTasksRequiredForDraw() { | 423 void TileManager::DidFinishRunningTileTasksRequiredForDraw() { | 
| 433 TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw"); | 424 TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw"); | 
| 434 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 425 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 
| 435 ScheduledTasksStateAsValue()); | 426 ScheduledTasksStateAsValue()); | 
| 436 signals_.ready_to_draw = true; | 427 DCHECK(tile_task_manager_); | 
| 437 signals_check_notifier_.Schedule(); | 428 CheckAndNotifyReadyToDraw(); | 
| 438 } | 429 } | 
| 439 | 430 | 
| 440 void TileManager::DidFinishRunningAllTileTasks() { | 431 void TileManager::DidFinishRunningAllTileTasks() { | 
| 441 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); | 432 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); | 
| 442 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); | 433 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); | 
| 443 DCHECK(resource_pool_); | 434 DCHECK(resource_pool_); | 
| 444 DCHECK(tile_task_manager_); | 435 DCHECK(tile_task_manager_); | 
| 445 | 436 | 
| 446 has_scheduled_tile_tasks_ = false; | 437 has_scheduled_tile_tasks_ = false; | 
| 447 | 438 | 
| 448 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() > | 439 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() > | 
| 449 global_state_.soft_memory_limit_in_bytes; | 440 global_state_.soft_memory_limit_in_bytes; | 
| 450 | 441 | 
| 451 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && | 442 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && | 
| 452 !memory_usage_above_limit) { | 443 !memory_usage_above_limit) { | 
| 453 // TODO(ericrk): We should find a better way to safely handle re-entrant | 444 // TODO(ericrk): We should find a better way to safely handle re-entrant | 
| 
 
ericrk
2016/05/26 22:53:36
you can remove this TODO and close the associated
 
 | |
| 454 // notifications than always having to schedule a new task. | 445 // notifications than always having to schedule a new task. | 
| 455 // http://crbug.com/498439 | 446 // http://crbug.com/498439 | 
| 456 signals_.all_tile_tasks_completed = true; | 447 CheckAndNotifyAllTileTasksCompleted(); | 
| 457 signals_check_notifier_.Schedule(); | |
| 458 return; | 448 return; | 
| 459 } | 449 } | 
| 460 | 450 | 
| 461 more_tiles_need_prepare_check_notifier_.Schedule(); | 451 CheckIfMoreTilesNeedToBePrepared(); | 
| 462 } | 452 } | 
| 463 | 453 | 
| 464 bool TileManager::PrepareTiles( | 454 bool TileManager::PrepareTiles( | 
| 465 const GlobalStateThatImpactsTilePriority& state) { | 455 const GlobalStateThatImpactsTilePriority& state) { | 
| 466 ++prepare_tiles_count_; | 456 ++prepare_tiles_count_; | 
| 467 | 457 | 
| 468 TRACE_EVENT1("cc", "TileManager::PrepareTiles", "prepare_tiles_id", | 458 TRACE_EVENT1("cc", "TileManager::PrepareTiles", "prepare_tiles_id", | 
| 469 prepare_tiles_count_); | 459 prepare_tiles_count_); | 
| 470 | 460 | 
| 471 if (!tile_task_manager_) { | 461 if (!tile_task_manager_) { | 
| 472 TRACE_EVENT_INSTANT0("cc", "PrepareTiles aborted", | 462 TRACE_EVENT_INSTANT0("cc", "PrepareTiles aborted", | 
| 473 TRACE_EVENT_SCOPE_THREAD); | 463 TRACE_EVENT_SCOPE_THREAD); | 
| 474 return false; | 464 return false; | 
| 475 } | 465 } | 
| 476 | 466 | 
| 477 signals_.reset(); | |
| 478 global_state_ = state; | 467 global_state_ = state; | 
| 479 | 468 | 
| 480 // We need to call CheckForCompletedTasks() once in-between each call | 469 // We need to call CheckForCompletedTasks() once in-between each call | 
| 481 // to ScheduleTasks() to prevent canceled tasks from being scheduled. | 470 // to ScheduleTasks() to prevent canceled tasks from being scheduled. | 
| 482 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { | 471 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { | 
| 483 tile_task_manager_->CheckForCompletedTasks(); | 472 tile_task_manager_->CheckForCompletedTasks(); | 
| 484 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 473 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 
| 485 } | 474 } | 
| 486 | 475 | 
| 487 FreeResourcesForReleasedTiles(); | 476 FreeResourcesForReleasedTiles(); | 
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1069 return AreRequiredTilesReadyToDraw( | 1058 return AreRequiredTilesReadyToDraw( | 
| 1070 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 1059 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 
| 1071 } | 1060 } | 
| 1072 | 1061 | 
| 1073 bool TileManager::IsReadyToDraw() const { | 1062 bool TileManager::IsReadyToDraw() const { | 
| 1074 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); | 1063 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); | 
| 1075 return AreRequiredTilesReadyToDraw( | 1064 return AreRequiredTilesReadyToDraw( | 
| 1076 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 1065 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 
| 1077 } | 1066 } | 
| 1078 | 1067 | 
| 1079 void TileManager::CheckAndIssueSignals() { | 1068 void TileManager::CheckAndNotifyReadyToActivate() { | 
| 1080 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); | 1069 TRACE_EVENT0("cc", "TileManager::CheckAndNotifyReadyToActivate"); | 
| 1081 tile_task_manager_->CheckForCompletedTasks(); | 1070 tile_task_manager_->CheckForCompletedTasks(); | 
| 1082 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1071 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 
| 1083 | 1072 | 
| 1084 // Ready to activate. | 1073 // Ready to activate. | 
| 1085 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { | 1074 if (IsReadyToActivate()) { | 
| 1086 signals_.ready_to_activate = false; | 1075 TRACE_EVENT0( | 
| 1087 if (IsReadyToActivate()) { | 1076 "disabled-by-default-cc.debug", | 
| 1088 TRACE_EVENT0("disabled-by-default-cc.debug", | 1077 "TileManager::CheckAndNotifyReadyToActivate - ready to activate"); | 
| 1089 "TileManager::CheckAndIssueSignals - ready to activate"); | 1078 client_->NotifyReadyToActivate(); | 
| 1090 signals_.did_notify_ready_to_activate = true; | |
| 1091 client_->NotifyReadyToActivate(); | |
| 1092 } | |
| 1093 } | 1079 } | 
| 1080 } | |
| 1081 void TileManager::CheckAndNotifyReadyToDraw() { | |
| 1082 TRACE_EVENT0("cc", "TileManager::CheckAndNotifyReadyToDraw"); | |
| 1083 tile_task_manager_->CheckForCompletedTasks(); | |
| 1084 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | |
| 1094 | 1085 | 
| 1095 // Ready to draw. | 1086 // Ready to draw. | 
| 1096 if (signals_.ready_to_draw && !signals_.did_notify_ready_to_draw) { | 1087 if (IsReadyToDraw()) { | 
| 1097 signals_.ready_to_draw = false; | 1088 TRACE_EVENT0("disabled-by-default-cc.debug", | 
| 1098 if (IsReadyToDraw()) { | 1089 "TileManager::CheckAndNotifyReadyToDraw - ready to draw"); | 
| 1099 TRACE_EVENT0("disabled-by-default-cc.debug", | 1090 client_->NotifyReadyToDraw(); | 
| 1100 "TileManager::CheckAndIssueSignals - ready to draw"); | |
| 1101 signals_.did_notify_ready_to_draw = true; | |
| 1102 client_->NotifyReadyToDraw(); | |
| 1103 } | |
| 1104 } | |
| 1105 | |
| 1106 // All tile tasks completed. | |
| 1107 if (signals_.all_tile_tasks_completed && | |
| 1108 !signals_.did_notify_all_tile_tasks_completed) { | |
| 1109 signals_.all_tile_tasks_completed = false; | |
| 1110 if (!has_scheduled_tile_tasks_) { | |
| 1111 TRACE_EVENT0( | |
| 1112 "disabled-by-default-cc.debug", | |
| 1113 "TileManager::CheckAndIssueSignals - all tile tasks completed"); | |
| 1114 signals_.did_notify_all_tile_tasks_completed = true; | |
| 1115 client_->NotifyAllTileTasksCompleted(); | |
| 1116 } | |
| 1117 } | 1091 } | 
| 1118 } | 1092 } | 
| 1119 | 1093 | 
| 1094 void TileManager::CheckAndNotifyAllTileTasksCompleted() { | |
| 1095 TRACE_EVENT0("cc", "TileManager::CheckAndNotifyAllTileTasksCompleted"); | |
| 1096 tile_task_manager_->CheckForCompletedTasks(); | |
| 1097 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | |
| 1098 | |
| 1099 // All tile tasks completed. | |
| 1100 if (!has_scheduled_tile_tasks_) { | |
| 1101 TRACE_EVENT0("disabled-by-default-cc.debug", | |
| 1102 "TileManager::CheckAndNotifyAllTileTasksCompleted - all tile " | |
| 1103 "tasks completed"); | |
| 1104 client_->NotifyAllTileTasksCompleted(); | |
| 1105 } | |
| 1106 } | |
| 1107 | |
| 1120 void TileManager::CheckIfMoreTilesNeedToBePrepared() { | 1108 void TileManager::CheckIfMoreTilesNeedToBePrepared() { | 
| 1121 tile_task_manager_->CheckForCompletedTasks(); | 1109 tile_task_manager_->CheckForCompletedTasks(); | 
| 1122 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1110 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 
| 1123 | 1111 | 
| 1124 // When OOM, keep re-assigning memory until we reach a steady state | 1112 // When OOM, keep re-assigning memory until we reach a steady state | 
| 1125 // where top-priority tiles are initialized. | 1113 // where top-priority tiles are initialized. | 
| 1126 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 1114 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 
| 1127 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( | 1115 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( | 
| 1128 client_->BuildRasterQueue(global_state_.tree_priority, | 1116 client_->BuildRasterQueue(global_state_.tree_priority, | 
| 1129 RasterTilePriorityQueue::Type::ALL)); | 1117 RasterTilePriorityQueue::Type::ALL)); | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1142 if (!tiles_that_need_to_be_rasterized.empty()) { | 1130 if (!tiles_that_need_to_be_rasterized.empty()) { | 
| 1143 ScheduleTasks(tiles_that_need_to_be_rasterized); | 1131 ScheduleTasks(tiles_that_need_to_be_rasterized); | 
| 1144 return; | 1132 return; | 
| 1145 } | 1133 } | 
| 1146 | 1134 | 
| 1147 FreeResourcesForReleasedTiles(); | 1135 FreeResourcesForReleasedTiles(); | 
| 1148 | 1136 | 
| 1149 resource_pool_->ReduceResourceUsage(); | 1137 resource_pool_->ReduceResourceUsage(); | 
| 1150 image_decode_controller_->ReduceCacheUsage(); | 1138 image_decode_controller_->ReduceCacheUsage(); | 
| 1151 | 1139 | 
| 1152 signals_.all_tile_tasks_completed = true; | 1140 bool need_to_signal_all_tile_tasks_completed = true; | 
| 
 
ericrk
2016/05/26 22:53:36
no need fo rthis variable if it's always true... j
 
 | |
| 1153 signals_check_notifier_.Schedule(); | |
| 1154 | 1141 | 
| 1155 // We don't reserve memory for required-for-activation tiles during | 1142 // We don't reserve memory for required-for-activation tiles during | 
| 1156 // accelerated gestures, so we just postpone activation when we don't | 1143 // accelerated gestures, so we just postpone activation when we don't | 
| 1157 // have these tiles, and activate after the accelerated gesture. | 1144 // have these tiles, and activate after the accelerated gesture. | 
| 1158 // Likewise if we don't allow any tiles (as is the case when we're | 1145 // Likewise if we don't allow any tiles (as is the case when we're | 
| 1159 // invisible), if we have tiles that aren't ready, then we shouldn't | 1146 // invisible), if we have tiles that aren't ready, then we shouldn't | 
| 1160 // activate as activation can cause checkerboards. | 1147 // activate as activation can cause checkerboards. | 
| 1161 bool wait_for_all_required_tiles = | 1148 bool wait_for_all_required_tiles = | 
| 1162 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY || | 1149 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY || | 
| 1163 global_state_.memory_limit_policy == ALLOW_NOTHING; | 1150 global_state_.memory_limit_policy == ALLOW_NOTHING; | 
| 1164 | 1151 | 
| 1165 // If we have tiles left to raster for activation, and we don't allow | 1152 // If we have tiles left to raster for activation, and we don't allow | 
| 1166 // activating without them, then skip activation and return early. | 1153 // activating without them, then skip activation and return early. | 
| 1167 if (wait_for_all_required_tiles) | 1154 if (wait_for_all_required_tiles) | 
| 1168 return; | 1155 return; | 
| 1169 | 1156 | 
| 1170 // Mark any required tiles that have not been been assigned memory after | 1157 // Mark any required tiles that have not been been assigned memory after | 
| 1171 // reaching a steady memory state as OOM. This ensures that we activate/draw | 1158 // reaching a steady memory state as OOM. This ensures that we activate/draw | 
| 1172 // even when OOM. Note that we can't reuse the queue we used for | 1159 // even when OOM. Note that we can't reuse the queue we used for | 
| 1173 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have | 1160 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have | 
| 1174 // evicted some tiles that would not be picked up by the old raster queue. | 1161 // evicted some tiles that would not be picked up by the old raster queue. | 
| 1175 bool need_to_signal_activate = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 1162 bool need_to_signal_activate = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 
| 1176 global_state_.tree_priority, | 1163 global_state_.tree_priority, | 
| 1177 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 1164 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 
| 1178 bool need_to_signal_draw = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 1165 bool need_to_signal_draw = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 
| 1179 global_state_.tree_priority, | 1166 global_state_.tree_priority, | 
| 1180 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 1167 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 
| 1181 | 1168 | 
| 1182 DCHECK(IsReadyToActivate()); | 1169 if (need_to_signal_activate) | 
| 1183 DCHECK(IsReadyToDraw()); | 1170 CheckAndNotifyReadyToActivate(); | 
| 1184 signals_.ready_to_activate = need_to_signal_activate; | 1171 | 
| 1185 signals_.ready_to_draw = need_to_signal_draw; | 1172 if (need_to_signal_draw) | 
| 1186 // TODO(ericrk): Investigate why we need to schedule this (not just call it | 1173 CheckAndNotifyReadyToDraw(); | 
| 1187 // inline). http://crbug.com/498439 | 1174 | 
| 1188 signals_check_notifier_.Schedule(); | 1175 if (need_to_signal_all_tile_tasks_completed) | 
| 1176 CheckAndNotifyAllTileTasksCompleted(); | |
| 1189 } | 1177 } | 
| 1190 | 1178 | 
| 1191 bool TileManager::MarkTilesOutOfMemory( | 1179 bool TileManager::MarkTilesOutOfMemory( | 
| 1192 std::unique_ptr<RasterTilePriorityQueue> queue) const { | 1180 std::unique_ptr<RasterTilePriorityQueue> queue) const { | 
| 1193 // Mark required tiles as OOM so that we can activate/draw without them. | 1181 // Mark required tiles as OOM so that we can activate/draw without them. | 
| 1194 if (queue->IsEmpty()) | 1182 if (queue->IsEmpty()) | 
| 1195 return false; | 1183 return false; | 
| 1196 | 1184 | 
| 1197 for (; !queue->IsEmpty(); queue->Pop()) { | 1185 for (; !queue->IsEmpty(); queue->Pop()) { | 
| 1198 Tile* tile = queue->Top().tile(); | 1186 Tile* tile = queue->Top().tile(); | 
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1212 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 1200 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 
| 1213 return tile_task_manager_->GetRasterBufferProvider() | 1201 return tile_task_manager_->GetRasterBufferProvider() | 
| 1214 ->GetResourceRequiresSwizzle(!tile->is_opaque()); | 1202 ->GetResourceRequiresSwizzle(!tile->is_opaque()); | 
| 1215 } | 1203 } | 
| 1216 | 1204 | 
| 1217 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 1205 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 
| 1218 TileManager::ScheduledTasksStateAsValue() const { | 1206 TileManager::ScheduledTasksStateAsValue() const { | 
| 1219 std::unique_ptr<base::trace_event::TracedValue> state( | 1207 std::unique_ptr<base::trace_event::TracedValue> state( | 
| 1220 new base::trace_event::TracedValue()); | 1208 new base::trace_event::TracedValue()); | 
| 1221 state->BeginDictionary("tasks_pending"); | 1209 state->BeginDictionary("tasks_pending"); | 
| 1222 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); | 1210 | 
| 1223 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 1211 // TODO(prashant.n): Modify this accordingly. | 
| 
 
ericrk
2016/05/26 22:53:36
We'll need to fix this before landing.
 
 | |
| 1224 state->SetBoolean("all_tile_tasks_completed", | 1212 // state->SetBoolean("ready_to_activate", signals_.ready_to_activate); | 
| 1225 signals_.all_tile_tasks_completed); | 1213 // state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 
| 1214 // state->SetBoolean("all_tile_tasks_completed", | |
| 1215 // signals_.all_tile_tasks_completed); | |
| 1216 | |
| 1226 state->EndDictionary(); | 1217 state->EndDictionary(); | 
| 1227 return std::move(state); | 1218 return std::move(state); | 
| 1228 } | 1219 } | 
| 1229 | 1220 | 
| 1230 // Utility function that can be used to create a "Task set finished" task that | 1221 // Utility function that can be used to create a "Task set finished" task that | 
| 1231 // posts |callback| to |task_runner| when run. | 1222 // posts |callback| to |task_runner| when run. | 
| 1232 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 1223 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 
| 1233 void (TileManager::*callback)()) { | 1224 void (TileManager::*callback)()) { | 
| 1234 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 1225 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 
| 1235 task_runner_.get(), | 1226 task_runner_.get(), | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1292 MemoryUsage result = *this; | 1283 MemoryUsage result = *this; | 
| 1293 result -= other; | 1284 result -= other; | 
| 1294 return result; | 1285 return result; | 
| 1295 } | 1286 } | 
| 1296 | 1287 | 
| 1297 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1288 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 
| 1298 return memory_bytes_ > limit.memory_bytes_ || | 1289 return memory_bytes_ > limit.memory_bytes_ || | 
| 1299 resource_count_ > limit.resource_count_; | 1290 resource_count_ > limit.resource_count_; | 
| 1300 } | 1291 } | 
| 1301 | 1292 | 
| 1302 TileManager::Signals::Signals() { | |
| 1303 reset(); | |
| 1304 } | |
| 1305 | |
| 1306 void TileManager::Signals::reset() { | |
| 1307 ready_to_activate = false; | |
| 1308 did_notify_ready_to_activate = false; | |
| 1309 ready_to_draw = false; | |
| 1310 did_notify_ready_to_draw = false; | |
| 1311 all_tile_tasks_completed = false; | |
| 1312 did_notify_all_tile_tasks_completed = false; | |
| 1313 } | |
| 1314 | |
| 1315 } // namespace cc | 1293 } // namespace cc | 
| OLD | NEW |