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

Side by Side Diff: src/gpu/GrStyle.h

Issue 1957363002: Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Fix issue where hairlines were going to MSAAPathRenderer Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrStyle_DEFINED 8 #ifndef GrStyle_DEFINED
9 #define GrStyle_DEFINED 9 #define GrStyle_DEFINED
10 10
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR ec) { 78 GrStyle(const SkStrokeRec& strokeRec, SkPathEffect* pe) : fStrokeRec(strokeR ec) {
79 this->initPathEffect(pe); 79 this->initPathEffect(pe);
80 } 80 }
81 81
82 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { *t his = that; } 82 GrStyle(const GrStyle& that) : fStrokeRec(SkStrokeRec::kFill_InitStyle) { *t his = that; }
83 83
84 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) { 84 explicit GrStyle(const SkPaint& paint) : fStrokeRec(paint) {
85 this->initPathEffect(paint.getPathEffect()); 85 this->initPathEffect(paint.getPathEffect());
86 } 86 }
87 87
88 explicit GrStyle(const SkPaint& paint, SkPaint::Style overrideStyle)
89 : fStrokeRec(paint, overrideStyle) {
90 this->initPathEffect(paint.getPathEffect());
91 }
92
88 GrStyle& operator=(const GrStyle& that) { 93 GrStyle& operator=(const GrStyle& that) {
89 fPathEffect = that.fPathEffect; 94 fPathEffect = that.fPathEffect;
90 fDashInfo = that.fDashInfo; 95 fDashInfo = that.fDashInfo;
91 fStrokeRec = that.fStrokeRec; 96 fStrokeRec = that.fStrokeRec;
92 return *this; 97 return *this;
93 } 98 }
94 99
95 void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline) { 100 void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline) {
96 fDashInfo.reset(); 101 fDashInfo.reset();
97 fPathEffect.reset(nullptr); 102 fPathEffect.reset(nullptr);
(...skipping 28 matching lines...) Expand all
126 return fDashInfo.fIntervals.get(); 131 return fDashInfo.fIntervals.get();
127 } 132 }
128 133
129 const SkStrokeRec& strokeRec() const { return fStrokeRec; } 134 const SkStrokeRec& strokeRec() const { return fStrokeRec; }
130 135
131 /** Hairline or fill styles without path effects make no alterations to a ge ometry. */ 136 /** Hairline or fill styles without path effects make no alterations to a ge ometry. */
132 bool applies() const { 137 bool applies() const {
133 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i sHairlineStyle()); 138 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i sHairlineStyle());
134 } 139 }
135 140
141 static SkScalar MatrixToScaleFactor(const SkMatrix& matrix) {
142 // getMaxScale will return -1 if the matrix has perspective. In that cas e we can use a scale
143 // factor of 1. This isn't necessarily a good choice and in the future w e might consider
144 // taking a bounds here for the perspective case.
145 return SkScalarAbs(matrix.getMaxScale());
146 }
136 /** 147 /**
137 * Applies just the path effect and returns remaining stroke information. Th is will fail if 148 * Applies just the path effect and returns remaining stroke information. Th is will fail if
138 * there is no path effect. dst may or may not have been overwritten on fail ure. Scale controls 149 * there is no path effect. dst may or may not have been overwritten on fail ure. Scale controls
139 * geometric approximations made by the path effect. It is typically compute d from the view 150 * geometric approximations made by the path effect. It is typically compute d from the view
140 * matrix. 151 * matrix.
141 */ 152 */
142 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r emainingStoke, 153 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r emainingStoke,
143 const SkPath& src, SkScalar scale) const; 154 const SkPath& src, SkScalar scale) const;
144 155
145 /** 156 /**
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 SkScalar fPhase; 194 SkScalar fPhase;
184 SkAutoSTArray<4, SkScalar> fIntervals; 195 SkAutoSTArray<4, SkScalar> fIntervals;
185 }; 196 };
186 197
187 SkStrokeRec fStrokeRec; 198 SkStrokeRec fStrokeRec;
188 sk_sp<SkPathEffect> fPathEffect; 199 sk_sp<SkPathEffect> fPathEffect;
189 DashInfo fDashInfo; 200 DashInfo fDashInfo;
190 }; 201 };
191 202
192 #endif 203 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698