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

Unified Diff: src/gpu/GrStrokeInfo.h

Issue 1110093002: Avoid using SkPathEffect::DashInfo in GrStrokeInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@dashing-nvpr
Patch Set: rebase Created 5 years, 8 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 | « no previous file | 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 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;
};
« no previous file with comments | « no previous file | src/gpu/GrStrokeInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698