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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 more_tiles_need_prepare_check_notifier_( | 359 more_tiles_need_prepare_check_notifier_( |
| 360 task_runner_, | 360 task_runner_, |
| 361 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, | 361 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, |
| 362 base::Unretained(this))), | 362 base::Unretained(this))), |
| 363 signals_check_notifier_(task_runner_, | 363 signals_check_notifier_(task_runner_, |
| 364 base::Bind(&TileManager::CheckAndIssueSignals, | 364 base::Bind(&TileManager::CheckAndIssueSignals, |
| 365 base::Unretained(this))), | 365 base::Unretained(this))), |
| 366 has_scheduled_tile_tasks_(false), | 366 has_scheduled_tile_tasks_(false), |
| 367 prepare_tiles_count_(0u), | 367 prepare_tiles_count_(0u), |
| 368 next_tile_id_(0u), | 368 next_tile_id_(0u), |
| 369 task_set_finished_weak_ptr_factory_(this) {} | 369 task_set_finished_weak_ptr_factory_(this), |
| 370 ready_to_draw_callback_weak_ptr_factory_(this) {} | |
| 370 | 371 |
| 371 TileManager::~TileManager() { | 372 TileManager::~TileManager() { |
| 372 FinishTasksAndCleanUp(); | 373 FinishTasksAndCleanUp(); |
| 373 } | 374 } |
| 374 | 375 |
| 375 void TileManager::FinishTasksAndCleanUp() { | 376 void TileManager::FinishTasksAndCleanUp() { |
| 376 if (!tile_task_manager_) | 377 if (!tile_task_manager_) |
| 377 return; | 378 return; |
| 378 | 379 |
| 379 global_state_ = GlobalStateThatImpactsTilePriority(); | 380 global_state_ = GlobalStateThatImpactsTilePriority(); |
| 380 | 381 |
| 381 // This cancels tasks if possible, finishes pending tasks, and release any | 382 // This cancels tasks if possible, finishes pending tasks, and release any |
| 382 // uninitialized resources. | 383 // uninitialized resources. |
| 383 tile_task_manager_->Shutdown(); | 384 tile_task_manager_->Shutdown(); |
| 384 | 385 |
| 385 raster_buffer_provider_->Shutdown(); | 386 raster_buffer_provider_->Shutdown(); |
| 386 | 387 |
| 387 tile_task_manager_->CheckForCompletedTasks(); | 388 tile_task_manager_->CheckForCompletedTasks(); |
| 388 | 389 |
| 389 FreeResourcesForReleasedTiles(); | 390 FreeResourcesForReleasedTiles(); |
| 390 CleanUpReleasedTiles(); | 391 CleanUpReleasedTiles(); |
| 391 | 392 |
| 392 tile_task_manager_ = nullptr; | 393 tile_task_manager_ = nullptr; |
| 393 resource_pool_ = nullptr; | 394 resource_pool_ = nullptr; |
| 394 more_tiles_need_prepare_check_notifier_.Cancel(); | 395 more_tiles_need_prepare_check_notifier_.Cancel(); |
| 395 signals_check_notifier_.Cancel(); | 396 signals_check_notifier_.Cancel(); |
| 396 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 397 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 398 ready_to_draw_callback_weak_ptr_factory_.InvalidateWeakPtrs(); | |
| 397 | 399 |
| 398 image_controller_.SetImageDecodeCache(nullptr); | 400 image_controller_.SetImageDecodeCache(nullptr); |
| 399 locked_image_tasks_.clear(); | 401 locked_image_tasks_.clear(); |
| 400 } | 402 } |
| 401 | 403 |
| 402 void TileManager::SetResources(ResourcePool* resource_pool, | 404 void TileManager::SetResources(ResourcePool* resource_pool, |
| 403 ImageDecodeCache* image_decode_cache, | 405 ImageDecodeCache* image_decode_cache, |
| 404 TaskGraphRunner* task_graph_runner, | 406 TaskGraphRunner* task_graph_runner, |
| 405 RasterBufferProvider* raster_buffer_provider, | 407 RasterBufferProvider* raster_buffer_provider, |
| 406 size_t scheduled_raster_task_limit, | 408 size_t scheduled_raster_task_limit, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 // We need to call CheckForCompletedTasks() once in-between each call | 507 // We need to call CheckForCompletedTasks() once in-between each call |
| 506 // to ScheduleTasks() to prevent canceled tasks from being scheduled. | 508 // to ScheduleTasks() to prevent canceled tasks from being scheduled. |
| 507 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { | 509 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { |
| 508 tile_task_manager_->CheckForCompletedTasks(); | 510 tile_task_manager_->CheckForCompletedTasks(); |
| 509 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 511 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 510 } | 512 } |
| 511 | 513 |
| 512 FreeResourcesForReleasedTiles(); | 514 FreeResourcesForReleasedTiles(); |
| 513 CleanUpReleasedTiles(); | 515 CleanUpReleasedTiles(); |
| 514 | 516 |
| 517 // The required for activate/draw status of tiles may have changed any time | |
| 518 // PrepareTiles is called. If we have any |pending_ready_to_draw_tiles_|, | |
| 519 // set a flag so we know to re-compute these requirements. | |
| 520 if (!pending_ready_for_draw_tiles_.empty()) | |
|
vmpstr
2016/12/14 18:03:31
If it's empty, then we won't do much work anyway.
ericrk
2016/12/14 19:53:48
true enough...
| |
| 521 pending_tile_requirements_dirty_ = true; | |
| 522 | |
| 515 PrioritizedWorkToSchedule prioritized_work = AssignGpuMemoryToTiles(); | 523 PrioritizedWorkToSchedule prioritized_work = AssignGpuMemoryToTiles(); |
| 516 | 524 |
| 517 // Inform the client that will likely require a draw if the highest priority | 525 // Inform the client that will likely require a draw if the highest priority |
| 518 // tile that will be rasterized is required for draw. | 526 // tile that will be rasterized is required for draw. |
| 519 client_->SetIsLikelyToRequireADraw( | 527 client_->SetIsLikelyToRequireADraw( |
| 520 !prioritized_work.tiles_to_raster.empty() && | 528 !prioritized_work.tiles_to_raster.empty() && |
| 521 prioritized_work.tiles_to_raster.front().tile()->required_for_draw()); | 529 prioritized_work.tiles_to_raster.front().tile()->required_for_draw()); |
| 522 | 530 |
| 523 // Schedule tile tasks. | 531 // Schedule tile tasks. |
| 524 ScheduleTasks(prioritized_work); | 532 ScheduleTasks(prioritized_work); |
| 525 | 533 |
| 526 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD, | 534 TRACE_EVENT_INSTANT1("cc", "DidPrepareTiles", TRACE_EVENT_SCOPE_THREAD, |
| 527 "state", BasicStateAsValue()); | 535 "state", BasicStateAsValue()); |
| 528 return true; | 536 return true; |
| 529 } | 537 } |
| 530 | 538 |
| 531 void TileManager::Flush() { | 539 void TileManager::Flush() { |
| 532 TRACE_EVENT0("cc", "TileManager::Flush"); | 540 TRACE_EVENT0("cc", "TileManager::Flush"); |
| 533 | 541 |
| 534 if (!tile_task_manager_) { | 542 if (!tile_task_manager_) { |
| 535 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); | 543 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); |
| 536 return; | 544 return; |
| 537 } | 545 } |
| 538 | 546 |
| 539 tile_task_manager_->CheckForCompletedTasks(); | 547 tile_task_manager_->CheckForCompletedTasks(); |
| 540 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 548 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 549 CheckPendingReadyToDrawTiles(true /* issue_signals */); | |
| 541 | 550 |
| 542 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", | 551 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", |
| 543 RasterTaskCompletionStatsAsValue(flush_stats_)); | 552 RasterTaskCompletionStatsAsValue(flush_stats_)); |
| 544 flush_stats_ = RasterTaskCompletionStats(); | 553 flush_stats_ = RasterTaskCompletionStats(); |
| 545 } | 554 } |
| 546 | 555 |
| 547 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 556 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 548 TileManager::BasicStateAsValue() const { | 557 TileManager::BasicStateAsValue() const { |
| 549 std::unique_ptr<base::trace_event::TracedValue> value( | 558 std::unique_ptr<base::trace_event::TracedValue> value( |
| 550 new base::trace_event::TracedValue()); | 559 new base::trace_event::TracedValue()); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 // or drop the tile for scheduling and raster. | 683 // or drop the tile for scheduling and raster. |
| 675 // TODO(sohanjg): Check if we could use a shared analysis | 684 // TODO(sohanjg): Check if we could use a shared analysis |
| 676 // canvas which is reset between tiles. | 685 // canvas which is reset between tiles. |
| 677 tile->set_solid_color_analysis_performed(true); | 686 tile->set_solid_color_analysis_performed(true); |
| 678 SkColor color = SK_ColorTRANSPARENT; | 687 SkColor color = SK_ColorTRANSPARENT; |
| 679 bool is_solid_color = | 688 bool is_solid_color = |
| 680 prioritized_tile.raster_source()->PerformSolidColorAnalysis( | 689 prioritized_tile.raster_source()->PerformSolidColorAnalysis( |
| 681 tile->content_rect(), tile->raster_scales(), &color); | 690 tile->content_rect(), tile->raster_scales(), &color); |
| 682 if (is_solid_color) { | 691 if (is_solid_color) { |
| 683 tile->draw_info().set_solid_color(color); | 692 tile->draw_info().set_solid_color(color); |
| 684 tile->draw_info().set_was_ever_ready_to_draw(); | |
| 685 if (!tile_is_needed_now) | 693 if (!tile_is_needed_now) |
| 686 tile->draw_info().set_was_a_prepaint_tile(); | 694 tile->draw_info().set_was_a_prepaint_tile(); |
| 687 client_->NotifyTileStateChanged(tile); | 695 client_->NotifyTileStateChanged(tile); |
| 688 continue; | 696 continue; |
| 689 } | 697 } |
| 690 } | 698 } |
| 691 | 699 |
| 692 // Prepaint tiles that are far away are only processed for images. | 700 // Prepaint tiles that are far away are only processed for images. |
| 693 if (!tile->required_for_activation() && !tile->required_for_draw() && | 701 if (!tile->required_for_activation() && !tile->required_for_draw() && |
| 694 prioritized_tile.is_process_for_images_only()) { | 702 prioritized_tile.is_process_for_images_only()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 "all_tiles_that_need_to_be_rasterized_are_scheduled", | 781 "all_tiles_that_need_to_be_rasterized_are_scheduled", |
| 774 all_tiles_that_need_to_be_rasterized_are_scheduled_, | 782 all_tiles_that_need_to_be_rasterized_are_scheduled_, |
| 775 "had_enough_memory_to_schedule_tiles_needed_now", | 783 "had_enough_memory_to_schedule_tiles_needed_now", |
| 776 had_enough_memory_to_schedule_tiles_needed_now); | 784 had_enough_memory_to_schedule_tiles_needed_now); |
| 777 return work_to_schedule; | 785 return work_to_schedule; |
| 778 } | 786 } |
| 779 | 787 |
| 780 void TileManager::FreeResourcesForTile(Tile* tile) { | 788 void TileManager::FreeResourcesForTile(Tile* tile) { |
| 781 TileDrawInfo& draw_info = tile->draw_info(); | 789 TileDrawInfo& draw_info = tile->draw_info(); |
| 782 if (draw_info.resource_) { | 790 if (draw_info.resource_) { |
| 783 resource_pool_->ReleaseResource(draw_info.resource_); | 791 resource_pool_->ReleaseResource(draw_info.resource_); |
|
vmpstr
2016/12/14 18:03:31
Can you add a TakeResource to the draw info that a
ericrk
2016/12/14 19:53:48
sure, added.
| |
| 784 draw_info.resource_ = nullptr; | 792 draw_info.set_resource(nullptr); |
| 785 } | 793 } |
| 786 } | 794 } |
| 787 | 795 |
| 788 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( | 796 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( |
| 789 Tile* tile) { | 797 Tile* tile) { |
| 790 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); | 798 bool was_ready_to_draw = tile->draw_info().IsReadyToDraw(); |
| 791 FreeResourcesForTile(tile); | 799 FreeResourcesForTile(tile); |
| 792 if (was_ready_to_draw) | 800 if (was_ready_to_draw) |
| 793 client_->NotifyTileStateChanged(tile); | 801 client_->NotifyTileStateChanged(tile); |
| 794 } | 802 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1029 | 1037 |
| 1030 if (was_canceled) { | 1038 if (was_canceled) { |
| 1031 ++flush_stats_.canceled_count; | 1039 ++flush_stats_.canceled_count; |
| 1032 resource_pool_->ReleaseResource(resource); | 1040 resource_pool_->ReleaseResource(resource); |
| 1033 return; | 1041 return; |
| 1034 } | 1042 } |
| 1035 | 1043 |
| 1036 resource_pool_->OnContentReplaced(resource->id(), tile->id()); | 1044 resource_pool_->OnContentReplaced(resource->id(), tile->id()); |
| 1037 ++flush_stats_.completed_count; | 1045 ++flush_stats_.completed_count; |
| 1038 | 1046 |
| 1039 draw_info.set_use_resource(); | 1047 draw_info.set_resource(resource); |
| 1040 draw_info.resource_ = resource; | |
| 1041 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); | 1048 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); |
| 1042 | 1049 if (global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY && |
| 1043 DCHECK(draw_info.IsReadyToDraw()); | 1050 !raster_buffer_provider_->IsResourceReadyToDraw(resource->id())) { |
| 1044 draw_info.set_was_ever_ready_to_draw(); | 1051 // In SMOOTHNESS_TAKES_PRIORITY mode, we wait for GPU work to complete |
| 1045 | 1052 // for a tile before setting it as ready to draw. |
| 1046 client_->NotifyTileStateChanged(tile); | 1053 pending_ready_for_draw_tiles_.push_back(tile); |
| 1054 } else { | |
| 1055 draw_info.set_resource_ready_for_draw(); | |
| 1056 client_->NotifyTileStateChanged(tile); | |
| 1057 } | |
| 1047 } | 1058 } |
| 1048 | 1059 |
| 1049 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, | 1060 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, |
| 1050 int layer_id, | 1061 int layer_id, |
| 1051 int source_frame_number, | 1062 int source_frame_number, |
| 1052 int flags) { | 1063 int flags) { |
| 1053 // We need to have a tile task worker pool to do anything meaningful with | 1064 // We need to have a tile task worker pool to do anything meaningful with |
| 1054 // tiles. | 1065 // tiles. |
| 1055 DCHECK(tile_task_manager_); | 1066 DCHECK(tile_task_manager_); |
| 1056 ScopedTilePtr tile( | 1067 ScopedTilePtr tile( |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1085 Tile* tile = all_queue->Top().tile(); | 1096 Tile* tile = all_queue->Top().tile(); |
| 1086 DCHECK(!tile->required_for_activation() || | 1097 DCHECK(!tile->required_for_activation() || |
| 1087 tile->draw_info().IsReadyToDraw()); | 1098 tile->draw_info().IsReadyToDraw()); |
| 1088 } | 1099 } |
| 1089 #endif | 1100 #endif |
| 1090 return true; | 1101 return true; |
| 1091 } | 1102 } |
| 1092 | 1103 |
| 1093 bool TileManager::IsReadyToActivate() const { | 1104 bool TileManager::IsReadyToActivate() const { |
| 1094 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); | 1105 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
| 1095 return AreRequiredTilesReadyToDraw( | 1106 return pending_required_for_activation_callback_id_ == 0 && |
| 1096 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | 1107 AreRequiredTilesReadyToDraw( |
| 1108 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); | |
| 1097 } | 1109 } |
| 1098 | 1110 |
| 1099 bool TileManager::IsReadyToDraw() const { | 1111 bool TileManager::IsReadyToDraw() const { |
| 1100 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); | 1112 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); |
| 1101 return AreRequiredTilesReadyToDraw( | 1113 return pending_required_for_draw_callback_id_ == 0 && |
| 1102 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 1114 AreRequiredTilesReadyToDraw( |
| 1115 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | |
| 1103 } | 1116 } |
| 1104 | 1117 |
| 1105 void TileManager::CheckAndIssueSignals() { | 1118 void TileManager::CheckAndIssueSignals() { |
| 1106 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); | 1119 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); |
| 1107 tile_task_manager_->CheckForCompletedTasks(); | 1120 tile_task_manager_->CheckForCompletedTasks(); |
| 1108 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1121 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1109 | 1122 |
| 1123 CheckPendingReadyToDrawTiles(false /* issue_signals */); | |
| 1124 | |
| 1110 // Ready to activate. | 1125 // Ready to activate. |
| 1111 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { | 1126 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { |
| 1112 signals_.ready_to_activate = false; | 1127 signals_.ready_to_activate = false; |
| 1113 if (IsReadyToActivate()) { | 1128 if (IsReadyToActivate()) { |
| 1114 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 1129 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 1115 "TileManager::CheckAndIssueSignals - ready to activate"); | 1130 "TileManager::CheckAndIssueSignals - ready to activate"); |
| 1116 signals_.did_notify_ready_to_activate = true; | 1131 signals_.did_notify_ready_to_activate = true; |
| 1117 client_->NotifyReadyToActivate(); | 1132 client_->NotifyReadyToActivate(); |
| 1118 } | 1133 } |
| 1119 } | 1134 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 signals_.all_tile_tasks_completed); | 1268 signals_.all_tile_tasks_completed); |
| 1254 state->EndDictionary(); | 1269 state->EndDictionary(); |
| 1255 return std::move(state); | 1270 return std::move(state); |
| 1256 } | 1271 } |
| 1257 | 1272 |
| 1258 bool TileManager::UsePartialRaster() const { | 1273 bool TileManager::UsePartialRaster() const { |
| 1259 return use_partial_raster_ && | 1274 return use_partial_raster_ && |
| 1260 raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); | 1275 raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); |
| 1261 } | 1276 } |
| 1262 | 1277 |
| 1278 void TileManager::CheckPendingReadyToDrawTiles(bool issue_signals) { | |
| 1279 bool in_smoothness_mode = | |
| 1280 global_state_.tree_priority == SMOOTHNESS_TAKES_PRIORITY; | |
| 1281 ResourceProvider::ResourceIdArray required_for_activation_ids; | |
| 1282 ResourceProvider::ResourceIdArray required_for_draw_ids; | |
| 1283 | |
| 1284 for (auto it = pending_ready_for_draw_tiles_.begin(); | |
| 1285 it != pending_ready_for_draw_tiles_.end();) { | |
| 1286 Tile* tile = *it; | |
| 1287 Resource* resource = tile->draw_info().resource_; | |
|
vmpstr
2016/12/14 18:03:31
Can you change this to a getter instead?
ericrk
2016/12/14 19:53:48
Done.
| |
| 1288 if (!resource) { | |
| 1289 // The tile has been evicted or deleted. Remove it from our list. | |
| 1290 it = pending_ready_for_draw_tiles_.erase(it); | |
| 1291 continue; | |
| 1292 } | |
| 1293 | |
| 1294 if (!in_smoothness_mode || | |
| 1295 raster_buffer_provider_->IsResourceReadyToDraw(resource->id())) { | |
| 1296 // Tile is ready to draw. | |
| 1297 tile->draw_info().set_resource_ready_for_draw(); | |
| 1298 client_->NotifyTileStateChanged(tile); | |
| 1299 it = pending_ready_for_draw_tiles_.erase(it); | |
| 1300 continue; | |
| 1301 } | |
| 1302 | |
| 1303 if (pending_tile_requirements_dirty_) | |
| 1304 tile->tiling()->UpdateRequiredStatesOnTile(tile); | |
| 1305 if (tile->required_for_activation()) | |
| 1306 required_for_activation_ids.push_back(resource->id()); | |
| 1307 if (tile->required_for_draw()) | |
| 1308 required_for_draw_ids.push_back(resource->id()); | |
| 1309 | |
| 1310 ++it; | |
| 1311 } | |
| 1312 | |
| 1313 if (required_for_activation_ids.empty()) { | |
| 1314 pending_required_for_activation_callback_id_ = 0; | |
| 1315 } else { | |
| 1316 pending_required_for_activation_callback_id_ = | |
| 1317 raster_buffer_provider_->SetReadyToDrawCallback( | |
| 1318 required_for_activation_ids, | |
| 1319 base::Bind(&TileManager::CheckPendingReadyToDrawTiles, | |
| 1320 ready_to_draw_callback_weak_ptr_factory_.GetWeakPtr(), | |
| 1321 true /* issue_signals */), | |
| 1322 pending_required_for_activation_callback_id_); | |
| 1323 } | |
| 1324 | |
| 1325 if (required_for_draw_ids.empty()) { | |
| 1326 pending_required_for_draw_callback_id_ = 0; | |
| 1327 } else { | |
| 1328 pending_required_for_draw_callback_id_ = | |
| 1329 raster_buffer_provider_->SetReadyToDrawCallback( | |
| 1330 required_for_draw_ids, | |
| 1331 base::Bind(&TileManager::CheckPendingReadyToDrawTiles, | |
| 1332 ready_to_draw_callback_weak_ptr_factory_.GetWeakPtr(), | |
| 1333 true /* issue_signals */), | |
| 1334 pending_required_for_draw_callback_id_); | |
| 1335 } | |
| 1336 | |
| 1337 // Update our signals now that we know whether we have pending resources. | |
| 1338 signals_.ready_to_activate = | |
|
vmpstr
2016/12/14 18:03:31
I think there might be some counter-intuitive inte
ericrk
2016/12/14 19:53:48
Looked through the code. I believe this is prevent
| |
| 1339 (pending_required_for_activation_callback_id_ == 0); | |
| 1340 signals_.ready_to_draw = (pending_required_for_draw_callback_id_ == 0); | |
| 1341 | |
| 1342 if (issue_signals && (signals_.ready_to_activate || signals_.ready_to_draw)) | |
| 1343 signals_check_notifier_.Schedule(); | |
| 1344 | |
| 1345 // We've just updated all pending tile requirements if necessary. | |
| 1346 pending_tile_requirements_dirty_ = false; | |
| 1347 } | |
| 1348 | |
| 1263 // Utility function that can be used to create a "Task set finished" task that | 1349 // Utility function that can be used to create a "Task set finished" task that |
| 1264 // posts |callback| to |task_runner| when run. | 1350 // posts |callback| to |task_runner| when run. |
| 1265 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 1351 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( |
| 1266 void (TileManager::*callback)()) { | 1352 void (TileManager::*callback)()) { |
| 1267 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 1353 return make_scoped_refptr(new TaskSetFinishedTaskImpl( |
| 1268 task_runner_, | 1354 task_runner_, |
| 1269 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); | 1355 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); |
| 1270 } | 1356 } |
| 1271 | 1357 |
| 1272 TileManager::MemoryUsage::MemoryUsage() | 1358 TileManager::MemoryUsage::MemoryUsage() |
| 1273 : memory_bytes_(0), resource_count_(0) {} | 1359 : memory_bytes_(0), resource_count_(0) {} |
| 1274 | 1360 |
| 1275 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, | 1361 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, |
| 1276 size_t resource_count) | 1362 size_t resource_count) |
| 1277 : memory_bytes_(static_cast<int64_t>(memory_bytes)), | 1363 : memory_bytes_(static_cast<int64_t>(memory_bytes)), |
| 1278 resource_count_(static_cast<int>(resource_count)) { | 1364 resource_count_(static_cast<int>(resource_count)) { |
| 1279 // MemoryUsage is constructed using size_ts, since it deals with memory and | 1365 // MemoryUsage is constructed using size_ts, since it deals with memory and |
| 1280 // the inputs are typically size_t. However, during the course of usage (in | 1366 // the inputs are typically size_t. However, during the course of usage (in |
| 1281 // particular operator-=) can cause internal values to become negative. Thus, | 1367 // particular operator-=) can cause internal values to become negative. |
| 1282 // member variables are signed. | 1368 // Thus, member variables are signed. |
| 1283 DCHECK_LE(memory_bytes, | 1369 DCHECK_LE(memory_bytes, |
| 1284 static_cast<size_t>(std::numeric_limits<int64_t>::max())); | 1370 static_cast<size_t>(std::numeric_limits<int64_t>::max())); |
| 1285 DCHECK_LE(resource_count, | 1371 DCHECK_LE(resource_count, |
| 1286 static_cast<size_t>(std::numeric_limits<int>::max())); | 1372 static_cast<size_t>(std::numeric_limits<int>::max())); |
| 1287 } | 1373 } |
| 1288 | 1374 |
| 1289 // static | 1375 // static |
| 1290 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( | 1376 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( |
| 1291 const gfx::Size& size, | 1377 const gfx::Size& size, |
| 1292 ResourceFormat format) { | 1378 ResourceFormat format) { |
| 1293 // We can use UncheckedSizeInBytes here since this is used with a tile | 1379 // We can use UncheckedSizeInBytes here since this is used with a tile |
| 1294 // size which is determined by the compositor (it's at most max texture size). | 1380 // size which is determined by the compositor (it's at most max texture |
| 1381 // size). | |
| 1295 return MemoryUsage(ResourceUtil::UncheckedSizeInBytes<size_t>(size, format), | 1382 return MemoryUsage(ResourceUtil::UncheckedSizeInBytes<size_t>(size, format), |
| 1296 1); | 1383 1); |
| 1297 } | 1384 } |
| 1298 | 1385 |
| 1299 // static | 1386 // static |
| 1300 TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) { | 1387 TileManager::MemoryUsage TileManager::MemoryUsage::FromTile(const Tile* tile) { |
| 1301 const TileDrawInfo& draw_info = tile->draw_info(); | 1388 const TileDrawInfo& draw_info = tile->draw_info(); |
| 1302 if (draw_info.resource_) { | 1389 if (draw_info.resource_) { |
| 1303 return MemoryUsage::FromConfig(draw_info.resource_->size(), | 1390 return MemoryUsage::FromConfig(draw_info.resource_->size(), |
| 1304 draw_info.resource_->format()); | 1391 draw_info.resource_->format()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 all_tile_tasks_completed = false; | 1431 all_tile_tasks_completed = false; |
| 1345 did_notify_all_tile_tasks_completed = false; | 1432 did_notify_all_tile_tasks_completed = false; |
| 1346 } | 1433 } |
| 1347 | 1434 |
| 1348 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1435 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1349 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1436 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1350 PrioritizedWorkToSchedule&& other) = default; | 1437 PrioritizedWorkToSchedule&& other) = default; |
| 1351 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1438 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1352 | 1439 |
| 1353 } // namespace cc | 1440 } // namespace cc |
| OLD | NEW |