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

Side by Side Diff: cc/base/rtree.h

Issue 1484163002: Raster display item lists via a visual rect RTree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head. Created 5 years 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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_BASE_RTREE_H_ 5 #ifndef CC_BASE_RTREE_H_
6 #define CC_BASE_RTREE_H_ 6 #define CC_BASE_RTREE_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <vector> 9 #include <vector>
10 10
11 #include "cc/base/cc_export.h" 11 #include "cc/base/cc_export.h"
12 #include "ui/gfx/geometry/rect_f.h" 12 #include "ui/gfx/geometry/rect.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 // The following description and most of the implementation is borrowed from 16 // The following description and most of the implementation is borrowed from
17 // Skia's SkRTree implementation. 17 // Skia's SkRTree implementation.
18 // 18 //
19 // An R-Tree implementation. In short, it is a balanced n-ary tree containing a 19 // An R-Tree implementation. In short, it is a balanced n-ary tree containing a
20 // hierarchy of bounding rectangles. 20 // hierarchy of bounding rectangles.
21 // 21 //
22 // It only supports bulk-loading, i.e. creation from a batch of bounding 22 // It only supports bulk-loading, i.e. creation from a batch of bounding
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 } 69 }
70 70
71 template <typename Container> 71 template <typename Container>
72 void Build(const Container& items) { 72 void Build(const Container& items) {
73 Build(items, [](const gfx::Rect& bounds) { return bounds; }); 73 Build(items, [](const gfx::Rect& bounds) { return bounds; });
74 } 74 }
75 75
76 void Search(const gfx::Rect& query, std::vector<size_t>* results) const; 76 void Search(const gfx::Rect& query, std::vector<size_t>* results) const;
77 77
78 gfx::Rect GetBounds() const;
79
78 private: 80 private:
79 // These values were empirically determined to produce reasonable performance 81 // These values were empirically determined to produce reasonable performance
80 // in most cases. 82 // in most cases.
81 enum { MIN_CHILDREN = 6, MAX_CHILDREN = 11 }; 83 enum { MIN_CHILDREN = 6, MAX_CHILDREN = 11 };
82 84
83 struct Node; 85 struct Node;
84 struct Branch { 86 struct Branch {
85 // When the node level is 0, then the node is a leaf and the branch has a 87 // When the node level is 0, then the node is a leaf and the branch has a
86 // valid index pointing to an element in the vector that was used to build 88 // valid index pointing to an element in the vector that was used to build
87 // this rtree. When the level is not 0, it's an internal node and it has a 89 // this rtree. When the level is not 0, it's an internal node and it has a
(...skipping 21 matching lines...) Expand all
109 111
110 // This is the count of data elements (rather than total nodes in the tree) 112 // This is the count of data elements (rather than total nodes in the tree)
111 size_t num_data_elements_; 113 size_t num_data_elements_;
112 Branch root_; 114 Branch root_;
113 std::deque<Node> nodes_; 115 std::deque<Node> nodes_;
114 }; 116 };
115 117
116 } // namespace cc 118 } // namespace cc
117 119
118 #endif // CC_BASE_RTREE_H_ 120 #endif // CC_BASE_RTREE_H_
OLDNEW
« no previous file with comments | « no previous file | cc/base/rtree.cc » ('j') | third_party/WebKit/Source/platform/graphics/paint/PaintController.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698