Index: src/gpu/GrStrokeInfo.h |
diff --git a/src/gpu/GrStrokeInfo.h b/src/gpu/GrStrokeInfo.h |
index dd942c52e96be8ba39fd2f1f3e14c20cd80bdd87..c2476ed172c8b4d87a915be26facf98a2505c15c 100644 |
--- a/src/gpu/GrStrokeInfo.h |
+++ b/src/gpu/GrStrokeInfo.h |
@@ -23,11 +23,11 @@ public: |
fStroke(style), fDashType(SkPathEffect::kNone_DashType) {} |
GrStrokeInfo(const GrStrokeInfo& src, bool includeDash = true) : fStroke(src.fStroke) { |
- if (includeDash) { |
- fDashInfo = src.fDashInfo; |
+ if (includeDash && src.isDashed()) { |
fDashType = src.fDashType; |
- fIntervals.reset(src.dashCount()); |
- memcpy(fIntervals.get(), src.fIntervals.get(), src.dashCount() * sizeof(SkScalar)); |
+ fDashPhase = src.fDashPhase; |
+ fIntervals.reset(src.getDashCount()); |
+ memcpy(fIntervals.get(), src.fIntervals.get(), fIntervals.count() * sizeof(SkScalar)); |
} else { |
fDashType = SkPathEffect::kNone_DashType; |
} |
@@ -45,11 +45,15 @@ public: |
} |
GrStrokeInfo& operator=(const GrStrokeInfo& other) { |
+ if (other.isDashed()) { |
+ fDashType = other.fDashType; |
+ fDashPhase = other.fDashPhase; |
+ fIntervals.reset(other.getDashCount()); |
+ memcpy(fIntervals.get(), other.fIntervals.get(), fIntervals.count() * sizeof(SkScalar)); |
+ } else { |
+ this->removeDash(); |
+ } |
fStroke = other.fStroke; |
- fDashInfo = other.fDashInfo; |
- fDashType = other.fDashType; |
- fIntervals.reset(other.dashCount()); |
- memcpy(fIntervals.get(), other.fIntervals.get(), other.dashCount() * sizeof(SkScalar)); |
return *this; |
} |
@@ -66,12 +70,13 @@ public: |
*/ |
bool setDashInfo(const SkPathEffect* pe) { |
if (pe && !fStroke.isFillStyle()) { |
- fDashInfo.fIntervals = NULL; |
- fDashType = pe->asADash(&fDashInfo); |
+ SkPathEffect::DashInfo dashInfo; |
+ fDashType = pe->asADash(&dashInfo); |
if (SkPathEffect::kDash_DashType == fDashType) { |
- fIntervals.reset(fDashInfo.fCount); |
- fDashInfo.fIntervals = fIntervals.get(); |
- pe->asADash(&fDashInfo); |
+ fIntervals.reset(dashInfo.fCount); |
+ dashInfo.fIntervals = fIntervals.get(); |
+ pe->asADash(&dashInfo); |
+ fDashPhase = dashInfo.fPhase; |
return true; |
} |
} |
@@ -84,15 +89,24 @@ public: |
bool isFillStyle() const { return fStroke.isFillStyle(); } |
- int32_t dashCount() const { |
- return fDashInfo.fCount; |
+ int32_t getDashCount() const { |
+ SkASSERT(this->isDashed()); |
+ return fIntervals.count(); |
+ } |
+ |
+ SkScalar getDashPhase() const { |
+ SkASSERT(this->isDashed()); |
+ return fDashPhase; |
+ } |
+ |
+ const SkScalar* getDashIntervals() const { |
+ SkASSERT(this->isDashed()); |
+ return fIntervals.get(); |
} |
void removeDash() { |
fDashType = SkPathEffect::kNone_DashType; |
} |
- |
- const SkPathEffect::DashInfo& getDashInfo() const { return fDashInfo; } |
/** Applies the dash to a path, if the stroke info has dashing. |
* @return true if the dash ingwas applied (dst and dstStrokeInfo will be modified). |
@@ -111,7 +125,7 @@ private: |
SkStrokeRec fStroke; |
SkPathEffect::DashType fDashType; |
- SkPathEffect::DashInfo fDashInfo; |
+ SkScalar fDashPhase; |
SkAutoSTArray<2, SkScalar> fIntervals; |
}; |