aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RTreeTest.cpp
diff options
context:
space:
mode:
authorGravatar sglez@google.com <sglez@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-30 17:27:47 +0000
committerGravatar sglez@google.com <sglez@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-30 17:27:47 +0000
commit8c902126a90f37b6a038a78488c6215fa0c34b7d (patch)
tree2697cadd11b02c99a3d775241d801dcb227a9bc1 /tests/RTreeTest.cpp
parent6be61ce03947b7d69305c37c1efa389160afada5 (diff)
R-Tree -- Don't sort draw commands unless specified.
We expect Webkit and Bink to give us draw commands in a reasonable x,y order. We can maintain correctness and get a 17% recording speedup for the R-Tree by not sorting in x and y when bulk-loading. R=caryclark@google.com, reed@google.com Review URL: https://codereview.chromium.org/23480002 git-svn-id: http://skia.googlecode.com/svn/trunk@11037 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/RTreeTest.cpp')
-rw-r--r--tests/RTreeTest.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp
index 6296c4e7b8..655336c676 100644
--- a/tests/RTreeTest.cpp
+++ b/tests/RTreeTest.cpp
@@ -68,7 +68,7 @@ static bool verify_query(SkIRect query, DataRect rects[],
return found == expected;
}
-static void runQueries(skiatest::Reporter* reporter, SkMWCRandom& rand, DataRect rects[],
+static void run_queries(skiatest::Reporter* reporter, SkMWCRandom& rand, DataRect rects[],
SkRTree& tree) {
for (size_t i = 0; i < NUM_QUERIES; ++i) {
SkTDArray<void*> hits;
@@ -78,11 +78,9 @@ static void runQueries(skiatest::Reporter* reporter, SkMWCRandom& rand, DataRect
}
}
-static void TestRTree(skiatest::Reporter* reporter) {
+static void rtree_test_main(SkRTree* rtree, skiatest::Reporter* reporter) {
DataRect rects[NUM_RECTS];
SkMWCRandom rand;
- SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN);
- SkAutoUnref au(rtree);
REPORTER_ASSERT(reporter, NULL != rtree);
int expectedDepthMin = -1;
@@ -110,7 +108,7 @@ static void TestRTree(skiatest::Reporter* reporter) {
rtree->insert(rects[i].data, rects[i].rect, true);
}
rtree->flushDeferredInserts();
- runQueries(reporter, rand, rects, *rtree);
+ run_queries(reporter, rand, rects, *rtree);
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount());
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() &&
expectedDepthMax >= rtree->getDepth());
@@ -121,7 +119,7 @@ static void TestRTree(skiatest::Reporter* reporter) {
for (int i = 0; i < NUM_RECTS; ++i) {
rtree->insert(rects[i].data, rects[i].rect);
}
- runQueries(reporter, rand, rects, *rtree);
+ run_queries(reporter, rand, rects, *rtree);
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount());
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() &&
expectedDepthMax >= rtree->getDepth());
@@ -132,7 +130,7 @@ static void TestRTree(skiatest::Reporter* reporter) {
for (int i = NUM_RECTS - 1; i >= 0; --i) {
rtree->insert(rects[i].data, rects[i].rect);
}
- runQueries(reporter, rand, rects, *rtree);
+ run_queries(reporter, rand, rects, *rtree);
REPORTER_ASSERT(reporter, NUM_RECTS == rtree->getCount());
REPORTER_ASSERT(reporter, expectedDepthMin <= rtree->getDepth() &&
expectedDepthMax >= rtree->getDepth());
@@ -141,5 +139,17 @@ static void TestRTree(skiatest::Reporter* reporter) {
}
}
+static void test_rtree(skiatest::Reporter* reporter) {
+ SkRTree* rtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN);
+ SkAutoUnref au(rtree);
+ rtree_test_main(rtree, reporter);
+
+ // Rtree that orders input rectangles on deferred insert.
+ SkRTree* unsortedRtree = SkRTree::Create(MIN_CHILDREN, MAX_CHILDREN, false);
+ SkAutoUnref auo(orderedRtree);
+ rtree_test_main(orderedRtree, reporter);
+}
+
+
#include "TestClassDef.h"
-DEFINE_TESTCLASS("RTree", RTreeTestClass, TestRTree)
+DEFINE_TESTCLASS("RTree", RTreeTestClass, test_rtree)