| 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_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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (scrollbar_needs_animation) { | 270 if (scrollbar_needs_animation) { |
| 271 ScrollbarAnimationController* controller = | 271 ScrollbarAnimationController* controller = |
| 272 layer_tree_host_impl_->ScrollbarAnimationControllerForId( | 272 layer_tree_host_impl_->ScrollbarAnimationControllerForId( |
| 273 scroll_layer_id); | 273 scroll_layer_id); |
| 274 if (controller) | 274 if (controller) |
| 275 controller->DidScrollUpdate(scroll_layer_size_did_change); | 275 controller->DidScrollUpdate(scroll_layer_size_did_change); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { | 279 RenderSurfaceImpl* LayerTreeImpl::RootRenderSurface() const { |
| 280 return layer_list_.empty() ? nullptr : layer_list_[0]->render_surface(); | 280 return layer_list_.empty() ? nullptr : layer_list_[0]->GetRenderSurface(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 bool LayerTreeImpl::LayerListIsEmpty() const { | 283 bool LayerTreeImpl::LayerListIsEmpty() const { |
| 284 return layer_list_.empty(); | 284 return layer_list_.empty(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 void LayerTreeImpl::SetRootLayerForTesting(std::unique_ptr<LayerImpl> layer) { | 287 void LayerTreeImpl::SetRootLayerForTesting(std::unique_ptr<LayerImpl> layer) { |
| 288 if (root_layer_for_testing_ && layer.get() != root_layer_for_testing_) | 288 if (root_layer_for_testing_ && layer.get() != root_layer_for_testing_) |
| 289 RemoveLayer(root_layer_for_testing_->id()); | 289 RemoveLayer(root_layer_for_testing_->id()); |
| 290 root_layer_for_testing_ = layer.get(); | 290 root_layer_for_testing_ = layer.get(); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 base::StringPrintf("Compositing.%s.NumRenderSurfaces", client_name), | 1042 base::StringPrintf("Compositing.%s.NumRenderSurfaces", client_name), |
| 1043 base::saturated_cast<int>(render_surface_layer_list_.size())); | 1043 base::saturated_cast<int>(render_surface_layer_list_.size())); |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 { | 1047 { |
| 1048 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", | 1048 TRACE_EVENT2("cc", "LayerTreeImpl::UpdateDrawProperties::Occlusion", |
| 1049 "IsActive", IsActiveTree(), "SourceFrameNumber", | 1049 "IsActive", IsActiveTree(), "SourceFrameNumber", |
| 1050 source_frame_number_); | 1050 source_frame_number_); |
| 1051 OcclusionTracker occlusion_tracker( | 1051 OcclusionTracker occlusion_tracker( |
| 1052 layer_list_[0]->render_surface()->content_rect()); | 1052 layer_list_[0]->GetRenderSurface()->content_rect()); |
| 1053 occlusion_tracker.set_minimum_tracking_size( | 1053 occlusion_tracker.set_minimum_tracking_size( |
| 1054 settings().minimum_occlusion_tracking_size); | 1054 settings().minimum_occlusion_tracking_size); |
| 1055 | 1055 |
| 1056 // LayerIterator is used here instead of CallFunctionForEveryLayer to only | 1056 // LayerIterator is used here instead of CallFunctionForEveryLayer to only |
| 1057 // UpdateTilePriorities on layers that will be visible (and thus have valid | 1057 // UpdateTilePriorities on layers that will be visible (and thus have valid |
| 1058 // draw properties) and not because any ordering is required. | 1058 // draw properties) and not because any ordering is required. |
| 1059 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); | 1059 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); |
| 1060 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); | 1060 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); |
| 1061 it != end; ++it) { | 1061 it != end; ++it) { |
| 1062 occlusion_tracker.EnterLayer(it); | 1062 occlusion_tracker.EnterLayer(it); |
| 1063 | 1063 |
| 1064 if (it.represents_itself()) { | 1064 if (it.represents_itself()) { |
| 1065 it->draw_properties().occlusion_in_content_space = | 1065 it->draw_properties().occlusion_in_content_space = |
| 1066 occlusion_tracker.GetCurrentOcclusionForLayer(it->DrawTransform()); | 1066 occlusion_tracker.GetCurrentOcclusionForLayer(it->DrawTransform()); |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 if (it.represents_contributing_render_surface()) { | 1069 if (it.represents_contributing_render_surface()) { |
| 1070 const RenderSurfaceImpl* occlusion_surface = | 1070 const RenderSurfaceImpl* occlusion_surface = |
| 1071 occlusion_tracker.OcclusionSurfaceForContributingSurface(); | 1071 occlusion_tracker.OcclusionSurfaceForContributingSurface(); |
| 1072 gfx::Transform draw_transform; | 1072 gfx::Transform draw_transform; |
| 1073 RenderSurfaceImpl* render_surface = it->render_surface(); | 1073 RenderSurfaceImpl* render_surface = it->GetRenderSurface(); |
| 1074 if (occlusion_surface) { | 1074 if (occlusion_surface) { |
| 1075 // We are calculating transform between two render surfaces. So, we | 1075 // We are calculating transform between two render surfaces. So, we |
| 1076 // need to apply the surface contents scale at target and remove the | 1076 // need to apply the surface contents scale at target and remove the |
| 1077 // surface contents scale at source. | 1077 // surface contents scale at source. |
| 1078 property_trees()->GetToTarget(render_surface->TransformTreeIndex(), | 1078 property_trees()->GetToTarget(render_surface->TransformTreeIndex(), |
| 1079 occlusion_surface->EffectTreeIndex(), | 1079 occlusion_surface->EffectTreeIndex(), |
| 1080 &draw_transform); | 1080 &draw_transform); |
| 1081 const EffectNode* effect_node = property_trees()->effect_tree.Node( | 1081 const EffectNode* effect_node = property_trees()->effect_tree.Node( |
| 1082 render_surface->EffectTreeIndex()); | 1082 render_surface->EffectTreeIndex()); |
| 1083 draw_property_utils::ConcatInverseSurfaceContentsScale( | 1083 draw_property_utils::ConcatInverseSurfaceContentsScale( |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 return false; | 1786 return false; |
| 1787 | 1787 |
| 1788 return layer_space_region.Contains( | 1788 return layer_space_region.Contains( |
| 1789 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); | 1789 gfx::ToRoundedPoint(hit_test_point_in_layer_space)); |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 static const gfx::Transform SurfaceScreenSpaceTransform( | 1792 static const gfx::Transform SurfaceScreenSpaceTransform( |
| 1793 const LayerImpl* layer) { | 1793 const LayerImpl* layer) { |
| 1794 const PropertyTrees* property_trees = | 1794 const PropertyTrees* property_trees = |
| 1795 layer->layer_tree_impl()->property_trees(); | 1795 layer->layer_tree_impl()->property_trees(); |
| 1796 RenderSurfaceImpl* render_surface = layer->render_surface(); | 1796 RenderSurfaceImpl* render_surface = layer->GetRenderSurface(); |
| 1797 DCHECK(render_surface); | 1797 DCHECK(render_surface); |
| 1798 return layer->is_drawn_render_surface_layer_list_member() | 1798 return layer->is_drawn_render_surface_layer_list_member() |
| 1799 ? render_surface->screen_space_transform() | 1799 ? render_surface->screen_space_transform() |
| 1800 : property_trees | 1800 : property_trees |
| 1801 ->ToScreenSpaceTransformWithoutSurfaceContentsScale( | 1801 ->ToScreenSpaceTransformWithoutSurfaceContentsScale( |
| 1802 render_surface->TransformTreeIndex(), | 1802 render_surface->TransformTreeIndex(), |
| 1803 render_surface->EffectTreeIndex()); | 1803 render_surface->EffectTreeIndex()); |
| 1804 } | 1804 } |
| 1805 | 1805 |
| 1806 static bool PointIsClippedByAncestorClipNode( | 1806 static bool PointIsClippedByAncestorClipNode( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1831 | 1831 |
| 1832 gfx::Transform screen_space_transform = | 1832 gfx::Transform screen_space_transform = |
| 1833 transform_tree.ToScreen(clip_node->transform_id); | 1833 transform_tree.ToScreen(clip_node->transform_id); |
| 1834 if (!PointHitsRect(screen_space_point, screen_space_transform, clip, | 1834 if (!PointHitsRect(screen_space_point, screen_space_transform, clip, |
| 1835 NULL)) { | 1835 NULL)) { |
| 1836 return true; | 1836 return true; |
| 1837 } | 1837 } |
| 1838 } | 1838 } |
| 1839 const LayerImpl* clip_node_owner = | 1839 const LayerImpl* clip_node_owner = |
| 1840 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id); | 1840 layer->layer_tree_impl()->LayerById(clip_node->owning_layer_id); |
| 1841 RenderSurfaceImpl* render_surface = clip_node_owner->render_surface(); | 1841 RenderSurfaceImpl* render_surface = clip_node_owner->GetRenderSurface(); |
| 1842 if (render_surface && | 1842 if (render_surface && |
| 1843 !PointHitsRect(screen_space_point, | 1843 !PointHitsRect(screen_space_point, |
| 1844 SurfaceScreenSpaceTransform(clip_node_owner), | 1844 SurfaceScreenSpaceTransform(clip_node_owner), |
| 1845 render_surface->content_rect(), NULL)) { | 1845 render_surface->content_rect(), NULL)) { |
| 1846 return true; | 1846 return true; |
| 1847 } | 1847 } |
| 1848 } | 1848 } |
| 1849 return false; | 1849 return false; |
| 1850 } | 1850 } |
| 1851 | 1851 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 | 2118 |
| 2119 void LayerTreeImpl::ResetAllChangeTracking() { | 2119 void LayerTreeImpl::ResetAllChangeTracking() { |
| 2120 layers_that_should_push_properties_.clear(); | 2120 layers_that_should_push_properties_.clear(); |
| 2121 // Iterate over all layers, including masks. | 2121 // Iterate over all layers, including masks. |
| 2122 for (auto& layer : *layers_) | 2122 for (auto& layer : *layers_) |
| 2123 layer->ResetChangeTracking(); | 2123 layer->ResetChangeTracking(); |
| 2124 property_trees_.ResetAllChangeTracking(); | 2124 property_trees_.ResetAllChangeTracking(); |
| 2125 } | 2125 } |
| 2126 | 2126 |
| 2127 } // namespace cc | 2127 } // namespace cc |
| OLD | NEW |