| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 return gfx::ScaleSize(InnerViewportContainerLayer()->BoundsForScrolling(), | 547 return gfx::ScaleSize(InnerViewportContainerLayer()->BoundsForScrolling(), |
| 548 1.0f / current_page_scale_factor()); | 548 1.0f / current_page_scale_factor()); |
| 549 } | 549 } |
| 550 | 550 |
| 551 gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { | 551 gfx::Rect LayerTreeImpl::RootScrollLayerDeviceViewportBounds() const { |
| 552 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 552 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
| 553 ? OuterViewportScrollLayer() | 553 ? OuterViewportScrollLayer() |
| 554 : InnerViewportScrollLayer(); | 554 : InnerViewportScrollLayer(); |
| 555 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 555 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
| 556 return gfx::Rect(); | 556 return gfx::Rect(); |
| 557 LayerImpl* layer = root_scroll_layer->children()[0]; | 557 LayerImpl* layer = root_scroll_layer->children()[0].get(); |
| 558 return MathUtil::MapEnclosingClippedRect(layer->screen_space_transform(), | 558 return MathUtil::MapEnclosingClippedRect(layer->screen_space_transform(), |
| 559 gfx::Rect(layer->bounds())); | 559 gfx::Rect(layer->bounds())); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { | 562 void LayerTreeImpl::ApplySentScrollAndScaleDeltasFromAbortedCommit() { |
| 563 DCHECK(IsActiveTree()); | 563 DCHECK(IsActiveTree()); |
| 564 | 564 |
| 565 page_scale_factor()->AbortCommit(); | 565 page_scale_factor()->AbortCommit(); |
| 566 top_controls_shown_ratio()->AbortCommit(); | 566 top_controls_shown_ratio()->AbortCommit(); |
| 567 elastic_overscroll()->AbortCommit(); | 567 elastic_overscroll()->AbortCommit(); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 | 858 |
| 859 // Always reset this flag on activation, as we would only have activated | 859 // Always reset this flag on activation, as we would only have activated |
| 860 // if we were in a good state. | 860 // if we were in a good state. |
| 861 layer_tree_host_impl_->ResetRequiresHighResToDraw(); | 861 layer_tree_host_impl_->ResetRequiresHighResToDraw(); |
| 862 | 862 |
| 863 if (root_layer()) { | 863 if (root_layer()) { |
| 864 LayerTreeHostCommon::CallFunctionForSubtree( | 864 LayerTreeHostCommon::CallFunctionForSubtree( |
| 865 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); | 865 root_layer(), [](LayerImpl* layer) { layer->DidBecomeActive(); }); |
| 866 } | 866 } |
| 867 | 867 |
| 868 for (auto* swap_promise : swap_promise_list_) | 868 for (const auto& swap_promise : swap_promise_list_) |
| 869 swap_promise->DidActivate(); | 869 swap_promise->DidActivate(); |
| 870 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), | 870 devtools_instrumentation::DidActivateLayerTree(layer_tree_host_impl_->id(), |
| 871 source_frame_number_); | 871 source_frame_number_); |
| 872 } | 872 } |
| 873 | 873 |
| 874 bool LayerTreeImpl::RequiresHighResToDraw() const { | 874 bool LayerTreeImpl::RequiresHighResToDraw() const { |
| 875 return layer_tree_host_impl_->RequiresHighResToDraw(); | 875 return layer_tree_host_impl_->RequiresHighResToDraw(); |
| 876 } | 876 } |
| 877 | 877 |
| 878 bool LayerTreeImpl::ViewportSizeInvalid() const { | 878 bool LayerTreeImpl::ViewportSizeInvalid() const { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); | 1071 LayerIterator end = LayerIterator::End(&render_surface_layer_list_); |
| 1072 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); | 1072 for (LayerIterator it = LayerIterator::Begin(&render_surface_layer_list_); |
| 1073 it != end; ++it) { | 1073 it != end; ++it) { |
| 1074 if (!it.represents_itself()) | 1074 if (!it.represents_itself()) |
| 1075 continue; | 1075 continue; |
| 1076 TracedValue::AppendIDRef(*it, state); | 1076 TracedValue::AppendIDRef(*it, state); |
| 1077 } | 1077 } |
| 1078 state->EndArray(); | 1078 state->EndArray(); |
| 1079 | 1079 |
| 1080 state->BeginArray("swap_promise_trace_ids"); | 1080 state->BeginArray("swap_promise_trace_ids"); |
| 1081 for (auto* swap_promise : swap_promise_list_) | 1081 for (const auto& swap_promise : swap_promise_list_) |
| 1082 state->AppendDouble(swap_promise->TraceId()); | 1082 state->AppendDouble(swap_promise->TraceId()); |
| 1083 state->EndArray(); | 1083 state->EndArray(); |
| 1084 | 1084 |
| 1085 state->BeginArray("pinned_swap_promise_trace_ids"); | 1085 state->BeginArray("pinned_swap_promise_trace_ids"); |
| 1086 for (auto* swap_promise : pinned_swap_promise_list_) | 1086 for (const auto& swap_promise : pinned_swap_promise_list_) |
| 1087 state->AppendDouble(swap_promise->TraceId()); | 1087 state->AppendDouble(swap_promise->TraceId()); |
| 1088 state->EndArray(); | 1088 state->EndArray(); |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 bool LayerTreeImpl::DistributeRootScrollOffset( | 1091 bool LayerTreeImpl::DistributeRootScrollOffset( |
| 1092 const gfx::ScrollOffset& root_offset) { | 1092 const gfx::ScrollOffset& root_offset) { |
| 1093 if (!InnerViewportScrollLayer()) | 1093 if (!InnerViewportScrollLayer()) |
| 1094 return false; | 1094 return false; |
| 1095 | 1095 |
| 1096 DCHECK(OuterViewportScrollLayer()); | 1096 DCHECK(OuterViewportScrollLayer()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 void LayerTreeImpl::QueuePinnedSwapPromise( | 1128 void LayerTreeImpl::QueuePinnedSwapPromise( |
| 1129 scoped_ptr<SwapPromise> swap_promise) { | 1129 scoped_ptr<SwapPromise> swap_promise) { |
| 1130 DCHECK(IsActiveTree()); | 1130 DCHECK(IsActiveTree()); |
| 1131 DCHECK(swap_promise); | 1131 DCHECK(swap_promise); |
| 1132 pinned_swap_promise_list_.push_back(swap_promise.Pass()); | 1132 pinned_swap_promise_list_.push_back(swap_promise.Pass()); |
| 1133 } | 1133 } |
| 1134 | 1134 |
| 1135 void LayerTreeImpl::PassSwapPromises( | 1135 void LayerTreeImpl::PassSwapPromises( |
| 1136 ScopedPtrVector<SwapPromise>* new_swap_promise) { | 1136 std::vector<scoped_ptr<SwapPromise>>* new_swap_promise) { |
| 1137 for (auto* swap_promise : swap_promise_list_) | 1137 for (const auto& swap_promise : swap_promise_list_) |
| 1138 swap_promise->DidNotSwap(SwapPromise::SWAP_FAILS); | 1138 swap_promise->DidNotSwap(SwapPromise::SWAP_FAILS); |
| 1139 swap_promise_list_.clear(); | 1139 swap_promise_list_.clear(); |
| 1140 swap_promise_list_.swap(*new_swap_promise); | 1140 swap_promise_list_.swap(*new_swap_promise); |
| 1141 } | 1141 } |
| 1142 | 1142 |
| 1143 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { | 1143 void LayerTreeImpl::FinishSwapPromises(CompositorFrameMetadata* metadata) { |
| 1144 for (auto* swap_promise : swap_promise_list_) | 1144 for (const auto& swap_promise : swap_promise_list_) |
| 1145 swap_promise->DidSwap(metadata); | 1145 swap_promise->DidSwap(metadata); |
| 1146 swap_promise_list_.clear(); | 1146 swap_promise_list_.clear(); |
| 1147 for (auto* swap_promise : pinned_swap_promise_list_) | 1147 for (const auto& swap_promise : pinned_swap_promise_list_) |
| 1148 swap_promise->DidSwap(metadata); | 1148 swap_promise->DidSwap(metadata); |
| 1149 pinned_swap_promise_list_.clear(); | 1149 pinned_swap_promise_list_.clear(); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 void LayerTreeImpl::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { | 1152 void LayerTreeImpl::BreakSwapPromises(SwapPromise::DidNotSwapReason reason) { |
| 1153 for (auto* swap_promise : swap_promise_list_) | 1153 for (const auto& swap_promise : swap_promise_list_) |
| 1154 swap_promise->DidNotSwap(reason); | 1154 swap_promise->DidNotSwap(reason); |
| 1155 swap_promise_list_.clear(); | 1155 swap_promise_list_.clear(); |
| 1156 for (auto* swap_promise : pinned_swap_promise_list_) | 1156 for (const auto& swap_promise : pinned_swap_promise_list_) |
| 1157 swap_promise->DidNotSwap(reason); | 1157 swap_promise->DidNotSwap(reason); |
| 1158 pinned_swap_promise_list_.clear(); | 1158 pinned_swap_promise_list_.clear(); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 void LayerTreeImpl::DidModifyTilePriorities() { | 1161 void LayerTreeImpl::DidModifyTilePriorities() { |
| 1162 layer_tree_host_impl_->DidModifyTilePriorities(); | 1162 layer_tree_host_impl_->DidModifyTilePriorities(); |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 void LayerTreeImpl::set_ui_resource_request_queue( | 1165 void LayerTreeImpl::set_ui_resource_request_queue( |
| 1166 const UIResourceRequestQueue& queue) { | 1166 const UIResourceRequestQueue& queue) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 static void FindClosestMatchingLayer( | 1485 static void FindClosestMatchingLayer( |
| 1486 const gfx::PointF& screen_space_point, | 1486 const gfx::PointF& screen_space_point, |
| 1487 LayerImpl* layer, | 1487 LayerImpl* layer, |
| 1488 const Functor& func, | 1488 const Functor& func, |
| 1489 const TransformTree& transform_tree, | 1489 const TransformTree& transform_tree, |
| 1490 const bool use_property_trees, | 1490 const bool use_property_trees, |
| 1491 FindClosestMatchingLayerDataForRecursion* data_for_recursion) { | 1491 FindClosestMatchingLayerDataForRecursion* data_for_recursion) { |
| 1492 size_t children_size = layer->children().size(); | 1492 size_t children_size = layer->children().size(); |
| 1493 for (size_t i = 0; i < children_size; ++i) { | 1493 for (size_t i = 0; i < children_size; ++i) { |
| 1494 size_t index = children_size - 1 - i; | 1494 size_t index = children_size - 1 - i; |
| 1495 FindClosestMatchingLayer(screen_space_point, layer->children()[index], func, | 1495 FindClosestMatchingLayer(screen_space_point, layer->children()[index].get(), |
| 1496 transform_tree, use_property_trees, | 1496 func, transform_tree, use_property_trees, |
| 1497 data_for_recursion); | 1497 data_for_recursion); |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 if (!func(layer)) | 1500 if (!func(layer)) |
| 1501 return; | 1501 return; |
| 1502 | 1502 |
| 1503 float distance_to_intersection = 0.f; | 1503 float distance_to_intersection = 0.f; |
| 1504 bool hit = false; | 1504 bool hit = false; |
| 1505 if (layer->Is3dSorted()) | 1505 if (layer->Is3dSorted()) |
| 1506 hit = PointHitsLayer(layer, screen_space_point, &distance_to_intersection, | 1506 hit = PointHitsLayer(layer, screen_space_point, &distance_to_intersection, |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 const gfx::BoxF& box, | 1927 const gfx::BoxF& box, |
| 1928 gfx::BoxF* bounds) const { | 1928 gfx::BoxF* bounds) const { |
| 1929 *bounds = gfx::BoxF(); | 1929 *bounds = gfx::BoxF(); |
| 1930 return layer_tree_host_impl_->animation_host() | 1930 return layer_tree_host_impl_->animation_host() |
| 1931 ? layer_tree_host_impl_->animation_host() | 1931 ? layer_tree_host_impl_->animation_host() |
| 1932 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) | 1932 ->TransformAnimationBoundsForBox(layer->id(), box, bounds) |
| 1933 : true; | 1933 : true; |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 } // namespace cc | 1936 } // namespace cc |
| OLD | NEW |