| 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 #include "SkRandom.h" | 9 #include "SkRandom.h" |
| 10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 SkTDArray<void*> hits; | 77 SkTDArray<void*> hits; |
| 78 SkRect query = random_rect(rand); | 78 SkRect query = random_rect(rand); |
| 79 tree.search(query, &hits); | 79 tree.search(query, &hits); |
| 80 REPORTER_ASSERT(reporter, verify_query(query, rects, hits)); | 80 REPORTER_ASSERT(reporter, verify_query(query, rects, hits)); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 static void rtree_test_main(SkRTree* rtree, skiatest::Reporter* reporter) { | 84 static void rtree_test_main(SkRTree* rtree, skiatest::Reporter* reporter) { |
| 85 DataRect rects[NUM_RECTS]; | 85 DataRect rects[NUM_RECTS]; |
| 86 SkRandom rand; | 86 SkRandom rand; |
| 87 REPORTER_ASSERT(reporter, NULL != rtree); | 87 REPORTER_ASSERT(reporter, rtree); |
| 88 | 88 |
| 89 int expectedDepthMin = -1; | 89 int expectedDepthMin = -1; |
| 90 int expectedDepthMax = -1; | 90 int expectedDepthMax = -1; |
| 91 | 91 |
| 92 int tmp = NUM_RECTS; | 92 int tmp = NUM_RECTS; |
| 93 while (tmp > 0) { | 93 while (tmp > 0) { |
| 94 tmp -= static_cast<int>(pow(static_cast<double>(MAX_CHILDREN), | 94 tmp -= static_cast<int>(pow(static_cast<double>(MAX_CHILDREN), |
| 95 static_cast<double>(expectedDepthMin + 1))); | 95 static_cast<double>(expectedDepthMin + 1))); |
| 96 ++expectedDepthMin; | 96 ++expectedDepthMin; |
| 97 } | 97 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 DEF_TEST(RTree, reporter) { | 145 DEF_TEST(RTree, reporter) { |
| 146 SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN); | 146 SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN); |
| 147 SkAutoUnref au(rtree); | 147 SkAutoUnref au(rtree); |
| 148 rtree_test_main(rtree, reporter); | 148 rtree_test_main(rtree, reporter); |
| 149 | 149 |
| 150 // Rtree that orders input rectangles on deferred insert. | 150 // Rtree that orders input rectangles on deferred insert. |
| 151 SkRTree* unsortedRtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN, 1, fals
e); | 151 SkRTree* unsortedRtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN, 1, fals
e); |
| 152 SkAutoUnref auo(unsortedRtree); | 152 SkAutoUnref auo(unsortedRtree); |
| 153 rtree_test_main(unsortedRtree, reporter); | 153 rtree_test_main(unsortedRtree, reporter); |
| 154 } | 154 } |
| OLD | NEW |