Chromium Code Reviews| 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.h" | 5 #include "cc/trees/layer_tree_host.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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 | 206 |
| 207 std::unique_ptr<LayerTreeHost> layer_tree_host( | 207 std::unique_ptr<LayerTreeHost> layer_tree_host( |
| 208 new LayerTreeHost(params, CompositorMode::REMOTE)); | 208 new LayerTreeHost(params, CompositorMode::REMOTE)); |
| 209 layer_tree_host->InitializeRemoteClient( | 209 layer_tree_host->InitializeRemoteClient( |
| 210 remote_proto_channel, params->main_task_runner, impl_task_runner); | 210 remote_proto_channel, params->main_task_runner, impl_task_runner); |
| 211 return layer_tree_host; | 211 return layer_tree_host; |
| 212 } | 212 } |
| 213 | 213 |
| 214 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) | 214 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) |
| 215 : micro_benchmark_controller_(this), | 215 : micro_benchmark_controller_(this), |
| 216 layer_tree_(base::WrapUnique( | |
| 217 new LayerTree(std::move(params->animation_host), this))), | |
| 216 next_ui_resource_id_(1), | 218 next_ui_resource_id_(1), |
| 217 compositor_mode_(mode), | 219 compositor_mode_(mode), |
| 218 needs_full_tree_sync_(true), | 220 needs_full_tree_sync_(true), |
| 219 needs_meta_info_recomputation_(true), | 221 needs_meta_info_recomputation_(true), |
| 220 client_(params->client), | 222 client_(params->client), |
| 221 source_frame_number_(0), | 223 source_frame_number_(0), |
| 222 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 224 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
| 223 output_surface_lost_(true), | 225 output_surface_lost_(true), |
| 224 settings_(*params->settings), | 226 settings_(*params->settings), |
| 225 debug_state_(settings_.initial_debug_state), | 227 debug_state_(settings_.initial_debug_state), |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 240 have_scroll_event_handlers_(false), | 242 have_scroll_event_handlers_(false), |
| 241 event_listener_properties_(), | 243 event_listener_properties_(), |
| 242 did_complete_scale_animation_(false), | 244 did_complete_scale_animation_(false), |
| 243 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 245 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
| 244 next_commit_forces_redraw_(false), | 246 next_commit_forces_redraw_(false), |
| 245 shared_bitmap_manager_(params->shared_bitmap_manager), | 247 shared_bitmap_manager_(params->shared_bitmap_manager), |
| 246 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 248 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
| 247 task_graph_runner_(params->task_graph_runner), | 249 task_graph_runner_(params->task_graph_runner), |
| 248 image_serialization_processor_(params->image_serialization_processor), | 250 image_serialization_processor_(params->image_serialization_processor), |
| 249 surface_client_id_(0u), | 251 surface_client_id_(0u), |
| 250 next_surface_sequence_(1u), | 252 next_surface_sequence_(1u) { |
| 251 layer_tree_(std::move(params->animation_host)) { | |
| 252 DCHECK(task_graph_runner_); | 253 DCHECK(task_graph_runner_); |
| 253 | 254 |
| 254 layer_tree_.animation_host()->SetMutatorHostClient(this); | |
| 255 | |
| 256 rendering_stats_instrumentation_->set_record_rendering_stats( | 255 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 257 debug_state_.RecordRenderingStats()); | 256 debug_state_.RecordRenderingStats()); |
| 258 } | 257 } |
| 259 | 258 |
| 260 void LayerTreeHost::InitializeThreaded( | 259 void LayerTreeHost::InitializeThreaded( |
| 261 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 260 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 262 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 261 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 263 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 262 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
| 264 task_runner_provider_ = | 263 task_runner_provider_ = |
| 265 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 264 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 | 354 |
| 356 void LayerTreeHost::InitializeProxy( | 355 void LayerTreeHost::InitializeProxy( |
| 357 std::unique_ptr<Proxy> proxy, | 356 std::unique_ptr<Proxy> proxy, |
| 358 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 357 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
| 359 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); | 358 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
| 360 DCHECK(task_runner_provider_); | 359 DCHECK(task_runner_provider_); |
| 361 | 360 |
| 362 proxy_ = std::move(proxy); | 361 proxy_ = std::move(proxy); |
| 363 proxy_->Start(std::move(external_begin_frame_source)); | 362 proxy_->Start(std::move(external_begin_frame_source)); |
| 364 | 363 |
| 365 layer_tree_.animation_host()->SetSupportsScrollAnimations( | 364 layer_tree_->animation_host()->SetSupportsScrollAnimations( |
|
loyso (OOO)
2016/08/16 00:21:17
Notice that LayerTreeHost still deals with layer_t
xingliu
2016/08/16 02:25:25
I agree in general this breaks the symmetric, but
| |
| 366 proxy_->SupportsImplScrolling()); | 365 proxy_->SupportsImplScrolling()); |
| 367 } | 366 } |
| 368 | 367 |
| 369 LayerTreeHost::~LayerTreeHost() { | 368 LayerTreeHost::~LayerTreeHost() { |
| 370 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 369 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| 371 | 370 |
| 372 layer_tree_.animation_host()->SetMutatorHostClient(nullptr); | |
| 373 | |
| 374 if (root_layer_.get()) | 371 if (root_layer_.get()) |
| 375 root_layer_->SetLayerTreeHost(NULL); | 372 root_layer_->SetLayerTreeHost(NULL); |
| 376 | 373 |
| 377 DCHECK(swap_promise_monitor_.empty()); | 374 DCHECK(swap_promise_monitor_.empty()); |
| 378 | 375 |
| 379 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 376 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
| 380 | 377 |
| 381 if (proxy_) { | 378 if (proxy_) { |
| 382 DCHECK(task_runner_provider_->IsMainThread()); | 379 DCHECK(task_runner_provider_->IsMainThread()); |
| 383 proxy_->Stop(); | 380 proxy_->Stop(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { | 428 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
| 432 DCHECK(!IsRemoteServer()); | 429 DCHECK(!IsRemoteServer()); |
| 433 DCHECK(task_runner_provider_->IsImplThread()); | 430 DCHECK(task_runner_provider_->IsImplThread()); |
| 434 | 431 |
| 435 bool is_new_trace; | 432 bool is_new_trace; |
| 436 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 433 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
| 437 if (is_new_trace && | 434 if (is_new_trace && |
| 438 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && | 435 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && |
| 439 root_layer()) { | 436 root_layer()) { |
| 440 LayerTreeHostCommon::CallFunctionForEveryLayer( | 437 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 441 this, [](Layer* layer) { layer->DidBeginTracing(); }); | 438 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); |
| 442 } | 439 } |
| 443 | 440 |
| 444 LayerTreeImpl* sync_tree = host_impl->sync_tree(); | 441 LayerTreeImpl* sync_tree = host_impl->sync_tree(); |
| 445 | 442 |
| 446 if (next_commit_forces_redraw_) { | 443 if (next_commit_forces_redraw_) { |
| 447 sync_tree->ForceRedrawNextActivation(); | 444 sync_tree->ForceRedrawNextActivation(); |
| 448 next_commit_forces_redraw_ = false; | 445 next_commit_forces_redraw_ = false; |
| 449 } | 446 } |
| 450 | 447 |
| 451 sync_tree->set_source_frame_number(source_frame_number()); | 448 sync_tree->set_source_frame_number(source_frame_number()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 ui_resource_request_queue_.clear(); | 537 ui_resource_request_queue_.clear(); |
| 541 } | 538 } |
| 542 | 539 |
| 543 DCHECK(!sync_tree->ViewportSizeInvalid()); | 540 DCHECK(!sync_tree->ViewportSizeInvalid()); |
| 544 | 541 |
| 545 sync_tree->set_has_ever_been_drawn(false); | 542 sync_tree->set_has_ever_been_drawn(false); |
| 546 | 543 |
| 547 { | 544 { |
| 548 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 545 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
| 549 | 546 |
| 550 TreeSynchronizer::PushLayerProperties(&layer_tree_, sync_tree); | 547 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); |
| 551 | 548 |
| 552 // This must happen after synchronizing property trees and after push | 549 // This must happen after synchronizing property trees and after push |
| 553 // properties, which updates property tree indices, but before animation | 550 // properties, which updates property tree indices, but before animation |
| 554 // host pushes properties as animation host push properties can change | 551 // host pushes properties as animation host push properties can change |
| 555 // Animation::InEffect and we want the old InEffect value for updating | 552 // Animation::InEffect and we want the old InEffect value for updating |
| 556 // property tree scrolling and animation. | 553 // property tree scrolling and animation. |
| 557 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); | 554 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); |
| 558 | 555 |
| 559 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); | 556 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); |
| 560 DCHECK(host_impl->animation_host()); | 557 DCHECK(host_impl->animation_host()); |
| 561 layer_tree_.animation_host()->PushPropertiesTo(host_impl->animation_host()); | 558 layer_tree_->animation_host()->PushPropertiesTo( |
|
loyso (OOO)
2016/08/16 00:21:17
and here.
loyso (OOO)
2016/08/16 00:28:05
And if you add LayerTree::PushProperties (as in ot
xingliu
2016/08/16 02:25:25
For PushPropertiesTo, there is another refactoring
| |
| 559 host_impl->animation_host()); | |
| 562 } | 560 } |
| 563 | 561 |
| 564 // This must happen after synchronizing property trees and after pushing | 562 // This must happen after synchronizing property trees and after pushing |
| 565 // properties, which updates the clobber_active_value flag. | 563 // properties, which updates the clobber_active_value flag. |
| 566 sync_tree->UpdatePropertyTreeScrollOffset(&property_trees_); | 564 sync_tree->UpdatePropertyTreeScrollOffset(&property_trees_); |
| 567 | 565 |
| 568 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 566 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
| 569 property_trees_.ResetAllChangeTracking(); | 567 property_trees_.ResetAllChangeTracking(); |
| 570 } | 568 } |
| 571 | 569 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 client_->DidFailToInitializeOutputSurface(); | 636 client_->DidFailToInitializeOutputSurface(); |
| 639 } | 637 } |
| 640 | 638 |
| 641 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 639 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
| 642 LayerTreeHostImplClient* client) { | 640 LayerTreeHostImplClient* client) { |
| 643 DCHECK(!IsRemoteServer()); | 641 DCHECK(!IsRemoteServer()); |
| 644 DCHECK(task_runner_provider_->IsImplThread()); | 642 DCHECK(task_runner_provider_->IsImplThread()); |
| 645 | 643 |
| 646 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); | 644 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); |
| 647 std::unique_ptr<AnimationHost> animation_host_impl = | 645 std::unique_ptr<AnimationHost> animation_host_impl = |
| 648 layer_tree_.animation_host()->CreateImplInstance(supports_impl_scrolling); | 646 layer_tree_->animation_host()->CreateImplInstance( |
|
loyso (OOO)
2016/08/16 00:21:17
Same here. This is the logic how to pass Animation
| |
| 647 supports_impl_scrolling); | |
| 649 | 648 |
| 650 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 649 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
| 651 settings_, client, task_runner_provider_.get(), | 650 settings_, client, task_runner_provider_.get(), |
| 652 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, | 651 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, |
| 653 gpu_memory_buffer_manager_, task_graph_runner_, | 652 gpu_memory_buffer_manager_, task_graph_runner_, |
| 654 std::move(animation_host_impl), id_); | 653 std::move(animation_host_impl), id_); |
| 655 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | 654 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); |
| 656 host_impl->SetContentIsSuitableForGpuRasterization( | 655 host_impl->SetContentIsSuitableForGpuRasterization( |
| 657 content_is_suitable_for_gpu_rasterization_); | 656 content_is_suitable_for_gpu_rasterization_); |
| 658 shared_bitmap_manager_ = NULL; | 657 shared_bitmap_manager_ = NULL; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 670 return; | 669 return; |
| 671 | 670 |
| 672 output_surface_lost_ = true; | 671 output_surface_lost_ = true; |
| 673 SetNeedsCommit(); | 672 SetNeedsCommit(); |
| 674 } | 673 } |
| 675 | 674 |
| 676 void LayerTreeHost::SetDeferCommits(bool defer_commits) { | 675 void LayerTreeHost::SetDeferCommits(bool defer_commits) { |
| 677 proxy_->SetDeferCommits(defer_commits); | 676 proxy_->SetDeferCommits(defer_commits); |
| 678 } | 677 } |
| 679 | 678 |
| 680 void LayerTreeHost::SetNeedsDisplayOnAllLayers() { | |
| 681 for (auto* layer : *this) | |
| 682 layer->SetNeedsDisplay(); | |
| 683 } | |
| 684 | |
| 685 const RendererCapabilities& LayerTreeHost::GetRendererCapabilities() const { | 679 const RendererCapabilities& LayerTreeHost::GetRendererCapabilities() const { |
| 686 return proxy_->GetRendererCapabilities(); | 680 return proxy_->GetRendererCapabilities(); |
| 687 } | 681 } |
| 688 | 682 |
| 689 void LayerTreeHost::SetNeedsAnimate() { | 683 void LayerTreeHost::SetNeedsAnimate() { |
| 690 proxy_->SetNeedsAnimate(); | 684 proxy_->SetNeedsAnimate(); |
| 691 NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 685 NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
| 692 } | 686 } |
| 693 | 687 |
| 694 void LayerTreeHost::SetNeedsUpdateLayers() { | 688 void LayerTreeHost::SetNeedsUpdateLayers() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 739 } | 733 } |
| 740 | 734 |
| 741 void LayerTreeHost::SetNextCommitForcesRedraw() { | 735 void LayerTreeHost::SetNextCommitForcesRedraw() { |
| 742 next_commit_forces_redraw_ = true; | 736 next_commit_forces_redraw_ = true; |
| 743 proxy_->SetNeedsUpdateLayers(); | 737 proxy_->SetNeedsUpdateLayers(); |
| 744 } | 738 } |
| 745 | 739 |
| 746 void LayerTreeHost::SetAnimationEvents( | 740 void LayerTreeHost::SetAnimationEvents( |
| 747 std::unique_ptr<AnimationEvents> events) { | 741 std::unique_ptr<AnimationEvents> events) { |
| 748 DCHECK(task_runner_provider_->IsMainThread()); | 742 DCHECK(task_runner_provider_->IsMainThread()); |
| 749 layer_tree_.animation_host()->SetAnimationEvents(std::move(events)); | 743 layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); |
|
loyso (OOO)
2016/08/16 00:21:17
.. and here.
| |
| 750 } | 744 } |
| 751 | 745 |
| 752 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { | 746 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { |
| 753 if (root_layer_.get() == root_layer.get()) | 747 if (root_layer_.get() == root_layer.get()) |
| 754 return; | 748 return; |
| 755 | 749 |
| 756 if (root_layer_.get()) | 750 if (root_layer_.get()) |
| 757 root_layer_->SetLayerTreeHost(NULL); | 751 root_layer_->SetLayerTreeHost(NULL); |
| 758 root_layer_ = root_layer; | 752 root_layer_ = root_layer; |
| 759 if (root_layer_.get()) { | 753 if (root_layer_.get()) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 bool LayerTreeHost::UpdateLayers() { | 903 bool LayerTreeHost::UpdateLayers() { |
| 910 DCHECK(!output_surface_lost_); | 904 DCHECK(!output_surface_lost_); |
| 911 if (!root_layer()) | 905 if (!root_layer()) |
| 912 return false; | 906 return false; |
| 913 DCHECK(!root_layer()->parent()); | 907 DCHECK(!root_layer()->parent()); |
| 914 bool result = DoUpdateLayers(root_layer()); | 908 bool result = DoUpdateLayers(root_layer()); |
| 915 micro_benchmark_controller_.DidUpdateLayers(); | 909 micro_benchmark_controller_.DidUpdateLayers(); |
| 916 return result || next_commit_forces_redraw_; | 910 return result || next_commit_forces_redraw_; |
| 917 } | 911 } |
| 918 | 912 |
| 919 LayerListIterator<Layer> LayerTreeHost::begin() const { | |
| 920 return LayerListIterator<Layer>(root_layer_.get()); | |
| 921 } | |
| 922 | |
| 923 LayerListIterator<Layer> LayerTreeHost::end() const { | |
| 924 return LayerListIterator<Layer>(nullptr); | |
| 925 } | |
| 926 | |
| 927 LayerListReverseIterator<Layer> LayerTreeHost::rbegin() { | |
| 928 return LayerListReverseIterator<Layer>(root_layer_.get()); | |
| 929 } | |
| 930 | |
| 931 LayerListReverseIterator<Layer> LayerTreeHost::rend() { | |
| 932 return LayerListReverseIterator<Layer>(nullptr); | |
| 933 } | |
| 934 | |
| 935 void LayerTreeHost::DidCompletePageScaleAnimation() { | 913 void LayerTreeHost::DidCompletePageScaleAnimation() { |
| 936 did_complete_scale_animation_ = true; | 914 did_complete_scale_animation_ = true; |
| 937 } | 915 } |
| 938 | 916 |
| 939 void LayerTreeHost::RecordGpuRasterizationHistogram() { | 917 void LayerTreeHost::RecordGpuRasterizationHistogram() { |
| 940 // Gpu rasterization is only supported for Renderer compositors. | 918 // Gpu rasterization is only supported for Renderer compositors. |
| 941 // Checking for IsSingleThreaded() to exclude Browser compositors. | 919 // Checking for IsSingleThreaded() to exclude Browser compositors. |
| 942 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded()) | 920 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded()) |
| 943 return; | 921 return; |
| 944 | 922 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 966 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer_.get()); | 944 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer_.get()); |
| 967 gfx::Transform identity_transform; | 945 gfx::Transform identity_transform; |
| 968 PropertyTreeBuilder::BuildPropertyTrees( | 946 PropertyTreeBuilder::BuildPropertyTrees( |
| 969 root_layer_.get(), page_scale_layer_.get(), | 947 root_layer_.get(), page_scale_layer_.get(), |
| 970 inner_viewport_scroll_layer_.get(), outer_viewport_scroll_layer_.get(), | 948 inner_viewport_scroll_layer_.get(), outer_viewport_scroll_layer_.get(), |
| 971 overscroll_elasticity_layer_.get(), elastic_overscroll_, | 949 overscroll_elasticity_layer_.get(), elastic_overscroll_, |
| 972 page_scale_factor_, device_scale_factor_, | 950 page_scale_factor_, device_scale_factor_, |
| 973 gfx::Rect(device_viewport_size_), identity_transform, &property_trees_); | 951 gfx::Rect(device_viewport_size_), identity_transform, &property_trees_); |
| 974 } | 952 } |
| 975 | 953 |
| 976 static void SetElementIdForTesting(Layer* layer) { | |
| 977 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); | |
| 978 } | |
| 979 | |
| 980 void LayerTreeHost::SetElementIdsForTesting() { | |
| 981 LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting); | |
| 982 } | |
| 983 | |
| 984 bool LayerTreeHost::UsingSharedMemoryResources() { | 954 bool LayerTreeHost::UsingSharedMemoryResources() { |
| 985 return GetRendererCapabilities().using_shared_memory_resources; | 955 return GetRendererCapabilities().using_shared_memory_resources; |
| 986 } | 956 } |
| 987 | 957 |
| 988 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { | 958 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { |
| 989 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", | 959 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", |
| 990 source_frame_number()); | 960 source_frame_number()); |
| 991 | 961 |
| 992 UpdateHudLayer(); | 962 UpdateHudLayer(); |
| 993 | 963 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 property_trees_.AsTracedValue()); | 997 property_trees_.AsTracedValue()); |
| 1028 } else { | 998 } else { |
| 1029 TRACE_EVENT_INSTANT1("cc", | 999 TRACE_EVENT_INSTANT1("cc", |
| 1030 "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees", | 1000 "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees", |
| 1031 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 1001 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
| 1032 property_trees_.AsTracedValue()); | 1002 property_trees_.AsTracedValue()); |
| 1033 } | 1003 } |
| 1034 draw_property_utils::UpdatePropertyTrees(&property_trees_, | 1004 draw_property_utils::UpdatePropertyTrees(&property_trees_, |
| 1035 can_render_to_separate_surface); | 1005 can_render_to_separate_surface); |
| 1036 draw_property_utils::FindLayersThatNeedUpdates( | 1006 draw_property_utils::FindLayersThatNeedUpdates( |
| 1037 this, property_trees_.transform_tree, property_trees_.effect_tree, | 1007 layer_tree_.get(), property_trees_.transform_tree, |
| 1038 &update_layer_list); | 1008 property_trees_.effect_tree, &update_layer_list); |
| 1039 } | 1009 } |
| 1040 | 1010 |
| 1041 for (const auto& layer : update_layer_list) | 1011 for (const auto& layer : update_layer_list) |
| 1042 layer->SavePaintProperties(); | 1012 layer->SavePaintProperties(); |
| 1043 | 1013 |
| 1044 bool content_is_suitable_for_gpu = true; | 1014 bool content_is_suitable_for_gpu = true; |
| 1045 bool did_paint_content = | 1015 bool did_paint_content = layer_tree_->UpdateLayers( |
| 1046 layer_tree_.UpdateLayers(update_layer_list, &content_is_suitable_for_gpu); | 1016 update_layer_list, &content_is_suitable_for_gpu); |
| 1047 | 1017 |
| 1048 if (content_is_suitable_for_gpu) { | 1018 if (content_is_suitable_for_gpu) { |
| 1049 ++num_consecutive_frames_suitable_for_gpu_; | 1019 ++num_consecutive_frames_suitable_for_gpu_; |
| 1050 if (num_consecutive_frames_suitable_for_gpu_ >= | 1020 if (num_consecutive_frames_suitable_for_gpu_ >= |
| 1051 kNumFramesToConsiderBeforeGpuRasterization) { | 1021 kNumFramesToConsiderBeforeGpuRasterization) { |
| 1052 content_is_suitable_for_gpu_rasterization_ = true; | 1022 content_is_suitable_for_gpu_rasterization_ = true; |
| 1053 } | 1023 } |
| 1054 } else { | 1024 } else { |
| 1055 num_consecutive_frames_suitable_for_gpu_ = 0; | 1025 num_consecutive_frames_suitable_for_gpu_ = 0; |
| 1056 content_is_suitable_for_gpu_rasterization_ = false; | 1026 content_is_suitable_for_gpu_rasterization_ = false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 1063 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
| 1094 "LatencyInfo.Flow", | 1064 "LatencyInfo.Flow", |
| 1095 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), | 1065 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), |
| 1096 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 1066 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
| 1097 "step", "Main thread scroll update"); | 1067 "step", "Main thread scroll update"); |
| 1098 QueueSwapPromise(std::move(swap_promise)); | 1068 QueueSwapPromise(std::move(swap_promise)); |
| 1099 } | 1069 } |
| 1100 | 1070 |
| 1101 if (root_layer_.get()) { | 1071 if (root_layer_.get()) { |
| 1102 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 1072 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
| 1103 Layer* layer = LayerById(info->scrolls[i].layer_id); | 1073 Layer* layer = layer_tree_->LayerById(info->scrolls[i].layer_id); |
| 1104 if (!layer) | 1074 if (!layer) |
| 1105 continue; | 1075 continue; |
| 1106 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( | 1076 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( |
| 1107 layer->scroll_offset(), info->scrolls[i].scroll_delta)); | 1077 layer->scroll_offset(), info->scrolls[i].scroll_delta)); |
| 1108 SetNeedsUpdateLayers(); | 1078 SetNeedsUpdateLayers(); |
| 1109 } | 1079 } |
| 1110 } | 1080 } |
| 1111 | 1081 |
| 1112 // This needs to happen after scroll deltas have been sent to prevent top | 1082 // This needs to happen after scroll deltas have been sent to prevent top |
| 1113 // controls from clamping the layout viewport both on the compositor and | 1083 // controls from clamping the layout viewport both on the compositor and |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1135 | 1105 |
| 1136 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, | 1106 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
| 1137 TopControlsState current, | 1107 TopControlsState current, |
| 1138 bool animate) { | 1108 bool animate) { |
| 1139 // Top controls are only used in threaded or remote mode. | 1109 // Top controls are only used in threaded or remote mode. |
| 1140 DCHECK(IsThreaded() || IsRemoteServer()); | 1110 DCHECK(IsThreaded() || IsRemoteServer()); |
| 1141 proxy_->UpdateTopControlsState(constraints, current, animate); | 1111 proxy_->UpdateTopControlsState(constraints, current, animate); |
| 1142 } | 1112 } |
| 1143 | 1113 |
| 1144 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 1114 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
| 1145 AnimationHost* animation_host = layer_tree_.animation_host(); | 1115 AnimationHost* animation_host = layer_tree_->animation_host(); |
|
loyso (OOO)
2016/08/16 00:21:17
Same here. Move AnimateLayers method to LayerTree?
| |
| 1146 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); | 1116 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); |
| 1147 | 1117 |
| 1148 if (animation_host->AnimateLayers(monotonic_time)) | 1118 if (animation_host->AnimateLayers(monotonic_time)) |
| 1149 animation_host->UpdateAnimationState(true, events.get()); | 1119 animation_host->UpdateAnimationState(true, events.get()); |
| 1150 | 1120 |
| 1151 if (!events->events_.empty()) | 1121 if (!events->events_.empty()) |
| 1152 property_trees_.needs_rebuild = true; | 1122 property_trees_.needs_rebuild = true; |
| 1153 } | 1123 } |
| 1154 | 1124 |
| 1155 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { | 1125 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1303 | 1273 |
| 1304 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { | 1274 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { |
| 1305 return SurfaceSequence(surface_client_id_, next_surface_sequence_++); | 1275 return SurfaceSequence(surface_client_id_, next_surface_sequence_++); |
| 1306 } | 1276 } |
| 1307 | 1277 |
| 1308 void LayerTreeHost::SetLayerTreeMutator( | 1278 void LayerTreeHost::SetLayerTreeMutator( |
| 1309 std::unique_ptr<LayerTreeMutator> mutator) { | 1279 std::unique_ptr<LayerTreeMutator> mutator) { |
| 1310 proxy_->SetMutator(std::move(mutator)); | 1280 proxy_->SetMutator(std::move(mutator)); |
| 1311 } | 1281 } |
| 1312 | 1282 |
| 1313 Layer* LayerTreeHost::LayerById(int id) const { | |
| 1314 return layer_tree_.LayerById(id); | |
| 1315 } | |
| 1316 | |
| 1317 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const { | |
| 1318 ElementLayersMap::const_iterator iter = element_layers_map_.find(element_id); | |
| 1319 return iter != element_layers_map_.end() ? iter->second : nullptr; | |
| 1320 } | |
| 1321 | |
| 1322 void LayerTreeHost::AddToElementMap(Layer* layer) { | |
| 1323 if (!layer->element_id()) | |
| 1324 return; | |
| 1325 | |
| 1326 element_layers_map_[layer->element_id()] = layer; | |
| 1327 } | |
| 1328 | |
| 1329 void LayerTreeHost::RemoveFromElementMap(Layer* layer) { | |
| 1330 if (!layer->element_id()) | |
| 1331 return; | |
| 1332 | |
| 1333 element_layers_map_.erase(layer->element_id()); | |
| 1334 } | |
| 1335 | |
| 1336 bool LayerTreeHost::IsElementInList(ElementId element_id, | |
| 1337 ElementListType list_type) const { | |
| 1338 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); | |
| 1339 } | |
| 1340 | |
| 1341 void LayerTreeHost::SetMutatorsNeedCommit() { | |
| 1342 SetNeedsCommit(); | |
| 1343 } | |
| 1344 | |
| 1345 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { | |
| 1346 property_trees_.needs_rebuild = true; | |
| 1347 } | |
| 1348 | |
| 1349 void LayerTreeHost::SetElementFilterMutated(ElementId element_id, | |
| 1350 ElementListType list_type, | |
| 1351 const FilterOperations& filters) { | |
| 1352 Layer* layer = LayerByElementId(element_id); | |
| 1353 DCHECK(layer); | |
| 1354 layer->OnFilterAnimated(filters); | |
| 1355 } | |
| 1356 | |
| 1357 void LayerTreeHost::SetElementOpacityMutated(ElementId element_id, | |
| 1358 ElementListType list_type, | |
| 1359 float opacity) { | |
| 1360 Layer* layer = LayerByElementId(element_id); | |
| 1361 DCHECK(layer); | |
| 1362 layer->OnOpacityAnimated(opacity); | |
| 1363 } | |
| 1364 | |
| 1365 void LayerTreeHost::SetElementTransformMutated( | |
| 1366 ElementId element_id, | |
| 1367 ElementListType list_type, | |
| 1368 const gfx::Transform& transform) { | |
| 1369 Layer* layer = LayerByElementId(element_id); | |
| 1370 DCHECK(layer); | |
| 1371 layer->OnTransformAnimated(transform); | |
| 1372 } | |
| 1373 | |
| 1374 void LayerTreeHost::SetElementScrollOffsetMutated( | |
| 1375 ElementId element_id, | |
| 1376 ElementListType list_type, | |
| 1377 const gfx::ScrollOffset& scroll_offset) { | |
| 1378 Layer* layer = LayerByElementId(element_id); | |
| 1379 DCHECK(layer); | |
| 1380 layer->OnScrollOffsetAnimated(scroll_offset); | |
| 1381 } | |
| 1382 | |
| 1383 void LayerTreeHost::ElementTransformIsAnimatingChanged( | |
| 1384 ElementId element_id, | |
| 1385 ElementListType list_type, | |
| 1386 AnimationChangeType change_type, | |
| 1387 bool is_animating) { | |
| 1388 Layer* layer = LayerByElementId(element_id); | |
| 1389 if (layer) { | |
| 1390 switch (change_type) { | |
| 1391 case AnimationChangeType::POTENTIAL: | |
| 1392 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); | |
| 1393 break; | |
| 1394 case AnimationChangeType::RUNNING: | |
| 1395 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); | |
| 1396 break; | |
| 1397 case AnimationChangeType::BOTH: | |
| 1398 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); | |
| 1399 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); | |
| 1400 break; | |
| 1401 } | |
| 1402 } | |
| 1403 } | |
| 1404 | |
| 1405 void LayerTreeHost::ElementOpacityIsAnimatingChanged( | |
| 1406 ElementId element_id, | |
| 1407 ElementListType list_type, | |
| 1408 AnimationChangeType change_type, | |
| 1409 bool is_animating) { | |
| 1410 Layer* layer = LayerByElementId(element_id); | |
| 1411 if (layer) { | |
| 1412 switch (change_type) { | |
| 1413 case AnimationChangeType::POTENTIAL: | |
| 1414 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); | |
| 1415 break; | |
| 1416 case AnimationChangeType::RUNNING: | |
| 1417 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); | |
| 1418 break; | |
| 1419 case AnimationChangeType::BOTH: | |
| 1420 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); | |
| 1421 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); | |
| 1422 break; | |
| 1423 } | |
| 1424 } | |
| 1425 } | |
| 1426 | |
| 1427 void LayerTreeHost::ElementFilterIsAnimatingChanged( | |
| 1428 ElementId element_id, | |
| 1429 ElementListType list_type, | |
| 1430 AnimationChangeType change_type, | |
| 1431 bool is_animating) { | |
| 1432 Layer* layer = LayerByElementId(element_id); | |
| 1433 if (layer) { | |
| 1434 switch (change_type) { | |
| 1435 case AnimationChangeType::POTENTIAL: | |
| 1436 layer->OnFilterIsPotentiallyAnimatingChanged(is_animating); | |
| 1437 break; | |
| 1438 case AnimationChangeType::RUNNING: | |
| 1439 layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); | |
| 1440 break; | |
| 1441 case AnimationChangeType::BOTH: | |
| 1442 layer->OnFilterIsPotentiallyAnimatingChanged(is_animating); | |
| 1443 layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); | |
| 1444 break; | |
| 1445 } | |
| 1446 } | |
| 1447 } | |
| 1448 | |
| 1449 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( | |
| 1450 ElementId element_id) const { | |
| 1451 Layer* layer = LayerByElementId(element_id); | |
| 1452 DCHECK(layer); | |
| 1453 return layer->ScrollOffsetForAnimation(); | |
| 1454 } | |
| 1455 | |
| 1456 bool LayerTreeHost::IsSingleThreaded() const { | 1283 bool LayerTreeHost::IsSingleThreaded() const { |
| 1457 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || | 1284 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || |
| 1458 !task_runner_provider_->HasImplThread()); | 1285 !task_runner_provider_->HasImplThread()); |
| 1459 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 1286 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
| 1460 } | 1287 } |
| 1461 | 1288 |
| 1462 bool LayerTreeHost::IsThreaded() const { | 1289 bool LayerTreeHost::IsThreaded() const { |
| 1463 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 1290 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
| 1464 task_runner_provider_->HasImplThread()); | 1291 task_runner_provider_->HasImplThread()); |
| 1465 return compositor_mode_ == CompositorMode::THREADED; | 1292 return compositor_mode_ == CompositorMode::THREADED; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1507 proto->set_needs_full_tree_sync(needs_full_tree_sync_); | 1334 proto->set_needs_full_tree_sync(needs_full_tree_sync_); |
| 1508 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); | 1335 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); |
| 1509 proto->set_source_frame_number(source_frame_number_); | 1336 proto->set_source_frame_number(source_frame_number_); |
| 1510 | 1337 |
| 1511 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, | 1338 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, |
| 1512 proto->mutable_root_layer()); | 1339 proto->mutable_root_layer()); |
| 1513 | 1340 |
| 1514 // Serialize the LayerTree before serializing the properties. During layer | 1341 // Serialize the LayerTree before serializing the properties. During layer |
| 1515 // property serialization, we clear the list |layer_that_should_properties_| | 1342 // property serialization, we clear the list |layer_that_should_properties_| |
| 1516 // from the LayerTree. | 1343 // from the LayerTree. |
| 1517 layer_tree_.ToProtobuf(proto->mutable_layer_tree()); | 1344 layer_tree_->ToProtobuf(proto->mutable_layer_tree()); |
| 1518 | 1345 |
| 1519 LayerProtoConverter::SerializeLayerProperties(this, | 1346 LayerProtoConverter::SerializeLayerProperties(this, |
| 1520 proto->mutable_layer_updates()); | 1347 proto->mutable_layer_updates()); |
| 1521 | 1348 |
| 1522 std::vector<PictureData> pictures = | 1349 std::vector<PictureData> pictures = |
| 1523 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 1350 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
| 1524 proto::PictureDataVectorToSkPicturesProto(pictures, | 1351 proto::PictureDataVectorToSkPicturesProto(pictures, |
| 1525 proto->mutable_pictures()); | 1352 proto->mutable_pictures()); |
| 1526 | 1353 |
| 1527 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); | 1354 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1585 source_frame_number_ = proto.source_frame_number(); | 1412 source_frame_number_ = proto.source_frame_number(); |
| 1586 | 1413 |
| 1587 // Layer hierarchy. | 1414 // Layer hierarchy. |
| 1588 scoped_refptr<Layer> new_root_layer = | 1415 scoped_refptr<Layer> new_root_layer = |
| 1589 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, | 1416 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, |
| 1590 proto.root_layer(), this); | 1417 proto.root_layer(), this); |
| 1591 if (root_layer_ != new_root_layer) { | 1418 if (root_layer_ != new_root_layer) { |
| 1592 root_layer_ = new_root_layer; | 1419 root_layer_ = new_root_layer; |
| 1593 } | 1420 } |
| 1594 | 1421 |
| 1595 layer_tree_.FromProtobuf(proto.layer_tree()); | 1422 layer_tree_->FromProtobuf(proto.layer_tree()); |
| 1596 | 1423 |
| 1597 // Ensure ClientPictureCache contains all the necessary SkPictures before | 1424 // Ensure ClientPictureCache contains all the necessary SkPictures before |
| 1598 // deserializing the properties. | 1425 // deserializing the properties. |
| 1599 proto::SkPictures proto_pictures = proto.pictures(); | 1426 proto::SkPictures proto_pictures = proto.pictures(); |
| 1600 std::vector<PictureData> pictures = | 1427 std::vector<PictureData> pictures = |
| 1601 SkPicturesProtoToPictureDataVector(proto_pictures); | 1428 SkPicturesProtoToPictureDataVector(proto_pictures); |
| 1602 client_picture_cache_->ApplyCacheUpdate(pictures); | 1429 client_picture_cache_->ApplyCacheUpdate(pictures); |
| 1603 | 1430 |
| 1604 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), | 1431 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), |
| 1605 proto.layer_updates()); | 1432 proto.layer_updates()); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1632 EventListenerClass::kTouchStartOrMove)] = | 1459 EventListenerClass::kTouchStartOrMove)] = |
| 1633 static_cast<EventListenerProperties>( | 1460 static_cast<EventListenerProperties>( |
| 1634 proto.touch_start_or_move_event_listener_properties()); | 1461 proto.touch_start_or_move_event_listener_properties()); |
| 1635 event_listener_properties_[static_cast<size_t>( | 1462 event_listener_properties_[static_cast<size_t>( |
| 1636 EventListenerClass::kTouchEndOrCancel)] = | 1463 EventListenerClass::kTouchEndOrCancel)] = |
| 1637 static_cast<EventListenerProperties>( | 1464 static_cast<EventListenerProperties>( |
| 1638 proto.touch_end_or_cancel_event_listener_properties()); | 1465 proto.touch_end_or_cancel_event_listener_properties()); |
| 1639 id_ = proto.id(); | 1466 id_ = proto.id(); |
| 1640 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1467 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
| 1641 | 1468 |
| 1642 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( | 1469 hud_layer_ = static_cast<HeadsUpDisplayLayer*>(UpdateAndGetLayer( |
| 1643 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), &layer_tree_)); | 1470 hud_layer_.get(), proto.hud_layer_id(), layer_tree_.get())); |
| 1644 overscroll_elasticity_layer_ = | 1471 overscroll_elasticity_layer_ = UpdateAndGetLayer( |
| 1645 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), | 1472 overscroll_elasticity_layer_.get(), |
| 1646 proto.overscroll_elasticity_layer_id(), &layer_tree_); | 1473 proto.overscroll_elasticity_layer_id(), layer_tree_.get()); |
| 1647 page_scale_layer_ = UpdateAndGetLayer( | 1474 page_scale_layer_ = UpdateAndGetLayer( |
| 1648 page_scale_layer_.get(), proto.page_scale_layer_id(), &layer_tree_); | 1475 page_scale_layer_.get(), proto.page_scale_layer_id(), layer_tree_.get()); |
| 1649 inner_viewport_scroll_layer_ = | 1476 inner_viewport_scroll_layer_ = UpdateAndGetLayer( |
| 1650 UpdateAndGetLayer(inner_viewport_scroll_layer_.get(), | 1477 inner_viewport_scroll_layer_.get(), |
| 1651 proto.inner_viewport_scroll_layer_id(), &layer_tree_); | 1478 proto.inner_viewport_scroll_layer_id(), layer_tree_.get()); |
| 1652 outer_viewport_scroll_layer_ = | 1479 outer_viewport_scroll_layer_ = UpdateAndGetLayer( |
| 1653 UpdateAndGetLayer(outer_viewport_scroll_layer_.get(), | 1480 outer_viewport_scroll_layer_.get(), |
| 1654 proto.outer_viewport_scroll_layer_id(), &layer_tree_); | 1481 proto.outer_viewport_scroll_layer_id(), layer_tree_.get()); |
| 1655 | 1482 |
| 1656 LayerSelectionFromProtobuf(&selection_, proto.selection()); | 1483 LayerSelectionFromProtobuf(&selection_, proto.selection()); |
| 1657 | 1484 |
| 1658 // It is required to create new PropertyTrees before deserializing it. | 1485 // It is required to create new PropertyTrees before deserializing it. |
| 1659 property_trees_ = PropertyTrees(); | 1486 property_trees_ = PropertyTrees(); |
| 1660 property_trees_.FromProtobuf(proto.property_trees()); | 1487 property_trees_.FromProtobuf(proto.property_trees()); |
| 1661 | 1488 |
| 1662 // Forcefully override the sequence number of all layers in the tree to have | 1489 // Forcefully override the sequence number of all layers in the tree to have |
| 1663 // a valid sequence number. Changing the sequence number for a layer does not | 1490 // a valid sequence number. Changing the sequence number for a layer does not |
| 1664 // need a commit, so the value will become out of date for layers that are not | 1491 // need a commit, so the value will become out of date for layers that are not |
| 1665 // updated for other reasons. All layers that at this point are part of the | 1492 // updated for other reasons. All layers that at this point are part of the |
| 1666 // layer tree are valid, so it is OK that they have a valid sequence number. | 1493 // layer tree are valid, so it is OK that they have a valid sequence number. |
| 1667 int seq_num = property_trees_.sequence_number; | 1494 int seq_num = property_trees_.sequence_number; |
| 1668 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | 1495 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 1669 layer->set_property_tree_sequence_number(seq_num); | 1496 layer_tree_.get(), [seq_num](Layer* layer) { |
| 1670 }); | 1497 layer->set_property_tree_sequence_number(seq_num); |
| 1498 }); | |
| 1671 | 1499 |
| 1672 surface_client_id_ = proto.surface_client_id(); | 1500 surface_client_id_ = proto.surface_client_id(); |
| 1673 next_surface_sequence_ = proto.next_surface_sequence(); | 1501 next_surface_sequence_ = proto.next_surface_sequence(); |
| 1674 } | 1502 } |
| 1675 | |
| 1676 AnimationHost* LayerTreeHost::animation_host() const { | |
| 1677 return layer_tree_.animation_host(); | |
| 1678 } | |
| 1679 | |
| 1680 } // namespace cc | 1503 } // namespace cc |
| OLD | NEW |