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

Unified Diff: src/gpu/GrStrokeInfo.h

Issue 1128113008: Make GrStrokeInfo inherit from SkStrokeRec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address review comments Created 5 years, 7 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/gpu/GrStencilAndCoverPathRenderer.cpp ('k') | src/gpu/GrStrokeInfo.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrStrokeInfo.h
diff --git a/src/gpu/GrStrokeInfo.h b/src/gpu/GrStrokeInfo.h
index e1349a7eece9d941afdc8dfdd801154d759ccc62..5ba3cfe91dbb8fe8672ff61329ce4619d0bbccce 100644
--- a/src/gpu/GrStrokeInfo.h
+++ b/src/gpu/GrStrokeInfo.h
@@ -16,12 +16,15 @@
* which holds information on fill style, width, miter, cap, and join. It also holds information
* about the dash like intervals, count, and phase.
*/
-class GrStrokeInfo {
-public:
- GrStrokeInfo(SkStrokeRec::InitStyle style) :
- fStroke(style), fDashType(SkPathEffect::kNone_DashType) {}
+class GrStrokeInfo : public SkStrokeRec {
+public:
+ GrStrokeInfo(SkStrokeRec::InitStyle style)
+ : INHERITED(style)
+ , fDashType(SkPathEffect::kNone_DashType) {
+ }
- GrStrokeInfo(const GrStrokeInfo& src, bool includeDash = true) : fStroke(src.fStroke) {
+ GrStrokeInfo(const GrStrokeInfo& src, bool includeDash = true)
+ : INHERITED(src) {
if (includeDash && src.isDashed()) {
fDashType = src.fDashType;
fDashPhase = src.fDashPhase;
@@ -32,13 +35,15 @@ public:
}
}
- GrStrokeInfo(const SkPaint& paint, SkPaint::Style styleOverride) :
- fStroke(paint, styleOverride), fDashType(SkPathEffect::kNone_DashType) {
+ GrStrokeInfo(const SkPaint& paint, SkPaint::Style styleOverride)
+ : INHERITED(paint, styleOverride)
+ , fDashType(SkPathEffect::kNone_DashType) {
this->init(paint);
}
- explicit GrStrokeInfo(const SkPaint& paint) :
- fStroke(paint), fDashType(SkPathEffect::kNone_DashType) {
+ explicit GrStrokeInfo(const SkPaint& paint)
+ : INHERITED(paint)
+ , fDashType(SkPathEffect::kNone_DashType) {
this->init(paint);
}
@@ -51,23 +56,17 @@ public:
} else {
this->removeDash();
}
- fStroke = other.fStroke;
+ this->INHERITED::operator=(other);
return *this;
}
- const SkStrokeRec& getStrokeRec() const { return fStroke; }
-
- SkStrokeRec* getStrokeRecPtr() { return &fStroke; }
-
- void setFillStyle() { fStroke.setFillStyle(); }
-
/*
* This functions takes in a patheffect and updates the dashing information if the path effect
* is a Dash type. Returns true if the path effect is a dashed effect and we are stroking,
* otherwise it returns false.
*/
bool setDashInfo(const SkPathEffect* pe) {
- if (pe && !fStroke.isFillStyle()) {
+ if (pe && !this->isFillStyle()) {
SkPathEffect::DashInfo dashInfo;
fDashType = pe->asADash(&dashInfo);
if (SkPathEffect::kDash_DashType == fDashType) {
@@ -85,8 +84,7 @@ public:
* Like the above, but sets with an explicit SkPathEffect::DashInfo
*/
bool setDashInfo(const SkPathEffect::DashInfo& info) {
- if (!fStroke.isFillStyle()) {
- SkASSERT(!fStroke.isFillStyle());
+ if (!this->isFillStyle()) {
fDashType = SkPathEffect::kDash_DashType;
fDashPhase = info.fPhase;
fIntervals.reset(info.fCount);
@@ -99,11 +97,9 @@ public:
}
bool isDashed() const {
- return (!fStroke.isFillStyle() && SkPathEffect::kDash_DashType == fDashType);
+ return (!this->isFillStyle() && SkPathEffect::kDash_DashType == fDashType);
}
- bool isFillStyle() const { return fStroke.isFillStyle(); }
-
int32_t getDashCount() const {
SkASSERT(this->isDashed());
return fIntervals.count();
@@ -129,19 +125,21 @@ public:
* will be unmodified. The stroking in the SkStrokeRec might still
* be applicable.
*/
- bool applyDash(SkPath* dst, GrStrokeInfo* dstStrokeInfo, const SkPath& src) const;
+ bool applyDashToPath(SkPath* dst, GrStrokeInfo* dstStrokeInfo, const SkPath& src) const;
private:
+ // Prevent accidental usage, not implemented for GrStrokeInfos.
+ bool hasEqualEffect(const SkStrokeRec& other) const;
void init(const SkPaint& paint) {
const SkPathEffect* pe = paint.getPathEffect();
this->setDashInfo(pe);
}
- SkStrokeRec fStroke;
SkPathEffect::DashType fDashType;
SkScalar fDashPhase;
SkAutoSTArray<2, SkScalar> fIntervals;
+ typedef SkStrokeRec INHERITED;
};
#endif
« no previous file with comments | « src/gpu/GrStencilAndCoverPathRenderer.cpp ('k') | src/gpu/GrStrokeInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698