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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 TaskSetFinished(); | 268 TaskSetFinished(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Overridden from TileTask: | 271 // Overridden from TileTask: |
| 272 void OnTaskCompleted() override {} | 272 void OnTaskCompleted() override {} |
| 273 | 273 |
| 274 protected: | 274 protected: |
| 275 ~TaskSetFinishedTaskImpl() override {} | 275 ~TaskSetFinishedTaskImpl() override {} |
| 276 | 276 |
| 277 void TaskSetFinished() { | 277 void TaskSetFinished() { |
| 278 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); | 278 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); |
|
prashant.n
2016/06/02 01:16:46
Stack unwinding is ensured by PostTask(). This ens
vmpstr
2016/06/07 18:44:47
What thread is this run on? Maybe we can just call
prashant.n
2016/06/08 03:50:22
This is run on worker and we cannot call the callb
| |
| 279 } | 279 } |
| 280 | 280 |
| 281 private: | 281 private: |
| 282 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 282 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 283 const base::Closure on_task_set_finished_callback_; | 283 const base::Closure on_task_set_finished_callback_; |
| 284 | 284 |
| 285 DISALLOW_COPY_AND_ASSIGN(TaskSetFinishedTaskImpl); | 285 DISALLOW_COPY_AND_ASSIGN(TaskSetFinishedTaskImpl); |
| 286 }; | 286 }; |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 : client_(client), | 321 : client_(client), |
| 322 task_runner_(std::move(task_runner)), | 322 task_runner_(std::move(task_runner)), |
| 323 resource_pool_(nullptr), | 323 resource_pool_(nullptr), |
| 324 tile_task_manager_(nullptr), | 324 tile_task_manager_(nullptr), |
| 325 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 325 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
| 326 use_partial_raster_(use_partial_raster), | 326 use_partial_raster_(use_partial_raster), |
| 327 use_gpu_rasterization_(false), | 327 use_gpu_rasterization_(false), |
| 328 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 328 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
| 329 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 329 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
| 330 did_oom_on_last_assign_(false), | 330 did_oom_on_last_assign_(false), |
| 331 more_tiles_need_prepare_check_notifier_( | |
| 332 task_runner_.get(), | |
| 333 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, | |
| 334 base::Unretained(this))), | |
| 335 signals_check_notifier_(task_runner_.get(), | |
| 336 base::Bind(&TileManager::CheckAndIssueSignals, | |
| 337 base::Unretained(this))), | |
| 338 has_scheduled_tile_tasks_(false), | 331 has_scheduled_tile_tasks_(false), |
| 339 prepare_tiles_count_(0u), | 332 prepare_tiles_count_(0u), |
| 340 next_tile_id_(0u), | 333 next_tile_id_(0u), |
| 341 task_set_finished_weak_ptr_factory_(this) {} | 334 task_set_finished_weak_ptr_factory_(this) {} |
| 342 | 335 |
| 343 TileManager::~TileManager() { | 336 TileManager::~TileManager() { |
| 344 FinishTasksAndCleanUp(); | 337 FinishTasksAndCleanUp(); |
| 345 } | 338 } |
| 346 | 339 |
| 347 void TileManager::FinishTasksAndCleanUp() { | 340 void TileManager::FinishTasksAndCleanUp() { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 358 // |orphan_tasks_|. | 351 // |orphan_tasks_|. |
| 359 orphan_tasks_.clear(); | 352 orphan_tasks_.clear(); |
| 360 | 353 |
| 361 tile_task_manager_->CheckForCompletedTasks(); | 354 tile_task_manager_->CheckForCompletedTasks(); |
| 362 | 355 |
| 363 FreeResourcesForReleasedTiles(); | 356 FreeResourcesForReleasedTiles(); |
| 364 CleanUpReleasedTiles(); | 357 CleanUpReleasedTiles(); |
| 365 | 358 |
| 366 tile_task_manager_ = nullptr; | 359 tile_task_manager_ = nullptr; |
| 367 resource_pool_ = nullptr; | 360 resource_pool_ = nullptr; |
| 368 more_tiles_need_prepare_check_notifier_.Cancel(); | |
| 369 signals_check_notifier_.Cancel(); | |
| 370 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 361 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 371 } | 362 } |
| 372 | 363 |
| 373 void TileManager::SetResources(ResourcePool* resource_pool, | 364 void TileManager::SetResources(ResourcePool* resource_pool, |
| 374 ImageDecodeController* image_decode_controller, | 365 ImageDecodeController* image_decode_controller, |
| 375 TileTaskManager* tile_task_manager, | 366 TileTaskManager* tile_task_manager, |
| 376 size_t scheduled_raster_task_limit, | 367 size_t scheduled_raster_task_limit, |
| 377 bool use_gpu_rasterization) { | 368 bool use_gpu_rasterization) { |
| 378 DCHECK(!tile_task_manager_); | 369 DCHECK(!tile_task_manager_); |
| 379 DCHECK(tile_task_manager); | 370 DCHECK(tile_task_manager); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 404 | 395 |
| 405 DCHECK(!tile->draw_info().has_resource()); | 396 DCHECK(!tile->draw_info().has_resource()); |
| 406 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 397 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| 407 tiles_.erase(tile->id()); | 398 tiles_.erase(tile->id()); |
| 408 | 399 |
| 409 delete tile; | 400 delete tile; |
| 410 } | 401 } |
| 411 released_tiles_.swap(tiles_to_retain); | 402 released_tiles_.swap(tiles_to_retain); |
| 412 } | 403 } |
| 413 | 404 |
| 414 void TileManager::DidFinishRunningTileTasksRequiredForActivation() { | 405 void TileManager::DidFinishRunningTileTasksRequiredForActivation( |
| 406 uint64_t source_prepare_tiles_id) { | |
| 415 TRACE_EVENT0("cc", | 407 TRACE_EVENT0("cc", |
| 416 "TileManager::DidFinishRunningTileTasksRequiredForActivation"); | 408 "TileManager::DidFinishRunningTileTasksRequiredForActivation"); |
| 417 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 409 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| 418 ScheduledTasksStateAsValue()); | 410 ScheduledTasksStateAsValue()); |
| 411 | |
| 412 // Check if there is another request to PrepareTiles(). | |
| 413 if (prepare_tiles_count_ != source_prepare_tiles_id) | |
| 414 return; | |
|
prashant.n
2016/06/02 01:16:47
This is a separate thing which we did not take car
| |
| 415 | |
| 419 signals_.ready_to_activate = true; | 416 signals_.ready_to_activate = true; |
| 420 signals_check_notifier_.Schedule(); | 417 CheckAndNotifyReadyToActivate(); |
| 421 } | 418 } |
| 422 | 419 |
| 423 void TileManager::DidFinishRunningTileTasksRequiredForDraw() { | 420 void TileManager::DidFinishRunningTileTasksRequiredForDraw( |
| 421 uint64_t source_prepare_tiles_id) { | |
| 424 TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw"); | 422 TRACE_EVENT0("cc", "TileManager::DidFinishRunningTileTasksRequiredForDraw"); |
| 425 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 423 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
| 426 ScheduledTasksStateAsValue()); | 424 ScheduledTasksStateAsValue()); |
| 425 | |
| 426 // Check if there is another request to PrepareTiles(). | |
| 427 if (prepare_tiles_count_ != source_prepare_tiles_id) | |
| 428 return; | |
| 429 | |
| 427 signals_.ready_to_draw = true; | 430 signals_.ready_to_draw = true; |
| 428 signals_check_notifier_.Schedule(); | 431 CheckAndNotifyReadyToDraw(); |
| 429 } | 432 } |
| 430 | 433 |
| 431 void TileManager::DidFinishRunningAllTileTasks() { | 434 void TileManager::DidFinishRunningAllTileTasks( |
| 435 uint64_t source_prepare_tiles_id) { | |
| 432 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); | 436 TRACE_EVENT0("cc", "TileManager::DidFinishRunningAllTileTasks"); |
| 433 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); | 437 TRACE_EVENT_ASYNC_END0("cc", "ScheduledTasks", this); |
| 434 DCHECK(resource_pool_); | 438 |
| 435 DCHECK(tile_task_manager_); | 439 // Check if there is another request to PrepareTiles(). |
| 440 if (prepare_tiles_count_ != source_prepare_tiles_id) | |
| 441 return; | |
| 436 | 442 |
| 437 has_scheduled_tile_tasks_ = false; | 443 has_scheduled_tile_tasks_ = false; |
| 438 | 444 |
| 445 DCHECK(resource_pool_); | |
| 446 | |
| 439 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() > | 447 bool memory_usage_above_limit = resource_pool_->memory_usage_bytes() > |
| 440 global_state_.soft_memory_limit_in_bytes; | 448 global_state_.soft_memory_limit_in_bytes; |
| 441 | 449 |
| 442 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && | 450 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && |
| 443 !memory_usage_above_limit) { | 451 !memory_usage_above_limit) { |
| 444 // TODO(ericrk): We should find a better way to safely handle re-entrant | |
| 445 // notifications than always having to schedule a new task. | |
| 446 // http://crbug.com/498439 | |
| 447 signals_.all_tile_tasks_completed = true; | 452 signals_.all_tile_tasks_completed = true; |
| 448 signals_check_notifier_.Schedule(); | 453 CheckAndNotifyAllTileTasksCompleted(); |
| 449 return; | 454 return; |
| 450 } | 455 } |
| 451 | 456 |
| 452 more_tiles_need_prepare_check_notifier_.Schedule(); | 457 CheckIfMoreTilesNeedToBePrepared(); |
| 453 } | 458 } |
| 454 | 459 |
| 455 bool TileManager::PrepareTiles( | 460 bool TileManager::PrepareTiles( |
| 456 const GlobalStateThatImpactsTilePriority& state) { | 461 const GlobalStateThatImpactsTilePriority& state) { |
| 457 ++prepare_tiles_count_; | 462 ++prepare_tiles_count_; |
| 458 | 463 |
| 459 TRACE_EVENT1("cc", "TileManager::PrepareTiles", "prepare_tiles_id", | 464 TRACE_EVENT1("cc", "TileManager::PrepareTiles", "prepare_tiles_id", |
| 460 prepare_tiles_count_); | 465 prepare_tiles_count_); |
| 461 | 466 |
| 462 if (!tile_task_manager_) { | 467 if (!tile_task_manager_) { |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1045 return AreRequiredTilesReadyToDraw( | 1050 return AreRequiredTilesReadyToDraw( |
| 1046 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 1051 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
| 1047 } | 1052 } |
| 1048 | 1053 |
| 1049 bool TileManager::IsReadyToDraw() const { | 1054 bool TileManager::IsReadyToDraw() const { |
| 1050 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); | 1055 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); |
| 1051 return AreRequiredTilesReadyToDraw( | 1056 return AreRequiredTilesReadyToDraw( |
| 1052 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 1057 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
| 1053 } | 1058 } |
| 1054 | 1059 |
| 1055 void TileManager::CheckAndIssueSignals() { | 1060 void TileManager::CheckAndNotifyReadyToActivate() { |
| 1056 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); | 1061 TRACE_EVENT0("cc", "TileManager::CheckAndNotifyReadyToActivate"); |
| 1062 DCHECK(tile_task_manager_); | |
| 1063 | |
| 1057 tile_task_manager_->CheckForCompletedTasks(); | 1064 tile_task_manager_->CheckForCompletedTasks(); |
| 1058 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1065 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1059 | 1066 |
| 1060 // Ready to activate. | 1067 // Check if ready to activate and notification is not sent since |
| 1061 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { | 1068 // PrepareTiles() requested. |
| 1062 signals_.ready_to_activate = false; | 1069 if (!signals_.did_notify_ready_to_activate && IsReadyToActivate()) { |
|
prashant.n
2016/06/02 01:16:46
Unique notification per prepare tiles is ensured b
| |
| 1063 if (IsReadyToActivate()) { | 1070 TRACE_EVENT0( |
| 1064 TRACE_EVENT0("disabled-by-default-cc.debug", | 1071 "disabled-by-default-cc.debug", |
| 1065 "TileManager::CheckAndIssueSignals - ready to activate"); | 1072 "TileManager::CheckAndNotifyReadyToActivate - ready to activate"); |
| 1066 signals_.did_notify_ready_to_activate = true; | 1073 client_->NotifyReadyToActivate(); |
| 1067 client_->NotifyReadyToActivate(); | 1074 signals_.did_notify_ready_to_activate = true; |
| 1068 } | |
| 1069 } | 1075 } |
| 1076 } | |
| 1070 | 1077 |
| 1071 // Ready to draw. | 1078 void TileManager::CheckAndNotifyReadyToDraw() { |
| 1072 if (signals_.ready_to_draw && !signals_.did_notify_ready_to_draw) { | 1079 TRACE_EVENT0("cc", "TileManager::CheckAndNotifyReadyToDraw"); |
| 1073 signals_.ready_to_draw = false; | 1080 |
| 1074 if (IsReadyToDraw()) { | 1081 DCHECK(tile_task_manager_); |
| 1075 TRACE_EVENT0("disabled-by-default-cc.debug", | 1082 |
| 1076 "TileManager::CheckAndIssueSignals - ready to draw"); | 1083 tile_task_manager_->CheckForCompletedTasks(); |
| 1077 signals_.did_notify_ready_to_draw = true; | 1084 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1078 client_->NotifyReadyToDraw(); | 1085 |
| 1079 } | 1086 // Check if ready to draw and notification is not sent since |
| 1087 // PrepareTiles() requested. | |
| 1088 if (!signals_.did_notify_ready_to_draw && IsReadyToDraw()) { | |
| 1089 TRACE_EVENT0("disabled-by-default-cc.debug", | |
| 1090 "TileManager::CheckAndNotifyReadyToDraw - ready to draw"); | |
| 1091 signals_.did_notify_ready_to_draw = true; | |
| 1092 client_->NotifyReadyToDraw(); | |
| 1080 } | 1093 } |
| 1094 } | |
| 1081 | 1095 |
| 1082 // All tile tasks completed. | 1096 void TileManager::CheckAndNotifyAllTileTasksCompleted() { |
| 1083 if (signals_.all_tile_tasks_completed && | 1097 TRACE_EVENT0("cc", "TileManager::CheckAndNotifyAllTileTasksCompleted"); |
| 1084 !signals_.did_notify_all_tile_tasks_completed) { | 1098 |
| 1085 signals_.all_tile_tasks_completed = false; | 1099 DCHECK(tile_task_manager_); |
| 1086 if (!has_scheduled_tile_tasks_) { | 1100 tile_task_manager_->CheckForCompletedTasks(); |
| 1087 TRACE_EVENT0( | 1101 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1088 "disabled-by-default-cc.debug", | 1102 |
| 1089 "TileManager::CheckAndIssueSignals - all tile tasks completed"); | 1103 // Check if notification is not sent since PrepareTiles() requested. |
| 1090 signals_.did_notify_all_tile_tasks_completed = true; | 1104 if (!signals_.did_notify_all_tile_tasks_completed) { |
| 1091 client_->NotifyAllTileTasksCompleted(); | 1105 TRACE_EVENT0("disabled-by-default-cc.debug", |
| 1092 } | 1106 "TileManager::CheckAndNotifyAllTileTasksCompleted - all tile " |
| 1107 "tasks completed"); | |
| 1108 signals_.did_notify_all_tile_tasks_completed = true; | |
| 1109 client_->NotifyAllTileTasksCompleted(); | |
| 1093 } | 1110 } |
| 1094 } | 1111 } |
| 1095 | 1112 |
| 1096 void TileManager::CheckIfMoreTilesNeedToBePrepared() { | 1113 void TileManager::CheckIfMoreTilesNeedToBePrepared() { |
| 1114 DCHECK(tile_task_manager_); | |
| 1115 | |
| 1097 tile_task_manager_->CheckForCompletedTasks(); | 1116 tile_task_manager_->CheckForCompletedTasks(); |
| 1098 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1117 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1099 | 1118 |
| 1100 // When OOM, keep re-assigning memory until we reach a steady state | 1119 // When OOM, keep re-assigning memory until we reach a steady state |
| 1101 // where top-priority tiles are initialized. | 1120 // where top-priority tiles are initialized. |
| 1102 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 1121 PrioritizedTileVector tiles_that_need_to_be_rasterized; |
| 1103 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( | 1122 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 1104 client_->BuildRasterQueue(global_state_.tree_priority, | 1123 client_->BuildRasterQueue(global_state_.tree_priority, |
| 1105 RasterTilePriorityQueue::Type::ALL)); | 1124 RasterTilePriorityQueue::Type::ALL)); |
| 1106 AssignGpuMemoryToTiles(raster_priority_queue.get(), | 1125 AssignGpuMemoryToTiles(raster_priority_queue.get(), |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1118 if (!tiles_that_need_to_be_rasterized.empty()) { | 1137 if (!tiles_that_need_to_be_rasterized.empty()) { |
| 1119 ScheduleTasks(tiles_that_need_to_be_rasterized); | 1138 ScheduleTasks(tiles_that_need_to_be_rasterized); |
| 1120 return; | 1139 return; |
| 1121 } | 1140 } |
| 1122 | 1141 |
| 1123 FreeResourcesForReleasedTiles(); | 1142 FreeResourcesForReleasedTiles(); |
| 1124 | 1143 |
| 1125 resource_pool_->ReduceResourceUsage(); | 1144 resource_pool_->ReduceResourceUsage(); |
| 1126 image_decode_controller_->ReduceCacheUsage(); | 1145 image_decode_controller_->ReduceCacheUsage(); |
| 1127 | 1146 |
| 1128 signals_.all_tile_tasks_completed = true; | |
| 1129 signals_check_notifier_.Schedule(); | |
| 1130 | |
| 1131 // We don't reserve memory for required-for-activation tiles during | 1147 // We don't reserve memory for required-for-activation tiles during |
| 1132 // accelerated gestures, so we just postpone activation when we don't | 1148 // accelerated gestures, so we just postpone activation when we don't |
| 1133 // have these tiles, and activate after the accelerated gesture. | 1149 // have these tiles, and activate after the accelerated gesture. |
| 1134 // Likewise if we don't allow any tiles (as is the case when we're | 1150 // Likewise if we don't allow any tiles (as is the case when we're |
| 1135 // invisible), if we have tiles that aren't ready, then we shouldn't | 1151 // invisible), if we have tiles that aren't ready, then we shouldn't |
| 1136 // activate as activation can cause checkerboards. | 1152 // activate as activation can cause checkerboards. |
| 1137 bool wait_for_all_required_tiles = | 1153 bool wait_for_all_required_tiles = |
| 1138 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY || | 1154 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY || |
| 1139 global_state_.memory_limit_policy == ALLOW_NOTHING; | 1155 global_state_.memory_limit_policy == ALLOW_NOTHING; |
| 1140 | 1156 |
| 1141 // If we have tiles left to raster for activation, and we don't allow | 1157 // If we have tiles left to raster for activation, and we don't allow |
| 1142 // activating without them, then skip activation and return early. | 1158 // activating without them, then skip activation and return early. |
| 1143 if (wait_for_all_required_tiles) | 1159 if (wait_for_all_required_tiles) |
| 1144 return; | 1160 return; |
| 1145 | 1161 |
| 1146 // Mark any required tiles that have not been been assigned memory after | 1162 // Mark any required tiles that have not been been assigned memory after |
| 1147 // reaching a steady memory state as OOM. This ensures that we activate/draw | 1163 // reaching a steady memory state as OOM. This ensures that we activate/draw |
| 1148 // even when OOM. Note that we can't reuse the queue we used for | 1164 // even when OOM. Note that we can't reuse the queue we used for |
| 1149 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have | 1165 // AssignGpuMemoryToTiles, since the AssignGpuMemoryToTiles call could have |
| 1150 // evicted some tiles that would not be picked up by the old raster queue. | 1166 // evicted some tiles that would not be picked up by the old raster queue. |
| 1151 bool need_to_signal_activate = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 1167 bool need_to_signal_activate = MarkTilesOutOfMemory(client_->BuildRasterQueue( |
| 1152 global_state_.tree_priority, | 1168 global_state_.tree_priority, |
| 1153 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 1169 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 1154 bool need_to_signal_draw = MarkTilesOutOfMemory(client_->BuildRasterQueue( | 1170 bool need_to_signal_draw = MarkTilesOutOfMemory(client_->BuildRasterQueue( |
| 1155 global_state_.tree_priority, | 1171 global_state_.tree_priority, |
| 1156 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 1172 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
| 1157 | 1173 |
| 1158 DCHECK(IsReadyToActivate()); | 1174 DCHECK(IsReadyToActivate()); |
| 1159 DCHECK(IsReadyToDraw()); | 1175 DCHECK(IsReadyToDraw()); |
| 1160 signals_.ready_to_activate = need_to_signal_activate; | 1176 |
| 1161 signals_.ready_to_draw = need_to_signal_draw; | 1177 if (need_to_signal_activate) |
| 1162 // TODO(ericrk): Investigate why we need to schedule this (not just call it | 1178 CheckAndNotifyReadyToActivate(); |
| 1163 // inline). http://crbug.com/498439 | 1179 |
| 1164 signals_check_notifier_.Schedule(); | 1180 if (need_to_signal_draw) |
| 1181 CheckAndNotifyReadyToDraw(); | |
| 1182 | |
| 1183 CheckAndNotifyAllTileTasksCompleted(); | |
| 1165 } | 1184 } |
| 1166 | 1185 |
| 1167 bool TileManager::MarkTilesOutOfMemory( | 1186 bool TileManager::MarkTilesOutOfMemory( |
| 1168 std::unique_ptr<RasterTilePriorityQueue> queue) const { | 1187 std::unique_ptr<RasterTilePriorityQueue> queue) const { |
| 1169 // Mark required tiles as OOM so that we can activate/draw without them. | 1188 // Mark required tiles as OOM so that we can activate/draw without them. |
| 1170 if (queue->IsEmpty()) | 1189 if (queue->IsEmpty()) |
| 1171 return false; | 1190 return false; |
| 1172 | 1191 |
| 1173 for (; !queue->IsEmpty(); queue->Pop()) { | 1192 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1174 Tile* tile = queue->Top().tile(); | 1193 Tile* tile = queue->Top().tile(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1199 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 1218 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); |
| 1200 state->SetBoolean("all_tile_tasks_completed", | 1219 state->SetBoolean("all_tile_tasks_completed", |
| 1201 signals_.all_tile_tasks_completed); | 1220 signals_.all_tile_tasks_completed); |
| 1202 state->EndDictionary(); | 1221 state->EndDictionary(); |
| 1203 return std::move(state); | 1222 return std::move(state); |
| 1204 } | 1223 } |
| 1205 | 1224 |
| 1206 // Utility function that can be used to create a "Task set finished" task that | 1225 // Utility function that can be used to create a "Task set finished" task that |
| 1207 // posts |callback| to |task_runner| when run. | 1226 // posts |callback| to |task_runner| when run. |
| 1208 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 1227 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( |
| 1209 void (TileManager::*callback)()) { | 1228 void (TileManager::*callback)(uint64_t source_prepare_tiles_id)) { |
| 1210 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 1229 return make_scoped_refptr(new TaskSetFinishedTaskImpl( |
| 1211 task_runner_.get(), | 1230 task_runner_.get(), |
| 1212 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); | 1231 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr(), |
| 1232 prepare_tiles_count_))); | |
| 1213 } | 1233 } |
| 1214 | 1234 |
| 1215 TileManager::MemoryUsage::MemoryUsage() | 1235 TileManager::MemoryUsage::MemoryUsage() |
| 1216 : memory_bytes_(0), resource_count_(0) {} | 1236 : memory_bytes_(0), resource_count_(0) {} |
| 1217 | 1237 |
| 1218 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, | 1238 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, |
| 1219 size_t resource_count) | 1239 size_t resource_count) |
| 1220 : memory_bytes_(static_cast<int64_t>(memory_bytes)), | 1240 : memory_bytes_(static_cast<int64_t>(memory_bytes)), |
| 1221 resource_count_(static_cast<int>(resource_count)) { | 1241 resource_count_(static_cast<int>(resource_count)) { |
| 1222 // MemoryUsage is constructed using size_ts, since it deals with memory and | 1242 // MemoryUsage is constructed using size_ts, since it deals with memory and |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1282 void TileManager::Signals::reset() { | 1302 void TileManager::Signals::reset() { |
| 1283 ready_to_activate = false; | 1303 ready_to_activate = false; |
| 1284 did_notify_ready_to_activate = false; | 1304 did_notify_ready_to_activate = false; |
| 1285 ready_to_draw = false; | 1305 ready_to_draw = false; |
| 1286 did_notify_ready_to_draw = false; | 1306 did_notify_ready_to_draw = false; |
| 1287 all_tile_tasks_completed = false; | 1307 all_tile_tasks_completed = false; |
| 1288 did_notify_all_tile_tasks_completed = false; | 1308 did_notify_all_tile_tasks_completed = false; |
| 1289 } | 1309 } |
| 1290 | 1310 |
| 1291 } // namespace cc | 1311 } // namespace cc |
| OLD | NEW |