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) {} |
11 | 11 |
| 12 SkRect SkRTree::getRootBound() const { |
| 13 if (fCount) { |
| 14 return fRoot.fBounds; |
| 15 } else { |
| 16 return SkRect::MakeEmpty(); |
| 17 } |
| 18 } |
| 19 |
12 void SkRTree::insert(const SkRect boundsArray[], int N) { | 20 void SkRTree::insert(const SkRect boundsArray[], int N) { |
13 SkASSERT(0 == fCount); | 21 SkASSERT(0 == fCount); |
14 | 22 |
15 SkTDArray<Branch> branches; | 23 SkTDArray<Branch> branches; |
16 branches.setReserve(N); | 24 branches.setReserve(N); |
17 | 25 |
18 for (int i = 0; i < N; i++) { | 26 for (int i = 0; i < N; i++) { |
19 const SkRect& bounds = boundsArray[i]; | 27 const SkRect& bounds = boundsArray[i]; |
20 if (bounds.isEmpty()) { | 28 if (bounds.isEmpty()) { |
21 continue; | 29 continue; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 179 } |
172 } | 180 } |
173 | 181 |
174 size_t SkRTree::bytesUsed() const { | 182 size_t SkRTree::bytesUsed() const { |
175 size_t byteCount = sizeof(SkRTree); | 183 size_t byteCount = sizeof(SkRTree); |
176 | 184 |
177 byteCount += fNodes.reserved() * sizeof(Node); | 185 byteCount += fNodes.reserved() * sizeof(Node); |
178 | 186 |
179 return byteCount; | 187 return byteCount; |
180 } | 188 } |
OLD | NEW |