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 "Test.h" | 8 #include "Test.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkRTree.h" | 10 #include "SkRTree.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 SkRect query = random_rect(rand); | 79 SkRect query = random_rect(rand); |
80 tree.search(query, &hits); | 80 tree.search(query, &hits); |
81 REPORTER_ASSERT(reporter, verify_query(query, rects, hits)); | 81 REPORTER_ASSERT(reporter, verify_query(query, rects, hits)); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 static void tree_test_main(SkBBoxHierarchy* tree, int minChildren, int maxChildr
en, | 85 static void tree_test_main(SkBBoxHierarchy* tree, int minChildren, int maxChildr
en, |
86 skiatest::Reporter* reporter) { | 86 skiatest::Reporter* reporter) { |
87 DataRect rects[NUM_RECTS]; | 87 DataRect rects[NUM_RECTS]; |
88 SkRandom rand; | 88 SkRandom rand; |
89 REPORTER_ASSERT(reporter, NULL != tree); | 89 REPORTER_ASSERT(reporter, tree); |
90 | 90 |
91 int expectedDepthMin = -1; | 91 int expectedDepthMin = -1; |
92 int expectedDepthMax = -1; | 92 int expectedDepthMax = -1; |
93 | 93 |
94 int tmp = NUM_RECTS; | 94 int tmp = NUM_RECTS; |
95 if (maxChildren > 0) { | 95 if (maxChildren > 0) { |
96 while (tmp > 0) { | 96 while (tmp > 0) { |
97 tmp -= static_cast<int>(pow(static_cast<double>(maxChildren), | 97 tmp -= static_cast<int>(pow(static_cast<double>(maxChildren), |
98 static_cast<double>(expectedDepthMin + 1))); | 98 static_cast<double>(expectedDepthMin + 1))); |
99 ++expectedDepthMin; | 99 ++expectedDepthMin; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 SkRTree* rtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN)
; | 161 SkRTree* rtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN)
; |
162 SkAutoUnref au(rtree); | 162 SkAutoUnref au(rtree); |
163 tree_test_main(rtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, reporter); | 163 tree_test_main(rtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, reporter); |
164 | 164 |
165 // Rtree that orders input rectangles on deferred insert. | 165 // Rtree that orders input rectangles on deferred insert. |
166 SkRTree* unsortedRtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_C
HILDREN, 1, false); | 166 SkRTree* unsortedRtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_C
HILDREN, 1, false); |
167 SkAutoUnref auo(unsortedRtree); | 167 SkAutoUnref auo(unsortedRtree); |
168 tree_test_main(unsortedRtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, re
porter); | 168 tree_test_main(unsortedRtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, re
porter); |
169 } | 169 } |
170 } | 170 } |
OLD | NEW |