diff options
author | 2016-06-23 11:48:26 -0700 | |
---|---|---|
committer | 2016-06-23 11:48:26 -0700 | |
commit | a4817afe5095b67a68c907ff2e48e3e07907140c (patch) | |
tree | c5f5540ad63b6ee99b7a8e79bad2a9d676ead766 /src | |
parent | 42a41499de94ff9201ca3c56554d7b92ce32b247 (diff) |
Canonicalize path fill types for stroked paths in GrShape.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2085913003
Review-Url: https://codereview.chromium.org/2085913003
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrShape.cpp | 40 | ||||
-rw-r--r-- | src/gpu/GrShape.h | 9 |
2 files changed, 26 insertions, 23 deletions
diff --git a/src/gpu/GrShape.cpp b/src/gpu/GrShape.cpp index 0fb339555e..93ecd6187a 100644 --- a/src/gpu/GrShape.cpp +++ b/src/gpu/GrShape.cpp @@ -332,27 +332,25 @@ void GrShape::attemptToSimplifyPath() { fPath.get()->setIsVolatile(true); } } - if (fPath.get()->isConvex()) { - // There is no distinction between even/odd and non-zero winding count for convex - // paths. - if (fPath.get()->isInverseFillType()) { - fPath.get()->setFillType(SkPath::kInverseEvenOdd_FillType); - } else { - fPath.get()->setFillType(SkPath::kEvenOdd_FillType); - } - } - if (this->style().isDashed()) { - // Dashing ignores inverseness (skbug.com/5421) - switch (fPath.get()->getFillType()) { - case SkPath::kWinding_FillType: - case SkPath::kEvenOdd_FillType: - break; - case SkPath::kInverseWinding_FillType: - fPath.get()->setFillType(SkPath::kWinding_FillType); - break; - case SkPath::kInverseEvenOdd_FillType: - fPath.get()->setFillType(SkPath::kEvenOdd_FillType); - break; + if (!this->style().hasNonDashPathEffect()) { + if (this->style().strokeRec().getStyle() == SkStrokeRec::kStroke_Style || + this->style().strokeRec().getStyle() == SkStrokeRec::kHairline_Style) { + // Stroke styles don't differentiate between winding and even/odd. + // Moreover, dashing ignores inverseness (skbug.com/5421) + bool inverse = !this->fStyle.isDashed() && fPath.get()->isInverseFillType(); + if (inverse) { + fPath.get()->setFillType(kDefaultPathInverseFillType); + } else { + fPath.get()->setFillType(kDefaultPathFillType); + } + } else if (fPath.get()->isConvex()) { + // There is no distinction between even/odd and non-zero winding count for convex + // paths. + if (fPath.get()->isInverseFillType()) { + fPath.get()->setFillType(kDefaultPathInverseFillType); + } else { + fPath.get()->setFillType(kDefaultPathFillType); + } } } } diff --git a/src/gpu/GrShape.h b/src/gpu/GrShape.h index 1ed69ba6e8..6b4e46fb82 100644 --- a/src/gpu/GrShape.h +++ b/src/gpu/GrShape.h @@ -190,9 +190,9 @@ public: out->addRRect(fRRect, fRRectDir, fRRectStart); // Below matches the fill type that attemptToSimplifyPath uses. if (fRRectIsInverted) { - out->setFillType(SkPath::kInverseEvenOdd_FillType); + out->setFillType(kDefaultPathInverseFillType); } else { - out->setFillType(SkPath::kEvenOdd_FillType); + out->setFillType(kDefaultPathFillType); } break; case Type::kPath: @@ -284,6 +284,11 @@ private: void attemptToSimplifyPath(); void attemptToSimplifyRRect(); + // Defaults to use when there is no distinction between even/odd and winding fills. + static constexpr SkPath::FillType kDefaultPathFillType = SkPath::kEvenOdd_FillType; + static constexpr SkPath::FillType kDefaultPathInverseFillType = + SkPath::kInverseEvenOdd_FillType; + static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction; static constexpr unsigned kDefaultRRectStart = 0; |