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

Unified Diff: tests/GrShapeTest.cpp

Issue 2055253002: Add control over whether lines are special cased in SkDashPath. Disable when called from GrShape. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: update comments Created 4 years, 6 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/utils/SkDashPathPriv.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 2edfd1276eba571f7140bc2034daf9c47e12ec9f..5fa1db9f7e147859e715b7cb3a3f5a5e9c856c43 100644
--- a/tests/GrShapeTest.cpp
+++ b/tests/GrShapeTest.cpp
@@ -325,6 +325,11 @@ void check_equivalence(skiatest::Reporter* r, const GrShape& a, const GrShape& b
REPORTER_ASSERT(r, a.knownToBeClosed() == b.knownToBeClosed());
REPORTER_ASSERT(r, a.bounds() == b.bounds());
REPORTER_ASSERT(r, a.segmentMask() == b.segmentMask());
+ SkPoint pts[4];
+ REPORTER_ASSERT(r, a.asLine(pts) == b.asLine(pts + 2));
+ if (a.asLine(pts)) {
+ REPORTER_ASSERT(r, pts[2] == pts[0] && pts[3] == pts[1]);
+ }
}
void TestCase::compare(skiatest::Reporter* r, const TestCase& that,
@@ -1269,6 +1274,8 @@ DEF_TEST(GrShape, reporter) {
test_path_effect_makes_empty_shape(reporter, r);
test_path_effect_fails(reporter, r);
test_make_hairline_path_effect(reporter, r, true);
+ GrShape shape(r);
+ REPORTER_ASSERT(reporter, !shape.asLine(nullptr));
}
for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)),
@@ -1295,39 +1302,47 @@ DEF_TEST(GrShape, reporter) {
test_path_effect_makes_empty_shape(reporter, rr);
test_path_effect_fails(reporter, rr);
test_make_hairline_path_effect(reporter, rr, true);
+ GrShape shape(rr);
+ REPORTER_ASSERT(reporter, !shape.asLine(nullptr));
}
struct TestPath {
- TestPath(const SkPath& path, bool isRRectFill, bool isRRectStroke, const SkRRect& rrect)
+ TestPath(const SkPath& path, bool isRRectFill, bool isRRectStroke, bool isLine, const SkRRect& rrect)
: fPath(path)
, fIsRRectForFill(isRRectFill)
, fIsRRectForStroke(isRRectStroke)
+ , fIsLine(isLine)
, fRRect(rrect) {}
SkPath fPath;
bool fIsRRectForFill;
bool fIsRRectForStroke;
+ bool fIsLine;
SkRRect fRRect;
};
SkTArray<TestPath> paths;
SkPath circlePath;
circlePath.addCircle(10, 10, 10);
- paths.emplace_back(circlePath, true, true, SkRRect::MakeOval(SkRect::MakeWH(20,20)));
+ paths.emplace_back(circlePath, true, true, false, SkRRect::MakeOval(SkRect::MakeWH(20,20)));
SkPath rectPath;
rectPath.addRect(SkRect::MakeWH(10, 10));
- paths.emplace_back(rectPath, true, true, SkRRect::MakeRect(SkRect::MakeWH(10, 10)));
+ paths.emplace_back(rectPath, true, true, false, SkRRect::MakeRect(SkRect::MakeWH(10, 10)));
SkPath openRectPath;
openRectPath.moveTo(0, 0);
openRectPath.lineTo(10, 0);
openRectPath.lineTo(10, 10);
openRectPath.lineTo(0, 10);
- paths.emplace_back(openRectPath, true, false, SkRRect::MakeRect(SkRect::MakeWH(10, 10)));
+ paths.emplace_back(openRectPath, true, false, false, SkRRect::MakeRect(SkRect::MakeWH(10, 10)));
SkPath quadPath;
quadPath.quadTo(10, 10, 5, 8);
- paths.emplace_back(quadPath, false, false, SkRRect());
+ paths.emplace_back(quadPath, false, false, false, SkRRect());
+
+ SkPath linePath;
+ linePath.lineTo(10, 10);
+ paths.emplace_back(linePath, false, false, true, SkRRect());
for (auto testPath : paths) {
for (bool inverseFill : {false, true}) {
@@ -1399,6 +1414,8 @@ DEF_TEST(GrShape, reporter) {
strokePathCase.compare(reporter, strokeRRectCase,
TestCase::kAllSame_ComparisonExpecation);
}
+ REPORTER_ASSERT(reporter, testPath.fIsLine == fillPathCase.baseShape().asLine(nullptr));
+ REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape().asLine(nullptr));
}
// Test a volatile empty path.
« no previous file with comments | « src/utils/SkDashPathPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698