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

Unified Diff: tests/GrShapeTest.cpp

Issue 1971613004: Add isEmpty() query to GrShape and improve comments. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/GrShape.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GrShapeTest.cpp
diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp
index 75f27eda35173912e465b23dcaed07529f0e81a5..138028d738d26d00274552913abc53fd3cda8650 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -83,6 +83,15 @@ private:
fAppliedPEThenStroke.asPath(&a);
fAppliedFull.asPath(&b);
REPORTER_ASSERT(r, a == b);
+ REPORTER_ASSERT(r, fAppliedFull.isEmpty() == fAppliedPEThenStroke.isEmpty());
+
+ SkPath path;
+ fBase.asPath(&path);
+ REPORTER_ASSERT(r, path.isEmpty() == fBase.isEmpty());
+ fAppliedPE.asPath(&path);
robertphillips 2016/05/11 21:38:40 Couldn't we have a PE for which this isn't true? I
bsalomon 2016/05/11 21:47:49 This is asserting that after applying the PE the e
+ REPORTER_ASSERT(r, path.isEmpty() == fAppliedPE.isEmpty());
+ fAppliedFull.asPath(&path);
+ REPORTER_ASSERT(r, path.isEmpty() == fAppliedFull.isEmpty());
// Check that the same path is produced when style is applied by GrShape and GrStyle.
SkPath preStyle;
@@ -170,6 +179,7 @@ void TestCase::compare(skiatest::Reporter* reporter, const TestCase& that,
fBase.asPath(&a);
that.fBase.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fBase.isEmpty() == that.fBase.isEmpty());
REPORTER_ASSERT(reporter, fAppliedPEKey != that.fAppliedPEKey);
REPORTER_ASSERT(reporter, fAppliedFullKey != that.fAppliedFullKey);
break;
@@ -178,10 +188,12 @@ void TestCase::compare(skiatest::Reporter* reporter, const TestCase& that,
fBase.asPath(&a);
that.fBase.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fBase.isEmpty() == that.fBase.isEmpty());
REPORTER_ASSERT(reporter, fAppliedPEKey == that.fAppliedPEKey);
fAppliedPE.asPath(&a);
that.fAppliedPE.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fAppliedPE.isEmpty() == that.fAppliedPE.isEmpty());
REPORTER_ASSERT(reporter, fAppliedFullKey != that.fAppliedFullKey);
break;
case kAllSame_ComparisonExpecation:
@@ -189,14 +201,17 @@ void TestCase::compare(skiatest::Reporter* reporter, const TestCase& that,
fBase.asPath(&a);
that.fBase.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fBase.isEmpty() == that.fBase.isEmpty());
REPORTER_ASSERT(reporter, fAppliedPEKey == that.fAppliedPEKey);
fAppliedPE.asPath(&a);
that.fAppliedPE.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fAppliedPE.isEmpty() == that.fAppliedPE.isEmpty());
REPORTER_ASSERT(reporter, fAppliedFullKey == that.fAppliedFullKey);
fAppliedFull.asPath(&a);
that.fAppliedFull.asPath(&b);
REPORTER_ASSERT(reporter, a == b);
+ REPORTER_ASSERT(reporter, fAppliedFull.isEmpty() == that.fAppliedFull.isEmpty());
break;
}
}
@@ -745,6 +760,7 @@ void test_path_effect_makes_empty_shape(skiatest::Reporter* reporter, const GEO&
GrShape emptyShape(emptyPath);
Key emptyKey;
make_key(&emptyKey, emptyShape);
+ REPORTER_ASSERT(reporter, emptyShape.isEmpty());
SkPaint pe;
pe.setPathEffect(EmptyPathEffect::Make());
@@ -752,6 +768,8 @@ void test_path_effect_makes_empty_shape(skiatest::Reporter* reporter, const GEO&
REPORTER_ASSERT(reporter, geoCase.appliedFullStyleKey() == emptyKey);
REPORTER_ASSERT(reporter, geoCase.appliedPathEffectKey() == emptyKey);
REPORTER_ASSERT(reporter, geoCase.appliedPathEffectThenStrokeKey() == emptyKey);
+ REPORTER_ASSERT(reporter, geoCase.appliedPathEffectShape().isEmpty());
+ REPORTER_ASSERT(reporter, geoCase.appliedFullStyleShape().isEmpty());
SkPaint peStroke;
peStroke.setPathEffect(EmptyPathEffect::Make());
@@ -761,12 +779,17 @@ void test_path_effect_makes_empty_shape(skiatest::Reporter* reporter, const GEO&
REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedFullStyleKey() == emptyKey);
REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectKey() == emptyKey);
REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectThenStrokeKey() == emptyKey);
+ REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectShape().isEmpty());
+ REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedFullStyleShape().isEmpty());
}
void test_empty_shape(skiatest::Reporter* reporter) {
SkPath emptyPath;
SkPaint fill;
TestCase fillEmptyCase(emptyPath, fill, reporter);
+ REPORTER_ASSERT(reporter, fillEmptyCase.baseShape().isEmpty());
+ REPORTER_ASSERT(reporter, fillEmptyCase.appliedPathEffectShape().isEmpty());
+ REPORTER_ASSERT(reporter, fillEmptyCase.appliedFullStyleShape().isEmpty());
Key emptyKey(fillEmptyCase.baseKey());
REPORTER_ASSERT(reporter, emptyKey.count());
« no previous file with comments | « src/gpu/GrShape.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698