From 8c902126a90f37b6a038a78488c6215fa0c34b7d Mon Sep 17 00:00:00 2001 From: "sglez@google.com" Date: Fri, 30 Aug 2013 17:27:47 +0000 Subject: 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 --- tests/RTreeTest.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'tests/RTreeTest.cpp') 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 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) -- cgit v1.2.3