| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 /** Returns the unstyled geometry as a path. */ | 182 /** Returns the unstyled geometry as a path. */ |
| 183 void asPath(SkPath* out) const { | 183 void asPath(SkPath* out) const { |
| 184 switch (fType) { | 184 switch (fType) { |
| 185 case Type::kEmpty: | 185 case Type::kEmpty: |
| 186 out->reset(); | 186 out->reset(); |
| 187 break; | 187 break; |
| 188 case Type::kRRect: | 188 case Type::kRRect: |
| 189 out->reset(); | 189 out->reset(); |
| 190 out->addRRect(fRRect, fRRectDir, fRRectStart); | 190 out->addRRect(fRRect, fRRectDir, fRRectStart); |
| 191 // Below matches the fill type that attemptToSimplifyPath uses. |
| 191 if (fRRectIsInverted) { | 192 if (fRRectIsInverted) { |
| 192 out->setFillType(SkPath::kInverseWinding_FillType); | 193 out->setFillType(SkPath::kInverseEvenOdd_FillType); |
| 194 } else { |
| 195 out->setFillType(SkPath::kEvenOdd_FillType); |
| 193 } | 196 } |
| 194 break; | 197 break; |
| 195 case Type::kPath: | 198 case Type::kPath: |
| 196 *out = *fPath.get(); | 199 *out = *fPath.get(); |
| 197 break; | 200 break; |
| 198 } | 201 } |
| 199 } | 202 } |
| 200 | 203 |
| 201 /** | 204 /** |
| 202 * Returns whether the geometry is empty. Note that applying the style could
produce a | 205 * Returns whether the geometry is empty. Note that applying the style could
produce a |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 /** Constructor used by the applyStyle() function */ | 275 /** Constructor used by the applyStyle() function */ |
| 273 GrShape(const GrShape& parentShape, GrStyle::Apply, SkScalar scale); | 276 GrShape(const GrShape& parentShape, GrStyle::Apply, SkScalar scale); |
| 274 | 277 |
| 275 /** | 278 /** |
| 276 * Determines the key we should inherit from the input shape's geometry and
style when | 279 * Determines the key we should inherit from the input shape's geometry and
style when |
| 277 * we are applying the style to create a new shape. | 280 * we are applying the style to create a new shape. |
| 278 */ | 281 */ |
| 279 void setInheritedKey(const GrShape& parentShape, GrStyle::Apply, SkScalar sc
ale); | 282 void setInheritedKey(const GrShape& parentShape, GrStyle::Apply, SkScalar sc
ale); |
| 280 | 283 |
| 281 void attemptToSimplifyPath(); | 284 void attemptToSimplifyPath(); |
| 282 | |
| 283 void attemptToSimplifyRRect(); | 285 void attemptToSimplifyRRect(); |
| 284 | 286 |
| 285 static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction; | 287 static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction; |
| 286 static constexpr unsigned kDefaultRRectStart = 0; | 288 static constexpr unsigned kDefaultRRectStart = 0; |
| 287 | 289 |
| 288 static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPath
Effect, | 290 static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPath
Effect, |
| 289 SkPath::Direction* dir) { | 291 SkPath::Direction* dir) { |
| 290 *dir = kDefaultRRectDir; | 292 *dir = kDefaultRRectDir; |
| 291 // This comes from SkPath's interface. The default for adding a SkRect i
s counter clockwise | 293 // This comes from SkPath's interface. The default for adding a SkRect i
s counter clockwise |
| 292 // beginning at index 0 (which happens to correspond to rrect index 0 or
7). | 294 // beginning at index 0 (which happens to correspond to rrect index 0 or
7). |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 328 } |
| 327 return kPathRRectStartIdx; | 329 return kPathRRectStartIdx; |
| 328 } | 330 } |
| 329 | 331 |
| 330 Type fType; | 332 Type fType; |
| 331 SkRRect fRRect; | 333 SkRRect fRRect; |
| 332 SkPath::Direction fRRectDir; | 334 SkPath::Direction fRRectDir; |
| 333 unsigned fRRectStart; | 335 unsigned fRRectStart; |
| 334 bool fRRectIsInverted; | 336 bool fRRectIsInverted; |
| 335 SkTLazy<SkPath> fPath; | 337 SkTLazy<SkPath> fPath; |
| 338 // Gen ID of the original path (fPath may be modified) |
| 339 int32_t fPathGenID = 0; |
| 336 GrStyle fStyle; | 340 GrStyle fStyle; |
| 337 SkAutoSTArray<8, uint32_t> fInheritedKey; | 341 SkAutoSTArray<8, uint32_t> fInheritedKey; |
| 338 }; | 342 }; |
| 339 #endif | 343 #endif |
| OLD | NEW |