OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/trace_event/trace_event_argument.h" | 5 #include "base/trace_event/trace_event_argument.h" |
6 #include "cc/base/math_util.h" | 6 #include "cc/base/math_util.h" |
7 #include "cc/proto/gfx_conversions.h" | 7 #include "cc/proto/gfx_conversions.h" |
8 #include "cc/proto/property_tree.pb.h" | 8 #include "cc/proto/property_tree.pb.h" |
9 #include "cc/trees/transform_node.h" | 9 #include "cc/trees/transform_node.h" |
10 #include "ui/gfx/geometry/point3_f.h" | 10 #include "ui/gfx/geometry/point3_f.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 is_invertible(true), | 23 is_invertible(true), |
24 ancestors_are_invertible(true), | 24 ancestors_are_invertible(true), |
25 has_potential_animation(false), | 25 has_potential_animation(false), |
26 is_currently_animating(false), | 26 is_currently_animating(false), |
27 to_screen_is_potentially_animated(false), | 27 to_screen_is_potentially_animated(false), |
28 has_only_translation_animations(true), | 28 has_only_translation_animations(true), |
29 flattens_inherited_transform(false), | 29 flattens_inherited_transform(false), |
30 node_and_ancestors_are_flat(true), | 30 node_and_ancestors_are_flat(true), |
31 node_and_ancestors_have_only_integer_translation(true), | 31 node_and_ancestors_have_only_integer_translation(true), |
32 scrolls(false), | 32 scrolls(false), |
| 33 should_be_snapped(false), |
33 needs_surface_contents_scale(false), | 34 needs_surface_contents_scale(false), |
34 affected_by_inner_viewport_bounds_delta_x(false), | 35 affected_by_inner_viewport_bounds_delta_x(false), |
35 affected_by_inner_viewport_bounds_delta_y(false), | 36 affected_by_inner_viewport_bounds_delta_y(false), |
36 affected_by_outer_viewport_bounds_delta_x(false), | 37 affected_by_outer_viewport_bounds_delta_x(false), |
37 affected_by_outer_viewport_bounds_delta_y(false), | 38 affected_by_outer_viewport_bounds_delta_y(false), |
38 in_subtree_of_page_scale_layer(false), | 39 in_subtree_of_page_scale_layer(false), |
39 transform_changed(false), | 40 transform_changed(false), |
40 post_local_scale_factor(1.0f) {} | 41 post_local_scale_factor(1.0f) {} |
41 | 42 |
42 TransformNode::TransformNode(const TransformNode&) = default; | 43 TransformNode::TransformNode(const TransformNode&) = default; |
(...skipping 14 matching lines...) Expand all Loading... |
57 is_currently_animating == other.is_currently_animating && | 58 is_currently_animating == other.is_currently_animating && |
58 to_screen_is_potentially_animated == | 59 to_screen_is_potentially_animated == |
59 other.to_screen_is_potentially_animated && | 60 other.to_screen_is_potentially_animated && |
60 has_only_translation_animations == | 61 has_only_translation_animations == |
61 other.has_only_translation_animations && | 62 other.has_only_translation_animations && |
62 flattens_inherited_transform == other.flattens_inherited_transform && | 63 flattens_inherited_transform == other.flattens_inherited_transform && |
63 node_and_ancestors_are_flat == other.node_and_ancestors_are_flat && | 64 node_and_ancestors_are_flat == other.node_and_ancestors_are_flat && |
64 node_and_ancestors_have_only_integer_translation == | 65 node_and_ancestors_have_only_integer_translation == |
65 other.node_and_ancestors_have_only_integer_translation && | 66 other.node_and_ancestors_have_only_integer_translation && |
66 scrolls == other.scrolls && | 67 scrolls == other.scrolls && |
| 68 should_be_snapped == other.should_be_snapped && |
67 needs_surface_contents_scale == other.needs_surface_contents_scale && | 69 needs_surface_contents_scale == other.needs_surface_contents_scale && |
68 affected_by_inner_viewport_bounds_delta_x == | 70 affected_by_inner_viewport_bounds_delta_x == |
69 other.affected_by_inner_viewport_bounds_delta_x && | 71 other.affected_by_inner_viewport_bounds_delta_x && |
70 affected_by_inner_viewport_bounds_delta_y == | 72 affected_by_inner_viewport_bounds_delta_y == |
71 other.affected_by_inner_viewport_bounds_delta_y && | 73 other.affected_by_inner_viewport_bounds_delta_y && |
72 affected_by_outer_viewport_bounds_delta_x == | 74 affected_by_outer_viewport_bounds_delta_x == |
73 other.affected_by_outer_viewport_bounds_delta_x && | 75 other.affected_by_outer_viewport_bounds_delta_x && |
74 affected_by_outer_viewport_bounds_delta_y == | 76 affected_by_outer_viewport_bounds_delta_y == |
75 other.affected_by_outer_viewport_bounds_delta_y && | 77 other.affected_by_outer_viewport_bounds_delta_y && |
76 in_subtree_of_page_scale_layer == | 78 in_subtree_of_page_scale_layer == |
77 other.in_subtree_of_page_scale_layer && | 79 other.in_subtree_of_page_scale_layer && |
78 transform_changed == other.transform_changed && | 80 transform_changed == other.transform_changed && |
79 post_local_scale_factor == other.post_local_scale_factor && | 81 post_local_scale_factor == other.post_local_scale_factor && |
80 surface_contents_scale == other.surface_contents_scale && | 82 surface_contents_scale == other.surface_contents_scale && |
81 scroll_offset == other.scroll_offset && | 83 scroll_offset == other.scroll_offset && |
82 scroll_snap == other.scroll_snap && | 84 snap_amount == other.snap_amount && |
83 source_offset == other.source_offset && | 85 source_offset == other.source_offset && |
84 source_to_parent == other.source_to_parent; | 86 source_to_parent == other.source_to_parent; |
85 } | 87 } |
86 | 88 |
87 void TransformNode::update_pre_local_transform( | 89 void TransformNode::update_pre_local_transform( |
88 const gfx::Point3F& transform_origin) { | 90 const gfx::Point3F& transform_origin) { |
89 pre_local.MakeIdentity(); | 91 pre_local.MakeIdentity(); |
90 pre_local.Translate3d(-transform_origin.x(), -transform_origin.y(), | 92 pre_local.Translate3d(-transform_origin.x(), -transform_origin.y(), |
91 -transform_origin.z()); | 93 -transform_origin.z()); |
92 } | 94 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 data->set_to_screen_is_potentially_animated( | 134 data->set_to_screen_is_potentially_animated( |
133 to_screen_is_potentially_animated); | 135 to_screen_is_potentially_animated); |
134 data->set_has_only_translation_animations(has_only_translation_animations); | 136 data->set_has_only_translation_animations(has_only_translation_animations); |
135 | 137 |
136 data->set_flattens_inherited_transform(flattens_inherited_transform); | 138 data->set_flattens_inherited_transform(flattens_inherited_transform); |
137 data->set_node_and_ancestors_are_flat(node_and_ancestors_are_flat); | 139 data->set_node_and_ancestors_are_flat(node_and_ancestors_are_flat); |
138 | 140 |
139 data->set_node_and_ancestors_have_only_integer_translation( | 141 data->set_node_and_ancestors_have_only_integer_translation( |
140 node_and_ancestors_have_only_integer_translation); | 142 node_and_ancestors_have_only_integer_translation); |
141 data->set_scrolls(scrolls); | 143 data->set_scrolls(scrolls); |
| 144 data->set_should_be_snapped(should_be_snapped); |
142 data->set_needs_surface_contents_scale(needs_surface_contents_scale); | 145 data->set_needs_surface_contents_scale(needs_surface_contents_scale); |
143 | 146 |
144 data->set_affected_by_inner_viewport_bounds_delta_x( | 147 data->set_affected_by_inner_viewport_bounds_delta_x( |
145 affected_by_inner_viewport_bounds_delta_x); | 148 affected_by_inner_viewport_bounds_delta_x); |
146 data->set_affected_by_inner_viewport_bounds_delta_y( | 149 data->set_affected_by_inner_viewport_bounds_delta_y( |
147 affected_by_inner_viewport_bounds_delta_y); | 150 affected_by_inner_viewport_bounds_delta_y); |
148 data->set_affected_by_outer_viewport_bounds_delta_x( | 151 data->set_affected_by_outer_viewport_bounds_delta_x( |
149 affected_by_outer_viewport_bounds_delta_x); | 152 affected_by_outer_viewport_bounds_delta_x); |
150 data->set_affected_by_outer_viewport_bounds_delta_y( | 153 data->set_affected_by_outer_viewport_bounds_delta_y( |
151 affected_by_outer_viewport_bounds_delta_y); | 154 affected_by_outer_viewport_bounds_delta_y); |
152 | 155 |
153 data->set_in_subtree_of_page_scale_layer(in_subtree_of_page_scale_layer); | 156 data->set_in_subtree_of_page_scale_layer(in_subtree_of_page_scale_layer); |
154 data->set_transform_changed(transform_changed); | 157 data->set_transform_changed(transform_changed); |
155 data->set_post_local_scale_factor(post_local_scale_factor); | 158 data->set_post_local_scale_factor(post_local_scale_factor); |
156 | 159 |
157 Vector2dFToProto(surface_contents_scale, | 160 Vector2dFToProto(surface_contents_scale, |
158 data->mutable_surface_contents_scale()); | 161 data->mutable_surface_contents_scale()); |
159 ScrollOffsetToProto(scroll_offset, data->mutable_scroll_offset()); | 162 ScrollOffsetToProto(scroll_offset, data->mutable_scroll_offset()); |
160 Vector2dFToProto(scroll_snap, data->mutable_scroll_snap()); | 163 Vector2dFToProto(snap_amount, data->mutable_snap_amount()); |
161 Vector2dFToProto(source_offset, data->mutable_source_offset()); | 164 Vector2dFToProto(source_offset, data->mutable_source_offset()); |
162 Vector2dFToProto(source_to_parent, data->mutable_source_to_parent()); | 165 Vector2dFToProto(source_to_parent, data->mutable_source_to_parent()); |
163 } | 166 } |
164 | 167 |
165 void TransformNode::FromProtobuf(const proto::TreeNode& proto) { | 168 void TransformNode::FromProtobuf(const proto::TreeNode& proto) { |
166 id = proto.id(); | 169 id = proto.id(); |
167 parent_id = proto.parent_id(); | 170 parent_id = proto.parent_id(); |
168 owner_id = proto.owner_id(); | 171 owner_id = proto.owner_id(); |
169 | 172 |
170 DCHECK(proto.has_transform_node_data()); | 173 DCHECK(proto.has_transform_node_data()); |
(...skipping 20 matching lines...) Expand all Loading... |
191 is_currently_animating = data.is_currently_animating(); | 194 is_currently_animating = data.is_currently_animating(); |
192 to_screen_is_potentially_animated = data.to_screen_is_potentially_animated(); | 195 to_screen_is_potentially_animated = data.to_screen_is_potentially_animated(); |
193 has_only_translation_animations = data.has_only_translation_animations(); | 196 has_only_translation_animations = data.has_only_translation_animations(); |
194 | 197 |
195 flattens_inherited_transform = data.flattens_inherited_transform(); | 198 flattens_inherited_transform = data.flattens_inherited_transform(); |
196 node_and_ancestors_are_flat = data.node_and_ancestors_are_flat(); | 199 node_and_ancestors_are_flat = data.node_and_ancestors_are_flat(); |
197 | 200 |
198 node_and_ancestors_have_only_integer_translation = | 201 node_and_ancestors_have_only_integer_translation = |
199 data.node_and_ancestors_have_only_integer_translation(); | 202 data.node_and_ancestors_have_only_integer_translation(); |
200 scrolls = data.scrolls(); | 203 scrolls = data.scrolls(); |
| 204 should_be_snapped = data.should_be_snapped(); |
201 needs_surface_contents_scale = data.needs_surface_contents_scale(); | 205 needs_surface_contents_scale = data.needs_surface_contents_scale(); |
202 | 206 |
203 affected_by_inner_viewport_bounds_delta_x = | 207 affected_by_inner_viewport_bounds_delta_x = |
204 data.affected_by_inner_viewport_bounds_delta_x(); | 208 data.affected_by_inner_viewport_bounds_delta_x(); |
205 affected_by_inner_viewport_bounds_delta_y = | 209 affected_by_inner_viewport_bounds_delta_y = |
206 data.affected_by_inner_viewport_bounds_delta_y(); | 210 data.affected_by_inner_viewport_bounds_delta_y(); |
207 affected_by_outer_viewport_bounds_delta_x = | 211 affected_by_outer_viewport_bounds_delta_x = |
208 data.affected_by_outer_viewport_bounds_delta_x(); | 212 data.affected_by_outer_viewport_bounds_delta_x(); |
209 affected_by_outer_viewport_bounds_delta_y = | 213 affected_by_outer_viewport_bounds_delta_y = |
210 data.affected_by_outer_viewport_bounds_delta_y(); | 214 data.affected_by_outer_viewport_bounds_delta_y(); |
211 | 215 |
212 in_subtree_of_page_scale_layer = data.in_subtree_of_page_scale_layer(); | 216 in_subtree_of_page_scale_layer = data.in_subtree_of_page_scale_layer(); |
213 transform_changed = data.transform_changed(); | 217 transform_changed = data.transform_changed(); |
214 post_local_scale_factor = data.post_local_scale_factor(); | 218 post_local_scale_factor = data.post_local_scale_factor(); |
215 | 219 |
216 surface_contents_scale = ProtoToVector2dF(data.surface_contents_scale()); | 220 surface_contents_scale = ProtoToVector2dF(data.surface_contents_scale()); |
217 scroll_offset = ProtoToScrollOffset(data.scroll_offset()); | 221 scroll_offset = ProtoToScrollOffset(data.scroll_offset()); |
218 scroll_snap = ProtoToVector2dF(data.scroll_snap()); | 222 snap_amount = ProtoToVector2dF(data.snap_amount()); |
219 source_offset = ProtoToVector2dF(data.source_offset()); | 223 source_offset = ProtoToVector2dF(data.source_offset()); |
220 source_to_parent = ProtoToVector2dF(data.source_to_parent()); | 224 source_to_parent = ProtoToVector2dF(data.source_to_parent()); |
221 } | 225 } |
222 | 226 |
223 void TransformNode::AsValueInto(base::trace_event::TracedValue* value) const { | 227 void TransformNode::AsValueInto(base::trace_event::TracedValue* value) const { |
224 value->SetInteger("id", id); | 228 value->SetInteger("id", id); |
225 value->SetInteger("parent_id", parent_id); | 229 value->SetInteger("parent_id", parent_id); |
226 value->SetInteger("owner_id", owner_id); | 230 value->SetInteger("owner_id", owner_id); |
227 MathUtil::AddToTracedValue("pre_local", pre_local, value); | 231 MathUtil::AddToTracedValue("pre_local", pre_local, value); |
228 MathUtil::AddToTracedValue("local", local, value); | 232 MathUtil::AddToTracedValue("local", local, value); |
229 MathUtil::AddToTracedValue("post_local", post_local, value); | 233 MathUtil::AddToTracedValue("post_local", post_local, value); |
230 // TODO(sunxd): make frameviewer work without target_id | 234 // TODO(sunxd): make frameviewer work without target_id |
231 value->SetInteger("target_id", 0); | 235 value->SetInteger("target_id", 0); |
232 value->SetInteger("content_target_id", 0); | 236 value->SetInteger("content_target_id", 0); |
233 value->SetInteger("source_node_id", source_node_id); | 237 value->SetInteger("source_node_id", source_node_id); |
234 value->SetInteger("sorting_context_id", sorting_context_id); | 238 value->SetInteger("sorting_context_id", sorting_context_id); |
235 MathUtil::AddToTracedValue("scroll_offset", scroll_offset, value); | 239 MathUtil::AddToTracedValue("scroll_offset", scroll_offset, value); |
236 MathUtil::AddToTracedValue("scroll_snap", scroll_snap, value); | 240 MathUtil::AddToTracedValue("snap_amount", snap_amount, value); |
237 } | 241 } |
238 | 242 |
239 TransformCachedNodeData::TransformCachedNodeData() | 243 TransformCachedNodeData::TransformCachedNodeData() |
240 : target_id(-1), content_target_id(-1) {} | 244 : target_id(-1), content_target_id(-1) {} |
241 | 245 |
242 TransformCachedNodeData::TransformCachedNodeData( | 246 TransformCachedNodeData::TransformCachedNodeData( |
243 const TransformCachedNodeData& other) = default; | 247 const TransformCachedNodeData& other) = default; |
244 | 248 |
245 TransformCachedNodeData::~TransformCachedNodeData() {} | 249 TransformCachedNodeData::~TransformCachedNodeData() {} |
246 | 250 |
(...skipping 19 matching lines...) Expand all Loading... |
266 const proto::TransformCachedNodeData& proto) { | 270 const proto::TransformCachedNodeData& proto) { |
267 from_target = ProtoToTransform(proto.from_target()); | 271 from_target = ProtoToTransform(proto.from_target()); |
268 to_target = ProtoToTransform(proto.to_target()); | 272 to_target = ProtoToTransform(proto.to_target()); |
269 from_screen = ProtoToTransform(proto.from_screen()); | 273 from_screen = ProtoToTransform(proto.from_screen()); |
270 to_screen = ProtoToTransform(proto.to_screen()); | 274 to_screen = ProtoToTransform(proto.to_screen()); |
271 target_id = proto.target_id(); | 275 target_id = proto.target_id(); |
272 content_target_id = proto.content_target_id(); | 276 content_target_id = proto.content_target_id(); |
273 } | 277 } |
274 | 278 |
275 } // namespace cc | 279 } // namespace cc |
OLD | NEW |