diff options
author | Brian Salomon <bsalomon@google.com> | 2018-04-26 15:22:04 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-26 19:50:23 +0000 |
commit | e4949406ebcc5d5d8f83c1cd96209763d278b1e2 (patch) | |
tree | 758eb7f1bc477b258435ac248d0392c41aa18506 /src/gpu/GrShape.h | |
parent | 8f379d4d642d83fcf712d819ced716a9df01e234 (diff) |
Revert "Reland "Revert "Add arcs as a specialized geometry to GrShape."""
This reverts commit 580aee2fa4a57bf8208498fbc23acea04e16e092.
Bug: skia:7794
Change-Id: I9c2b923859c826dff58c22c529dc4e2ab4d0f186
Reviewed-on: https://skia-review.googlesource.com/124042
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrShape.h')
-rw-r--r-- | src/gpu/GrShape.h | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/src/gpu/GrShape.h b/src/gpu/GrShape.h index 99579ba4c3..36402330ce 100644 --- a/src/gpu/GrShape.h +++ b/src/gpu/GrShape.h @@ -116,6 +116,9 @@ public: this->attemptToSimplifyRRect(); } + static GrShape MakeArc(const SkRect& oval, SkScalar startAngleDegrees, + SkScalar sweepAngleDegrees, bool useCenter, const GrStyle& style); + GrShape(const GrShape&); GrShape& operator=(const GrShape& that); @@ -209,6 +212,16 @@ public: out->setFillType(kDefaultPathFillType); } break; + case Type::kArc: + SkPathPriv::CreateDrawArcPath(out, fArcData.fOval, fArcData.fStartAngleDegrees, + fArcData.fSweepAngleDegrees, fArcData.fUseCenter, + fStyle.isSimpleFill()); + if (fArcData.fInverted) { + out->setFillType(kDefaultPathInverseFillType); + } else { + out->setFillType(kDefaultPathFillType); + } + break; case Type::kLine: out->reset(); out->moveTo(fLineData.fPts[0]); @@ -256,6 +269,10 @@ public: return true; case Type::kRRect: return true; + case Type::kArc: + return SkPathPriv::DrawArcIsConvex(fArcData.fSweepAngleDegrees, + SkToBool(fArcData.fUseCenter), + fStyle.isSimpleFill()); case Type::kLine: return true; case Type::kPath: @@ -282,6 +299,9 @@ public: case Type::kRRect: ret = fRRectData.fInverted; break; + case Type::kArc: + ret = fArcData.fInverted; + break; case Type::kLine: ret = fLineData.fInverted; break; @@ -320,6 +340,8 @@ public: return true; case Type::kRRect: return true; + case Type::kArc: + return fArcData.fUseCenter; case Type::kLine: return false; case Type::kPath: @@ -343,6 +365,11 @@ public: return SkPath::kLine_SegmentMask; } return SkPath::kLine_SegmentMask | SkPath::kConic_SegmentMask; + case Type::kArc: + if (fArcData.fUseCenter) { + return SkPath::kConic_SegmentMask | SkPath::kLine_SegmentMask; + } + return SkPath::kConic_SegmentMask; case Type::kLine: return SkPath::kLine_SegmentMask; case Type::kPath: @@ -387,6 +414,7 @@ private: kEmpty, kInvertedEmpty, kRRect, + kArc, kLine, kPath, }; @@ -438,6 +466,7 @@ private: void attemptToSimplifyPath(); void attemptToSimplifyRRect(); void attemptToSimplifyLine(); + void attemptToSimplifyArc(); bool attemptToSimplifyStrokedLineToRRect(); @@ -494,26 +523,33 @@ private: return kPathRRectStartIdx; } - Type fType; union { struct { - SkRRect fRRect; - SkPath::Direction fDir; - unsigned fStart; - bool fInverted; + SkRRect fRRect; + SkPath::Direction fDir; + unsigned fStart; + bool fInverted; } fRRectData; struct { - SkPath fPath; + SkRect fOval; + SkScalar fStartAngleDegrees; + SkScalar fSweepAngleDegrees; + int16_t fUseCenter; + int16_t fInverted; + } fArcData; + struct { + SkPath fPath; // Gen ID of the original path (fPath may be modified) - int32_t fGenID; + int32_t fGenID; } fPathData; struct { - SkPoint fPts[2]; - bool fInverted; + SkPoint fPts[2]; + bool fInverted; } fLineData; }; - GrStyle fStyle; - SkTLazy<SkPath> fInheritedPathForListeners; + GrStyle fStyle; + SkTLazy<SkPath> fInheritedPathForListeners; SkAutoSTArray<8, uint32_t> fInheritedKey; + Type fType; }; #endif |