| 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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) | 1079 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) |
| 1080 return; | 1080 return; |
| 1081 | 1081 |
| 1082 // Preemptively apply the scroll offset and scale delta here before sending | 1082 // Preemptively apply the scroll offset and scale delta here before sending |
| 1083 // it to the client. If the client comes back and sets it to the same | 1083 // it to the client. If the client comes back and sets it to the same |
| 1084 // value, then the layer can early out without needing a full commit. | 1084 // value, then the layer can early out without needing a full commit. |
| 1085 if (inner_viewport_scroll_layer_.get()) { | 1085 if (inner_viewport_scroll_layer_.get()) { |
| 1086 inner_viewport_scroll_layer_->SetScrollOffsetFromImplSide( | 1086 inner_viewport_scroll_layer_->SetScrollOffsetFromImplSide( |
| 1087 gfx::ScrollOffsetWithDelta( | 1087 gfx::ScrollOffsetWithDelta( |
| 1088 inner_viewport_scroll_layer_->scroll_offset(), | 1088 inner_viewport_scroll_layer_->scroll_offset(), |
| 1089 inner_viewport_scroll_delta)); | 1089 inner_viewport_scroll_delta), |
| 1090 nullptr); |
| 1090 } | 1091 } |
| 1091 | 1092 |
| 1092 ApplyPageScaleDeltaFromImplSide(info->page_scale_delta); | 1093 ApplyPageScaleDeltaFromImplSide(info->page_scale_delta); |
| 1093 elastic_overscroll_ += info->elastic_overscroll_delta; | 1094 elastic_overscroll_ += info->elastic_overscroll_delta; |
| 1094 // TODO(ccameron): pass the elastic overscroll here so that input events | 1095 // TODO(ccameron): pass the elastic overscroll here so that input events |
| 1095 // may be translated appropriately. | 1096 // may be translated appropriately. |
| 1096 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), | 1097 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), |
| 1097 info->elastic_overscroll_delta, | 1098 info->elastic_overscroll_delta, |
| 1098 info->page_scale_delta, | 1099 info->page_scale_delta, |
| 1099 info->top_controls_delta); | 1100 info->top_controls_delta); |
| 1100 SetNeedsUpdateLayers(); | 1101 SetNeedsUpdateLayers(); |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { | 1104 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { |
| 1104 for (auto& swap_promise : info->swap_promises) { | 1105 for (auto& swap_promise : info->swap_promises) { |
| 1105 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 1106 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
| 1106 "LatencyInfo.Flow", | 1107 "LatencyInfo.Flow", |
| 1107 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), | 1108 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), |
| 1108 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 1109 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
| 1109 "step", "Main thread scroll update"); | 1110 "step", "Main thread scroll update"); |
| 1110 QueueSwapPromise(std::move(swap_promise)); | 1111 QueueSwapPromise(std::move(swap_promise)); |
| 1111 } | 1112 } |
| 1112 | 1113 |
| 1113 if (root_layer_.get()) { | 1114 if (root_layer_.get()) { |
| 1114 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 1115 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
| 1115 Layer* layer = LayerById(info->scrolls[i].layer_id); | 1116 Layer* layer = LayerById(info->scrolls[i].layer_id); |
| 1116 if (!layer) | 1117 if (!layer) |
| 1117 continue; | 1118 continue; |
| 1118 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( | 1119 |
| 1119 layer->scroll_offset(), info->scrolls[i].scroll_delta)); | 1120 layer->SetScrollOffsetFromImplSide( |
| 1121 gfx::ScrollOffsetWithDelta(layer->scroll_offset(), |
| 1122 info->scrolls[i].scroll_delta), |
| 1123 &info->elastic_overscroll_delta); |
| 1120 SetNeedsUpdateLayers(); | 1124 SetNeedsUpdateLayers(); |
| 1121 } | 1125 } |
| 1122 } | 1126 } |
| 1123 | 1127 |
| 1124 // This needs to happen after scroll deltas have been sent to prevent top | 1128 // This needs to happen after scroll deltas have been sent to prevent top |
| 1125 // controls from clamping the layout viewport both on the compositor and | 1129 // controls from clamping the layout viewport both on the compositor and |
| 1126 // on the main thread. | 1130 // on the main thread. |
| 1127 ApplyViewportDeltas(info); | 1131 ApplyViewportDeltas(info); |
| 1128 } | 1132 } |
| 1129 | 1133 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 int seq_num = property_trees_.sequence_number; | 1719 int seq_num = property_trees_.sequence_number; |
| 1716 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | 1720 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { |
| 1717 layer->set_property_tree_sequence_number(seq_num); | 1721 layer->set_property_tree_sequence_number(seq_num); |
| 1718 }); | 1722 }); |
| 1719 | 1723 |
| 1720 surface_client_id_ = proto.surface_client_id(); | 1724 surface_client_id_ = proto.surface_client_id(); |
| 1721 next_surface_sequence_ = proto.next_surface_sequence(); | 1725 next_surface_sequence_ = proto.next_surface_sequence(); |
| 1722 } | 1726 } |
| 1723 | 1727 |
| 1724 } // namespace cc | 1728 } // namespace cc |
| OLD | NEW |