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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 event_listener_properties_(), | 241 event_listener_properties_(), |
242 did_complete_scale_animation_(false), | 242 did_complete_scale_animation_(false), |
243 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 243 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
244 next_commit_forces_redraw_(false), | 244 next_commit_forces_redraw_(false), |
245 shared_bitmap_manager_(params->shared_bitmap_manager), | 245 shared_bitmap_manager_(params->shared_bitmap_manager), |
246 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 246 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
247 task_graph_runner_(params->task_graph_runner), | 247 task_graph_runner_(params->task_graph_runner), |
248 image_serialization_processor_(params->image_serialization_processor), | 248 image_serialization_processor_(params->image_serialization_processor), |
249 surface_client_id_(0u), | 249 surface_client_id_(0u), |
250 next_surface_sequence_(1u), | 250 next_surface_sequence_(1u), |
251 layer_tree_(std::move(params->animation_host)) { | 251 layer_tree_(base::WrapUnique( |
252 new LayerTree(std::move(params->animation_host), this))) { | |
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( |
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); | 371 layer_tree_->animation_host()->SetMutatorHostClient(nullptr); |
Khushal
2016/08/08 16:55:03
This should be done in the LayerTree dtor. But you
ajuma
2016/08/08 17:56:34
Sounds good.
xingliu
2016/08/09 20:57:04
Done.
| |
373 | 372 |
374 if (root_layer_.get()) | 373 if (root_layer_.get()) |
375 root_layer_->SetLayerTreeHost(NULL); | 374 root_layer_->SetLayerTreeHost(NULL); |
376 | 375 |
377 DCHECK(swap_promise_monitor_.empty()); | 376 DCHECK(swap_promise_monitor_.empty()); |
378 | 377 |
379 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 378 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
380 | 379 |
381 if (proxy_) { | 380 if (proxy_) { |
382 DCHECK(task_runner_provider_->IsMainThread()); | 381 DCHECK(task_runner_provider_->IsMainThread()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
540 ui_resource_request_queue_.clear(); | 539 ui_resource_request_queue_.clear(); |
541 } | 540 } |
542 | 541 |
543 DCHECK(!sync_tree->ViewportSizeInvalid()); | 542 DCHECK(!sync_tree->ViewportSizeInvalid()); |
544 | 543 |
545 sync_tree->set_has_ever_been_drawn(false); | 544 sync_tree->set_has_ever_been_drawn(false); |
546 | 545 |
547 { | 546 { |
548 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 547 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
549 | 548 |
550 TreeSynchronizer::PushLayerProperties(&layer_tree_, sync_tree); | 549 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); |
551 | 550 |
552 // This must happen after synchronizing property trees and after push | 551 // This must happen after synchronizing property trees and after push |
553 // properties, which updates property tree indices, but before animation | 552 // properties, which updates property tree indices, but before animation |
554 // host pushes properties as animation host push properties can change | 553 // host pushes properties as animation host push properties can change |
555 // Animation::InEffect and we want the old InEffect value for updating | 554 // Animation::InEffect and we want the old InEffect value for updating |
556 // property tree scrolling and animation. | 555 // property tree scrolling and animation. |
557 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); | 556 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); |
558 | 557 |
559 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); | 558 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); |
560 DCHECK(host_impl->animation_host()); | 559 DCHECK(host_impl->animation_host()); |
561 layer_tree_.animation_host()->PushPropertiesTo(host_impl->animation_host()); | 560 layer_tree_->animation_host()->PushPropertiesTo( |
561 host_impl->animation_host()); | |
562 } | 562 } |
563 | 563 |
564 // This must happen after synchronizing property trees and after pushing | 564 // This must happen after synchronizing property trees and after pushing |
565 // properties, which updates the clobber_active_value flag. | 565 // properties, which updates the clobber_active_value flag. |
566 sync_tree->UpdatePropertyTreeScrollOffset(&property_trees_); | 566 sync_tree->UpdatePropertyTreeScrollOffset(&property_trees_); |
567 | 567 |
568 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 568 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
569 property_trees_.ResetAllChangeTracking(); | 569 property_trees_.ResetAllChangeTracking(); |
570 } | 570 } |
571 | 571 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 client_->DidFailToInitializeOutputSurface(); | 638 client_->DidFailToInitializeOutputSurface(); |
639 } | 639 } |
640 | 640 |
641 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 641 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
642 LayerTreeHostImplClient* client) { | 642 LayerTreeHostImplClient* client) { |
643 DCHECK(!IsRemoteServer()); | 643 DCHECK(!IsRemoteServer()); |
644 DCHECK(task_runner_provider_->IsImplThread()); | 644 DCHECK(task_runner_provider_->IsImplThread()); |
645 | 645 |
646 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); | 646 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); |
647 std::unique_ptr<AnimationHost> animation_host_impl = | 647 std::unique_ptr<AnimationHost> animation_host_impl = |
648 layer_tree_.animation_host()->CreateImplInstance(supports_impl_scrolling); | 648 layer_tree_->animation_host()->CreateImplInstance( |
649 supports_impl_scrolling); | |
649 | 650 |
650 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 651 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
651 settings_, client, task_runner_provider_.get(), | 652 settings_, client, task_runner_provider_.get(), |
652 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, | 653 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, |
653 gpu_memory_buffer_manager_, task_graph_runner_, | 654 gpu_memory_buffer_manager_, task_graph_runner_, |
654 std::move(animation_host_impl), id_); | 655 std::move(animation_host_impl), id_); |
655 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | 656 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); |
656 host_impl->SetContentIsSuitableForGpuRasterization( | 657 host_impl->SetContentIsSuitableForGpuRasterization( |
657 content_is_suitable_for_gpu_rasterization_); | 658 content_is_suitable_for_gpu_rasterization_); |
658 shared_bitmap_manager_ = NULL; | 659 shared_bitmap_manager_ = NULL; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 } | 744 } |
744 | 745 |
745 void LayerTreeHost::SetNextCommitForcesRedraw() { | 746 void LayerTreeHost::SetNextCommitForcesRedraw() { |
746 next_commit_forces_redraw_ = true; | 747 next_commit_forces_redraw_ = true; |
747 proxy_->SetNeedsUpdateLayers(); | 748 proxy_->SetNeedsUpdateLayers(); |
748 } | 749 } |
749 | 750 |
750 void LayerTreeHost::SetAnimationEvents( | 751 void LayerTreeHost::SetAnimationEvents( |
751 std::unique_ptr<AnimationEvents> events) { | 752 std::unique_ptr<AnimationEvents> events) { |
752 DCHECK(task_runner_provider_->IsMainThread()); | 753 DCHECK(task_runner_provider_->IsMainThread()); |
753 layer_tree_.animation_host()->SetAnimationEvents(std::move(events)); | 754 layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); |
754 } | 755 } |
755 | 756 |
756 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { | 757 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { |
757 if (root_layer_.get() == root_layer.get()) | 758 if (root_layer_.get() == root_layer.get()) |
758 return; | 759 return; |
759 | 760 |
760 if (root_layer_.get()) | 761 if (root_layer_.get()) |
761 root_layer_->SetLayerTreeHost(NULL); | 762 root_layer_->SetLayerTreeHost(NULL); |
762 root_layer_ = root_layer; | 763 root_layer_ = root_layer; |
763 if (root_layer_.get()) { | 764 if (root_layer_.get()) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1039 can_render_to_separate_surface); | 1040 can_render_to_separate_surface); |
1040 draw_property_utils::FindLayersThatNeedUpdates( | 1041 draw_property_utils::FindLayersThatNeedUpdates( |
1041 this, property_trees_.transform_tree, property_trees_.effect_tree, | 1042 this, property_trees_.transform_tree, property_trees_.effect_tree, |
1042 &update_layer_list); | 1043 &update_layer_list); |
1043 } | 1044 } |
1044 | 1045 |
1045 for (const auto& layer : update_layer_list) | 1046 for (const auto& layer : update_layer_list) |
1046 layer->SavePaintProperties(); | 1047 layer->SavePaintProperties(); |
1047 | 1048 |
1048 bool content_is_suitable_for_gpu = true; | 1049 bool content_is_suitable_for_gpu = true; |
1049 bool did_paint_content = | 1050 bool did_paint_content = layer_tree_->UpdateLayers( |
1050 layer_tree_.UpdateLayers(update_layer_list, &content_is_suitable_for_gpu); | 1051 update_layer_list, &content_is_suitable_for_gpu); |
1051 | 1052 |
1052 if (content_is_suitable_for_gpu) { | 1053 if (content_is_suitable_for_gpu) { |
1053 ++num_consecutive_frames_suitable_for_gpu_; | 1054 ++num_consecutive_frames_suitable_for_gpu_; |
1054 if (num_consecutive_frames_suitable_for_gpu_ >= | 1055 if (num_consecutive_frames_suitable_for_gpu_ >= |
1055 kNumFramesToConsiderBeforeGpuRasterization) { | 1056 kNumFramesToConsiderBeforeGpuRasterization) { |
1056 content_is_suitable_for_gpu_rasterization_ = true; | 1057 content_is_suitable_for_gpu_rasterization_ = true; |
1057 } | 1058 } |
1058 } else { | 1059 } else { |
1059 num_consecutive_frames_suitable_for_gpu_ = 0; | 1060 num_consecutive_frames_suitable_for_gpu_ = 0; |
1060 content_is_suitable_for_gpu_rasterization_ = false; | 1061 content_is_suitable_for_gpu_rasterization_ = false; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 | 1140 |
1140 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, | 1141 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
1141 TopControlsState current, | 1142 TopControlsState current, |
1142 bool animate) { | 1143 bool animate) { |
1143 // Top controls are only used in threaded or remote mode. | 1144 // Top controls are only used in threaded or remote mode. |
1144 DCHECK(IsThreaded() || IsRemoteServer()); | 1145 DCHECK(IsThreaded() || IsRemoteServer()); |
1145 proxy_->UpdateTopControlsState(constraints, current, animate); | 1146 proxy_->UpdateTopControlsState(constraints, current, animate); |
1146 } | 1147 } |
1147 | 1148 |
1148 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 1149 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
1149 AnimationHost* animation_host = layer_tree_.animation_host(); | 1150 AnimationHost* animation_host = layer_tree_->animation_host(); |
1150 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); | 1151 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); |
1151 | 1152 |
1152 if (animation_host->AnimateLayers(monotonic_time)) | 1153 if (animation_host->AnimateLayers(monotonic_time)) |
1153 animation_host->UpdateAnimationState(true, events.get()); | 1154 animation_host->UpdateAnimationState(true, events.get()); |
1154 | 1155 |
1155 if (!events->events_.empty()) | 1156 if (!events->events_.empty()) |
1156 property_trees_.needs_rebuild = true; | 1157 property_trees_.needs_rebuild = true; |
1157 } | 1158 } |
1158 | 1159 |
1159 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { | 1160 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { | 1303 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { |
1303 return SurfaceSequence(surface_client_id_, next_surface_sequence_++); | 1304 return SurfaceSequence(surface_client_id_, next_surface_sequence_++); |
1304 } | 1305 } |
1305 | 1306 |
1306 void LayerTreeHost::SetLayerTreeMutator( | 1307 void LayerTreeHost::SetLayerTreeMutator( |
1307 std::unique_ptr<LayerTreeMutator> mutator) { | 1308 std::unique_ptr<LayerTreeMutator> mutator) { |
1308 proxy_->SetMutator(std::move(mutator)); | 1309 proxy_->SetMutator(std::move(mutator)); |
1309 } | 1310 } |
1310 | 1311 |
1311 Layer* LayerTreeHost::LayerById(int id) const { | 1312 Layer* LayerTreeHost::LayerById(int id) const { |
1312 return layer_tree_.LayerById(id); | 1313 return layer_tree_->LayerById(id); |
Khushal
2016/08/08 16:55:03
Callers can directly go to the LayerTree itself.
xingliu
2016/08/09 20:57:04
Done, also move the iterators and all call sites f
| |
1313 } | |
1314 | |
1315 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const { | |
1316 ElementLayersMap::const_iterator iter = element_layers_map_.find(element_id); | |
1317 return iter != element_layers_map_.end() ? iter->second : nullptr; | |
1318 } | |
1319 | |
1320 void LayerTreeHost::AddToElementMap(Layer* layer) { | |
1321 if (!layer->element_id()) | |
1322 return; | |
1323 | |
1324 element_layers_map_[layer->element_id()] = layer; | |
1325 } | |
1326 | |
1327 void LayerTreeHost::RemoveFromElementMap(Layer* layer) { | |
1328 if (!layer->element_id()) | |
1329 return; | |
1330 | |
1331 element_layers_map_.erase(layer->element_id()); | |
1332 } | |
1333 | |
1334 bool LayerTreeHost::IsElementInList(ElementId element_id, | |
1335 ElementListType list_type) const { | |
1336 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); | |
1337 } | |
1338 | |
1339 void LayerTreeHost::SetMutatorsNeedCommit() { | |
1340 SetNeedsCommit(); | |
1341 } | |
1342 | |
1343 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { | |
1344 property_trees_.needs_rebuild = true; | |
1345 } | |
1346 | |
1347 void LayerTreeHost::SetElementFilterMutated(ElementId element_id, | |
1348 ElementListType list_type, | |
1349 const FilterOperations& filters) { | |
1350 Layer* layer = LayerByElementId(element_id); | |
1351 DCHECK(layer); | |
1352 layer->OnFilterAnimated(filters); | |
1353 } | |
1354 | |
1355 void LayerTreeHost::SetElementOpacityMutated(ElementId element_id, | |
1356 ElementListType list_type, | |
1357 float opacity) { | |
1358 Layer* layer = LayerByElementId(element_id); | |
1359 DCHECK(layer); | |
1360 layer->OnOpacityAnimated(opacity); | |
1361 } | |
1362 | |
1363 void LayerTreeHost::SetElementTransformMutated( | |
1364 ElementId element_id, | |
1365 ElementListType list_type, | |
1366 const gfx::Transform& transform) { | |
1367 Layer* layer = LayerByElementId(element_id); | |
1368 DCHECK(layer); | |
1369 layer->OnTransformAnimated(transform); | |
1370 } | |
1371 | |
1372 void LayerTreeHost::SetElementScrollOffsetMutated( | |
1373 ElementId element_id, | |
1374 ElementListType list_type, | |
1375 const gfx::ScrollOffset& scroll_offset) { | |
1376 Layer* layer = LayerByElementId(element_id); | |
1377 DCHECK(layer); | |
1378 layer->OnScrollOffsetAnimated(scroll_offset); | |
1379 } | |
1380 | |
1381 void LayerTreeHost::ElementTransformIsAnimatingChanged( | |
1382 ElementId element_id, | |
1383 ElementListType list_type, | |
1384 AnimationChangeType change_type, | |
1385 bool is_animating) { | |
1386 Layer* layer = LayerByElementId(element_id); | |
1387 if (layer) { | |
1388 switch (change_type) { | |
1389 case AnimationChangeType::POTENTIAL: | |
1390 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); | |
1391 break; | |
1392 case AnimationChangeType::RUNNING: | |
1393 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); | |
1394 break; | |
1395 case AnimationChangeType::BOTH: | |
1396 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); | |
1397 layer->OnTransformIsCurrentlyAnimatingChanged(is_animating); | |
1398 break; | |
1399 } | |
1400 } | |
1401 } | |
1402 | |
1403 void LayerTreeHost::ElementOpacityIsAnimatingChanged( | |
1404 ElementId element_id, | |
1405 ElementListType list_type, | |
1406 AnimationChangeType change_type, | |
1407 bool is_animating) { | |
1408 Layer* layer = LayerByElementId(element_id); | |
1409 if (layer) { | |
1410 switch (change_type) { | |
1411 case AnimationChangeType::POTENTIAL: | |
1412 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); | |
1413 break; | |
1414 case AnimationChangeType::RUNNING: | |
1415 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); | |
1416 break; | |
1417 case AnimationChangeType::BOTH: | |
1418 layer->OnOpacityIsPotentiallyAnimatingChanged(is_animating); | |
1419 layer->OnOpacityIsCurrentlyAnimatingChanged(is_animating); | |
1420 break; | |
1421 } | |
1422 } | |
1423 } | |
1424 | |
1425 void LayerTreeHost::ElementFilterIsAnimatingChanged( | |
1426 ElementId element_id, | |
1427 ElementListType list_type, | |
1428 AnimationChangeType change_type, | |
1429 bool is_animating) { | |
1430 Layer* layer = LayerByElementId(element_id); | |
1431 if (layer) { | |
1432 switch (change_type) { | |
1433 case AnimationChangeType::POTENTIAL: | |
1434 layer->OnFilterIsPotentiallyAnimatingChanged(is_animating); | |
1435 break; | |
1436 case AnimationChangeType::RUNNING: | |
1437 layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); | |
1438 break; | |
1439 case AnimationChangeType::BOTH: | |
1440 layer->OnFilterIsPotentiallyAnimatingChanged(is_animating); | |
1441 layer->OnFilterIsCurrentlyAnimatingChanged(is_animating); | |
1442 break; | |
1443 } | |
1444 } | |
1445 } | |
1446 | |
1447 gfx::ScrollOffset LayerTreeHost::GetScrollOffsetForAnimation( | |
1448 ElementId element_id) const { | |
1449 Layer* layer = LayerByElementId(element_id); | |
1450 DCHECK(layer); | |
1451 return layer->ScrollOffsetForAnimation(); | |
1452 } | 1314 } |
1453 | 1315 |
1454 bool LayerTreeHost::IsSingleThreaded() const { | 1316 bool LayerTreeHost::IsSingleThreaded() const { |
1455 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || | 1317 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || |
1456 !task_runner_provider_->HasImplThread()); | 1318 !task_runner_provider_->HasImplThread()); |
1457 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 1319 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
1458 } | 1320 } |
1459 | 1321 |
1460 bool LayerTreeHost::IsThreaded() const { | 1322 bool LayerTreeHost::IsThreaded() const { |
1461 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 1323 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1505 proto->set_needs_full_tree_sync(needs_full_tree_sync_); | 1367 proto->set_needs_full_tree_sync(needs_full_tree_sync_); |
1506 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); | 1368 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); |
1507 proto->set_source_frame_number(source_frame_number_); | 1369 proto->set_source_frame_number(source_frame_number_); |
1508 | 1370 |
1509 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, | 1371 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, |
1510 proto->mutable_root_layer()); | 1372 proto->mutable_root_layer()); |
1511 | 1373 |
1512 // Serialize the LayerTree before serializing the properties. During layer | 1374 // Serialize the LayerTree before serializing the properties. During layer |
1513 // property serialization, we clear the list |layer_that_should_properties_| | 1375 // property serialization, we clear the list |layer_that_should_properties_| |
1514 // from the LayerTree. | 1376 // from the LayerTree. |
1515 layer_tree_.ToProtobuf(proto->mutable_layer_tree()); | 1377 layer_tree_->ToProtobuf(proto->mutable_layer_tree()); |
1516 | 1378 |
1517 LayerProtoConverter::SerializeLayerProperties(this, | 1379 LayerProtoConverter::SerializeLayerProperties(this, |
1518 proto->mutable_layer_updates()); | 1380 proto->mutable_layer_updates()); |
1519 | 1381 |
1520 std::vector<PictureData> pictures = | 1382 std::vector<PictureData> pictures = |
1521 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 1383 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
1522 proto::PictureDataVectorToSkPicturesProto(pictures, | 1384 proto::PictureDataVectorToSkPicturesProto(pictures, |
1523 proto->mutable_pictures()); | 1385 proto->mutable_pictures()); |
1524 | 1386 |
1525 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); | 1387 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... | |
1583 source_frame_number_ = proto.source_frame_number(); | 1445 source_frame_number_ = proto.source_frame_number(); |
1584 | 1446 |
1585 // Layer hierarchy. | 1447 // Layer hierarchy. |
1586 scoped_refptr<Layer> new_root_layer = | 1448 scoped_refptr<Layer> new_root_layer = |
1587 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, | 1449 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, |
1588 proto.root_layer(), this); | 1450 proto.root_layer(), this); |
1589 if (root_layer_ != new_root_layer) { | 1451 if (root_layer_ != new_root_layer) { |
1590 root_layer_ = new_root_layer; | 1452 root_layer_ = new_root_layer; |
1591 } | 1453 } |
1592 | 1454 |
1593 layer_tree_.FromProtobuf(proto.layer_tree()); | 1455 layer_tree_->FromProtobuf(proto.layer_tree()); |
1594 | 1456 |
1595 // Ensure ClientPictureCache contains all the necessary SkPictures before | 1457 // Ensure ClientPictureCache contains all the necessary SkPictures before |
1596 // deserializing the properties. | 1458 // deserializing the properties. |
1597 proto::SkPictures proto_pictures = proto.pictures(); | 1459 proto::SkPictures proto_pictures = proto.pictures(); |
1598 std::vector<PictureData> pictures = | 1460 std::vector<PictureData> pictures = |
1599 SkPicturesProtoToPictureDataVector(proto_pictures); | 1461 SkPicturesProtoToPictureDataVector(proto_pictures); |
1600 client_picture_cache_->ApplyCacheUpdate(pictures); | 1462 client_picture_cache_->ApplyCacheUpdate(pictures); |
1601 | 1463 |
1602 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), | 1464 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), |
1603 proto.layer_updates()); | 1465 proto.layer_updates()); |
(...skipping 26 matching lines...) Expand all Loading... | |
1630 EventListenerClass::kTouchStartOrMove)] = | 1492 EventListenerClass::kTouchStartOrMove)] = |
1631 static_cast<EventListenerProperties>( | 1493 static_cast<EventListenerProperties>( |
1632 proto.touch_start_or_move_event_listener_properties()); | 1494 proto.touch_start_or_move_event_listener_properties()); |
1633 event_listener_properties_[static_cast<size_t>( | 1495 event_listener_properties_[static_cast<size_t>( |
1634 EventListenerClass::kTouchEndOrCancel)] = | 1496 EventListenerClass::kTouchEndOrCancel)] = |
1635 static_cast<EventListenerProperties>( | 1497 static_cast<EventListenerProperties>( |
1636 proto.touch_end_or_cancel_event_listener_properties()); | 1498 proto.touch_end_or_cancel_event_listener_properties()); |
1637 id_ = proto.id(); | 1499 id_ = proto.id(); |
1638 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1500 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
1639 | 1501 |
1640 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( | 1502 hud_layer_ = static_cast<HeadsUpDisplayLayer*>(UpdateAndGetLayer( |
1641 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), &layer_tree_)); | 1503 hud_layer_.get(), proto.hud_layer_id(), layer_tree_.get())); |
1642 overscroll_elasticity_layer_ = | 1504 overscroll_elasticity_layer_ = UpdateAndGetLayer( |
1643 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), | 1505 overscroll_elasticity_layer_.get(), |
1644 proto.overscroll_elasticity_layer_id(), &layer_tree_); | 1506 proto.overscroll_elasticity_layer_id(), layer_tree_.get()); |
1645 page_scale_layer_ = UpdateAndGetLayer( | 1507 page_scale_layer_ = UpdateAndGetLayer( |
1646 page_scale_layer_.get(), proto.page_scale_layer_id(), &layer_tree_); | 1508 page_scale_layer_.get(), proto.page_scale_layer_id(), layer_tree_.get()); |
1647 inner_viewport_scroll_layer_ = | 1509 inner_viewport_scroll_layer_ = UpdateAndGetLayer( |
1648 UpdateAndGetLayer(inner_viewport_scroll_layer_.get(), | 1510 inner_viewport_scroll_layer_.get(), |
1649 proto.inner_viewport_scroll_layer_id(), &layer_tree_); | 1511 proto.inner_viewport_scroll_layer_id(), layer_tree_.get()); |
1650 outer_viewport_scroll_layer_ = | 1512 outer_viewport_scroll_layer_ = UpdateAndGetLayer( |
1651 UpdateAndGetLayer(outer_viewport_scroll_layer_.get(), | 1513 outer_viewport_scroll_layer_.get(), |
1652 proto.outer_viewport_scroll_layer_id(), &layer_tree_); | 1514 proto.outer_viewport_scroll_layer_id(), layer_tree_.get()); |
1653 | 1515 |
1654 LayerSelectionFromProtobuf(&selection_, proto.selection()); | 1516 LayerSelectionFromProtobuf(&selection_, proto.selection()); |
1655 | 1517 |
1656 // It is required to create new PropertyTrees before deserializing it. | 1518 // It is required to create new PropertyTrees before deserializing it. |
1657 property_trees_ = PropertyTrees(); | 1519 property_trees_ = PropertyTrees(); |
1658 property_trees_.FromProtobuf(proto.property_trees()); | 1520 property_trees_.FromProtobuf(proto.property_trees()); |
1659 | 1521 |
1660 // Forcefully override the sequence number of all layers in the tree to have | 1522 // Forcefully override the sequence number of all layers in the tree to have |
1661 // a valid sequence number. Changing the sequence number for a layer does not | 1523 // a valid sequence number. Changing the sequence number for a layer does not |
1662 // need a commit, so the value will become out of date for layers that are not | 1524 // need a commit, so the value will become out of date for layers that are not |
1663 // updated for other reasons. All layers that at this point are part of the | 1525 // updated for other reasons. All layers that at this point are part of the |
1664 // layer tree are valid, so it is OK that they have a valid sequence number. | 1526 // layer tree are valid, so it is OK that they have a valid sequence number. |
1665 int seq_num = property_trees_.sequence_number; | 1527 int seq_num = property_trees_.sequence_number; |
1666 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | 1528 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { |
1667 layer->set_property_tree_sequence_number(seq_num); | 1529 layer->set_property_tree_sequence_number(seq_num); |
1668 }); | 1530 }); |
1669 | 1531 |
1670 surface_client_id_ = proto.surface_client_id(); | 1532 surface_client_id_ = proto.surface_client_id(); |
1671 next_surface_sequence_ = proto.next_surface_sequence(); | 1533 next_surface_sequence_ = proto.next_surface_sequence(); |
1672 } | 1534 } |
1673 | 1535 |
1674 AnimationHost* LayerTreeHost::animation_host() const { | 1536 AnimationHost* LayerTreeHost::animation_host() const { |
1675 return layer_tree_.animation_host(); | 1537 return layer_tree_->animation_host(); |
Khushal
2016/08/08 16:55:02
While we are at it, may be we can remove the metho
xingliu
2016/08/09 20:57:04
Done, also fix the call sites.
| |
1676 } | 1538 } |
1677 | 1539 |
1678 } // namespace cc | 1540 } // namespace cc |
OLD | NEW |