Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: cc/trees/property_tree.h

Issue 2087963003: cc: Stop creating unused 0 property tree nodes other than transform Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 10 #include <memory>
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 class PropertyTrees; 354 class PropertyTrees;
355 355
356 template <typename T> 356 template <typename T>
357 class CC_EXPORT PropertyTree { 357 class CC_EXPORT PropertyTree {
358 public: 358 public:
359 PropertyTree(); 359 PropertyTree();
360 PropertyTree(const PropertyTree& other) = delete; 360 PropertyTree(const PropertyTree& other) = delete;
361 ~PropertyTree(); 361 ~PropertyTree();
362 362
363 // Property tree node starts from index 0.
364 static const int kInvalidNodeId = -1;
365 static const int kRootNodeId = 0;
366
363 bool operator==(const PropertyTree<T>& other) const; 367 bool operator==(const PropertyTree<T>& other) const;
364 368
365 int Insert(const T& tree_node, int parent_id); 369 int Insert(const T& tree_node, int parent_id);
366 370
367 T* Node(int i) { 371 T* Node(int i) {
368 // TODO(vollick): remove this. 372 // TODO(vollick): remove this.
369 CHECK(i < static_cast<int>(nodes_.size())); 373 CHECK(i < static_cast<int>(nodes_.size()));
370 return i > -1 ? &nodes_[i] : nullptr; 374 return i > -1 ? &nodes_[i] : nullptr;
371 } 375 }
372 const T* Node(int i) const { 376 const T* Node(int i) const {
373 // TODO(vollick): remove this. 377 // TODO(vollick): remove this.
374 CHECK(i < static_cast<int>(nodes_.size())); 378 CHECK(i < static_cast<int>(nodes_.size()));
375 return i > -1 ? &nodes_[i] : nullptr; 379 return i > -1 ? &nodes_[i] : nullptr;
376 } 380 }
377 381
378 T* parent(const T* t) { return Node(t->parent_id); } 382 T* parent(const T* t) {
379 const T* parent(const T* t) const { return Node(t->parent_id); } 383 return t->parent_id >= 0 ? Node(t->parent_id) : nullptr;
ajuma 2016/06/22 13:29:51 The Node method already checks if its argument is
384 }
385 const T* parent(const T* t) const {
386 return t->parent_id >= 0 ? Node(t->parent_id) : nullptr;
387 }
380 388
381 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } 389 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; }
382 const T* back() const { 390 const T* back() const {
383 return size() ? &nodes_[nodes_.size() - 1] : nullptr; 391 return size() ? &nodes_[nodes_.size() - 1] : nullptr;
384 } 392 }
385 393
386 void clear(); 394 void clear();
387 size_t size() const { return nodes_.size(); } 395 size_t size() const { return nodes_.size(); }
388 396
389 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } 397 void set_needs_update(bool needs_update) { needs_update_ = needs_update; }
(...skipping 20 matching lines...) Expand all
410 418
411 bool needs_update_; 419 bool needs_update_;
412 PropertyTrees* property_trees_; 420 PropertyTrees* property_trees_;
413 }; 421 };
414 422
415 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { 423 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> {
416 public: 424 public:
417 TransformTree(); 425 TransformTree();
418 ~TransformTree(); 426 ~TransformTree();
419 427
428 // Transform tree requires a dummy node 0 representing device space. The root
429 // node of transform tree with real information is node 1, unlike all other
430 // property trees. When transform tree is created, it is created with dummy
431 // node 0.
432 static const int kDeviceNodeId = 0;
433 static const int kRootNodeId = 1;
434
420 bool operator==(const TransformTree& other) const; 435 bool operator==(const TransformTree& other) const;
421 436
422 int Insert(const TransformNode& tree_node, int parent_id); 437 int Insert(const TransformNode& tree_node, int parent_id);
423 438
424 void clear(); 439 void clear();
425 440
426 // Computes the change of basis transform from node |source_id| to |dest_id|. 441 // Computes the change of basis transform from node |source_id| to |dest_id|.
427 // The function returns false iff the inverse of a singular transform was 442 // The function returns false iff the inverse of a singular transform was
428 // used (and the result should, therefore, not be trusted). Transforms may 443 // used (and the result should, therefore, not be trusted). Transforms may
429 // be computed between any pair of nodes that have an ancestor/descendant 444 // be computed between any pair of nodes that have an ancestor/descendant
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 float page_scale_factor_; 605 float page_scale_factor_;
591 float device_scale_factor_; 606 float device_scale_factor_;
592 float device_transform_scale_factor_; 607 float device_transform_scale_factor_;
593 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; 608 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_;
594 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; 609 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_;
595 std::vector<TransformCachedNodeData> cached_data_; 610 std::vector<TransformCachedNodeData> cached_data_;
596 }; 611 };
597 612
598 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { 613 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {
599 public: 614 public:
615 static const int kViewportNodeId = 0;
616
600 bool operator==(const ClipTree& other) const; 617 bool operator==(const ClipTree& other) const;
601 618
602 void SetViewportClip(gfx::RectF viewport_rect); 619 void SetViewportClip(gfx::RectF viewport_rect);
603 gfx::RectF ViewportClip(); 620 gfx::RectF ViewportClip();
604 621
605 void ToProtobuf(proto::PropertyTree* proto) const; 622 void ToProtobuf(proto::PropertyTree* proto) const;
606 void FromProtobuf(const proto::PropertyTree& proto, 623 void FromProtobuf(const proto::PropertyTree& proto,
607 std::unordered_map<int, int>* node_id_to_index_map); 624 std::unordered_map<int, int>* node_id_to_index_map);
608 }; 625 };
609 626
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 805
789 private: 806 private:
790 gfx::Vector2dF inner_viewport_container_bounds_delta_; 807 gfx::Vector2dF inner_viewport_container_bounds_delta_;
791 gfx::Vector2dF outer_viewport_container_bounds_delta_; 808 gfx::Vector2dF outer_viewport_container_bounds_delta_;
792 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 809 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
793 }; 810 };
794 811
795 } // namespace cc 812 } // namespace cc
796 813
797 #endif // CC_TREES_PROPERTY_TREE_H_ 814 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698