bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrShape_DEFINED |
| 9 | #define GrShape_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkPath.h" |
| 12 | #include "include/core/SkRRect.h" |
| 13 | #include "include/private/SkTemplates.h" |
| 14 | #include "src/core/SkPathPriv.h" |
| 15 | #include "src/core/SkTLazy.h" |
| 16 | #include "src/gpu/GrStyle.h" |
Mike Klein | 79aea6a | 2018-06-11 10:45:26 -0400 | [diff] [blame] | 17 | #include <new> |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Represents a geometric shape (rrect or path) and the GrStyle that it should be rendered with. |
| 21 | * It is possible to apply the style to the GrShape to produce a new GrShape where the geometry |
| 22 | * reflects the styling information (e.g. is stroked). It is also possible to apply just the |
| 23 | * path effect from the style. In this case the resulting shape will include any remaining |
| 24 | * stroking information that is to be applied after the path effect. |
| 25 | * |
| 26 | * Shapes can produce keys that represent only the geometry information, not the style. Note that |
| 27 | * when styling information is applied to produce a new shape then the style has been converted |
| 28 | * to geometric information and is included in the new shape's key. When the same style is applied |
| 29 | * to two shapes that reflect the same underlying geometry the computed keys of the stylized shapes |
| 30 | * will be the same. |
| 31 | * |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 32 | * Currently this can only be constructed from a path, rect, or rrect though it can become a path |
| 33 | * applying style to the geometry. The idea is to expand this to cover most or all of the geometries |
Brian Salomon | 4f40caf | 2017-09-01 09:00:45 -0400 | [diff] [blame] | 34 | * that have fast paths in the GPU backend. |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 35 | */ |
| 36 | class GrShape { |
| 37 | public: |
bsalomon | 67fa4e3 | 2016-09-21 08:26:57 -0700 | [diff] [blame] | 38 | // Keys for paths may be extracted from the path data for small paths. Clients aren't supposed |
| 39 | // to have to worry about this. This value is exposed for unit tests. |
| 40 | static constexpr int kMaxKeyFromDataVerbCnt = 10; |
| 41 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 42 | GrShape() { this->initType(Type::kEmpty); } |
bsalomon | 5e410b4 | 2016-04-28 09:30:46 -0700 | [diff] [blame] | 43 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 44 | explicit GrShape(const SkPath& path) : GrShape(path, GrStyle::SimpleFill()) {} |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 45 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 46 | explicit GrShape(const SkRRect& rrect) : GrShape(rrect, GrStyle::SimpleFill()) {} |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 47 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 48 | explicit GrShape(const SkRect& rect) : GrShape(rect, GrStyle::SimpleFill()) {} |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 49 | |
Brian Salomon | da6d072 | 2018-01-03 13:54:35 -0500 | [diff] [blame] | 50 | GrShape(const SkPath& path, const GrStyle& style) : fStyle(style) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 51 | this->initType(Type::kPath, &path); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 52 | this->attemptToSimplifyPath(); |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 55 | GrShape(const SkRRect& rrect, const GrStyle& style) : fStyle(style) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 56 | this->initType(Type::kRRect); |
| 57 | fRRectData.fRRect = rrect; |
| 58 | fRRectData.fInverted = false; |
| 59 | fRRectData.fStart = DefaultRRectDirAndStartIndex(rrect, style.hasPathEffect(), |
| 60 | &fRRectData.fDir); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 61 | this->attemptToSimplifyRRect(); |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 64 | GrShape(const SkRRect& rrect, SkPath::Direction dir, unsigned start, bool inverted, |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 65 | const GrStyle& style) |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 66 | : fStyle(style) { |
| 67 | this->initType(Type::kRRect); |
| 68 | fRRectData.fRRect = rrect; |
| 69 | fRRectData.fInverted = inverted; |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 70 | if (style.pathEffect()) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 71 | fRRectData.fDir = dir; |
| 72 | fRRectData.fStart = start; |
| 73 | if (fRRectData.fRRect.getType() == SkRRect::kRect_Type) { |
| 74 | fRRectData.fStart = (fRRectData.fStart + 1) & 0b110; |
| 75 | } else if (fRRectData.fRRect.getType() == SkRRect::kOval_Type) { |
| 76 | fRRectData.fStart &= 0b110; |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 77 | } |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 78 | } else { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 79 | fRRectData.fStart = DefaultRRectDirAndStartIndex(rrect, false, &fRRectData.fDir); |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 80 | } |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 81 | this->attemptToSimplifyRRect(); |
bsalomon | 5e410b4 | 2016-04-28 09:30:46 -0700 | [diff] [blame] | 82 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 83 | |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 84 | GrShape(const SkRect& rect, const GrStyle& style) : fStyle(style) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 85 | this->initType(Type::kRRect); |
| 86 | fRRectData.fRRect = SkRRect::MakeRect(rect); |
| 87 | fRRectData.fInverted = false; |
| 88 | fRRectData.fStart = DefaultRectDirAndStartIndex(rect, style.hasPathEffect(), |
| 89 | &fRRectData.fDir); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 90 | this->attemptToSimplifyRRect(); |
bsalomon | 5e410b4 | 2016-04-28 09:30:46 -0700 | [diff] [blame] | 91 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 92 | |
Brian Salomon | da6d072 | 2018-01-03 13:54:35 -0500 | [diff] [blame] | 93 | GrShape(const SkPath& path, const SkPaint& paint) : fStyle(paint) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 94 | this->initType(Type::kPath, &path); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 95 | this->attemptToSimplifyPath(); |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 98 | GrShape(const SkRRect& rrect, const SkPaint& paint) : fStyle(paint) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 99 | this->initType(Type::kRRect); |
| 100 | fRRectData.fRRect = rrect; |
| 101 | fRRectData.fInverted = false; |
| 102 | fRRectData.fStart = DefaultRRectDirAndStartIndex(rrect, fStyle.hasPathEffect(), |
| 103 | &fRRectData.fDir); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 104 | this->attemptToSimplifyRRect(); |
bsalomon | 5e410b4 | 2016-04-28 09:30:46 -0700 | [diff] [blame] | 105 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 106 | |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 107 | GrShape(const SkRect& rect, const SkPaint& paint) : fStyle(paint) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 108 | this->initType(Type::kRRect); |
| 109 | fRRectData.fRRect = SkRRect::MakeRect(rect); |
| 110 | fRRectData.fInverted = false; |
| 111 | fRRectData.fStart = DefaultRectDirAndStartIndex(rect, fStyle.hasPathEffect(), |
| 112 | &fRRectData.fDir); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 113 | this->attemptToSimplifyRRect(); |
bsalomon | 5e410b4 | 2016-04-28 09:30:46 -0700 | [diff] [blame] | 114 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 115 | |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 116 | static GrShape MakeArc(const SkRect& oval, SkScalar startAngleDegrees, |
| 117 | SkScalar sweepAngleDegrees, bool useCenter, const GrStyle& style); |
| 118 | |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 119 | GrShape(const GrShape&); |
| 120 | GrShape& operator=(const GrShape& that); |
| 121 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 122 | ~GrShape() { this->changeType(Type::kEmpty); } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 123 | |
Brian Salomon | 4f40caf | 2017-09-01 09:00:45 -0400 | [diff] [blame] | 124 | /** |
| 125 | * Informs MakeFilled on how to modify that shape's fill rule when making a simple filled |
| 126 | * version of the shape. |
| 127 | */ |
| 128 | enum class FillInversion { |
| 129 | kPreserve, |
| 130 | kFlip, |
| 131 | kForceNoninverted, |
| 132 | kForceInverted |
| 133 | }; |
| 134 | /** |
| 135 | * Makes a filled shape from the pre-styled original shape and optionally modifies whether |
| 136 | * the fill is inverted or not. It's important to note that the original shape's geometry |
| 137 | * may already have been modified if doing so was neutral with respect to its style |
| 138 | * (e.g. filled paths are always closed when stored in a shape and dashed paths are always |
| 139 | * made non-inverted since dashing ignores inverseness). |
| 140 | */ |
| 141 | static GrShape MakeFilled(const GrShape& original, FillInversion = FillInversion::kPreserve); |
| 142 | |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 143 | const GrStyle& style() const { return fStyle; } |
| 144 | |
bsalomon | 97fd2d4 | 2016-05-09 13:02:01 -0700 | [diff] [blame] | 145 | /** |
| 146 | * Returns a shape that has either applied the path effect or path effect and stroking |
| 147 | * information from this shape's style to its geometry. Scale is used when approximating the |
| 148 | * output geometry and typically is computed from the view matrix |
| 149 | */ |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 150 | GrShape applyStyle(GrStyle::Apply apply, SkScalar scale) const { |
bsalomon | 97fd2d4 | 2016-05-09 13:02:01 -0700 | [diff] [blame] | 151 | return GrShape(*this, apply, scale); |
| 152 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 153 | |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 154 | bool isRect() const { |
| 155 | if (Type::kRRect != fType) { |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | return fRRectData.fRRect.isRect(); |
| 160 | } |
| 161 | |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 162 | /** Returns the unstyled geometry as a rrect if possible. */ |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 163 | bool asRRect(SkRRect* rrect, SkPath::Direction* dir, unsigned* start, bool* inverted) const { |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 164 | if (Type::kRRect != fType) { |
| 165 | return false; |
| 166 | } |
| 167 | if (rrect) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 168 | *rrect = fRRectData.fRRect; |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 169 | } |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 170 | if (dir) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 171 | *dir = fRRectData.fDir; |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 172 | } |
| 173 | if (start) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 174 | *start = fRRectData.fStart; |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 175 | } |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 176 | if (inverted) { |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 177 | *inverted = fRRectData.fInverted; |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 178 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 179 | return true; |
| 180 | } |
| 181 | |
bsalomon | 398e3f4 | 2016-06-13 10:22:48 -0700 | [diff] [blame] | 182 | /** |
| 183 | * If the unstyled shape is a straight line segment, returns true and sets pts to the endpoints. |
| 184 | * An inverse filled line path is still considered a line. |
| 185 | */ |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 186 | bool asLine(SkPoint pts[2], bool* inverted) const { |
| 187 | if (fType != Type::kLine) { |
| 188 | return false; |
| 189 | } |
| 190 | if (pts) { |
| 191 | pts[0] = fLineData.fPts[0]; |
| 192 | pts[1] = fLineData.fPts[1]; |
| 193 | } |
| 194 | if (inverted) { |
| 195 | *inverted = fLineData.fInverted; |
| 196 | } |
| 197 | return true; |
| 198 | } |
bsalomon | 398e3f4 | 2016-06-13 10:22:48 -0700 | [diff] [blame] | 199 | |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 200 | /** Returns the unstyled geometry as a path. */ |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 201 | void asPath(SkPath* out) const { |
| 202 | switch (fType) { |
bsalomon | 0607756 | 2016-05-04 13:50:29 -0700 | [diff] [blame] | 203 | case Type::kEmpty: |
| 204 | out->reset(); |
| 205 | break; |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 206 | case Type::kInvertedEmpty: |
| 207 | out->reset(); |
| 208 | out->setFillType(kDefaultPathInverseFillType); |
| 209 | break; |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 210 | case Type::kRRect: |
| 211 | out->reset(); |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 212 | out->addRRect(fRRectData.fRRect, fRRectData.fDir, fRRectData.fStart); |
bsalomon | 93f66bc | 2016-06-21 08:35:49 -0700 | [diff] [blame] | 213 | // Below matches the fill type that attemptToSimplifyPath uses. |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 214 | if (fRRectData.fInverted) { |
bsalomon | a4817af | 2016-06-23 11:48:26 -0700 | [diff] [blame] | 215 | out->setFillType(kDefaultPathInverseFillType); |
bsalomon | 93f66bc | 2016-06-21 08:35:49 -0700 | [diff] [blame] | 216 | } else { |
bsalomon | a4817af | 2016-06-23 11:48:26 -0700 | [diff] [blame] | 217 | out->setFillType(kDefaultPathFillType); |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 218 | } |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 219 | break; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 220 | case Type::kArc: |
| 221 | SkPathPriv::CreateDrawArcPath(out, fArcData.fOval, fArcData.fStartAngleDegrees, |
| 222 | fArcData.fSweepAngleDegrees, fArcData.fUseCenter, |
| 223 | fStyle.isSimpleFill()); |
| 224 | if (fArcData.fInverted) { |
| 225 | out->setFillType(kDefaultPathInverseFillType); |
| 226 | } else { |
| 227 | out->setFillType(kDefaultPathFillType); |
| 228 | } |
| 229 | break; |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 230 | case Type::kLine: |
| 231 | out->reset(); |
| 232 | out->moveTo(fLineData.fPts[0]); |
| 233 | out->lineTo(fLineData.fPts[1]); |
| 234 | if (fLineData.fInverted) { |
| 235 | out->setFillType(kDefaultPathInverseFillType); |
| 236 | } else { |
| 237 | out->setFillType(kDefaultPathFillType); |
| 238 | } |
| 239 | break; |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 240 | case Type::kPath: |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 241 | *out = this->path(); |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 242 | break; |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | |
Robert Phillips | 73653b4 | 2018-08-22 12:42:42 -0400 | [diff] [blame] | 246 | // Can this shape be drawn as a pair of filled nested rectangles? |
| 247 | bool asNestedRects(SkRect rects[2]) const { |
| 248 | if (Type::kPath != fType) { |
| 249 | return false; |
| 250 | } |
| 251 | |
| 252 | // TODO: it would be better two store DRRects natively in the shape rather than converting |
| 253 | // them to a path and then reextracting the nested rects |
| 254 | if (this->path().isInverseFillType()) { |
| 255 | return false; |
| 256 | } |
| 257 | |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 258 | SkPath::Direction dirs[2]; |
Mike Reed | 430470d | 2019-09-12 17:09:12 -0400 | [diff] [blame] | 259 | if (!SkPathPriv::IsNestedFillRects(this->path(), rects, dirs)) { |
Robert Phillips | 73653b4 | 2018-08-22 12:42:42 -0400 | [diff] [blame] | 260 | return false; |
| 261 | } |
| 262 | |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 263 | if (SkPath::kWinding_FillType == this->path().getFillType() && dirs[0] == dirs[1]) { |
Robert Phillips | 73653b4 | 2018-08-22 12:42:42 -0400 | [diff] [blame] | 264 | // The two rects need to be wound opposite to each other |
| 265 | return false; |
| 266 | } |
| 267 | |
| 268 | // Right now, nested rects where the margin is not the same width |
| 269 | // all around do not render correctly |
| 270 | const SkScalar* outer = rects[0].asScalars(); |
| 271 | const SkScalar* inner = rects[1].asScalars(); |
| 272 | |
| 273 | bool allEq = true; |
| 274 | |
| 275 | SkScalar margin = SkScalarAbs(outer[0] - inner[0]); |
| 276 | bool allGoE1 = margin >= SK_Scalar1; |
| 277 | |
| 278 | for (int i = 1; i < 4; ++i) { |
| 279 | SkScalar temp = SkScalarAbs(outer[i] - inner[i]); |
| 280 | if (temp < SK_Scalar1) { |
| 281 | allGoE1 = false; |
| 282 | } |
| 283 | if (!SkScalarNearlyEqual(margin, temp)) { |
| 284 | allEq = false; |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | return allEq || allGoE1; |
| 289 | } |
| 290 | |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 291 | /** |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 292 | * Returns whether the geometry is empty. Note that applying the style could produce a |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 293 | * non-empty shape. It also may have an inverse fill. |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 294 | */ |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 295 | bool isEmpty() const { return Type::kEmpty == fType || Type::kInvertedEmpty == fType; } |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 296 | |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 297 | /** |
| 298 | * Gets the bounds of the geometry without reflecting the shape's styling. This ignores |
| 299 | * the inverse fill nature of the geometry. |
| 300 | */ |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 301 | SkRect bounds() const; |
bsalomon | 9fb4203 | 2016-05-13 09:23:38 -0700 | [diff] [blame] | 302 | |
bsalomon | 7049396 | 2016-06-10 08:05:14 -0700 | [diff] [blame] | 303 | /** |
| 304 | * Gets the bounds of the geometry reflecting the shape's styling (ignoring inverse fill |
| 305 | * status). |
| 306 | */ |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 307 | SkRect styledBounds() const; |
bsalomon | 9fb4203 | 2016-05-13 09:23:38 -0700 | [diff] [blame] | 308 | |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 309 | /** |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 310 | * Is this shape known to be convex, before styling is applied. An unclosed but otherwise |
| 311 | * convex path is considered to be closed if they styling reflects a fill and not otherwise. |
| 312 | * This is because filling closes all contours in the path. |
| 313 | */ |
| 314 | bool knownToBeConvex() const { |
| 315 | switch (fType) { |
| 316 | case Type::kEmpty: |
| 317 | return true; |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 318 | case Type::kInvertedEmpty: |
| 319 | return true; |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 320 | case Type::kRRect: |
| 321 | return true; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 322 | case Type::kArc: |
| 323 | return SkPathPriv::DrawArcIsConvex(fArcData.fSweepAngleDegrees, |
| 324 | SkToBool(fArcData.fUseCenter), |
| 325 | fStyle.isSimpleFill()); |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 326 | case Type::kLine: |
| 327 | return true; |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 328 | case Type::kPath: |
| 329 | // SkPath.isConvex() really means "is this path convex were it to be closed" and |
| 330 | // thus doesn't give the correct answer for stroked paths, hence we also check |
| 331 | // whether the path is either filled or closed. Convex paths may only have one |
| 332 | // contour hence isLastContourClosed() is a sufficient for a convex path. |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 333 | return (this->style().isSimpleFill() || this->path().isLastContourClosed()) && |
| 334 | this->path().isConvex(); |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 335 | } |
| 336 | return false; |
| 337 | } |
| 338 | |
Michael Ludwig | 0a1e9ef | 2019-08-30 10:03:15 -0400 | [diff] [blame] | 339 | /** |
| 340 | * Does the shape have a known winding direction. Some degenerate convex shapes may not have |
| 341 | * a computable direction, but this is not always a requirement for path renderers so it is |
| 342 | * kept separate from knownToBeConvex(). |
| 343 | */ |
| 344 | bool knownDirection() const { |
| 345 | switch (fType) { |
| 346 | case Type::kEmpty: |
| 347 | return true; |
| 348 | case Type::kInvertedEmpty: |
| 349 | return true; |
| 350 | case Type::kRRect: |
| 351 | return true; |
| 352 | case Type::kArc: |
| 353 | return true; |
| 354 | case Type::kLine: |
| 355 | return true; |
| 356 | case Type::kPath: |
| 357 | // Assuming this is called after knownToBeConvex(), this should just be relying on |
| 358 | // cached convexity and direction and will be cheap. |
| 359 | return !SkPathPriv::CheapIsFirstDirection(this->path(), |
| 360 | SkPathPriv::kUnknown_FirstDirection); |
| 361 | } |
| 362 | return false; |
| 363 | } |
| 364 | |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 365 | /** Is the pre-styled geometry inverse filled? */ |
| 366 | bool inverseFilled() const { |
| 367 | bool ret = false; |
| 368 | switch (fType) { |
| 369 | case Type::kEmpty: |
| 370 | ret = false; |
| 371 | break; |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 372 | case Type::kInvertedEmpty: |
| 373 | ret = true; |
| 374 | break; |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 375 | case Type::kRRect: |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 376 | ret = fRRectData.fInverted; |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 377 | break; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 378 | case Type::kArc: |
| 379 | ret = fArcData.fInverted; |
| 380 | break; |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 381 | case Type::kLine: |
| 382 | ret = fLineData.fInverted; |
| 383 | break; |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 384 | case Type::kPath: |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 385 | ret = this->path().isInverseFillType(); |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 386 | break; |
| 387 | } |
| 388 | // Dashing ignores inverseness. We should have caught this earlier. skbug.com/5421 |
| 389 | SkASSERT(!(ret && this->style().isDashed())); |
| 390 | return ret; |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Might applying the styling to the geometry produce an inverse fill. The "may" part comes in |
| 395 | * because an arbitrary path effect could produce an inverse filled path. In other cases this |
| 396 | * can be thought of as "inverseFilledAfterStyling()". |
| 397 | */ |
| 398 | bool mayBeInverseFilledAfterStyling() const { |
| 399 | // An arbitrary path effect can produce an arbitrary output path, which may be inverse |
| 400 | // filled. |
| 401 | if (this->style().hasNonDashPathEffect()) { |
| 402 | return true; |
| 403 | } |
| 404 | return this->inverseFilled(); |
| 405 | } |
| 406 | |
| 407 | /** |
bsalomon | 7c73a53 | 2016-05-11 15:15:56 -0700 | [diff] [blame] | 408 | * Is it known that the unstyled geometry has no unclosed contours. This means that it will |
| 409 | * not have any caps if stroked (modulo the effect of any path effect). |
bsalomon | 0607756 | 2016-05-04 13:50:29 -0700 | [diff] [blame] | 410 | */ |
| 411 | bool knownToBeClosed() const { |
| 412 | switch (fType) { |
| 413 | case Type::kEmpty: |
| 414 | return true; |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 415 | case Type::kInvertedEmpty: |
| 416 | return true; |
bsalomon | 0607756 | 2016-05-04 13:50:29 -0700 | [diff] [blame] | 417 | case Type::kRRect: |
| 418 | return true; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 419 | case Type::kArc: |
| 420 | return fArcData.fUseCenter; |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 421 | case Type::kLine: |
| 422 | return false; |
bsalomon | 0607756 | 2016-05-04 13:50:29 -0700 | [diff] [blame] | 423 | case Type::kPath: |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 424 | // SkPath doesn't keep track of the closed status of each contour. |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 425 | return SkPathPriv::IsClosedSingleContour(this->path()); |
bsalomon | 0607756 | 2016-05-04 13:50:29 -0700 | [diff] [blame] | 426 | } |
| 427 | return false; |
| 428 | } |
| 429 | |
bsalomon | 06115ee | 2016-06-07 06:28:51 -0700 | [diff] [blame] | 430 | uint32_t segmentMask() const { |
| 431 | switch (fType) { |
| 432 | case Type::kEmpty: |
| 433 | return 0; |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 434 | case Type::kInvertedEmpty: |
| 435 | return 0; |
bsalomon | 06115ee | 2016-06-07 06:28:51 -0700 | [diff] [blame] | 436 | case Type::kRRect: |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 437 | if (fRRectData.fRRect.getType() == SkRRect::kOval_Type) { |
bsalomon | 06115ee | 2016-06-07 06:28:51 -0700 | [diff] [blame] | 438 | return SkPath::kConic_SegmentMask; |
Brian Salomon | 2fad74a | 2017-12-20 13:28:55 -0500 | [diff] [blame] | 439 | } else if (fRRectData.fRRect.getType() == SkRRect::kRect_Type || |
| 440 | fRRectData.fRRect.getType() == SkRRect::kEmpty_Type) { |
bsalomon | 06115ee | 2016-06-07 06:28:51 -0700 | [diff] [blame] | 441 | return SkPath::kLine_SegmentMask; |
| 442 | } |
| 443 | return SkPath::kLine_SegmentMask | SkPath::kConic_SegmentMask; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 444 | case Type::kArc: |
| 445 | if (fArcData.fUseCenter) { |
| 446 | return SkPath::kConic_SegmentMask | SkPath::kLine_SegmentMask; |
| 447 | } |
| 448 | return SkPath::kConic_SegmentMask; |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 449 | case Type::kLine: |
| 450 | return SkPath::kLine_SegmentMask; |
bsalomon | 06115ee | 2016-06-07 06:28:51 -0700 | [diff] [blame] | 451 | case Type::kPath: |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 452 | return this->path().getSegmentMasks(); |
bsalomon | 06115ee | 2016-06-07 06:28:51 -0700 | [diff] [blame] | 453 | } |
| 454 | return 0; |
| 455 | } |
| 456 | |
bsalomon | 0607756 | 2016-05-04 13:50:29 -0700 | [diff] [blame] | 457 | /** |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 458 | * Gets the size of the key for the shape represented by this GrShape (ignoring its styling). |
| 459 | * A negative value is returned if the shape has no key (shouldn't be cached). |
| 460 | */ |
| 461 | int unstyledKeySize() const; |
| 462 | |
bsalomon | 425c27f | 2016-06-23 13:18:45 -0700 | [diff] [blame] | 463 | bool hasUnstyledKey() const { return this->unstyledKeySize() >= 0; } |
| 464 | |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 465 | /** |
| 466 | * Writes unstyledKeySize() bytes into the provided pointer. Assumes that there is enough |
| 467 | * space allocated for the key and that unstyledKeySize() does not return a negative value |
| 468 | * for this shape. |
| 469 | */ |
| 470 | void writeUnstyledKey(uint32_t* key) const; |
| 471 | |
Brian Osman | f6f7cf6 | 2017-09-25 16:49:55 -0400 | [diff] [blame] | 472 | /** |
| 473 | * Adds a listener to the *original* path. Typically used to invalidate cached resources when |
| 474 | * a path is no longer in-use. If the shape started out as something other than a path, this |
Chris Dalton | afa1158 | 2018-06-08 12:00:44 -0600 | [diff] [blame] | 475 | * does nothing. |
Brian Osman | f6f7cf6 | 2017-09-25 16:49:55 -0400 | [diff] [blame] | 476 | */ |
Chris Dalton | afa1158 | 2018-06-08 12:00:44 -0600 | [diff] [blame] | 477 | void addGenIDChangeListener(sk_sp<SkPathRef::GenIDChangeListener>) const; |
Brian Osman | f6f7cf6 | 2017-09-25 16:49:55 -0400 | [diff] [blame] | 478 | |
| 479 | /** |
Brian Osman | b379dcd | 2017-10-04 15:44:05 -0400 | [diff] [blame] | 480 | * Helpers that are only exposed for unit tests, to determine if the shape is a path, and get |
Brian Salomon | da6d072 | 2018-01-03 13:54:35 -0500 | [diff] [blame] | 481 | * the generation ID of the *original* path. This is the path that will receive |
| 482 | * GenIDChangeListeners added to this shape. |
Brian Osman | f6f7cf6 | 2017-09-25 16:49:55 -0400 | [diff] [blame] | 483 | */ |
| 484 | uint32_t testingOnly_getOriginalGenerationID() const; |
Brian Osman | b379dcd | 2017-10-04 15:44:05 -0400 | [diff] [blame] | 485 | bool testingOnly_isPath() const; |
Brian Salomon | da6d072 | 2018-01-03 13:54:35 -0500 | [diff] [blame] | 486 | bool testingOnly_isNonVolatilePath() const; |
Brian Osman | f6f7cf6 | 2017-09-25 16:49:55 -0400 | [diff] [blame] | 487 | |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 488 | private: |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 489 | enum class Type { |
| 490 | kEmpty, |
Brian Salomon | 085c086 | 2017-08-31 15:44:51 -0400 | [diff] [blame] | 491 | kInvertedEmpty, |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 492 | kRRect, |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 493 | kArc, |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 494 | kLine, |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 495 | kPath, |
| 496 | }; |
| 497 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 498 | void initType(Type type, const SkPath* path = nullptr) { |
| 499 | fType = Type::kEmpty; |
| 500 | this->changeType(type, path); |
| 501 | } |
| 502 | |
| 503 | void changeType(Type type, const SkPath* path = nullptr) { |
| 504 | bool wasPath = Type::kPath == fType; |
| 505 | fType = type; |
| 506 | bool isPath = Type::kPath == type; |
| 507 | SkASSERT(!path || isPath); |
| 508 | if (wasPath && !isPath) { |
| 509 | fPathData.fPath.~SkPath(); |
| 510 | } else if (!wasPath && isPath) { |
| 511 | if (path) { |
| 512 | new (&fPathData.fPath) SkPath(*path); |
| 513 | } else { |
| 514 | new (&fPathData.fPath) SkPath(); |
| 515 | } |
| 516 | } else if (isPath && path) { |
| 517 | fPathData.fPath = *path; |
| 518 | } |
| 519 | // Whether or not we use the path's gen ID is decided in attemptToSimplifyPath. |
| 520 | fPathData.fGenID = 0; |
| 521 | } |
| 522 | |
| 523 | SkPath& path() { |
| 524 | SkASSERT(Type::kPath == fType); |
| 525 | return fPathData.fPath; |
| 526 | } |
| 527 | |
| 528 | const SkPath& path() const { |
| 529 | SkASSERT(Type::kPath == fType); |
| 530 | return fPathData.fPath; |
| 531 | } |
| 532 | |
bsalomon | 97fd2d4 | 2016-05-09 13:02:01 -0700 | [diff] [blame] | 533 | /** Constructor used by the applyStyle() function */ |
| 534 | GrShape(const GrShape& parentShape, GrStyle::Apply, SkScalar scale); |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 535 | |
| 536 | /** |
| 537 | * Determines the key we should inherit from the input shape's geometry and style when |
| 538 | * we are applying the style to create a new shape. |
| 539 | */ |
bsalomon | 97fd2d4 | 2016-05-09 13:02:01 -0700 | [diff] [blame] | 540 | void setInheritedKey(const GrShape& parentShape, GrStyle::Apply, SkScalar scale); |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 541 | |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 542 | void attemptToSimplifyPath(); |
bsalomon | 1b28c1a | 2016-06-20 12:28:17 -0700 | [diff] [blame] | 543 | void attemptToSimplifyRRect(); |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 544 | void attemptToSimplifyLine(); |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 545 | void attemptToSimplifyArc(); |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 546 | |
Brian Salomon | 72f78c3 | 2017-12-21 11:56:42 -0500 | [diff] [blame] | 547 | bool attemptToSimplifyStrokedLineToRRect(); |
| 548 | |
Brian Salomon | da6d072 | 2018-01-03 13:54:35 -0500 | [diff] [blame] | 549 | /** Gets the path that gen id listeners should be added to. */ |
| 550 | const SkPath* originalPathForListeners() const; |
| 551 | |
bsalomon | a4817af | 2016-06-23 11:48:26 -0700 | [diff] [blame] | 552 | // Defaults to use when there is no distinction between even/odd and winding fills. |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 553 | static constexpr SkPath::FillType kDefaultPathFillType = SkPath::kEvenOdd_FillType; |
| 554 | static constexpr SkPath::FillType kDefaultPathInverseFillType = |
| 555 | SkPath::kInverseEvenOdd_FillType; |
bsalomon | a4817af | 2016-06-23 11:48:26 -0700 | [diff] [blame] | 556 | |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 557 | static constexpr SkPath::Direction kDefaultRRectDir = SkPath::kCW_Direction; |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 558 | static constexpr unsigned kDefaultRRectStart = 0; |
| 559 | |
| 560 | static unsigned DefaultRectDirAndStartIndex(const SkRect& rect, bool hasPathEffect, |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 561 | SkPath::Direction* dir) { |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 562 | *dir = kDefaultRRectDir; |
| 563 | // This comes from SkPath's interface. The default for adding a SkRect is counter clockwise |
| 564 | // beginning at index 0 (which happens to correspond to rrect index 0 or 7). |
| 565 | if (!hasPathEffect) { |
| 566 | // It doesn't matter what start we use, just be consistent to avoid redundant keys. |
| 567 | return kDefaultRRectStart; |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 568 | } |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 569 | // In SkPath a rect starts at index 0 by default. This is the top left corner. However, |
| 570 | // we store rects as rrects. RRects don't preserve the invertedness, but rather sort the |
| 571 | // rect edges. Thus, we may need to modify the rrect's start index to account for the sort. |
| 572 | bool swapX = rect.fLeft > rect.fRight; |
| 573 | bool swapY = rect.fTop > rect.fBottom; |
| 574 | if (swapX && swapY) { |
| 575 | // 0 becomes start index 2 and times 2 to convert from rect the rrect indices. |
| 576 | return 2 * 2; |
| 577 | } else if (swapX) { |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 578 | *dir = SkPath::kCCW_Direction; |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 579 | // 0 becomes start index 1 and times 2 to convert from rect the rrect indices. |
| 580 | return 2 * 1; |
| 581 | } else if (swapY) { |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 582 | *dir = SkPath::kCCW_Direction; |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 583 | // 0 becomes start index 3 and times 2 to convert from rect the rrect indices. |
| 584 | return 2 * 3; |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 585 | } |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 586 | return 0; |
| 587 | } |
| 588 | |
| 589 | static unsigned DefaultRRectDirAndStartIndex(const SkRRect& rrect, bool hasPathEffect, |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 590 | SkPath::Direction* dir) { |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 591 | // This comes from SkPath's interface. The default for adding a SkRRect to a path is |
| 592 | // clockwise beginning at starting index 6. |
| 593 | static constexpr unsigned kPathRRectStartIdx = 6; |
| 594 | *dir = kDefaultRRectDir; |
| 595 | if (!hasPathEffect) { |
| 596 | // It doesn't matter what start we use, just be consistent to avoid redundant keys. |
| 597 | return kDefaultRRectStart; |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 598 | } |
bsalomon | ee29564 | 2016-06-06 14:01:25 -0700 | [diff] [blame] | 599 | return kPathRRectStartIdx; |
bsalomon | 72dc51c | 2016-04-27 06:46:23 -0700 | [diff] [blame] | 600 | } |
| 601 | |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 602 | union { |
| 603 | struct { |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 604 | SkRRect fRRect; |
Mike Reed | 4241f5e | 2019-09-14 19:13:23 +0000 | [diff] [blame^] | 605 | SkPath::Direction fDir; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 606 | unsigned fStart; |
| 607 | bool fInverted; |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 608 | } fRRectData; |
| 609 | struct { |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 610 | SkRect fOval; |
| 611 | SkScalar fStartAngleDegrees; |
| 612 | SkScalar fSweepAngleDegrees; |
| 613 | int16_t fUseCenter; |
| 614 | int16_t fInverted; |
| 615 | } fArcData; |
| 616 | struct { |
| 617 | SkPath fPath; |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 618 | // Gen ID of the original path (fPath may be modified) |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 619 | int32_t fGenID; |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 620 | } fPathData; |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 621 | struct { |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 622 | SkPoint fPts[2]; |
| 623 | bool fInverted; |
bsalomon | 0a0f67e | 2016-06-28 11:56:42 -0700 | [diff] [blame] | 624 | } fLineData; |
bsalomon | 728b0f7 | 2016-06-27 10:00:19 -0700 | [diff] [blame] | 625 | }; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 626 | GrStyle fStyle; |
| 627 | SkTLazy<SkPath> fInheritedPathForListeners; |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 628 | SkAutoSTArray<8, uint32_t> fInheritedKey; |
Brian Salomon | e494940 | 2018-04-26 15:22:04 -0400 | [diff] [blame] | 629 | Type fType; |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 630 | }; |
| 631 | #endif |