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

Side by Side Diff: tests/GrShapeTest.cpp

Issue 2109613003: Revert of Make lines a special case in GrShape (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 = fBase.styledBounds(); 180 SkRect styledBounds;
181 fBase.styledBounds(&styledBounds);
181 CheckBounds(r, fAppliedFull, styledBounds); 182 CheckBounds(r, fAppliedFull, styledBounds);
182 styledBounds = fAppliedPE.styledBounds(); 183 fAppliedPE.styledBounds(&styledBounds);
183 CheckBounds(r, fAppliedFull, styledBounds); 184 CheckBounds(r, fAppliedFull, styledBounds);
184 185
185 // Check that the same path is produced when style is applied by GrShape and GrStyle. 186 // Check that the same path is produced when style is applied by GrShape and GrStyle.
186 SkPath preStyle; 187 SkPath preStyle;
187 SkPath postPathEffect; 188 SkPath postPathEffect;
188 SkPath postAllStyle; 189 SkPath postAllStyle;
189 190
190 fBase.asPath(&preStyle); 191 fBase.asPath(&preStyle);
191 SkStrokeRec postPEStrokeRec(SkStrokeRec::kFill_InitStyle); 192 SkStrokeRec postPEStrokeRec(SkStrokeRec::kFill_InitStyle);
192 if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPEStrokeRe c, preStyle, 193 if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPEStrokeRe c, preStyle,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // closedness can affect convexity. 365 // closedness can affect convexity.
365 REPORTER_ASSERT(r, allowedClosednessDiff || a.knownToBeConvex() == b.knownTo BeConvex()); 366 REPORTER_ASSERT(r, allowedClosednessDiff || a.knownToBeConvex() == b.knownTo BeConvex());
366 if (a.knownToBeConvex()) { 367 if (a.knownToBeConvex()) {
367 REPORTER_ASSERT(r, pathA.isConvex()); 368 REPORTER_ASSERT(r, pathA.isConvex());
368 } 369 }
369 if (b.knownToBeConvex()) { 370 if (b.knownToBeConvex()) {
370 REPORTER_ASSERT(r, pathB.isConvex()); 371 REPORTER_ASSERT(r, pathB.isConvex());
371 } 372 }
372 REPORTER_ASSERT(r, a.bounds() == b.bounds()); 373 REPORTER_ASSERT(r, a.bounds() == b.bounds());
373 REPORTER_ASSERT(r, a.segmentMask() == b.segmentMask()); 374 REPORTER_ASSERT(r, a.segmentMask() == b.segmentMask());
374 // Init these to suppress warnings. 375 SkPoint pts[4];
375 SkPoint pts[4] {{0, 0,}, {0, 0}, {0, 0}, {0, 0}} ; 376 REPORTER_ASSERT(r, a.asLine(pts) == b.asLine(pts + 2));
376 bool invertedLine[2] {true, true};
377 REPORTER_ASSERT(r, a.asLine(pts, &invertedLine[0]) == b.asLine(pts + 2, &inv ertedLine[1]));
378 // mayBeInverseFilledAfterStyling() is allowed to differ if one has a arbitr ary PE and the other 377 // mayBeInverseFilledAfterStyling() is allowed to differ if one has a arbitr ary PE and the other
379 // doesn't (since the PE can set any fill type on its output path). 378 // doesn't (since the PE can set any fill type on its output path).
380 // Moreover, dash style explicitly ignores inverseness. So if one is dashed but not the other 379 // Moreover, dash style explicitly ignores inverseness. So if one is dashed but not the other
381 // then they may disagree about inverseness. 380 // then they may disagree about inverseness.
382 if (a.style().hasNonDashPathEffect() == b.style().hasNonDashPathEffect() && 381 if (a.style().hasNonDashPathEffect() == b.style().hasNonDashPathEffect() &&
383 a.style().isDashed() == b.style().isDashed()) { 382 a.style().isDashed() == b.style().isDashed()) {
384 REPORTER_ASSERT(r, a.mayBeInverseFilledAfterStyling() == 383 REPORTER_ASSERT(r, a.mayBeInverseFilledAfterStyling() ==
385 b.mayBeInverseFilledAfterStyling()); 384 b.mayBeInverseFilledAfterStyling());
386 } 385 }
387 if (a.asLine(nullptr, nullptr)) { 386 if (a.asLine(pts)) {
388 REPORTER_ASSERT(r, pts[2] == pts[0] && pts[3] == pts[1]); 387 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());
392 } 388 }
393 REPORTER_ASSERT(r, ignoreInversenessDifference || a.inverseFilled() == b.inv erseFilled()); 389 REPORTER_ASSERT(r, ignoreInversenessDifference || a.inverseFilled() == b.inv erseFilled());
394 } 390 }
395 391
396 void TestCase::compare(skiatest::Reporter* r, const TestCase& that, 392 void TestCase::compare(skiatest::Reporter* r, const TestCase& that,
397 ComparisonExpecation expectation) const { 393 ComparisonExpecation expectation) const {
398 SkPath a, b; 394 SkPath a, b;
399 switch (expectation) { 395 switch (expectation) {
400 case kAllDifferent_ComparisonExpecation: 396 case kAllDifferent_ComparisonExpecation:
401 REPORTER_ASSERT(r, fBaseKey != that.fBaseKey); 397 REPORTER_ASSERT(r, fBaseKey != that.fBaseKey);
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 REPORTER_ASSERT(r, !hairlineCase.style().pathEffect()); 1342 REPORTER_ASSERT(r, !hairlineCase.style().pathEffect());
1347 e.compare(r, f, TestCase::kAllSame_ComparisonExpecation) ; 1343 e.compare(r, f, TestCase::kAllSame_ComparisonExpecation) ;
1348 g.compare(r, h, TestCase::kAllSame_ComparisonExpecation) ; 1344 g.compare(r, h, TestCase::kAllSame_ComparisonExpecation) ;
1349 } 1345 }
1350 } 1346 }
1351 } 1347 }
1352 } 1348 }
1353 } 1349 }
1354 } 1350 }
1355 1351
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
1464 DEF_TEST(GrShape, reporter) { 1352 DEF_TEST(GrShape, reporter) {
1465 for (auto r : { SkRect::MakeWH(10, 20), 1353 for (auto r : { SkRect::MakeWH(10, 20),
1466 SkRect::MakeWH(-10, -20), 1354 SkRect::MakeWH(-10, -20),
1467 SkRect::MakeWH(-10, 20), 1355 SkRect::MakeWH(-10, 20),
1468 SkRect::MakeWH(10, -20)}) { 1356 SkRect::MakeWH(10, -20)}) {
1469 test_basic(reporter, r); 1357 test_basic(reporter, r);
1470 test_scale(reporter, r); 1358 test_scale(reporter, r);
1471 test_dash_fill(reporter, r); 1359 test_dash_fill(reporter, r);
1472 test_null_dash(reporter, r); 1360 test_null_dash(reporter, r);
1473 // Test modifying various stroke params. 1361 // Test modifying various stroke params.
1474 test_stroke_param<SkRect, SkScalar>( 1362 test_stroke_param<SkRect, SkScalar>(
1475 reporter, r, 1363 reporter, r,
1476 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);}, 1364 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);},
1477 SkIntToScalar(2), SkIntToScalar(4)); 1365 SkIntToScalar(2), SkIntToScalar(4));
1478 test_stroke_param<SkRect, SkPaint::Join>( 1366 test_stroke_param<SkRect, SkPaint::Join>(
1479 reporter, r, 1367 reporter, r,
1480 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);}, 1368 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);},
1481 SkPaint::kMiter_Join, SkPaint::kRound_Join); 1369 SkPaint::kMiter_Join, SkPaint::kRound_Join);
1482 test_stroke_cap(reporter, r); 1370 test_stroke_cap(reporter, r);
1483 test_miter_limit(reporter, r); 1371 test_miter_limit(reporter, r);
1484 test_path_effect_makes_rrect(reporter, r); 1372 test_path_effect_makes_rrect(reporter, r);
1485 test_unknown_path_effect(reporter, r); 1373 test_unknown_path_effect(reporter, r);
1486 test_path_effect_makes_empty_shape(reporter, r); 1374 test_path_effect_makes_empty_shape(reporter, r);
1487 test_path_effect_fails(reporter, r); 1375 test_path_effect_fails(reporter, r);
1488 test_make_hairline_path_effect(reporter, r, true); 1376 test_make_hairline_path_effect(reporter, r, true);
1489 GrShape shape(r); 1377 GrShape shape(r);
1490 REPORTER_ASSERT(reporter, !shape.asLine(nullptr, nullptr)); 1378 REPORTER_ASSERT(reporter, !shape.asLine(nullptr));
1491 } 1379 }
1492 1380
1493 for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)), 1381 for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)),
1494 SkRRect::MakeRectXY(SkRect::MakeWH(10, 10), 3, 4), 1382 SkRRect::MakeRectXY(SkRect::MakeWH(10, 10), 3, 4),
1495 SkRRect::MakeOval(SkRect::MakeWH(20, 20))}) { 1383 SkRRect::MakeOval(SkRect::MakeWH(20, 20))}) {
1496 test_basic(reporter, rr); 1384 test_basic(reporter, rr);
1497 test_rrect(reporter, rr); 1385 test_rrect(reporter, rr);
1498 test_scale(reporter, rr); 1386 test_scale(reporter, rr);
1499 test_dash_fill(reporter, rr); 1387 test_dash_fill(reporter, rr);
1500 test_null_dash(reporter, rr); 1388 test_null_dash(reporter, rr);
1501 // Test modifying various stroke params. 1389 // Test modifying various stroke params.
1502 test_stroke_param<SkRRect, SkScalar>( 1390 test_stroke_param<SkRRect, SkScalar>(
1503 reporter, rr, 1391 reporter, rr,
1504 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);}, 1392 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);},
1505 SkIntToScalar(2), SkIntToScalar(4)); 1393 SkIntToScalar(2), SkIntToScalar(4));
1506 test_stroke_param<SkRRect, SkPaint::Join>( 1394 test_stroke_param<SkRRect, SkPaint::Join>(
1507 reporter, rr, 1395 reporter, rr,
1508 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j); }, 1396 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j); },
1509 SkPaint::kMiter_Join, SkPaint::kRound_Join); 1397 SkPaint::kMiter_Join, SkPaint::kRound_Join);
1510 test_stroke_cap(reporter, rr); 1398 test_stroke_cap(reporter, rr);
1511 test_miter_limit(reporter, rr); 1399 test_miter_limit(reporter, rr);
1512 test_path_effect_makes_rrect(reporter, rr); 1400 test_path_effect_makes_rrect(reporter, rr);
1513 test_unknown_path_effect(reporter, rr); 1401 test_unknown_path_effect(reporter, rr);
1514 test_path_effect_makes_empty_shape(reporter, rr); 1402 test_path_effect_makes_empty_shape(reporter, rr);
1515 test_path_effect_fails(reporter, rr); 1403 test_path_effect_fails(reporter, rr);
1516 test_make_hairline_path_effect(reporter, rr, true); 1404 test_make_hairline_path_effect(reporter, rr, true);
1517 GrShape shape(rr); 1405 GrShape shape(rr);
1518 REPORTER_ASSERT(reporter, !shape.asLine(nullptr, nullptr)); 1406 REPORTER_ASSERT(reporter, !shape.asLine(nullptr));
1519 } 1407 }
1520 1408
1521 struct TestPath { 1409 struct TestPath {
1522 TestPath(const SkPath& path, bool isRRectFill, bool isRRectStroke, bool isLine, 1410 TestPath(const SkPath& path, bool isRRectFill, bool isRRectStroke, bool isLine,
1523 const SkRRect& rrect) 1411 const SkRRect& rrect)
1524 : fPath(path) 1412 : fPath(path)
1525 , fIsRRectForFill(isRRectFill) 1413 , fIsRRectForFill(isRRectFill)
1526 , fIsRRectForStroke(isRRectStroke) 1414 , fIsRRectForStroke(isRRectStroke)
1527 , fIsLine(isLine) 1415 , fIsLine(isLine)
1528 , fRRect(rrect) {} 1416 , fRRect(rrect) {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 testPath.fPath.setFillType(SkPath::kInverseEvenOdd_FillType) ; 1452 testPath.fPath.setFillType(SkPath::kInverseEvenOdd_FillType) ;
1565 } else { 1453 } else {
1566 SkASSERT(testPath.fPath.getFillType() == SkPath::kWinding_Fi llType); 1454 SkASSERT(testPath.fPath.getFillType() == SkPath::kWinding_Fi llType);
1567 testPath.fPath.setFillType(SkPath::kInverseWinding_FillType) ; 1455 testPath.fPath.setFillType(SkPath::kInverseWinding_FillType) ;
1568 } 1456 }
1569 } 1457 }
1570 const SkPath& path = testPath.fPath; 1458 const SkPath& path = testPath.fPath;
1571 // These tests all assume that the original GrShape for fill and str oke will be the 1459 // These tests all assume that the original GrShape for fill and str oke will be the
1572 // same. 1460 // same.
1573 // However, that is not the case in special cases (e.g. an unclosed rect becomes a RRect 1461 // However, that is not the case in special cases (e.g. an unclosed rect becomes a RRect
1574 // GrShape with a fill style but becomes a Path GrShape when stroked ). Similarly, a path 1462 // GrShape with a fill style but becomes a Path GrShape when stroked ).
1575 // that is a line becomes empty when filled but is special-cased as a line when stroked. 1463 if (testPath.fIsRRectForFill == testPath.fIsRRectForStroke) {
1576 if (testPath.fIsRRectForFill == testPath.fIsRRectForStroke && !testP ath.fIsLine) {
1577 test_basic(reporter, path); 1464 test_basic(reporter, path);
1578 test_null_dash(reporter, path); 1465 test_null_dash(reporter, path);
1579 test_path_effect_makes_rrect(reporter, path); 1466 test_path_effect_makes_rrect(reporter, path);
1580 } 1467 }
1581 test_scale(reporter, path); 1468 test_scale(reporter, path);
1582 // This test uses a stroking paint, hence use of fIsRRectForStroke 1469 // This test uses a stroking paint, hence use of fIsRRectForStroke
1583 test_volatile_path(reporter, path, testPath.fIsRRectForStroke || tes tPath.fIsLine); 1470 test_volatile_path(reporter, path, testPath.fIsRRectForStroke);
1584 test_dash_fill(reporter, path); 1471 test_dash_fill(reporter, path);
1585 // Test modifying various stroke params. 1472 // Test modifying various stroke params.
1586 test_stroke_param<SkPath, SkScalar>( 1473 test_stroke_param<SkPath, SkScalar>(
1587 reporter, path, 1474 reporter, path,
1588 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);}, 1475 [](SkPaint* p, SkScalar w) { p->setStrokeWidth(w);},
1589 SkIntToScalar(2), SkIntToScalar(4)); 1476 SkIntToScalar(2), SkIntToScalar(4));
1590 test_stroke_param<SkPath, SkPaint::Join>( 1477 test_stroke_param<SkPath, SkPaint::Join>(
1591 reporter, path, 1478 reporter, path,
1592 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);}, 1479 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);},
1593 SkPaint::kMiter_Join, SkPaint::kRound_Join); 1480 SkPaint::kMiter_Join, SkPaint::kRound_Join);
1594 test_stroke_cap(reporter, path); 1481 test_stroke_cap(reporter, path);
1595 test_miter_limit(reporter, path); 1482 test_miter_limit(reporter, path);
1596 test_unknown_path_effect(reporter, path); 1483 test_unknown_path_effect(reporter, path);
1597 test_path_effect_makes_empty_shape(reporter, path); 1484 test_path_effect_makes_empty_shape(reporter, path);
1598 test_path_effect_fails(reporter, path); 1485 test_path_effect_fails(reporter, path);
1599 test_make_hairline_path_effect(reporter, path, testPath.fIsRRectForS troke || 1486 test_make_hairline_path_effect(reporter, path, testPath.fIsRRectForS troke);
1600 testPath.fIsLine);
1601 } 1487 }
1602 } 1488 }
1603 1489
1604 for (auto testPath : paths) { 1490 for (auto testPath : paths) {
1605 const SkPath& path = testPath.fPath; 1491 const SkPath& path = testPath.fPath;
1606 1492
1607 SkPaint fillPaint; 1493 SkPaint fillPaint;
1608 TestCase fillPathCase(path, fillPaint, reporter); 1494 TestCase fillPathCase(path, fillPaint, reporter);
1609 SkRRect rrect; 1495 SkRRect rrect;
1610 REPORTER_ASSERT(reporter, testPath.fIsRRectForFill == 1496 REPORTER_ASSERT(reporter, testPath.fIsRRectForFill ==
(...skipping 12 matching lines...) Expand all
1623 TestCase strokePathCase(path, strokePaint, reporter); 1509 TestCase strokePathCase(path, strokePaint, reporter);
1624 REPORTER_ASSERT(reporter, testPath.fIsRRectForStroke == 1510 REPORTER_ASSERT(reporter, testPath.fIsRRectForStroke ==
1625 strokePathCase.baseShape().asRRect(&rrect, nul lptr, nullptr, 1511 strokePathCase.baseShape().asRRect(&rrect, nul lptr, nullptr,
1626 nullptr)); 1512 nullptr));
1627 if (testPath.fIsRRectForStroke) { 1513 if (testPath.fIsRRectForStroke) {
1628 REPORTER_ASSERT(reporter, rrect == testPath.fRRect); 1514 REPORTER_ASSERT(reporter, rrect == testPath.fRRect);
1629 TestCase strokeRRectCase(rrect, strokePaint, reporter); 1515 TestCase strokeRRectCase(rrect, strokePaint, reporter);
1630 strokePathCase.compare(reporter, strokeRRectCase, 1516 strokePathCase.compare(reporter, strokeRRectCase,
1631 TestCase::kAllSame_ComparisonExpecation); 1517 TestCase::kAllSame_ComparisonExpecation);
1632 } 1518 }
1519 REPORTER_ASSERT(reporter, testPath.fIsLine == fillPathCase.baseShape().a sLine(nullptr));
1520 REPORTER_ASSERT(reporter, testPath.fIsLine == strokePathCase.baseShape() .asLine(nullptr));
1633 } 1521 }
1634 1522
1635 // Test a volatile empty path. 1523 // Test a volatile empty path.
1636 test_volatile_path(reporter, SkPath(), true); 1524 test_volatile_path(reporter, SkPath(), true);
1637 1525
1638 test_empty_shape(reporter); 1526 test_empty_shape(reporter);
1639
1640 test_lines(reporter);
1641 } 1527 }
1642 1528
1643 #endif 1529 #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