OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CC_TREES_PROPERTY_TREE_H_ | 5 #ifndef CC_TREES_PROPERTY_TREE_H_ |
6 #define CC_TREES_PROPERTY_TREE_H_ | 6 #define CC_TREES_PROPERTY_TREE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 }; | 263 }; |
264 | 264 |
265 typedef TreeNode<EffectNodeData> EffectNode; | 265 typedef TreeNode<EffectNodeData> EffectNode; |
266 | 266 |
267 struct CC_EXPORT ScrollNodeData { | 267 struct CC_EXPORT ScrollNodeData { |
268 ScrollNodeData(); | 268 ScrollNodeData(); |
269 | 269 |
270 bool scrollable; | 270 bool scrollable; |
271 uint32_t main_thread_scrolling_reasons; | 271 uint32_t main_thread_scrolling_reasons; |
272 bool contains_non_fast_scrollable_region; | 272 bool contains_non_fast_scrollable_region; |
273 | 273 gfx::Size scroll_clip_layer_bounds; |
274 int transform_id; | 274 gfx::Size bounds; |
| 275 bool max_scroll_offset_affected_by_page_scale; |
| 276 bool is_inner_viewport_scroll_layer; |
| 277 bool is_outer_viewport_scroll_layer; |
275 | 278 |
276 bool operator==(const ScrollNodeData& other) const; | 279 bool operator==(const ScrollNodeData& other) const; |
277 | 280 |
278 void ToProtobuf(proto::TreeNode* proto) const; | 281 void ToProtobuf(proto::TreeNode* proto) const; |
279 void FromProtobuf(const proto::TreeNode& proto); | 282 void FromProtobuf(const proto::TreeNode& proto); |
280 }; | 283 }; |
281 | 284 |
282 typedef TreeNode<ScrollNodeData> ScrollNode; | 285 typedef TreeNode<ScrollNodeData> ScrollNode; |
283 | 286 |
| 287 class PropertyTrees; |
| 288 |
284 template <typename T> | 289 template <typename T> |
285 class CC_EXPORT PropertyTree { | 290 class CC_EXPORT PropertyTree { |
286 public: | 291 public: |
287 PropertyTree(); | 292 PropertyTree(); |
288 virtual ~PropertyTree(); | 293 virtual ~PropertyTree(); |
289 | 294 |
290 bool operator==(const PropertyTree<T>& other) const; | 295 bool operator==(const PropertyTree<T>& other) const; |
291 | 296 |
292 int Insert(const T& tree_node, int parent_id); | 297 int Insert(const T& tree_node, int parent_id); |
293 | 298 |
(...skipping 23 matching lines...) Expand all Loading... |
317 bool needs_update() const { return needs_update_; } | 322 bool needs_update() const { return needs_update_; } |
318 | 323 |
319 std::vector<T>& nodes() { return nodes_; } | 324 std::vector<T>& nodes() { return nodes_; } |
320 const std::vector<T>& nodes() const { return nodes_; } | 325 const std::vector<T>& nodes() const { return nodes_; } |
321 | 326 |
322 int next_available_id() const { return static_cast<int>(size()); } | 327 int next_available_id() const { return static_cast<int>(size()); } |
323 | 328 |
324 void ToProtobuf(proto::PropertyTree* proto) const; | 329 void ToProtobuf(proto::PropertyTree* proto) const; |
325 void FromProtobuf(const proto::PropertyTree& proto); | 330 void FromProtobuf(const proto::PropertyTree& proto); |
326 | 331 |
| 332 void SetPropertyTrees(PropertyTrees* property_trees) { |
| 333 property_trees_ = property_trees; |
| 334 } |
| 335 PropertyTrees* property_trees() const { return property_trees_; } |
| 336 |
327 private: | 337 private: |
328 // Copy and assign are permitted. This is how we do tree sync. | 338 // Copy and assign are permitted. This is how we do tree sync. |
329 std::vector<T> nodes_; | 339 std::vector<T> nodes_; |
330 | 340 |
331 bool needs_update_; | 341 bool needs_update_; |
| 342 PropertyTrees* property_trees_; |
332 }; | 343 }; |
333 | 344 |
334 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { | 345 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
335 public: | 346 public: |
336 TransformTree(); | 347 TransformTree(); |
337 ~TransformTree() override; | 348 ~TransformTree() override; |
338 | 349 |
339 bool operator==(const TransformTree& other) const; | 350 bool operator==(const TransformTree& other) const; |
340 | 351 |
341 void clear() override; | 352 void clear() override; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 415 } |
405 float device_scale_factor() const { return device_scale_factor_; } | 416 float device_scale_factor() const { return device_scale_factor_; } |
406 | 417 |
407 void SetDeviceTransform(const gfx::Transform& transform, | 418 void SetDeviceTransform(const gfx::Transform& transform, |
408 gfx::PointF root_position); | 419 gfx::PointF root_position); |
409 void SetDeviceTransformScaleFactor(const gfx::Transform& transform); | 420 void SetDeviceTransformScaleFactor(const gfx::Transform& transform); |
410 float device_transform_scale_factor() const { | 421 float device_transform_scale_factor() const { |
411 return device_transform_scale_factor_; | 422 return device_transform_scale_factor_; |
412 } | 423 } |
413 | 424 |
414 void SetInnerViewportBoundsDelta(gfx::Vector2dF bounds_delta); | 425 void UpdateInnerViewportContainerBoundsDelta(); |
415 gfx::Vector2dF inner_viewport_bounds_delta() const { | |
416 return inner_viewport_bounds_delta_; | |
417 } | |
418 | 426 |
419 void SetOuterViewportBoundsDelta(gfx::Vector2dF bounds_delta); | 427 void UpdateOuterViewportContainerBoundsDelta(); |
420 gfx::Vector2dF outer_viewport_bounds_delta() const { | |
421 return outer_viewport_bounds_delta_; | |
422 } | |
423 | 428 |
424 void AddNodeAffectedByInnerViewportBoundsDelta(int node_id); | 429 void AddNodeAffectedByInnerViewportBoundsDelta(int node_id); |
425 void AddNodeAffectedByOuterViewportBoundsDelta(int node_id); | 430 void AddNodeAffectedByOuterViewportBoundsDelta(int node_id); |
426 | 431 |
427 bool HasNodesAffectedByInnerViewportBoundsDelta() const; | 432 bool HasNodesAffectedByInnerViewportBoundsDelta() const; |
428 bool HasNodesAffectedByOuterViewportBoundsDelta() const; | 433 bool HasNodesAffectedByOuterViewportBoundsDelta() const; |
429 | 434 |
430 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() | 435 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() |
431 const { | 436 const { |
432 return nodes_affected_by_inner_viewport_bounds_delta_; | 437 return nodes_affected_by_inner_viewport_bounds_delta_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 TransformNode* parent_node); | 479 TransformNode* parent_node); |
475 bool NeedsSourceToParentUpdate(TransformNode* node); | 480 bool NeedsSourceToParentUpdate(TransformNode* node); |
476 | 481 |
477 bool source_to_parent_updates_allowed_; | 482 bool source_to_parent_updates_allowed_; |
478 // When to_screen transform has perspective, the transform node's sublayer | 483 // When to_screen transform has perspective, the transform node's sublayer |
479 // scale is calculated using page scale factor, device scale factor and the | 484 // scale is calculated using page scale factor, device scale factor and the |
480 // scale factor of device transform. So we need to store them explicitly. | 485 // scale factor of device transform. So we need to store them explicitly. |
481 float page_scale_factor_; | 486 float page_scale_factor_; |
482 float device_scale_factor_; | 487 float device_scale_factor_; |
483 float device_transform_scale_factor_; | 488 float device_transform_scale_factor_; |
484 gfx::Vector2dF inner_viewport_bounds_delta_; | |
485 gfx::Vector2dF outer_viewport_bounds_delta_; | |
486 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; | 489 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; |
487 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; | 490 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; |
488 }; | 491 }; |
489 | 492 |
490 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { | 493 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
491 public: | 494 public: |
492 bool operator==(const ClipTree& other) const; | 495 bool operator==(const ClipTree& other) const; |
493 | 496 |
494 void SetViewportClip(gfx::RectF viewport_rect); | 497 void SetViewportClip(gfx::RectF viewport_rect); |
495 gfx::RectF ViewportClip(); | 498 gfx::RectF ViewportClip(); |
(...skipping 15 matching lines...) Expand all Loading... |
511 void ToProtobuf(proto::PropertyTree* proto) const; | 514 void ToProtobuf(proto::PropertyTree* proto) const; |
512 void FromProtobuf(const proto::PropertyTree& proto); | 515 void FromProtobuf(const proto::PropertyTree& proto); |
513 | 516 |
514 private: | 517 private: |
515 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); | 518 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); |
516 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); | 519 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); |
517 }; | 520 }; |
518 | 521 |
519 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { | 522 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { |
520 public: | 523 public: |
| 524 ScrollTree(); |
| 525 ~ScrollTree() override; |
| 526 |
521 bool operator==(const ScrollTree& other) const; | 527 bool operator==(const ScrollTree& other) const; |
522 | 528 |
523 void ToProtobuf(proto::PropertyTree* proto) const; | 529 void ToProtobuf(proto::PropertyTree* proto) const; |
524 void FromProtobuf(const proto::PropertyTree& proto); | 530 void FromProtobuf(const proto::PropertyTree& proto); |
| 531 |
| 532 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; |
525 }; | 533 }; |
526 | 534 |
527 class CC_EXPORT PropertyTrees final { | 535 class CC_EXPORT PropertyTrees final { |
528 public: | 536 public: |
529 PropertyTrees(); | 537 PropertyTrees(); |
530 ~PropertyTrees(); | 538 ~PropertyTrees(); |
531 | 539 |
532 bool operator==(const PropertyTrees& other) const; | 540 bool operator==(const PropertyTrees& other) const; |
| 541 PropertyTrees& operator=(const PropertyTrees& from); |
533 | 542 |
534 void ToProtobuf(proto::PropertyTrees* proto) const; | 543 void ToProtobuf(proto::PropertyTrees* proto) const; |
535 void FromProtobuf(const proto::PropertyTrees& proto); | 544 void FromProtobuf(const proto::PropertyTrees& proto); |
536 | 545 |
537 TransformTree transform_tree; | 546 TransformTree transform_tree; |
538 EffectTree effect_tree; | 547 EffectTree effect_tree; |
539 ClipTree clip_tree; | 548 ClipTree clip_tree; |
540 ScrollTree scroll_tree; | 549 ScrollTree scroll_tree; |
541 bool needs_rebuild; | 550 bool needs_rebuild; |
542 bool non_root_surfaces_enabled; | 551 bool non_root_surfaces_enabled; |
543 int sequence_number; | 552 int sequence_number; |
| 553 |
| 554 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
| 555 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
| 556 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); |
| 557 |
| 558 gfx::Vector2dF inner_viewport_container_bounds_delta() const { |
| 559 return inner_viewport_container_bounds_delta_; |
| 560 } |
| 561 |
| 562 gfx::Vector2dF outer_viewport_container_bounds_delta() const { |
| 563 return outer_viewport_container_bounds_delta_; |
| 564 } |
| 565 |
| 566 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const { |
| 567 return inner_viewport_scroll_bounds_delta_; |
| 568 } |
| 569 |
| 570 private: |
| 571 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
| 572 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
| 573 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
544 }; | 574 }; |
545 | 575 |
546 } // namespace cc | 576 } // namespace cc |
547 | 577 |
548 #endif // CC_TREES_PROPERTY_TREE_H_ | 578 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |