Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2232)

Unified Diff: tests/BBoxHierarchyTest.cpp

Issue 187233002: Fast implementation of QuadTree (Closed) Base URL: https://skia.googlesource.com/skia.git@bbh_select
Patch Set: I give up, stoopid compiler Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkTObjectPool.h ('k') | tests/ObjectPoolTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/BBoxHierarchyTest.cpp
diff --git a/tests/BBoxHierarchyTest.cpp b/tests/BBoxHierarchyTest.cpp
index a562da24f89c75ce11da4942dc91503eff8e9360..662cc370e758e8d225fcf3dfee1a878a1324755b 100644
--- a/tests/BBoxHierarchyTest.cpp
+++ b/tests/BBoxHierarchyTest.cpp
@@ -13,7 +13,7 @@
static const size_t RTREE_MIN_CHILDREN = 6;
static const size_t RTREE_MAX_CHILDREN = 11;
-static const size_t QUADTREE_MIN_CHILDREN = 4;
+static const size_t QUADTREE_MIN_CHILDREN = 0;
static const size_t QUADTREE_MAX_CHILDREN = 0; // No hard limit for quadtree
static const int NUM_RECTS = 200;
@@ -126,7 +126,9 @@ static void tree_test_main(SkBBoxHierarchy* tree, int minChildren, int maxChildr
REPORTER_ASSERT(reporter, 0 == tree->getCount());
// Then try immediate inserts
- for (int i = 0; i < NUM_RECTS; ++i) {
+ tree->insert(rects[0].data, rects[0].rect);
+ tree->flushDeferredInserts();
+ for (int i = 1; i < NUM_RECTS; ++i) {
tree->insert(rects[i].data, rects[i].rect);
}
run_queries(reporter, rand, rects, *tree);
@@ -138,7 +140,9 @@ static void tree_test_main(SkBBoxHierarchy* tree, int minChildren, int maxChildr
REPORTER_ASSERT(reporter, 0 == tree->getCount());
// And for good measure try immediate inserts, but in reversed order
- for (int i = NUM_RECTS - 1; i >= 0; --i) {
+ tree->insert(rects[NUM_RECTS - 1].data, rects[NUM_RECTS - 1].rect);
+ tree->flushDeferredInserts();
+ for (int i = NUM_RECTS - 2; i >= 0; --i) {
tree->insert(rects[i].data, rects[i].rect);
}
run_queries(reporter, rand, rects, *tree);
@@ -166,14 +170,14 @@ DEF_TEST(BBoxHierarchy, reporter) {
// QuadTree
{
- SkQuadTree* quadtree = SkQuadTree::Create(
- SkIRect::MakeLTRB(-MAX_SIZE, -MAX_SIZE, MAX_SIZE, MAX_SIZE));
+ SkQuadTree* quadtree = SkNEW_ARGS(SkQuadTree, (
+ SkIRect::MakeLTRB(-MAX_SIZE, -MAX_SIZE, MAX_SIZE, MAX_SIZE)));
SkAutoUnref au(quadtree);
tree_test_main(quadtree, QUADTREE_MIN_CHILDREN, QUADTREE_MAX_CHILDREN, reporter);
// QuadTree that orders input rectangles on deferred insert.
- SkQuadTree* unsortedQuadTree = SkQuadTree::Create(
- SkIRect::MakeLTRB(-MAX_SIZE, -MAX_SIZE, MAX_SIZE, MAX_SIZE));
+ SkQuadTree* unsortedQuadTree = SkNEW_ARGS(SkQuadTree, (
+ SkIRect::MakeLTRB(-MAX_SIZE, -MAX_SIZE, MAX_SIZE, MAX_SIZE)));
SkAutoUnref auo(unsortedQuadTree);
tree_test_main(unsortedQuadTree, QUADTREE_MIN_CHILDREN, QUADTREE_MAX_CHILDREN, reporter);
}
« no previous file with comments | « src/core/SkTObjectPool.h ('k') | tests/ObjectPoolTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698