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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return new SkQuadTree(bounds); | 184 return new SkQuadTree(bounds); |
185 } | 185 } |
186 | 186 |
187 SkQuadTree::SkQuadTree(const SkIRect& bounds) | 187 SkQuadTree::SkQuadTree(const SkIRect& bounds) |
188 : fCount(0) | 188 : fCount(0) |
189 , fRoot(SkNEW_ARGS(QuadTreeNode, (bounds))) { | 189 , fRoot(SkNEW_ARGS(QuadTreeNode, (bounds))) { |
190 SkASSERT((bounds.width() * bounds.height()) > 0); | 190 SkASSERT((bounds.width() * bounds.height()) > 0); |
191 } | 191 } |
192 | 192 |
193 SkQuadTree::~SkQuadTree() { | 193 SkQuadTree::~SkQuadTree() { |
| 194 SkDELETE(fRoot); |
194 } | 195 } |
195 | 196 |
196 void SkQuadTree::insert(void* data, const SkIRect& bounds, bool) { | 197 void SkQuadTree::insert(void* data, const SkIRect& bounds, bool) { |
197 if (bounds.isEmpty()) { | 198 if (bounds.isEmpty()) { |
198 SkASSERT(false); | 199 SkASSERT(false); |
199 return; | 200 return; |
200 } | 201 } |
201 | 202 |
202 QuadTreeNode::Data quadTreeData(bounds, data); | 203 QuadTreeNode::Data quadTreeData(bounds, data); |
203 fRoot->insert(quadTreeData); | 204 fRoot->insert(quadTreeData); |
(...skipping 11 matching lines...) Expand all Loading... |
215 } | 216 } |
216 | 217 |
217 int SkQuadTree::getDepth() const { | 218 int SkQuadTree::getDepth() const { |
218 return fRoot->getDepth(); | 219 return fRoot->getDepth(); |
219 } | 220 } |
220 | 221 |
221 void SkQuadTree::rewindInserts() { | 222 void SkQuadTree::rewindInserts() { |
222 SkASSERT(fClient); | 223 SkASSERT(fClient); |
223 fRoot->rewindInserts(fClient); | 224 fRoot->rewindInserts(fClient); |
224 } | 225 } |
OLD | NEW |