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

Unified Diff: tests/GrShapeTest.cpp

Issue 1923403003: Add tests for volatile paths to GrShapeTest (Closed) Base URL: https://chromium.googlesource.com/skia.git@emptyshape
Patch Set: cleanup Created 4 years, 8 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 | « no previous file | 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 14316c1f8d3fceab48a0c4cc9a8f23c6ee3bf9c7..de08457dbacc8a123eae42f77cc3c935890026bd 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -449,6 +449,36 @@ void test_unknown_path_effect(skiatest::Reporter* reporter, const GEO& geo) {
geoPEStrokeCase.testExpectations(reporter, expectations);
}
+/**
+ * isNonPath indicates whether the initial shape made from the path is expected to be recognized
+ * as a simpler shape type (e.g. rrect)
+ */
+void test_volatile_path(skiatest::Reporter* reporter, const SkPath& path,
+ bool isNonPath) {
+ SkPath vPath(path);
+ vPath.setIsVolatile(true);
+
+ SkPaint dashAndStroke;
+ dashAndStroke.setPathEffect(make_dash());
+ dashAndStroke.setStrokeWidth(2.f);
+ dashAndStroke.setStyle(SkPaint::kStroke_Style);
+ TestCase volatileCase(vPath, dashAndStroke);
+ // We expect a shape made from a volatile path to have a key iff the shape is recognized
+ // as a specialized geometry.
+ if (isNonPath) {
+ REPORTER_ASSERT(reporter, SkToBool(volatileCase.baseKey().count()));
+ // In this case all the keys should be identical to the non-volatile case.
+ TestCase nonVolatileCase(path, dashAndStroke);
+ volatileCase.compare(reporter, nonVolatileCase, TestCase::kAllSame_ComparisonExpecation);
+ } else {
+ // None of the keys should be valid.
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.baseKey().count()));
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectKey().count()));
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedFullStyleKey().count()));
+ REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectThenStrokeKey().count()));
+ }
+}
+
template <typename GEO>
void test_path_effect_makes_empty_shape(skiatest::Reporter* reporter, const GEO& geo) {
/**
@@ -594,6 +624,8 @@ DEF_TEST(GrShape, reporter) {
test_null_dash(reporter, path);
test_path_effect_makes_rrect(reporter, path);
}
+ // This test uses a stroking paint, hence use of fIsRRectForStroke
+ test_volatile_path(reporter, path, testPath.fIsRRectForStroke);
test_dash_fill(reporter, path);
// Test modifying various stroke params.
test_stroke_param<SkPath, SkScalar>(
@@ -637,6 +669,9 @@ DEF_TEST(GrShape, reporter) {
}
}
+ // Test a volatile empty path.
+ test_volatile_path(reporter, SkPath(), true);
+
test_empty_shape(reporter);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698