OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef SkRTree_DEFINED | 9 #ifndef SkRTree_DEFINED |
10 #define SkRTree_DEFINED | 10 #define SkRTree_DEFINED |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 * - min > 0 | 52 * - min > 0 |
53 * - max < SK_MaxU16 | 53 * - max < SK_MaxU16 |
54 * If you have some prior information about the distribution of bounds you'r
e expecting, you | 54 * If you have some prior information about the distribution of bounds you'r
e expecting, you |
55 * can provide an optional aspect ratio parameter. This allows the bulk-load
algorithm to create | 55 * can provide an optional aspect ratio parameter. This allows the bulk-load
algorithm to create |
56 * better proportioned tiles of rectangles. | 56 * better proportioned tiles of rectangles. |
57 */ | 57 */ |
58 static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRati
o = 1, | 58 static SkRTree* Create(int minChildren, int maxChildren, SkScalar aspectRati
o = 1, |
59 bool orderWhenBulkLoading = true); | 59 bool orderWhenBulkLoading = true); |
60 virtual ~SkRTree(); | 60 virtual ~SkRTree(); |
61 | 61 |
62 /** | 62 virtual void insert(SkAutoTMalloc<SkRect>* boundsArray, int N) SK_OVERRIDE; |
63 * Insert a node, consisting of bounds and a data value into the tree, if we
don't immediately | |
64 * need to use the tree; we may allow the insert to be deferred (this can al
low us to bulk-load | |
65 * a large batch of nodes at once, which tends to be faster and produce a be
tter tree). | |
66 * @param opIndex The data value | |
67 * @param bounds The corresponding bounding box | |
68 * @param defer Can this insert be deferred? (this may be ignored) | |
69 */ | |
70 virtual void insert(unsigned opIndex, const SkRect& bounds, bool defer = fal
se) SK_OVERRIDE; | |
71 | |
72 /** | |
73 * If any inserts have been deferred, this will add them into the tree | |
74 */ | |
75 virtual void flushDeferredInserts() SK_OVERRIDE; | |
76 | |
77 /** | |
78 * Given a query rectangle, populates the passed-in array with the elements
it intersects | |
79 */ | |
80 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
SK_OVERRIDE; | 63 virtual void search(const SkRect& query, SkTDArray<unsigned>* results) const
SK_OVERRIDE; |
81 | 64 |
82 void clear(); | 65 void clear(); |
83 // Return the depth of the tree structure. | 66 // Return the depth of the tree structure. |
84 int getDepth() const { return this->isEmpty() ? 0 : fRoot.fChild.subtree->fL
evel + 1; } | 67 int getDepth() const { return this->isEmpty() ? 0 : fRoot.fChild.subtree->fL
evel + 1; } |
85 // Insertion count (not overall node count, which may be greater). | 68 // Insertion count (not overall node count, which may be greater). |
86 int getCount() const { return fCount; } | 69 int getCount() const { return fCount; } |
87 | 70 |
88 private: | 71 private: |
89 bool isEmpty() const { return 0 == this->getCount(); } | 72 bool isEmpty() const { return 0 == this->getCount(); } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 155 |
173 const int fMinChildren; | 156 const int fMinChildren; |
174 const int fMaxChildren; | 157 const int fMaxChildren; |
175 const size_t fNodeSize; | 158 const size_t fNodeSize; |
176 | 159 |
177 // This is the count of data elements (rather than total nodes in the tree) | 160 // This is the count of data elements (rather than total nodes in the tree) |
178 int fCount; | 161 int fCount; |
179 | 162 |
180 Branch fRoot; | 163 Branch fRoot; |
181 SkChunkAlloc fNodes; | 164 SkChunkAlloc fNodes; |
182 SkTDArray<Branch> fDeferredInserts; | |
183 SkScalar fAspectRatio; | 165 SkScalar fAspectRatio; |
184 bool fSortWhenBulkLoading; | 166 bool fSortWhenBulkLoading; |
185 | 167 |
186 Node* allocateNode(uint16_t level); | 168 Node* allocateNode(uint16_t level); |
187 | 169 |
188 typedef SkBBoxHierarchy INHERITED; | 170 typedef SkBBoxHierarchy INHERITED; |
189 }; | 171 }; |
190 | 172 |
191 #endif | 173 #endif |
OLD | NEW |