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 GrShape_DEFINED | 8 #ifndef GrShape_DEFINED |
9 #define GrShape_DEFINED | 9 #define GrShape_DEFINED |
10 | 10 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 GrShape& operator=(const GrShape& that); | 99 GrShape& operator=(const GrShape& that); |
100 | 100 |
101 ~GrShape() { | 101 ~GrShape() { |
102 if (Type::kPath == fType) { | 102 if (Type::kPath == fType) { |
103 fPath.reset(); | 103 fPath.reset(); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 const GrStyle& style() const { return fStyle; } | 107 const GrStyle& style() const { return fStyle; } |
108 | 108 |
109 GrShape applyStyle(GrStyle::Apply apply) { return GrShape(*this, apply); } | 109 /** |
| 110 * Returns a shape that has either applied the path effect or path effect an
d stroking |
| 111 * information from this shape's style to its geometry. Scale is used when a
pproximating the |
| 112 * output geometry and typically is computed from the view matrix |
| 113 */ |
| 114 GrShape applyStyle(GrStyle::Apply apply, SkScalar scale) { |
| 115 return GrShape(*this, apply, scale); |
| 116 } |
110 | 117 |
111 bool asRRect(SkRRect* rrect) const { | 118 bool asRRect(SkRRect* rrect) const { |
112 if (Type::kRRect != fType) { | 119 if (Type::kRRect != fType) { |
113 return false; | 120 return false; |
114 } | 121 } |
115 if (rrect) { | 122 if (rrect) { |
116 *rrect = fRRect; | 123 *rrect = fRRect; |
117 } | 124 } |
118 return true; | 125 return true; |
119 } | 126 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 void writeUnstyledKey(uint32_t* key) const; | 170 void writeUnstyledKey(uint32_t* key) const; |
164 | 171 |
165 private: | 172 private: |
166 enum class Type { | 173 enum class Type { |
167 kEmpty, | 174 kEmpty, |
168 kRRect, | 175 kRRect, |
169 kPath, | 176 kPath, |
170 }; | 177 }; |
171 | 178 |
172 | 179 |
173 /** Constructor used by Apply* functions */ | 180 /** Constructor used by the applyStyle() function */ |
174 GrShape(const GrShape& parentShape, GrStyle::Apply); | 181 GrShape(const GrShape& parentShape, GrStyle::Apply, SkScalar scale); |
175 | 182 |
176 /** | 183 /** |
177 * Determines the key we should inherit from the input shape's geometry and
style when | 184 * Determines the key we should inherit from the input shape's geometry and
style when |
178 * we are applying the style to create a new shape. | 185 * we are applying the style to create a new shape. |
179 */ | 186 */ |
180 void setInheritedKey(const GrShape& parentShape, GrStyle::Apply); | 187 void setInheritedKey(const GrShape& parentShape, GrStyle::Apply, SkScalar sc
ale); |
181 | 188 |
182 void attemptToReduceFromPath() { | 189 void attemptToReduceFromPath() { |
183 SkASSERT(Type::kPath == fType); | 190 SkASSERT(Type::kPath == fType); |
184 fType = AttemptToReduceFromPathImpl(*fPath.get(), &fRRect, fStyle.pathEf
fect(), | 191 fType = AttemptToReduceFromPathImpl(*fPath.get(), &fRRect, fStyle.pathEf
fect(), |
185 fStyle.strokeRec()); | 192 fStyle.strokeRec()); |
186 if (Type::kPath != fType) { | 193 if (Type::kPath != fType) { |
187 fPath.reset(); | 194 fPath.reset(); |
188 fInheritedKey.reset(0); | 195 fInheritedKey.reset(0); |
189 } | 196 } |
190 } | 197 } |
(...skipping 30 matching lines...) Expand all Loading... |
221 return Type::kPath; | 228 return Type::kPath; |
222 } | 229 } |
223 | 230 |
224 Type fType; | 231 Type fType; |
225 SkRRect fRRect; | 232 SkRRect fRRect; |
226 SkTLazy<SkPath> fPath; | 233 SkTLazy<SkPath> fPath; |
227 GrStyle fStyle; | 234 GrStyle fStyle; |
228 SkAutoSTArray<8, uint32_t> fInheritedKey; | 235 SkAutoSTArray<8, uint32_t> fInheritedKey; |
229 }; | 236 }; |
230 #endif | 237 #endif |
OLD | NEW |