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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 if (start) { | 162 if (start) { |
163 *start = fRRectStart; | 163 *start = fRRectStart; |
164 } | 164 } |
165 if (inverted) { | 165 if (inverted) { |
166 *inverted = fRRectIsInverted; | 166 *inverted = fRRectIsInverted; |
167 } | 167 } |
168 return true; | 168 return true; |
169 } | 169 } |
170 | 170 |
| 171 /** |
| 172 * If the unstyled shape is a straight line segment, returns true and sets p
ts to the endpoints. |
| 173 * An inverse filled line path is still considered a line. |
| 174 */ |
| 175 bool asLine(SkPoint pts[2]) const { |
| 176 if (fType != Type::kPath) { |
| 177 return false; |
| 178 } |
| 179 return fPath.get()->isLine(pts); |
| 180 } |
| 181 |
171 /** Returns the unstyled geometry as a path. */ | 182 /** Returns the unstyled geometry as a path. */ |
172 void asPath(SkPath* out) const { | 183 void asPath(SkPath* out) const { |
173 switch (fType) { | 184 switch (fType) { |
174 case Type::kEmpty: | 185 case Type::kEmpty: |
175 out->reset(); | 186 out->reset(); |
176 break; | 187 break; |
177 case Type::kRRect: | 188 case Type::kRRect: |
178 out->reset(); | 189 out->reset(); |
179 out->addRRect(fRRect, fRRectDir, fRRectStart); | 190 out->addRRect(fRRect, fRRectDir, fRRectStart); |
180 if (fRRectIsInverted) { | 191 if (fRRectIsInverted) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 Type fType; | 359 Type fType; |
349 SkRRect fRRect; | 360 SkRRect fRRect; |
350 SkPath::Direction fRRectDir; | 361 SkPath::Direction fRRectDir; |
351 unsigned fRRectStart; | 362 unsigned fRRectStart; |
352 bool fRRectIsInverted; | 363 bool fRRectIsInverted; |
353 SkTLazy<SkPath> fPath; | 364 SkTLazy<SkPath> fPath; |
354 GrStyle fStyle; | 365 GrStyle fStyle; |
355 SkAutoSTArray<8, uint32_t> fInheritedKey; | 366 SkAutoSTArray<8, uint32_t> fInheritedKey; |
356 }; | 367 }; |
357 #endif | 368 #endif |
OLD | NEW |