OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && | 229 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && |
230 !settings.single_thread_proxy_scheduler), | 230 !settings.single_thread_proxy_scheduler), |
231 // Must be initialized after is_synchronous_single_threaded_ and | 231 // Must be initialized after is_synchronous_single_threaded_ and |
232 // task_runner_provider_. | 232 // task_runner_provider_. |
233 tile_manager_(this, | 233 tile_manager_(this, |
234 GetTaskRunner(), | 234 GetTaskRunner(), |
235 std::move(image_worker_task_runner), | 235 std::move(image_worker_task_runner), |
236 is_synchronous_single_threaded_ | 236 is_synchronous_single_threaded_ |
237 ? std::numeric_limits<size_t>::max() | 237 ? std::numeric_limits<size_t>::max() |
238 : settings.scheduled_raster_task_limit, | 238 : settings.scheduled_raster_task_limit, |
239 settings.use_partial_raster, | 239 settings.ToTileManagerSettings()), |
240 settings.check_tile_priority_inversion), | |
241 pinch_gesture_active_(false), | 240 pinch_gesture_active_(false), |
242 pinch_gesture_end_should_clear_scrolling_layer_(false), | 241 pinch_gesture_end_should_clear_scrolling_layer_(false), |
243 fps_counter_( | 242 fps_counter_( |
244 FrameRateCounter::Create(task_runner_provider_->HasImplThread())), | 243 FrameRateCounter::Create(task_runner_provider_->HasImplThread())), |
245 memory_history_(MemoryHistory::Create()), | 244 memory_history_(MemoryHistory::Create()), |
246 debug_rect_history_(DebugRectHistory::Create()), | 245 debug_rect_history_(DebugRectHistory::Create()), |
247 max_memory_needed_bytes_(0), | 246 max_memory_needed_bytes_(0), |
248 resourceless_software_draw_(false), | 247 resourceless_software_draw_(false), |
249 mutator_host_(std::move(mutator_host)), | 248 mutator_host_(std::move(mutator_host)), |
250 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 249 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 if (compositor_frame_sink_) | 344 if (compositor_frame_sink_) |
346 compositor_frame_sink_->ForceReclaimResources(); | 345 compositor_frame_sink_->ForceReclaimResources(); |
347 | 346 |
348 if (!CommitToActiveTree()) | 347 if (!CommitToActiveTree()) |
349 CreatePendingTree(); | 348 CreatePendingTree(); |
350 } | 349 } |
351 | 350 |
352 void LayerTreeHostImpl::CommitComplete() { | 351 void LayerTreeHostImpl::CommitComplete() { |
353 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 352 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
354 | 353 |
| 354 UpdateSyncTreeAfterCommitOrImplSideInvalidation(); |
| 355 micro_benchmark_controller_.DidCompleteCommit(); |
| 356 } |
| 357 |
| 358 void LayerTreeHostImpl::UpdateSyncTreeAfterCommitOrImplSideInvalidation() { |
| 359 sync_tree()->InvalidateRegionForImages( |
| 360 tile_manager_.TakeImagesToInvalidateOnSyncTree()); |
| 361 |
355 if (CommitToActiveTree()) { | 362 if (CommitToActiveTree()) { |
356 // We have to activate animations here or "IsActive()" is true on the layers | 363 // We have to activate animations here or "IsActive()" is true on the layers |
357 // but the animations aren't activated yet so they get ignored by | 364 // but the animations aren't activated yet so they get ignored by |
358 // UpdateDrawProperties. | 365 // UpdateDrawProperties. |
359 ActivateAnimations(); | 366 ActivateAnimations(); |
360 } | 367 } |
361 | 368 |
362 // Start animations before UpdateDrawProperties and PrepareTiles, as they can | 369 // Start animations before UpdateDrawProperties and PrepareTiles, as they can |
363 // change the results. When doing commit to the active tree, this must happen | 370 // change the results. When doing commit to the active tree, this must happen |
364 // after ActivateAnimations() in order for this ticking to be propogated to | 371 // after ActivateAnimations() in order for this ticking to be propogated to |
(...skipping 21 matching lines...) Expand all Loading... |
386 if (!did_prepare_tiles) { | 393 if (!did_prepare_tiles) { |
387 NotifyReadyToActivate(); | 394 NotifyReadyToActivate(); |
388 | 395 |
389 // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This | 396 // Ensure we get ReadyToDraw signal even when PrepareTiles not run. This |
390 // is important for SingleThreadProxy and impl-side painting case. For | 397 // is important for SingleThreadProxy and impl-side painting case. For |
391 // STP, we commit to active tree and RequiresHighResToDraw, and set | 398 // STP, we commit to active tree and RequiresHighResToDraw, and set |
392 // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard. | 399 // Scheduler to wait for ReadyToDraw signal to avoid Checkerboard. |
393 if (CommitToActiveTree()) | 400 if (CommitToActiveTree()) |
394 NotifyReadyToDraw(); | 401 NotifyReadyToDraw(); |
395 } | 402 } |
396 | |
397 micro_benchmark_controller_.DidCompleteCommit(); | |
398 } | 403 } |
399 | 404 |
400 bool LayerTreeHostImpl::CanDraw() const { | 405 bool LayerTreeHostImpl::CanDraw() const { |
401 // Note: If you are changing this function or any other function that might | 406 // Note: If you are changing this function or any other function that might |
402 // affect the result of CanDraw, make sure to call | 407 // affect the result of CanDraw, make sure to call |
403 // client_->OnCanDrawStateChanged in the proper places and update the | 408 // client_->OnCanDrawStateChanged in the proper places and update the |
404 // NotifyIfCanDrawChanged test. | 409 // NotifyIfCanDrawChanged test. |
405 | 410 |
406 if (!compositor_frame_sink_) { | 411 if (!compositor_frame_sink_) { |
407 TRACE_EVENT_INSTANT0("cc", | 412 TRACE_EVENT_INSTANT0("cc", |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 | 1052 |
1048 void LayerTreeHostImpl::DidAnimateScrollOffset() { | 1053 void LayerTreeHostImpl::DidAnimateScrollOffset() { |
1049 client_->SetNeedsCommitOnImplThread(); | 1054 client_->SetNeedsCommitOnImplThread(); |
1050 client_->RenewTreePriority(); | 1055 client_->RenewTreePriority(); |
1051 } | 1056 } |
1052 | 1057 |
1053 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { | 1058 void LayerTreeHostImpl::SetViewportDamage(const gfx::Rect& damage_rect) { |
1054 viewport_damage_rect_.Union(damage_rect); | 1059 viewport_damage_rect_.Union(damage_rect); |
1055 } | 1060 } |
1056 | 1061 |
| 1062 void LayerTreeHostImpl::InvalidateContentOnImplSide() { |
| 1063 DCHECK(!pending_tree_); |
| 1064 |
| 1065 if (!CommitToActiveTree()) |
| 1066 CreatePendingTree(); |
| 1067 UpdateSyncTreeAfterCommitOrImplSideInvalidation(); |
| 1068 } |
| 1069 |
1057 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { | 1070 DrawResult LayerTreeHostImpl::PrepareToDraw(FrameData* frame) { |
1058 TRACE_EVENT1("cc", "LayerTreeHostImpl::PrepareToDraw", "SourceFrameNumber", | 1071 TRACE_EVENT1("cc", "LayerTreeHostImpl::PrepareToDraw", "SourceFrameNumber", |
1059 active_tree_->source_frame_number()); | 1072 active_tree_->source_frame_number()); |
1060 if (input_handler_client_) | 1073 if (input_handler_client_) |
1061 input_handler_client_->ReconcileElasticOverscrollAndRootScroll(); | 1074 input_handler_client_->ReconcileElasticOverscrollAndRootScroll(); |
1062 | 1075 |
1063 if (const char* client_name = GetClientNameForMetrics()) { | 1076 if (const char* client_name = GetClientNameForMetrics()) { |
1064 size_t total_memory = 0; | 1077 size_t total_memory = 0; |
1065 for (const PictureLayerImpl* layer : active_tree()->picture_layers()) | 1078 for (const PictureLayerImpl* layer : active_tree()->picture_layers()) |
1066 total_memory += layer->GetRasterSource()->GetMemoryUsage(); | 1079 total_memory += layer->GetRasterSource()->GetMemoryUsage(); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 // we intend to draw so it may make worse scheduling decisions. | 1317 // we intend to draw so it may make worse scheduling decisions. |
1305 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; | 1318 is_likely_to_require_a_draw_ = is_likely_to_require_a_draw; |
1306 } | 1319 } |
1307 | 1320 |
1308 gfx::ColorSpace LayerTreeHostImpl::GetTileColorSpace() const { | 1321 gfx::ColorSpace LayerTreeHostImpl::GetTileColorSpace() const { |
1309 if (!sync_tree()) | 1322 if (!sync_tree()) |
1310 return gfx::ColorSpace(); | 1323 return gfx::ColorSpace(); |
1311 return sync_tree()->device_color_space(); | 1324 return sync_tree()->device_color_space(); |
1312 } | 1325 } |
1313 | 1326 |
| 1327 void LayerTreeHostImpl::RequestImplSideInvalidation() { |
| 1328 client_->NeedsImplSideInvalidation(); |
| 1329 } |
| 1330 |
1314 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1331 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1315 client_->NotifyReadyToActivate(); | 1332 client_->NotifyReadyToActivate(); |
1316 } | 1333 } |
1317 | 1334 |
1318 void LayerTreeHostImpl::NotifyReadyToDraw() { | 1335 void LayerTreeHostImpl::NotifyReadyToDraw() { |
1319 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we | 1336 // Tiles that are ready will cause NotifyTileStateChanged() to be called so we |
1320 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from | 1337 // don't need to schedule a draw here. Just stop WillBeginImplFrame() from |
1321 // causing optimistic requests to draw a frame. | 1338 // causing optimistic requests to draw a frame. |
1322 is_likely_to_require_a_draw_ = false; | 1339 is_likely_to_require_a_draw_ = false; |
1323 | 1340 |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 | 2036 |
2020 UpdateViewportContainerSizes(); | 2037 UpdateViewportContainerSizes(); |
2021 | 2038 |
2022 active_tree_->DidBecomeActive(); | 2039 active_tree_->DidBecomeActive(); |
2023 client_->RenewTreePriority(); | 2040 client_->RenewTreePriority(); |
2024 // If we have any picture layers, then by activating we also modified tile | 2041 // If we have any picture layers, then by activating we also modified tile |
2025 // priorities. | 2042 // priorities. |
2026 if (!active_tree_->picture_layers().empty()) | 2043 if (!active_tree_->picture_layers().empty()) |
2027 DidModifyTilePriorities(); | 2044 DidModifyTilePriorities(); |
2028 | 2045 |
| 2046 tile_manager_.DidActivateSyncTree(); |
2029 client_->OnCanDrawStateChanged(CanDraw()); | 2047 client_->OnCanDrawStateChanged(CanDraw()); |
2030 client_->DidActivateSyncTree(); | 2048 client_->DidActivateSyncTree(); |
2031 if (!tree_activation_callback_.is_null()) | 2049 if (!tree_activation_callback_.is_null()) |
2032 tree_activation_callback_.Run(); | 2050 tree_activation_callback_.Run(); |
2033 | 2051 |
2034 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation = | 2052 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation = |
2035 active_tree_->TakePendingPageScaleAnimation(); | 2053 active_tree_->TakePendingPageScaleAnimation(); |
2036 if (pending_page_scale_animation) { | 2054 if (pending_page_scale_animation) { |
2037 StartPageScaleAnimation(pending_page_scale_animation->target_offset, | 2055 StartPageScaleAnimation(pending_page_scale_animation->target_offset, |
2038 pending_page_scale_animation->use_anchor, | 2056 pending_page_scale_animation->use_anchor, |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4085 worker_context_visibility_ = | 4103 worker_context_visibility_ = |
4086 worker_context->CacheController()->ClientBecameVisible(); | 4104 worker_context->CacheController()->ClientBecameVisible(); |
4087 } else { | 4105 } else { |
4088 worker_context->CacheController()->ClientBecameNotVisible( | 4106 worker_context->CacheController()->ClientBecameNotVisible( |
4089 std::move(worker_context_visibility_)); | 4107 std::move(worker_context_visibility_)); |
4090 } | 4108 } |
4091 } | 4109 } |
4092 } | 4110 } |
4093 | 4111 |
4094 } // namespace cc | 4112 } // namespace cc |
OLD | NEW |