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 <unordered_map> | 10 #include <unordered_map> |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 }; | 316 }; |
317 | 317 |
318 typedef TreeNode<ScrollNodeData> ScrollNode; | 318 typedef TreeNode<ScrollNodeData> ScrollNode; |
319 | 319 |
320 class PropertyTrees; | 320 class PropertyTrees; |
321 | 321 |
322 template <typename T> | 322 template <typename T> |
323 class CC_EXPORT PropertyTree { | 323 class CC_EXPORT PropertyTree { |
324 public: | 324 public: |
325 PropertyTree(); | 325 PropertyTree(); |
326 virtual ~PropertyTree(); | 326 ~PropertyTree(); |
327 | 327 |
328 bool operator==(const PropertyTree<T>& other) const; | 328 bool operator==(const PropertyTree<T>& other) const; |
329 | 329 |
330 int Insert(const T& tree_node, int parent_id); | 330 int Insert(const T& tree_node, int parent_id); |
331 | 331 |
332 T* Node(int i) { | 332 T* Node(int i) { |
333 // TODO(vollick): remove this. | 333 // TODO(vollick): remove this. |
334 CHECK(i < static_cast<int>(nodes_.size())); | 334 CHECK(i < static_cast<int>(nodes_.size())); |
335 return i > -1 ? &nodes_[i] : nullptr; | 335 return i > -1 ? &nodes_[i] : nullptr; |
336 } | 336 } |
337 const T* Node(int i) const { | 337 const T* Node(int i) const { |
338 // TODO(vollick): remove this. | 338 // TODO(vollick): remove this. |
339 CHECK(i < static_cast<int>(nodes_.size())); | 339 CHECK(i < static_cast<int>(nodes_.size())); |
340 return i > -1 ? &nodes_[i] : nullptr; | 340 return i > -1 ? &nodes_[i] : nullptr; |
341 } | 341 } |
342 | 342 |
343 T* parent(const T* t) { return Node(t->parent_id); } | 343 T* parent(const T* t) { return Node(t->parent_id); } |
344 const T* parent(const T* t) const { return Node(t->parent_id); } | 344 const T* parent(const T* t) const { return Node(t->parent_id); } |
345 | 345 |
346 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } | 346 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } |
347 const T* back() const { | 347 const T* back() const { |
348 return size() ? &nodes_[nodes_.size() - 1] : nullptr; | 348 return size() ? &nodes_[nodes_.size() - 1] : nullptr; |
349 } | 349 } |
350 | 350 |
351 virtual void clear(); | 351 void clear(); |
352 size_t size() const { return nodes_.size(); } | 352 size_t size() const { return nodes_.size(); } |
353 | 353 |
354 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } | 354 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } |
355 bool needs_update() const { return needs_update_; } | 355 bool needs_update() const { return needs_update_; } |
356 | 356 |
357 std::vector<T>& nodes() { return nodes_; } | 357 std::vector<T>& nodes() { return nodes_; } |
358 const std::vector<T>& nodes() const { return nodes_; } | 358 const std::vector<T>& nodes() const { return nodes_; } |
359 | 359 |
360 int next_available_id() const { return static_cast<int>(size()); } | 360 int next_available_id() const { return static_cast<int>(size()); } |
361 | 361 |
(...skipping 10 matching lines...) Expand all Loading... |
372 std::vector<T> nodes_; | 372 std::vector<T> nodes_; |
373 | 373 |
374 bool needs_update_; | 374 bool needs_update_; |
375 PropertyTrees* property_trees_; | 375 PropertyTrees* property_trees_; |
376 }; | 376 }; |
377 | 377 |
378 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { | 378 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
379 public: | 379 public: |
380 TransformTree(); | 380 TransformTree(); |
381 TransformTree(const TransformTree& other); | 381 TransformTree(const TransformTree& other); |
382 ~TransformTree() override; | 382 ~TransformTree(); |
383 | 383 |
384 bool operator==(const TransformTree& other) const; | 384 bool operator==(const TransformTree& other) const; |
385 | 385 |
386 void clear() override; | 386 void clear(); |
387 | 387 |
388 // Computes the change of basis transform from node |source_id| to |dest_id|. | 388 // Computes the change of basis transform from node |source_id| to |dest_id|. |
389 // The function returns false iff the inverse of a singular transform was | 389 // The function returns false iff the inverse of a singular transform was |
390 // used (and the result should, therefore, not be trusted). Transforms may | 390 // used (and the result should, therefore, not be trusted). Transforms may |
391 // be computed between any pair of nodes that have an ancestor/descendant | 391 // be computed between any pair of nodes that have an ancestor/descendant |
392 // relationship. Transforms between other pairs of nodes may only be computed | 392 // relationship. Transforms between other pairs of nodes may only be computed |
393 // if the following condition holds: let id1 the larger id and let id2 be the | 393 // if the following condition holds: let id1 the larger id and let id2 be the |
394 // other id; then the nearest ancestor of node id1 whose id is smaller than | 394 // other id; then the nearest ancestor of node id1 whose id is smaller than |
395 // id2 is the lowest common ancestor of the pair of nodes, and the transform | 395 // id2 is the lowest common ancestor of the pair of nodes, and the transform |
396 // from this lowest common ancestor to node id2 is only a 2d translation. | 396 // from this lowest common ancestor to node id2 is only a 2d translation. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 private: | 564 private: |
565 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); | 565 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); |
566 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); | 566 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); |
567 void UpdateBackfaceVisibility(EffectNode* node, EffectNode* parent_node); | 567 void UpdateBackfaceVisibility(EffectNode* node, EffectNode* parent_node); |
568 }; | 568 }; |
569 | 569 |
570 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { | 570 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { |
571 public: | 571 public: |
572 ScrollTree(); | 572 ScrollTree(); |
573 ScrollTree(const ScrollTree& other); | 573 ScrollTree(const ScrollTree& other); |
574 ~ScrollTree() override; | 574 ~ScrollTree(); |
575 | 575 |
576 ScrollTree& operator=(const ScrollTree& from); | 576 ScrollTree& operator=(const ScrollTree& from); |
577 bool operator==(const ScrollTree& other) const; | 577 bool operator==(const ScrollTree& other) const; |
578 | 578 |
579 void ToProtobuf(proto::PropertyTree* proto) const; | 579 void ToProtobuf(proto::PropertyTree* proto) const; |
580 void FromProtobuf(const proto::PropertyTree& proto); | 580 void FromProtobuf(const proto::PropertyTree& proto); |
581 | 581 |
582 void clear() override; | 582 void clear(); |
583 | 583 |
584 typedef std::unordered_map<int, scoped_refptr<SyncedScrollOffset>> | 584 typedef std::unordered_map<int, scoped_refptr<SyncedScrollOffset>> |
585 ScrollOffsetMap; | 585 ScrollOffsetMap; |
586 | 586 |
587 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; | 587 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; |
588 gfx::Size scroll_clip_layer_bounds(int scroll_node_id) const; | 588 gfx::Size scroll_clip_layer_bounds(int scroll_node_id) const; |
589 ScrollNode* CurrentlyScrollingNode(); | 589 ScrollNode* CurrentlyScrollingNode(); |
590 const ScrollNode* CurrentlyScrollingNode() const; | 590 const ScrollNode* CurrentlyScrollingNode() const; |
591 void set_currently_scrolling_node(int scroll_node_id); | 591 void set_currently_scrolling_node(int scroll_node_id); |
592 gfx::Transform ScreenSpaceTransform(int scroll_node_id) const; | 592 gfx::Transform ScreenSpaceTransform(int scroll_node_id) const; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 | 686 |
687 private: | 687 private: |
688 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 688 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
689 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 689 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
690 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 690 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
691 }; | 691 }; |
692 | 692 |
693 } // namespace cc | 693 } // namespace cc |
694 | 694 |
695 #endif // CC_TREES_PROPERTY_TREE_H_ | 695 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |