| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkRTree.h" | 8 #include "SkRTree.h" |
| 9 | 9 |
| 10 SkRTree::SkRTree(SkScalar aspectRatio) : fCount(0), fAspectRatio(aspectRatio) {} | 10 SkRTree::SkRTree(SkScalar aspectRatio) : fCount(0), fAspectRatio(aspectRatio) {} |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 ++currentBranch; | 154 ++currentBranch; |
| 155 } | 155 } |
| 156 (*branches)[newBranches] = b; | 156 (*branches)[newBranches] = b; |
| 157 ++newBranches; | 157 ++newBranches; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 branches->setCount(newBranches); | 160 branches->setCount(newBranches); |
| 161 return this->bulkLoad(branches, level + 1); | 161 return this->bulkLoad(branches, level + 1); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void SkRTree::search(const SkRect& query, SkTDArray<unsigned>* results) const { | 164 void SkRTree::search(const SkRect& query, SkTDArray<int>* results) const { |
| 165 if (fCount > 0 && SkRect::Intersects(fRoot.fBounds, query)) { | 165 if (fCount > 0 && SkRect::Intersects(fRoot.fBounds, query)) { |
| 166 this->search(fRoot.fSubtree, query, results); | 166 this->search(fRoot.fSubtree, query, results); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 void SkRTree::search(Node* node, const SkRect& query, SkTDArray<unsigned>* resul
ts) const { | 170 void SkRTree::search(Node* node, const SkRect& query, SkTDArray<int>* results) c
onst { |
| 171 for (int i = 0; i < node->fNumChildren; ++i) { | 171 for (int i = 0; i < node->fNumChildren; ++i) { |
| 172 if (SkRect::Intersects(node->fChildren[i].fBounds, query)) { | 172 if (SkRect::Intersects(node->fChildren[i].fBounds, query)) { |
| 173 if (0 == node->fLevel) { | 173 if (0 == node->fLevel) { |
| 174 results->push(node->fChildren[i].fOpIndex); | 174 results->push(node->fChildren[i].fOpIndex); |
| 175 } else { | 175 } else { |
| 176 this->search(node->fChildren[i].fSubtree, query, results); | 176 this->search(node->fChildren[i].fSubtree, query, results); |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 size_t SkRTree::bytesUsed() const { | 182 size_t SkRTree::bytesUsed() const { |
| 183 size_t byteCount = sizeof(SkRTree); | 183 size_t byteCount = sizeof(SkRTree); |
| 184 | 184 |
| 185 byteCount += fNodes.reserved() * sizeof(Node); | 185 byteCount += fNodes.reserved() * sizeof(Node); |
| 186 | 186 |
| 187 return byteCount; | 187 return byteCount; |
| 188 } | 188 } |
| OLD | NEW |