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