OLD | NEW |
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 Loading... |
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 | |
93 GrStyle& operator=(const GrStyle& that) { | 88 GrStyle& operator=(const GrStyle& that) { |
94 fPathEffect = that.fPathEffect; | 89 fPathEffect = that.fPathEffect; |
95 fDashInfo = that.fDashInfo; | 90 fDashInfo = that.fDashInfo; |
96 fStrokeRec = that.fStrokeRec; | 91 fStrokeRec = that.fStrokeRec; |
97 return *this; | 92 return *this; |
98 } | 93 } |
99 | 94 |
100 void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline) { | 95 void resetToInitStyle(SkStrokeRec::InitStyle fillOrHairline) { |
101 fDashInfo.reset(); | 96 fDashInfo.reset(); |
102 fPathEffect.reset(nullptr); | 97 fPathEffect.reset(nullptr); |
(...skipping 28 matching lines...) Expand all Loading... |
131 return fDashInfo.fIntervals.get(); | 126 return fDashInfo.fIntervals.get(); |
132 } | 127 } |
133 | 128 |
134 const SkStrokeRec& strokeRec() const { return fStrokeRec; } | 129 const SkStrokeRec& strokeRec() const { return fStrokeRec; } |
135 | 130 |
136 /** Hairline or fill styles without path effects make no alterations to a ge
ometry. */ | 131 /** Hairline or fill styles without path effects make no alterations to a ge
ometry. */ |
137 bool applies() const { | 132 bool applies() const { |
138 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i
sHairlineStyle()); | 133 return this->pathEffect() || (!fStrokeRec.isFillStyle() && !fStrokeRec.i
sHairlineStyle()); |
139 } | 134 } |
140 | 135 |
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 } | |
147 /** | 136 /** |
148 * Applies just the path effect and returns remaining stroke information. Th
is will fail if | 137 * Applies just the path effect and returns remaining stroke information. Th
is will fail if |
149 * there is no path effect. dst may or may not have been overwritten on fail
ure. Scale controls | 138 * there is no path effect. dst may or may not have been overwritten on fail
ure. Scale controls |
150 * geometric approximations made by the path effect. It is typically compute
d from the view | 139 * geometric approximations made by the path effect. It is typically compute
d from the view |
151 * matrix. | 140 * matrix. |
152 */ | 141 */ |
153 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r
emainingStoke, | 142 bool SK_WARN_UNUSED_RESULT applyPathEffectToPath(SkPath* dst, SkStrokeRec* r
emainingStoke, |
154 const SkPath& src, SkScalar
scale) const; | 143 const SkPath& src, SkScalar
scale) const; |
155 | 144 |
156 /** | 145 /** |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 SkScalar fPhase; | 183 SkScalar fPhase; |
195 SkAutoSTArray<4, SkScalar> fIntervals; | 184 SkAutoSTArray<4, SkScalar> fIntervals; |
196 }; | 185 }; |
197 | 186 |
198 SkStrokeRec fStrokeRec; | 187 SkStrokeRec fStrokeRec; |
199 sk_sp<SkPathEffect> fPathEffect; | 188 sk_sp<SkPathEffect> fPathEffect; |
200 DashInfo fDashInfo; | 189 DashInfo fDashInfo; |
201 }; | 190 }; |
202 | 191 |
203 #endif | 192 #endif |
OLD | NEW |