Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1249)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 2080703005: cc: Remove LayerTreeImpl::root_layer usage outside tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_impl.h" 5 #include "cc/trees/layer_tree_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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 top_controls_shown_ratio_(top_controls_shown_ratio) { 83 top_controls_shown_ratio_(top_controls_shown_ratio) {
84 property_trees()->is_main_thread = false; 84 property_trees()->is_main_thread = false;
85 } 85 }
86 86
87 LayerTreeImpl::~LayerTreeImpl() { 87 LayerTreeImpl::~LayerTreeImpl() {
88 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS 88 BreakSwapPromises(IsActiveTree() ? SwapPromise::SWAP_FAILS
89 : SwapPromise::ACTIVATION_FAILS); 89 : SwapPromise::ACTIVATION_FAILS);
90 90
91 // Need to explicitly clear the tree prior to destroying this so that 91 // Need to explicitly clear the tree prior to destroying this so that
92 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. 92 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
93 DCHECK(!root_layer_); 93 DCHECK(LayerListIsEmpty());
94 DCHECK(layers_->empty()); 94 DCHECK(layers_->empty());
95 } 95 }
96 96
97 void LayerTreeImpl::Shutdown() { 97 void LayerTreeImpl::Shutdown() {
98 DetachLayers(); 98 DetachLayers();
99 DCHECK(!root_layer_); 99 DCHECK(LayerListIsEmpty());
100 } 100 }
101 101
102 void LayerTreeImpl::ReleaseResources() { 102 void LayerTreeImpl::ReleaseResources() {
103 if (root_layer_) { 103 if (!LayerListIsEmpty()) {
104 LayerTreeHostCommon::CallFunctionForEveryLayer( 104 LayerTreeHostCommon::CallFunctionForEveryLayer(
105 this, [](LayerImpl* layer) { layer->ReleaseResources(); }); 105 this, [](LayerImpl* layer) { layer->ReleaseResources(); });
106 } 106 }
107 } 107 }
108 108
109 void LayerTreeImpl::RecreateResources() { 109 void LayerTreeImpl::RecreateResources() {
110 if (root_layer_) { 110 if (!LayerListIsEmpty()) {
111 LayerTreeHostCommon::CallFunctionForEveryLayer( 111 LayerTreeHostCommon::CallFunctionForEveryLayer(
112 this, [](LayerImpl* layer) { layer->RecreateResources(); }); 112 this, [](LayerImpl* layer) { layer->RecreateResources(); });
113 } 113 }
114 } 114 }
115 115
116 bool LayerTreeImpl::IsViewportLayerId(int id) const { 116 bool LayerTreeImpl::IsViewportLayerId(int id) const {
117 if (id == inner_viewport_scroll_layer_id_ || 117 if (id == inner_viewport_scroll_layer_id_ ||
118 id == outer_viewport_scroll_layer_id_) 118 id == outer_viewport_scroll_layer_id_)
119 return true; 119 return true;
120 if (InnerViewportContainerLayer() && 120 if (InnerViewportContainerLayer() &&
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 if (scrollbar_needs_animation) { 247 if (scrollbar_needs_animation) {
248 ScrollbarAnimationController* controller = 248 ScrollbarAnimationController* controller =
249 layer_tree_host_impl_->ScrollbarAnimationControllerForId( 249 layer_tree_host_impl_->ScrollbarAnimationControllerForId(
250 scroll_layer_id); 250 scroll_layer_id);
251 if (controller) 251 if (controller)
252 controller->DidScrollUpdate(scroll_layer_size_did_change); 252 controller->DidScrollUpdate(scroll_layer_size_did_change);
253 } 253 }
254 } 254 }
255 255
256 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const {
257 return layer_list_.empty() ? nullptr : layer_list_[0]->render_surface();
258 }
259
260 bool LayerTreeImpl::LayerListIsEmpty() const {
261 return layer_list_.empty();
262 }
263
256 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) { 264 void LayerTreeImpl::SetRootLayer(std::unique_ptr<LayerImpl> layer) {
257 if (root_layer_ && layer.get() != root_layer_) 265 if (root_layer_ && layer.get() != root_layer_)
258 RemoveLayer(root_layer_->id()); 266 RemoveLayer(root_layer_->id());
259 root_layer_ = layer.get(); 267 root_layer_ = layer.get();
260 if (layer) 268 if (layer)
261 AddLayer(std::move(layer)); 269 AddLayer(std::move(layer));
262 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); 270 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
263 } 271 }
264 272
265 void LayerTreeImpl::SetRootLayerFromLayerList() { 273 void LayerTreeImpl::SetRootLayerFromLayerList() {
(...skipping 11 matching lines...) Expand all
277 285
278 void LayerTreeImpl::BuildLayerListForTesting() { 286 void LayerTreeImpl::BuildLayerListForTesting() {
279 ClearLayerList(); 287 ClearLayerList();
280 LayerListIterator<LayerImpl> it(root_layer_); 288 LayerListIterator<LayerImpl> it(root_layer_);
281 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) { 289 for (; it != LayerListIterator<LayerImpl>(nullptr); ++it) {
282 AddToLayerList(*it); 290 AddToLayerList(*it);
283 } 291 }
284 } 292 }
285 293
286 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const { 294 bool LayerTreeImpl::IsRootLayer(const LayerImpl* layer) const {
287 return root_layer_ == layer; 295 return layer_list_.empty() ? false : layer_list_[0] == layer;
288 } 296 }
289 297
290 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { 298 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const {
291 return LayerById(inner_viewport_scroll_layer_id_); 299 return LayerById(inner_viewport_scroll_layer_id_);
292 } 300 }
293 301
294 LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { 302 LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const {
295 return LayerById(outer_viewport_scroll_layer_id_); 303 return LayerById(outer_viewport_scroll_layer_id_);
296 } 304 }
297 305
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return page_scale_factor; 597 return page_scale_factor;
590 } 598 }
591 599
592 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { 600 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() {
593 // TODO(enne): This should get replaced by pulling out scrolling and 601 // TODO(enne): This should get replaced by pulling out scrolling and
594 // animations into their own trees. Then scrolls and animations would have 602 // animations into their own trees. Then scrolls and animations would have
595 // their own ways of synchronizing across commits. This occurs to push 603 // their own ways of synchronizing across commits. This occurs to push
596 // updates from scrolling deltas on the compositor thread that have occurred 604 // updates from scrolling deltas on the compositor thread that have occurred
597 // after begin frame and updates from animations that have ticked since begin 605 // after begin frame and updates from animations that have ticked since begin
598 // frame to a newly-committed property tree. 606 // frame to a newly-committed property tree.
599 if (!root_layer()) 607 if (layer_list_.empty())
600 return; 608 return;
601 for (auto& layer_id_to_opacity : opacity_animations_map_) { 609 for (auto& layer_id_to_opacity : opacity_animations_map_) {
602 const int id = layer_id_to_opacity.first; 610 const int id = layer_id_to_opacity.first;
603 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) { 611 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) {
604 EffectNode* node = property_trees_.effect_tree.Node( 612 EffectNode* node = property_trees_.effect_tree.Node(
605 property_trees_.effect_id_to_index_map[id]); 613 property_trees_.effect_id_to_index_map[id]);
606 if (!node->data.is_currently_animating_opacity || 614 if (!node->data.is_currently_animating_opacity ||
607 node->data.opacity == layer_id_to_opacity.second) 615 node->data.opacity == layer_id_to_opacity.second)
608 continue; 616 continue;
609 node->data.opacity = layer_id_to_opacity.second; 617 node->data.opacity = layer_id_to_opacity.second;
(...skipping 26 matching lines...) Expand all
636 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { 644 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) {
637 DCHECK(IsActiveTree()); 645 DCHECK(IsActiveTree());
638 if (page_scale_factor()->SetCurrent( 646 if (page_scale_factor()->SetCurrent(
639 ClampPageScaleFactorToLimits(active_page_scale))) { 647 ClampPageScaleFactorToLimits(active_page_scale))) {
640 DidUpdatePageScale(); 648 DidUpdatePageScale();
641 if (PageScaleLayer()) { 649 if (PageScaleLayer()) {
642 draw_property_utils::UpdatePageScaleFactor( 650 draw_property_utils::UpdatePageScaleFactor(
643 property_trees(), PageScaleLayer(), current_page_scale_factor(), 651 property_trees(), PageScaleLayer(), current_page_scale_factor(),
644 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); 652 device_scale_factor(), layer_tree_host_impl_->DrawTransform());
645 } else { 653 } else {
646 DCHECK(!root_layer_ || active_page_scale == 1); 654 DCHECK(layer_list_.empty() || active_page_scale == 1);
647 } 655 }
648 } 656 }
649 } 657 }
650 658
651 void LayerTreeImpl::PushPageScaleFromMainThread(float page_scale_factor, 659 void LayerTreeImpl::PushPageScaleFromMainThread(float page_scale_factor,
652 float min_page_scale_factor, 660 float min_page_scale_factor,
653 float max_page_scale_factor) { 661 float max_page_scale_factor) {
654 PushPageScaleFactorAndLimits(&page_scale_factor, min_page_scale_factor, 662 PushPageScaleFactorAndLimits(&page_scale_factor, min_page_scale_factor,
655 max_page_scale_factor); 663 max_page_scale_factor);
656 } 664 }
(...skipping 27 matching lines...) Expand all
684 692
685 if (changed_page_scale) 693 if (changed_page_scale)
686 DidUpdatePageScale(); 694 DidUpdatePageScale();
687 695
688 if (page_scale_factor) { 696 if (page_scale_factor) {
689 if (PageScaleLayer()) { 697 if (PageScaleLayer()) {
690 draw_property_utils::UpdatePageScaleFactor( 698 draw_property_utils::UpdatePageScaleFactor(
691 property_trees(), PageScaleLayer(), current_page_scale_factor(), 699 property_trees(), PageScaleLayer(), current_page_scale_factor(),
692 device_scale_factor(), layer_tree_host_impl_->DrawTransform()); 700 device_scale_factor(), layer_tree_host_impl_->DrawTransform());
693 } else { 701 } else {
694 DCHECK(!root_layer_ || *page_scale_factor == 1); 702 DCHECK(layer_list_.empty() || *page_scale_factor == 1);
695 } 703 }
696 } 704 }
697 } 705 }
698 706
699 void LayerTreeImpl::set_top_controls_shrink_blink_size(bool shrink) { 707 void LayerTreeImpl::set_top_controls_shrink_blink_size(bool shrink) {
700 if (top_controls_shrink_blink_size_ == shrink) 708 if (top_controls_shrink_blink_size_ == shrink)
701 return; 709 return;
702 710
703 top_controls_shrink_blink_size_ = shrink; 711 top_controls_shrink_blink_size_ = shrink;
704 if (IsActiveTree()) 712 if (IsActiveTree())
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 gfx::Rect(root_scroll_layer->bounds())); 804 gfx::Rect(root_scroll_layer->bounds()));
797 } 805 }
798 806
799 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { 807 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() {
800 DCHECK(IsActiveTree()); 808 DCHECK(IsActiveTree());
801 809
802 page_scale_factor()->AbortCommit(); 810 page_scale_factor()->AbortCommit();
803 top_controls_shown_ratio()->AbortCommit(); 811 top_controls_shown_ratio()->AbortCommit();
804 elastic_overscroll()->AbortCommit(); 812 elastic_overscroll()->AbortCommit();
805 813
806 if (!root_layer()) 814 if (layer_list_.empty())
807 return; 815 return;
808 816
809 property_trees()->scroll_tree.ApplySentScrollDeltasFromAbortedCommit(); 817 property_trees()->scroll_tree.ApplySentScrollDeltasFromAbortedCommit();
810 } 818 }
811 819
812 void LayerTreeImpl::SetViewportLayersFromIds( 820 void LayerTreeImpl::SetViewportLayersFromIds(
813 int overscroll_elasticity_layer_id, 821 int overscroll_elasticity_layer_id,
814 int page_scale_layer_id, 822 int page_scale_layer_id,
815 int inner_viewport_scroll_layer_id, 823 int inner_viewport_scroll_layer_id,
816 int outer_viewport_scroll_layer_id) { 824 int outer_viewport_scroll_layer_id) {
(...skipping 21 matching lines...) Expand all
838 // For max_texture_size. When the renderer is re-created in 846 // For max_texture_size. When the renderer is re-created in
839 // CreateAndSetRenderer, the needs update draw properties flag is set 847 // CreateAndSetRenderer, the needs update draw properties flag is set
840 // again. 848 // again.
841 if (!layer_tree_host_impl_->renderer()) 849 if (!layer_tree_host_impl_->renderer())
842 return false; 850 return false;
843 851
844 // Clear this after the renderer early out, as it should still be 852 // Clear this after the renderer early out, as it should still be
845 // possible to hit test even without a renderer. 853 // possible to hit test even without a renderer.
846 render_surface_layer_list_.clear(); 854 render_surface_layer_list_.clear();
847 855
848 if (!root_layer()) 856 if (layer_list_.empty())
849 return false; 857 return false;
850 858
851 { 859 {
852 base::ElapsedTimer timer; 860 base::ElapsedTimer timer;
853 TRACE_EVENT2( 861 TRACE_EVENT2(
854 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties", 862 "cc", "LayerTreeImpl::UpdateDrawProperties::CalculateDrawProperties",
855 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_); 863 "IsActive", IsActiveTree(), "SourceFrameNumber", source_frame_number_);
856 bool can_render_to_separate_surface = 864 bool can_render_to_separate_surface =
857 (!is_in_resourceless_software_draw_mode()); 865 (!is_in_resourceless_software_draw_mode());
858 866
859 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs( 867 LayerTreeHostCommon::CalcDrawPropsImplInputs inputs(
860 root_layer(), DrawViewportSize(), 868 layer_list_[0], DrawViewportSize(),
861 layer_tree_host_impl_->DrawTransform(), device_scale_factor(), 869 layer_tree_host_impl_->DrawTransform(), device_scale_factor(),
862 current_page_scale_factor(), PageScaleLayer(), 870 current_page_scale_factor(), PageScaleLayer(),
863 InnerViewportScrollLayer(), OuterViewportScrollLayer(), 871 InnerViewportScrollLayer(), OuterViewportScrollLayer(),
864 elastic_overscroll()->Current(IsActiveTree()), 872 elastic_overscroll()->Current(IsActiveTree()),
865 OverscrollElasticityLayer(), resource_provider()->max_texture_size(), 873 OverscrollElasticityLayer(), resource_provider()->max_texture_size(),
866 can_render_to_separate_surface, 874 can_render_to_separate_surface,
867 settings().layer_transforms_should_scale_layer_contents, 875 settings().layer_transforms_should_scale_layer_contents,
868 settings().verify_clip_tree_calculations, &render_surface_layer_list_, 876 settings().verify_clip_tree_calculations, &render_surface_layer_list_,
869 &property_trees_); 877 &property_trees_);
870 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 878 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
871 if (const char* client_name = GetClientNameForMetrics()) { 879 if (const char* client_name = GetClientNameForMetrics()) {
872 UMA_HISTOGRAM_COUNTS( 880 UMA_HISTOGRAM_COUNTS(
873 base::StringPrintf( 881 base::StringPrintf(
874 "Compositing.%s.LayerTreeImpl.CalculateDrawPropertiesUs", 882 "Compositing.%s.LayerTreeImpl.CalculateDrawPropertiesUs",
875 client_name), 883 client_name),
876 timer.Elapsed().InMicroseconds()); 884 timer.Elapsed().InMicroseconds());
877 UMA_HISTOGRAM_COUNTS_100( 885 UMA_HISTOGRAM_COUNTS_100(
878 base::StringPrintf("Compositing.%s.NumRenderSurfaces", client_name), 886 base::StringPrintf("Compositing.%s.NumRenderSurfaces", client_name),
879 base::saturated_cast<int>(render_surface_layer_list_.size())); 887 base::saturated_cast<int>(render_surface_layer_list_.size()));
880 } 888 }
881 } 889 }
882 890
883 { 891 {
884 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", 892 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion",
885 "IsActive", IsActiveTree(), "SourceFrameNumber", 893 "IsActive", IsActiveTree(), "SourceFrameNumber",
886 source_frame_number_); 894 source_frame_number_);
887 OcclusionTracker occlusion_tracker( 895 OcclusionTracker occlusion_tracker(
888 root_layer()->render_surface()->content_rect()); 896 layer_list_[0]->render_surface()->content_rect());
889 occlusion_tracker.set_minimum_tracking_size( 897 occlusion_tracker.set_minimum_tracking_size(
890 settings().minimum_occlusion_tracking_size); 898 settings().minimum_occlusion_tracking_size);
891 899
892 // LayerIterator is used here instead of CallFunctionForEveryLayer to only 900 // LayerIterator is used here instead of CallFunctionForEveryLayer to only
893 // UpdateTilePriorities on layers that will be visible (and thus have valid 901 // UpdateTilePriorities on layers that will be visible (and thus have valid
894 // draw properties) and not because any ordering is required. 902 // draw properties) and not because any ordering is required.
895 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); 903 LayerIterator end = LayerIterator::End(&render_surface_layer_list_);
896 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); 904 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_);
897 it != end; ++it) { 905 it != end; ++it) {
898 occlusion_tracker.EnterLayer(it); 906 occlusion_tracker.EnterLayer(it);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 layer->id(), 1072 layer->id(),
1065 IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING); 1073 IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING);
1066 } 1074 }
1067 1075
1068 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { 1076 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) {
1069 DCHECK(LayerById(layer->id())); 1077 DCHECK(LayerById(layer->id()));
1070 layer_tree_host_impl_->animation_host()->UnregisterElement( 1078 layer_tree_host_impl_->animation_host()->UnregisterElement(
1071 layer->id(), 1079 layer->id(),
1072 IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING); 1080 IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING);
1073 layer_id_map_.erase(layer->id()); 1081 layer_id_map_.erase(layer->id());
1074 DCHECK_NE(root_layer_, layer);
1075 } 1082 }
1076 1083
1077 // These manage ownership of the LayerImpl. 1084 // These manage ownership of the LayerImpl.
1078 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { 1085 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) {
1079 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); 1086 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end());
1080 layers_->push_back(std::move(layer)); 1087 layers_->push_back(std::move(layer));
1081 set_needs_update_draw_properties(); 1088 set_needs_update_draw_properties();
1082 } 1089 }
1083 1090
1084 std::unique_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) { 1091 std::unique_ptr<LayerImpl> LayerTreeImpl::RemoveLayer(int id) {
(...skipping 17 matching lines...) Expand all
1102 void LayerTreeImpl::DidBecomeActive() { 1109 void LayerTreeImpl::DidBecomeActive() {
1103 if (next_activation_forces_redraw_) { 1110 if (next_activation_forces_redraw_) {
1104 layer_tree_host_impl_->SetFullRootLayerDamage(); 1111 layer_tree_host_impl_->SetFullRootLayerDamage();
1105 next_activation_forces_redraw_ = false; 1112 next_activation_forces_redraw_ = false;
1106 } 1113 }
1107 1114
1108 // Always reset this flag on activation, as we would only have activated 1115 // Always reset this flag on activation, as we would only have activated
1109 // if we were in a good state. 1116 // if we were in a good state.
1110 layer_tree_host_impl_->ResetRequiresHighResToDraw(); 1117 layer_tree_host_impl_->ResetRequiresHighResToDraw();
1111 1118
1112 if (root_layer()) { 1119 if (!layer_list_.empty()) {
1113 LayerTreeHostCommon::CallFunctionForEveryLayer( 1120 LayerTreeHostCommon::CallFunctionForEveryLayer(
1114 this, [](LayerImpl* layer) { layer->DidBecomeActive(); }); 1121 this, [](LayerImpl* layer) { layer->DidBecomeActive(); });
1115 } 1122 }
1116 1123
1117 for (const auto& swap_promise : swap_promise_list_) 1124 for (const auto& swap_promise : swap_promise_list_)
1118 swap_promise->DidActivate(); 1125 swap_promise->DidActivate();
1119 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), 1126 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(),
1120 source_frame_number_); 1127 source_frame_number_);
1121 } 1128 }
1122 1129
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 struct FindScrollingLayerOrScrollbarLayerFunctor { 1768 struct FindScrollingLayerOrScrollbarLayerFunctor {
1762 bool operator()(LayerImpl* layer) const { 1769 bool operator()(LayerImpl* layer) const {
1763 return ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(layer); 1770 return ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(layer);
1764 } 1771 }
1765 }; 1772 };
1766 1773
1767 LayerImpl* 1774 LayerImpl*
1768 LayerTreeImpl::FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( 1775 LayerTreeImpl::FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint(
1769 const gfx::PointF& screen_space_point) { 1776 const gfx::PointF& screen_space_point) {
1770 FindClosestMatchingLayerState state; 1777 FindClosestMatchingLayerState state;
1771 FindClosestMatchingLayer(screen_space_point, root_layer(), 1778 LayerImpl* root_layer = layer_list_.empty() ? nullptr : layer_list_[0];
1779 FindClosestMatchingLayer(screen_space_point, root_layer,
1772 FindScrollingLayerOrScrollbarLayerFunctor(), 1780 FindScrollingLayerOrScrollbarLayerFunctor(),
1773 property_trees_.transform_tree, 1781 property_trees_.transform_tree,
1774 property_trees_.clip_tree, &state); 1782 property_trees_.clip_tree, &state);
1775 return state.closest_match; 1783 return state.closest_match;
1776 } 1784 }
1777 1785
1778 struct HitTestVisibleScrollableOrTouchableFunctor { 1786 struct HitTestVisibleScrollableOrTouchableFunctor {
1779 bool operator()(LayerImpl* layer) const { 1787 bool operator()(LayerImpl* layer) const {
1780 return layer->is_drawn_render_surface_layer_list_member() || 1788 return layer->is_drawn_render_surface_layer_list_member() ||
1781 ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(layer) || 1789 ScrollsOrScrollbarAnyDrawnRenderSurfaceLayerListMember(layer) ||
1782 !layer->touch_event_handler_region().IsEmpty(); 1790 !layer->touch_event_handler_region().IsEmpty();
1783 } 1791 }
1784 }; 1792 };
1785 1793
1786 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint( 1794 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPoint(
1787 const gfx::PointF& screen_space_point) { 1795 const gfx::PointF& screen_space_point) {
1788 if (!root_layer()) 1796 if (layer_list_.empty())
1789 return NULL; 1797 return NULL;
1790 bool update_lcd_text = false; 1798 bool update_lcd_text = false;
1791 if (!UpdateDrawProperties(update_lcd_text)) 1799 if (!UpdateDrawProperties(update_lcd_text))
1792 return NULL; 1800 return NULL;
1793 FindClosestMatchingLayerState state; 1801 FindClosestMatchingLayerState state;
1794 FindClosestMatchingLayer(screen_space_point, root_layer(), 1802 FindClosestMatchingLayer(screen_space_point, layer_list_[0],
1795 HitTestVisibleScrollableOrTouchableFunctor(), 1803 HitTestVisibleScrollableOrTouchableFunctor(),
1796 property_trees_.transform_tree, 1804 property_trees_.transform_tree,
1797 property_trees_.clip_tree, &state); 1805 property_trees_.clip_tree, &state);
1798 return state.closest_match; 1806 return state.closest_match;
1799 } 1807 }
1800 1808
1801 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point, 1809 static bool LayerHasTouchEventHandlersAt(const gfx::PointF& screen_space_point,
1802 LayerImpl* layer_impl, 1810 LayerImpl* layer_impl,
1803 const TransformTree& transform_tree, 1811 const TransformTree& transform_tree,
1804 const ClipTree& clip_tree) { 1812 const ClipTree& clip_tree) {
(...skipping 20 matching lines...) Expand all
1825 return LayerHasTouchEventHandlersAt(screen_space_point, layer, 1833 return LayerHasTouchEventHandlersAt(screen_space_point, layer,
1826 transform_tree, clip_tree); 1834 transform_tree, clip_tree);
1827 } 1835 }
1828 const gfx::PointF screen_space_point; 1836 const gfx::PointF screen_space_point;
1829 const TransformTree& transform_tree; 1837 const TransformTree& transform_tree;
1830 const ClipTree& clip_tree; 1838 const ClipTree& clip_tree;
1831 }; 1839 };
1832 1840
1833 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion( 1841 LayerImpl* LayerTreeImpl::FindLayerThatIsHitByPointInTouchHandlerRegion(
1834 const gfx::PointF& screen_space_point) { 1842 const gfx::PointF& screen_space_point) {
1835 if (!root_layer()) 1843 if (layer_list_.empty())
1836 return NULL; 1844 return NULL;
1837 bool update_lcd_text = false; 1845 bool update_lcd_text = false;
1838 if (!UpdateDrawProperties(update_lcd_text)) 1846 if (!UpdateDrawProperties(update_lcd_text))
1839 return NULL; 1847 return NULL;
1840 FindTouchEventLayerFunctor func = {screen_space_point, 1848 FindTouchEventLayerFunctor func = {screen_space_point,
1841 property_trees_.transform_tree, 1849 property_trees_.transform_tree,
1842 property_trees_.clip_tree}; 1850 property_trees_.clip_tree};
1843 FindClosestMatchingLayerState state; 1851 FindClosestMatchingLayerState state;
1844 FindClosestMatchingLayer(screen_space_point, root_layer(), func, 1852 FindClosestMatchingLayer(screen_space_point, layer_list_[0], func,
1845 property_trees_.transform_tree, 1853 property_trees_.transform_tree,
1846 property_trees_.clip_tree, &state); 1854 property_trees_.clip_tree, &state);
1847 return state.closest_match; 1855 return state.closest_match;
1848 } 1856 }
1849 1857
1850 void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) { 1858 void LayerTreeImpl::RegisterSelection(const LayerSelection& selection) {
1851 selection_ = selection; 1859 selection_ = selection;
1852 } 1860 }
1853 1861
1854 static gfx::SelectionBound ComputeViewportSelectionBound( 1862 static gfx::SelectionBound ComputeViewportSelectionBound(
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 2086
2079 void LayerTreeImpl::ResetAllChangeTracking() { 2087 void LayerTreeImpl::ResetAllChangeTracking() {
2080 layers_that_should_push_properties_.clear(); 2088 layers_that_should_push_properties_.clear();
2081 // Iterate over all layers, including masks and replicas. 2089 // Iterate over all layers, including masks and replicas.
2082 for (auto& layer : *layers_) 2090 for (auto& layer : *layers_)
2083 layer->ResetChangeTracking(); 2091 layer->ResetChangeTracking();
2084 property_trees_.ResetAllChangeTracking(); 2092 property_trees_.ResetAllChangeTracking();
2085 } 2093 }
2086 2094
2087 } // namespace cc 2095 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | cc/trees/layer_tree_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698