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

Unified Diff: tests/BBoxHierarchyTest.cpp

Issue 511613002: Convert BBH APIs to use SkRect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: another in BBH test Created 6 years, 4 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/gpu/SkGpuDevice.cpp ('k') | tests/PictureTest.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 305543b7eb8f7c9803dfff7d9a5a31ac0e20ccea..b9cbbc4f9a14957a15d90b4bee9991beabefcafa 100644
--- a/tests/BBoxHierarchyTest.cpp
+++ b/tests/BBoxHierarchyTest.cpp
@@ -17,20 +17,20 @@ static const int NUM_RECTS = 200;
static const size_t NUM_ITERATIONS = 100;
static const size_t NUM_QUERIES = 50;
-static const int MAX_SIZE = 1000;
+static const SkScalar MAX_SIZE = 1000.0f;
struct DataRect {
- SkIRect rect;
+ SkRect rect;
void* data;
};
-static SkIRect random_rect(SkRandom& rand) {
- SkIRect rect = {0,0,0,0};
+static SkRect random_rect(SkRandom& rand) {
+ SkRect rect = {0,0,0,0};
while (rect.isEmpty()) {
- rect.fLeft = rand.nextS() % MAX_SIZE;
- rect.fRight = rand.nextS() % MAX_SIZE;
- rect.fTop = rand.nextS() % MAX_SIZE;
- rect.fBottom = rand.nextS() % MAX_SIZE;
+ rect.fLeft = rand.nextRangeF(0, MAX_SIZE);
+ rect.fRight = rand.nextRangeF(0, MAX_SIZE);
+ rect.fTop = rand.nextRangeF(0, MAX_SIZE);
+ rect.fBottom = rand.nextRangeF(0, MAX_SIZE);
rect.sort();
}
return rect;
@@ -43,12 +43,15 @@ static void random_data_rects(SkRandom& rand, DataRect out[], int n) {
}
}
-static bool verify_query(SkIRect query, DataRect rects[],
+static bool verify_query(SkRect query, DataRect rects[],
SkTDArray<void*>& found) {
+ // TODO(mtklein): no need to do this after everything's SkRects
+ query.roundOut();
+
SkTDArray<void*> expected;
// manually intersect with every rectangle
for (int i = 0; i < NUM_RECTS; ++i) {
- if (SkIRect::IntersectsNoEmptyCheck(query, rects[i].rect)) {
+ if (SkRect::Intersects(query, rects[i].rect)) {
expected.push(rects[i].data);
}
}
@@ -73,7 +76,7 @@ static void run_queries(skiatest::Reporter* reporter, SkRandom& rand, DataRect r
SkBBoxHierarchy& tree) {
for (size_t i = 0; i < NUM_QUERIES; ++i) {
SkTDArray<void*> hits;
- SkIRect query = random_rect(rand);
+ SkRect query = random_rect(rand);
tree.search(query, &hits);
REPORTER_ASSERT(reporter, verify_query(query, rects, hits));
}
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698