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

Side by Side Diff: tests/GrShapeTest.cpp

Issue 2108523002: Make lines a special case in GrShape (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: reject empty shape in GrDC::internalDrawPath Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « src/gpu/batches/GrDashLinePathRenderer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <initializer_list> 8 #include <initializer_list>
9 #include <functional> 9 #include <functional>
10 #include "Test.h" 10 #include "Test.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 REPORTER_ASSERT(r, path.isEmpty() == fAppliedPE.isEmpty()); 170 REPORTER_ASSERT(r, path.isEmpty() == fAppliedPE.isEmpty());
171 REPORTER_ASSERT(r, path.getSegmentMasks() == fAppliedPE.segmentMask()); 171 REPORTER_ASSERT(r, path.getSegmentMasks() == fAppliedPE.segmentMask());
172 fAppliedFull.asPath(&path); 172 fAppliedFull.asPath(&path);
173 REPORTER_ASSERT(r, path.isEmpty() == fAppliedFull.isEmpty()); 173 REPORTER_ASSERT(r, path.isEmpty() == fAppliedFull.isEmpty());
174 REPORTER_ASSERT(r, path.getSegmentMasks() == fAppliedFull.segmentMask()) ; 174 REPORTER_ASSERT(r, path.getSegmentMasks() == fAppliedFull.segmentMask()) ;
175 175
176 CheckBounds(r, fBase, fBase.bounds()); 176 CheckBounds(r, fBase, fBase.bounds());
177 CheckBounds(r, fAppliedPE, fAppliedPE.bounds()); 177 CheckBounds(r, fAppliedPE, fAppliedPE.bounds());
178 CheckBounds(r, fAppliedPEThenStroke, fAppliedPEThenStroke.bounds()); 178 CheckBounds(r, fAppliedPEThenStroke, fAppliedPEThenStroke.bounds());
179 CheckBounds(r, fAppliedFull, fAppliedFull.bounds()); 179 CheckBounds(r, fAppliedFull, fAppliedFull.bounds());
180 SkRect styledBounds; 180 SkRect styledBounds = fBase.styledBounds();
181 fBase.styledBounds(&styledBounds);
182 CheckBounds(r, fAppliedFull, styledBounds); 181 CheckBounds(r, fAppliedFull, styledBounds);
183 fAppliedPE.styledBounds(&styledBounds); 182 styledBounds = fAppliedPE.styledBounds();
184 CheckBounds(r, fAppliedFull, styledBounds); 183 CheckBounds(r, fAppliedFull, styledBounds);
185 184
186 // Check that the same path is produced when style is applied by GrShape and GrStyle. 185 // Check that the same path is produced when style is applied by GrShape and GrStyle.
187 SkPath preStyle; 186 SkPath preStyle;
188 SkPath postPathEffect; 187 SkPath postPathEffect;
189 SkPath postAllStyle; 188 SkPath postAllStyle;
190 189
191 fBase.asPath(&preStyle); 190 fBase.asPath(&preStyle);
192 SkStrokeRec postPEStrokeRec(SkStrokeRec::kFill_InitStyle); 191 SkStrokeRec postPEStrokeRec(SkStrokeRec::kFill_InitStyle);
193 if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPEStrokeRe c, preStyle, 192 if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPEStrokeRe c, preStyle,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // closedness can affect convexity. 364 // closedness can affect convexity.
366 REPORTER_ASSERT(r, allowedClosednessDiff || a.knownToBeConvex() == b.knownTo BeConvex()); 365 REPORTER_ASSERT(r, allowedClosednessDiff || a.knownToBeConvex() == b.knownTo BeConvex());
367 if (a.knownToBeConvex()) { 366 if (a.knownToBeConvex()) {
368 REPORTER_ASSERT(r, pathA.isConvex()); 367 REPORTER_ASSERT(r, pathA.isConvex());
369 } 368 }
370 if (b.knownToBeConvex()) { 369 if (b.knownToBeConvex()) {
371 REPORTER_ASSERT(r, pathB.isConvex()); 370 REPORTER_ASSERT(r, pathB.isConvex());
372 } 371 }
373 REPORTER_ASSERT(r, a.bounds() == b.bounds()); 372 REPORTER_ASSERT(r, a.bounds() == b.bounds());
374 REPORTER_ASSERT(r, a.segmentMask() == b.segmentMask()); 373 REPORTER_ASSERT(r, a.segmentMask() == b.segmentMask());
375 SkPoint pts[4]; 374 // Init these to suppress warnings.
376 REPORTER_ASSERT(r, a.asLine(pts) == b.asLine(pts + 2)); 375 SkPoint pts[4] {{0, 0,}, {0, 0}, {0, 0}, {0, 0}} ;
376 bool invertedLine[2] {true, true};
377 REPORTER_ASSERT(r, a.asLine(pts, &invertedLine[0]) == b.asLine(pts + 2, &inv ertedLine[1]));
377 // mayBeInverseFilledAfterStyling() is allowed to differ if one has a arbitr ary PE and the other 378 // mayBeInverseFilledAfterStyling() is allowed to differ if one has a arbitr ary PE and the other
378 // doesn't (since the PE can set any fill type on its output path). 379 // doesn't (since the PE can set any fill type on its output path).
379 // Moreover, dash style explicitly ignores inverseness. So if one is dashed but not the other 380 // Moreover, dash style explicitly ignores inverseness. So if one is dashed but not the other
380 // then they may disagree about inverseness. 381 // then they may disagree about inverseness.
381 if (a.style().hasNonDashPathEffect() == b.style().hasNonDashPathEffect() && 382 if (a.style().hasNonDashPathEffect() == b.style().hasNonDashPathEffect() &&
382 a.style().isDashed() == b.style().isDashed()) { 383 a.style().isDashed() == b.style().isDashed()) {
383 REPORTER_ASSERT(r, a.mayBeInverseFilledAfterStyling() == 384 REPORTER_ASSERT(r, a.mayBeInverseFilledAfterStyling() ==
384 b.mayBeInverseFilledAfterStyling()); 385 b.mayBeInverseFilledAfterStyling());
385 } 386 }
386 if (a.asLine(pts)) { 387 if (a.asLine(nullptr, nullptr)) {
387 REPORTER_ASSERT(r, pts[2] == pts[0] && pts[3] == pts[1]); 388 REPORTER_ASSERT(r, pts[2] == pts[0] && pts[3] == pts[1]);
389 REPORTER_ASSERT(r, ignoreInversenessDifference || invertedLine[0] == inv ertedLine[1]);
390 REPORTER_ASSERT(r, invertedLine[0] == a.inverseFilled());
391 REPORTER_ASSERT(r, invertedLine[1] == b.inverseFilled());
388 } 392 }
389 REPORTER_ASSERT(r, ignoreInversenessDifference || a.inverseFilled() == b.inv erseFilled()); 393 REPORTER_ASSERT(r, ignoreInversenessDifference || a.inverseFilled() == b.inv erseFilled());
390 } 394 }
391 395
392 void TestCase::compare(skiatest::Reporter* r, const TestCase& that, 396 void TestCase::compare(skiatest::Reporter* r, const TestCase& that,
393 ComparisonExpecation expectation) const { 397 ComparisonExpecation expectation) const {
394 SkPath a, b; 398 SkPath a, b;
395 switch (expectation) { 399 switch (expectation) {
396 case kAllDifferent_ComparisonExpecation: 400 case kAllDifferent_ComparisonExpecation:
397 REPORTER_ASSERT(r, fBaseKey != that.fBaseKey); 401 REPORTER_ASSERT(r, fBaseKey != that.fBaseKey);
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 REPORTER_ASSERT(r, !hairlineCase.style().pathEffect()); 1346 REPORTER_ASSERT(r, !hairlineCase.style().pathEffect());
1343 e.compare(r, f, TestCase::kAllSame_ComparisonExpecation) ; 1347 e.compare(r, f, TestCase::kAllSame_ComparisonExpecation) ;
1344 g.compare(r, h, TestCase::kAllSame_ComparisonExpecation) ; 1348 g.compare(r, h, TestCase::kAllSame_ComparisonExpecation) ;
1345 } 1349 }
1346 } 1350 }
1347 } 1351 }
1348 } 1352 }
1349 } 1353 }
1350 } 1354 }
1351 1355
1356 void test_lines(skiatest::Reporter* r) {
1357 static constexpr SkPoint kA { 1, 1};
1358 static constexpr SkPoint kB { 5, -9};
1359 static constexpr SkPoint kC {-3, 17};
1360
1361 SkPath lineAB;
1362 lineAB.moveTo(kA);
1363 lineAB.lineTo(kB);
1364
1365 SkPath lineBA;
1366 lineBA.moveTo(kB);
1367 lineBA.lineTo(kA);
1368
1369 SkPath lineAC;
1370 lineAC.moveTo(kB);
1371 lineAC.lineTo(kC);
1372
1373 SkPath invLineAB = lineAB;
1374 invLineAB.setFillType(SkPath::kInverseEvenOdd_FillType);
1375
1376 SkPaint fill;
1377 SkPaint stroke;
1378 stroke.setStyle(SkPaint::kStroke_Style);
1379 stroke.setStrokeWidth(2.f);
1380 SkPaint hairline;
1381 hairline.setStyle(SkPaint::kStroke_Style);
1382 hairline.setStrokeWidth(0.f);
1383 SkPaint dash = stroke;
1384 dash.setPathEffect(make_dash());
1385
1386 TestCase fillAB(lineAB, fill, r);
1387 TestCase fillEmpty(SkPath(), fill, r);
1388 fillAB.compare(r, fillEmpty, TestCase::kAllSame_ComparisonExpecation);
1389 REPORTER_ASSERT(r, !fillAB.baseShape().asLine(nullptr, nullptr));
1390
1391 TestCase strokeAB(lineAB, stroke, r);
1392 TestCase strokeBA(lineBA, stroke, r);
1393 TestCase strokeAC(lineAC, stroke, r);
1394
1395 TestCase hairlineAB(lineAB, hairline, r);
1396 TestCase hairlineBA(lineBA, hairline, r);
1397 TestCase hairlineAC(lineAC, hairline, r);
1398
1399 TestCase dashAB(lineAB, dash, r);
1400 TestCase dashBA(lineBA, dash, r);
1401 TestCase dashAC(lineAC, dash, r);
1402
1403 strokeAB.compare(r, fillAB, TestCase::kAllDifferent_ComparisonExpecation);
1404
1405 strokeAB.compare(r, strokeBA, TestCase::kAllSame_ComparisonExpecation);
1406 strokeAB.compare(r, strokeAC, TestCase::kAllDifferent_ComparisonExpecation);
1407
1408 hairlineAB.compare(r, hairlineBA, TestCase::kAllSame_ComparisonExpecation);
1409 hairlineAB.compare(r, hairlineAC, TestCase::kAllDifferent_ComparisonExpecati on);
1410
1411 dashAB.compare(r, dashBA, TestCase::kAllDifferent_ComparisonExpecation);
1412 dashAB.compare(r, dashAC, TestCase::kAllDifferent_ComparisonExpecation);
1413
1414 strokeAB.compare(r, hairlineAB, TestCase::kSameUpToStroke_ComparisonExpecati on);
1415
1416 // One of dashAB or dashBA should have the same line as strokeAB. It depends upon how
1417 // GrShape canonicalizes line endpoints (when it can, i.e. when not dashed).
1418 bool canonicalizeAsAB;
1419 SkPoint canonicalPts[2] {kA, kB};
1420 // Init these to suppress warnings.
1421 bool inverted = true;
1422 SkPoint pts[2] {{0, 0}, {0, 0}};
1423 REPORTER_ASSERT(r, strokeAB.baseShape().asLine(pts, &inverted) && !inverted) ;
1424 if (pts[0] == kA && pts[1] == kB) {
1425 canonicalizeAsAB = true;
1426 } else if (pts[1] == kA && pts[0] == kB) {
1427 canonicalizeAsAB = false;
1428 SkTSwap(canonicalPts[0], canonicalPts[1]);
1429 } else {
1430 ERRORF(r, "Should return pts (a,b) or (b, a)");
1431 return;
1432 };
1433
1434 strokeAB.compare(r, canonicalizeAsAB ? dashAB : dashBA,
1435 TestCase::kSameUpToPE_ComparisonExpecation);
1436 REPORTER_ASSERT(r, strokeAB.baseShape().asLine(pts, &inverted) && !inverted &&
1437 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1438 REPORTER_ASSERT(r, hairlineAB.baseShape().asLine(pts, &inverted) && !inverte d &&
1439 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1440 REPORTER_ASSERT(r, dashAB.baseShape().asLine(pts, &inverted) && !inverted &&
1441 pts[0] == kA && pts[1] == kB);
1442 REPORTER_ASSERT(r, dashBA.baseShape().asLine(pts, &inverted) && !inverted &&
1443 pts[0] == kB && pts[1] == kA);
1444
1445
1446 TestCase strokeInvAB(invLineAB, stroke, r);
1447 TestCase hairlineInvAB(invLineAB, hairline, r);
1448 TestCase dashInvAB(invLineAB, dash, r);
1449 strokeInvAB.compare(r, strokeAB, TestCase::kAllDifferent_ComparisonExpecatio n);
1450 hairlineInvAB.compare(r, hairlineAB, TestCase::kAllDifferent_ComparisonExpec ation);
1451 // Dashing ignores inverse.
1452 dashInvAB.compare(r, dashAB, TestCase::kAllSame_ComparisonExpecation);
1453
1454 REPORTER_ASSERT(r, strokeInvAB.baseShape().asLine(pts, &inverted) && inverte d &&
1455 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1456 REPORTER_ASSERT(r, hairlineInvAB.baseShape().asLine(pts, &inverted) && inver ted &&
1457 pts[0] == canonicalPts[0] && pts[1] == canonicalPts[1]);
1458 // Dashing ignores inverse.
1459 REPORTER_ASSERT(r, dashInvAB.baseShape().asLine(pts, &inverted) && !inverted &&
1460 pts[0] == kA && pts[1] == kB);
1461
1462 }
1463
1352 DEF_TEST(GrShape, reporter) { 1464 DEF_TEST(GrShape, reporter) {
1353 for (auto r : { SkRect::MakeWH(10, 20), 1465 for (auto r : { SkRect::MakeWH(10, 20),
1354 SkRect::MakeWH(-10, -20), 1466 SkRect::MakeWH(-10, -20),
1355 SkRect::MakeWH(-10, 20), 1467 SkRect::MakeWH(-10, 20),
1356 SkRect::MakeWH(10, -20)}) { 1468 SkRect::MakeWH(10, -20)}) {
1357 test_basic(reporter, r); 1469 test_basic(reporter, r);
1358 test_scale(reporter, r); 1470 test_scale(reporter, r);
1359 test_dash_fill(reporter, r); 1471 test_dash_fill(reporter, r);
1360 test_null_dash(reporter, r); 1472 test_null_dash(reporter, r);
1361 // Test modifying various stroke params. 1473 // Test modifying various stroke params.
1362 test_stroke_param<SkRect, SkScalar>( 1474 test_stroke_param<SkRect, SkScalar>(
1363 reporter, r, 1475 reporter, r,
1364 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);}, 1476 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);},
1365 SkIntToScalar(2), SkIntToScalar(4)); 1477 SkIntToScalar(2), SkIntToScalar(4));
1366 test_stroke_param<SkRect, SkPaint::Join>( 1478 test_stroke_param<SkRect, SkPaint::Join>(
1367 reporter, r, 1479 reporter, r,
1368 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);}, 1480 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);},
1369 SkPaint::kMiter_Join, SkPaint::kRound_Join); 1481 SkPaint::kMiter_Join, SkPaint::kRound_Join);
1370 test_stroke_cap(reporter, r); 1482 test_stroke_cap(reporter, r);
1371 test_miter_limit(reporter, r); 1483 test_miter_limit(reporter, r);
1372 test_path_effect_makes_rrect(reporter, r); 1484 test_path_effect_makes_rrect(reporter, r);
1373 test_unknown_path_effect(reporter, r); 1485 test_unknown_path_effect(reporter, r);
1374 test_path_effect_makes_empty_shape(reporter, r); 1486 test_path_effect_makes_empty_shape(reporter, r);
1375 test_path_effect_fails(reporter, r); 1487 test_path_effect_fails(reporter, r);
1376 test_make_hairline_path_effect(reporter, r, true); 1488 test_make_hairline_path_effect(reporter, r, true);
1377 GrShape shape(r); 1489 GrShape shape(r);
1378 REPORTER_ASSERT(reporter, !shape.asLine(nullptr)); 1490 REPORTER_ASSERT(reporter, !shape.asLine(nullptr, nullptr));
1379 } 1491 }
1380 1492
1381 for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)), 1493 for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)),
1382 SkRRect::MakeRectXY(SkRect::MakeWH(10, 10), 3, 4), 1494 SkRRect::MakeRectXY(SkRect::MakeWH(10, 10), 3, 4),
1383 SkRRect::MakeOval(SkRect::MakeWH(20, 20))}) { 1495 SkRRect::MakeOval(SkRect::MakeWH(20, 20))}) {
1384 test_basic(reporter, rr); 1496 test_basic(reporter, rr);
1385 test_rrect(reporter, rr); 1497 test_rrect(reporter, rr);
1386 test_scale(reporter, rr); 1498 test_scale(reporter, rr);
1387 test_dash_fill(reporter, rr); 1499 test_dash_fill(reporter, rr);
1388 test_null_dash(reporter, rr); 1500 test_null_dash(reporter, rr);
1389 // Test modifying various stroke params. 1501 // Test modifying various stroke params.
1390 test_stroke_param<SkRRect, SkScalar>( 1502 test_stroke_param<SkRRect, SkScalar>(
1391 reporter, rr, 1503 reporter, rr,
1392 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);}, 1504 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);},
1393 SkIntToScalar(2), SkIntToScalar(4)); 1505 SkIntToScalar(2), SkIntToScalar(4));
1394 test_stroke_param<SkRRect, SkPaint::Join>( 1506 test_stroke_param<SkRRect, SkPaint::Join>(
1395 reporter, rr, 1507 reporter, rr,
1396 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j); }, 1508 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j); },
1397 SkPaint::kMiter_Join, SkPaint::kRound_Join); 1509 SkPaint::kMiter_Join, SkPaint::kRound_Join);
1398 test_stroke_cap(reporter, rr); 1510 test_stroke_cap(reporter, rr);
1399 test_miter_limit(reporter, rr); 1511 test_miter_limit(reporter, rr);
1400 test_path_effect_makes_rrect(reporter, rr); 1512 test_path_effect_makes_rrect(reporter, rr);
1401 test_unknown_path_effect(reporter, rr); 1513 test_unknown_path_effect(reporter, rr);
1402 test_path_effect_makes_empty_shape(reporter, rr); 1514 test_path_effect_makes_empty_shape(reporter, rr);
1403 test_path_effect_fails(reporter, rr); 1515 test_path_effect_fails(reporter, rr);
1404 test_make_hairline_path_effect(reporter, rr, true); 1516 test_make_hairline_path_effect(reporter, rr, true);
1405 GrShape shape(rr); 1517 GrShape shape(rr);
1406 REPORTER_ASSERT(reporter, !shape.asLine(nullptr)); 1518 REPORTER_ASSERT(reporter, !shape.asLine(nullptr, nullptr));
1407 } 1519 }
1408 1520
1409 struct TestPath { 1521 struct TestPath {
1410 TestPath(const SkPath& path, bool isRRectFill, bool isRRectStroke, bool isLine, 1522 TestPath(const SkPath& path, bool isRRectFill, bool isRRectStroke, bool isLine,
1411 const SkRRect& rrect) 1523 const SkRRect& rrect)
1412 : fPath(path) 1524 : fPath(path)
1413 , fIsRRectForFill(isRRectFill) 1525 , fIsRRectForFill(isRRectFill)
1414 , fIsRRectForStroke(isRRectStroke) 1526 , fIsRRectForStroke(isRRectStroke)
1415 , fIsLine(isLine) 1527 , fIsLine(isLine)
1416 , fRRect(rrect) {} 1528 , fRRect(rrect) {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 testPath.fPath.setFillType(SkPath::kInverseEvenOdd_FillType) ; 1564 testPath.fPath.setFillType(SkPath::kInverseEvenOdd_FillType) ;
1453 } else { 1565 } else {
1454 SkASSERT(testPath.fPath.getFillType() == SkPath::kWinding_Fi llType); 1566 SkASSERT(testPath.fPath.getFillType() == SkPath::kWinding_Fi llType);
1455 testPath.fPath.setFillType(SkPath::kInverseWinding_FillType) ; 1567 testPath.fPath.setFillType(SkPath::kInverseWinding_FillType) ;
1456 } 1568 }
1457 } 1569 }
1458 const SkPath& path = testPath.fPath; 1570 const SkPath& path = testPath.fPath;
1459 // These tests all assume that the original GrShape for fill and str oke will be the 1571 // These tests all assume that the original GrShape for fill and str oke will be the
1460 // same. 1572 // same.
1461 // However, that is not the case in special cases (e.g. an unclosed rect becomes a RRect 1573 // However, that is not the case in special cases (e.g. an unclosed rect becomes a RRect
1462 // GrShape with a fill style but becomes a Path GrShape when stroked ). 1574 // GrShape with a fill style but becomes a Path GrShape when stroked ). Similarly, a path
1463 if (testPath.fIsRRectForFill == testPath.fIsRRectForStroke) { 1575 // that is a line becomes empty when filled but is special-cased as a line when stroked.
1576 if (testPath.fIsRRectForFill == testPath.fIsRRectForStroke && !testP ath.fIsLine) {
1464 test_basic(reporter, path); 1577 test_basic(reporter, path);
1465 test_null_dash(reporter, path); 1578 test_null_dash(reporter, path);
1466 test_path_effect_makes_rrect(reporter, path); 1579 test_path_effect_makes_rrect(reporter, path);
1467 } 1580 }
1468 test_scale(reporter, path); 1581 test_scale(reporter, path);
1469 // This test uses a stroking paint, hence use of fIsRRectForStroke 1582 // This test uses a stroking paint, hence use of fIsRRectForStroke
1470 test_volatile_path(reporter, path, testPath.fIsRRectForStroke); 1583 test_volatile_path(reporter, path, testPath.fIsRRectForStroke || tes tPath.fIsLine);
1471 test_dash_fill(reporter, path); 1584 test_dash_fill(reporter, path);
1472 // Test modifying various stroke params. 1585 // Test modifying various stroke params.
1473 test_stroke_param<SkPath, SkScalar>( 1586 test_stroke_param<SkPath, SkScalar>(
1474 reporter, path, 1587 reporter, path,
1475 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);}, 1588 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);},
1476 SkIntToScalar(2), SkIntToScalar(4)); 1589 SkIntToScalar(2), SkIntToScalar(4));
1477 test_stroke_param<SkPath, SkPaint::Join>( 1590 test_stroke_param<SkPath, SkPaint::Join>(
1478 reporter, path, 1591 reporter, path,
1479 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);}, 1592 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);},
1480 SkPaint::kMiter_Join, SkPaint::kRound_Join); 1593 SkPaint::kMiter_Join, SkPaint::kRound_Join);
1481 test_stroke_cap(reporter, path); 1594 test_stroke_cap(reporter, path);
1482 test_miter_limit(reporter, path); 1595 test_miter_limit(reporter, path);
1483 test_unknown_path_effect(reporter, path); 1596 test_unknown_path_effect(reporter, path);
1484 test_path_effect_makes_empty_shape(reporter, path); 1597 test_path_effect_makes_empty_shape(reporter, path);
1485 test_path_effect_fails(reporter, path); 1598 test_path_effect_fails(reporter, path);
1486 test_make_hairline_path_effect(reporter, path, testPath.fIsRRectForS troke); 1599 test_make_hairline_path_effect(reporter, path, testPath.fIsRRectForS troke ||
1600 testPath.fIsLine);
1487 } 1601 }
1488 } 1602 }
1489 1603
1490 for (auto testPath : paths) { 1604 for (auto testPath : paths) {
1491 const SkPath& path = testPath.fPath; 1605 const SkPath& path = testPath.fPath;
1492 1606
1493 SkPaint fillPaint; 1607 SkPaint fillPaint;
1494 TestCase fillPathCase(path, fillPaint, reporter); 1608 TestCase fillPathCase(path, fillPaint, reporter);
1495 SkRRect rrect; 1609 SkRRect rrect;
1496 REPORTER_ASSERT(reporter, testPath.fIsRRectForFill == 1610 REPORTER_ASSERT(reporter, testPath.fIsRRectForFill ==
(...skipping 12 matching lines...) Expand all
1509 TestCase strokePathCase(path, strokePaint, reporter); 1623 TestCase strokePathCase(path, strokePaint, reporter);
1510 REPORTER_ASSERT(reporter, testPath.fIsRRectForStroke == 1624 REPORTER_ASSERT(reporter, testPath.fIsRRectForStroke ==
1511 strokePathCase.baseShape().asRRect(&rrect, nul lptr, nullptr, 1625 strokePathCase.baseShape().asRRect(&rrect, nul lptr, nullptr,
1512 nullptr)); 1626 nullptr));
1513 if (testPath.fIsRRectForStroke) { 1627 if (testPath.fIsRRectForStroke) {
1514 REPORTER_ASSERT(reporter, rrect == testPath.fRRect); 1628 REPORTER_ASSERT(reporter, rrect == testPath.fRRect);
1515 TestCase strokeRRectCase(rrect, strokePaint, reporter); 1629 TestCase strokeRRectCase(rrect, strokePaint, reporter);
1516 strokePathCase.compare(reporter, strokeRRectCase, 1630 strokePathCase.compare(reporter, strokeRRectCase,
1517 TestCase::kAllSame_ComparisonExpecation); 1631 TestCase::kAllSame_ComparisonExpecation);
1518 } 1632 }
1519 REPORTER_ASSERT(reporter, testPath.fIsLine == fillPathCase.baseShape().a sLine(nullptr));
1520 REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape() .asLine(nullptr));
1521 } 1633 }
1522 1634
1523 // Test a volatile empty path. 1635 // Test a volatile empty path.
1524 test_volatile_path(reporter, SkPath(), true); 1636 test_volatile_path(reporter, SkPath(), true);
1525 1637
1526 test_empty_shape(reporter); 1638 test_empty_shape(reporter);
1639
1640 test_lines(reporter);
1527 } 1641 }
1528 1642
1529 #endif 1643 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDashLinePathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698