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 "SkQuadTree.h" | |
11 #include "SkRTree.h" | 10 #include "SkRTree.h" |
12 #include "SkTSort.h" | 11 #include "SkTSort.h" |
13 | 12 |
14 static const size_t RTREE_MIN_CHILDREN = 6; | 13 static const size_t RTREE_MIN_CHILDREN = 6; |
15 static const size_t RTREE_MAX_CHILDREN = 11; | 14 static const size_t RTREE_MAX_CHILDREN = 11; |
16 static const size_t QUADTREE_MIN_CHILDREN = 0; | |
17 static const size_t QUADTREE_MAX_CHILDREN = 0; // No hard limit for quadtree | |
18 | 15 |
19 static const int NUM_RECTS = 200; | 16 static const int NUM_RECTS = 200; |
20 static const size_t NUM_ITERATIONS = 100; | 17 static const size_t NUM_ITERATIONS = 100; |
21 static const size_t NUM_QUERIES = 50; | 18 static const size_t NUM_QUERIES = 50; |
22 | 19 |
23 static const int MAX_SIZE = 1000; | 20 static const int MAX_SIZE = 1000; |
24 | 21 |
25 struct DataRect { | 22 struct DataRect { |
26 SkIRect rect; | 23 SkIRect rect; |
27 void* data; | 24 void* data; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 { | 157 { |
161 SkRTree* rtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN)
; | 158 SkRTree* rtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN)
; |
162 SkAutoUnref au(rtree); | 159 SkAutoUnref au(rtree); |
163 tree_test_main(rtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, reporter); | 160 tree_test_main(rtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, reporter); |
164 | 161 |
165 // Rtree that orders input rectangles on deferred insert. | 162 // Rtree that orders input rectangles on deferred insert. |
166 SkRTree* unsortedRtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_C
HILDREN, 1, false); | 163 SkRTree* unsortedRtree = SkRTree::Create(RTREE_MIN_CHILDREN, RTREE_MAX_C
HILDREN, 1, false); |
167 SkAutoUnref auo(unsortedRtree); | 164 SkAutoUnref auo(unsortedRtree); |
168 tree_test_main(unsortedRtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, re
porter); | 165 tree_test_main(unsortedRtree, RTREE_MIN_CHILDREN, RTREE_MAX_CHILDREN, re
porter); |
169 } | 166 } |
170 | |
171 // QuadTree | |
172 { | |
173 SkQuadTree* quadtree = SkNEW_ARGS(SkQuadTree, ( | |
174 SkIRect::MakeLTRB(-MAX_SIZE, -MAX_SIZE, MAX_SIZE, MAX_SIZE))); | |
175 SkAutoUnref au(quadtree); | |
176 tree_test_main(quadtree, QUADTREE_MIN_CHILDREN, QUADTREE_MAX_CHILDREN, r
eporter); | |
177 | |
178 // QuadTree that orders input rectangles on deferred insert. | |
179 SkQuadTree* unsortedQuadTree = SkNEW_ARGS(SkQuadTree, ( | |
180 SkIRect::MakeLTRB(-MAX_SIZE, -MAX_SIZE, MAX_SIZE, MAX_SIZE))); | |
181 SkAutoUnref auo(unsortedQuadTree); | |
182 tree_test_main(unsortedQuadTree, QUADTREE_MIN_CHILDREN, QUADTREE_MAX_CHI
LDREN, reporter); | |
183 } | |
184 } | 167 } |
OLD | NEW |