OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkQuadTree.h" | 8 #include "SkQuadTree.h" |
9 #include "SkTSort.h" | 9 #include "SkTSort.h" |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 Entry* entry = fEntryPool.acquire(); | 161 Entry* entry = fEntryPool.acquire(); |
162 entry->fData = data; | 162 entry->fData = data; |
163 entry->fBounds = bounds; | 163 entry->fBounds = bounds; |
164 if (NULL == fRoot) { | 164 if (NULL == fRoot) { |
165 fDeferred.push(entry); | 165 fDeferred.push(entry); |
166 } else { | 166 } else { |
167 this->insert(fRoot, entry); | 167 this->insert(fRoot, entry); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 void SkQuadTree::search(const SkIRect& query, SkTDArray<void*>* results) { | 171 void SkQuadTree::search(const SkIRect& query, SkTDArray<void*>* results) const { |
172 SkASSERT(NULL != fRoot); | 172 SkASSERT(NULL != fRoot); |
173 SkASSERT(NULL != results); | 173 SkASSERT(NULL != results); |
174 if (SkIRect::Intersects(fRootBounds, query)) { | 174 if (SkIRect::Intersects(fRootBounds, query)) { |
175 this->search(fRoot, query, results); | 175 this->search(fRoot, query, results); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 void SkQuadTree::clear() { | 179 void SkQuadTree::clear() { |
180 this->flushDeferredInserts(); | 180 this->flushDeferredInserts(); |
181 if (NULL != fRoot) { | 181 if (NULL != fRoot) { |
(...skipping 28 matching lines...) Expand all Loading... |
210 | 210 |
211 void SkQuadTree::flushDeferredInserts() { | 211 void SkQuadTree::flushDeferredInserts() { |
212 if (NULL == fRoot) { | 212 if (NULL == fRoot) { |
213 fRoot = fNodePool.acquire(); | 213 fRoot = fNodePool.acquire(); |
214 fRoot->fBounds = fRootBounds; | 214 fRoot->fBounds = fRootBounds; |
215 } | 215 } |
216 while(!fDeferred.isEmpty()) { | 216 while(!fDeferred.isEmpty()) { |
217 this->insert(fRoot, fDeferred.pop()); | 217 this->insert(fRoot, fDeferred.pop()); |
218 } | 218 } |
219 } | 219 } |
OLD | NEW |