bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 SkPathRef_DEFINED |
| 9 | #define SkPathRef_DEFINED |
| 10 | |
Hal Canary | c640d0d | 2018-06-13 09:59:02 -0400 | [diff] [blame] | 11 | #include "SkAtomics.h" |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 12 | #include "SkMatrix.h" |
Mike Klein | 0191ed8 | 2018-09-17 17:29:39 -0400 | [diff] [blame] | 13 | #include "SkMutex.h" |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 14 | #include "SkPoint.h" |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 15 | #include "SkRRect.h" |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 16 | #include "SkRect.h" |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 17 | #include "SkRefCnt.h" |
Chris Dalton | f30e493 | 2018-10-18 18:56:59 -0600 | [diff] [blame^] | 18 | #include "SkTArray.h" |
Hal Canary | c640d0d | 2018-06-13 09:59:02 -0400 | [diff] [blame] | 19 | #include "SkTDArray.h" |
Ben Wagner | ac32662 | 2017-07-31 16:57:01 -0400 | [diff] [blame] | 20 | #include "SkTemplates.h" |
Hal Canary | c640d0d | 2018-06-13 09:59:02 -0400 | [diff] [blame] | 21 | #include "SkTo.h" |
| 22 | |
Mike Klein | bf45c70 | 2018-06-11 11:56:57 -0400 | [diff] [blame] | 23 | #include <limits> |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 24 | |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 25 | class SkRBuffer; |
| 26 | class SkWBuffer; |
| 27 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 28 | /** |
| 29 | * Holds the path verbs and points. It is versioned by a generation ID. None of its public methods |
| 30 | * modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an |
| 31 | * SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 32 | * copy-on-write if the SkPathRef is shared by multiple SkPaths. The caller passes the Editor's |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 33 | * constructor a pointer to a sk_sp<SkPathRef>, which may be updated to point to a new SkPathRef |
| 34 | * after the editor's constructor returns. |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 35 | * |
| 36 | * The points and verbs are stored in a single allocation. The points are at the begining of the |
| 37 | * allocation while the verbs are stored at end of the allocation, in reverse order. Thus the points |
| 38 | * and verbs both grow into the middle of the allocation until the meet. To access verb i in the |
| 39 | * verb array use ref.verbs()[~i] (because verbs() returns a pointer just beyond the first |
| 40 | * logical verb or the last verb in memory). |
| 41 | */ |
bsalomon@google.com | ae09f2d | 2012-10-03 19:57:01 +0000 | [diff] [blame] | 42 | |
mtklein | b47cd4b | 2016-08-09 12:20:04 -0700 | [diff] [blame] | 43 | class SK_API SkPathRef final : public SkNVRefCnt<SkPathRef> { |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 44 | public: |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 45 | class Editor { |
| 46 | public: |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 47 | Editor(sk_sp<SkPathRef>* pathRef, |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 48 | int incReserveVerbs = 0, |
robertphillips@google.com | 3e292aa | 2013-09-27 17:48:49 +0000 | [diff] [blame] | 49 | int incReservePoints = 0); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 50 | |
commit-bot@chromium.org | f48e475 | 2013-06-27 18:39:39 +0000 | [diff] [blame] | 51 | ~Editor() { SkDEBUGCODE(sk_atomic_dec(&fPathRef->fEditorsAttached);) } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Returns the array of points. |
| 55 | */ |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 56 | SkPoint* points() { return fPathRef->getPoints(); } |
| 57 | const SkPoint* points() const { return fPathRef->points(); } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * Gets the ith point. Shortcut for this->points() + i |
| 61 | */ |
| 62 | SkPoint* atPoint(int i) { |
| 63 | SkASSERT((unsigned) i < (unsigned) fPathRef->fPointCnt); |
| 64 | return this->points() + i; |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 65 | } |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 66 | const SkPoint* atPoint(int i) const { |
| 67 | SkASSERT((unsigned) i < (unsigned) fPathRef->fPointCnt); |
| 68 | return this->points() + i; |
Mike Klein | fc6c37b | 2016-09-27 09:34:10 -0400 | [diff] [blame] | 69 | } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * Adds the verb and allocates space for the number of points indicated by the verb. The |
| 73 | * return value is a pointer to where the points for the verb should be written. |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 74 | * 'weight' is only used if 'verb' is kConic_Verb |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 75 | */ |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 76 | SkPoint* growForVerb(int /*SkPath::Verb*/ verb, SkScalar weight = 0) { |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 77 | SkDEBUGCODE(fPathRef->validate();) |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 78 | return fPathRef->growForVerb(verb, weight); |
robertphillips@google.com | 3e292aa | 2013-09-27 17:48:49 +0000 | [diff] [blame] | 79 | } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 80 | |
| 81 | /** |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 82 | * Allocates space for multiple instances of a particular verb and the |
| 83 | * requisite points & weights. |
| 84 | * The return pointer points at the first new point (indexed normally [<i>]). |
| 85 | * If 'verb' is kConic_Verb, 'weights' will return a pointer to the |
skia.committer@gmail.com | 96f5fa0 | 2013-12-16 07:01:40 +0000 | [diff] [blame] | 86 | * space for the conic weights (indexed normally). |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 87 | */ |
skia.committer@gmail.com | 96f5fa0 | 2013-12-16 07:01:40 +0000 | [diff] [blame] | 88 | SkPoint* growForRepeatedVerb(int /*SkPath::Verb*/ verb, |
| 89 | int numVbs, |
Ben Wagner | a93a14a | 2017-08-28 10:34:05 -0400 | [diff] [blame] | 90 | SkScalar** weights = nullptr) { |
skia.committer@gmail.com | 96f5fa0 | 2013-12-16 07:01:40 +0000 | [diff] [blame] | 91 | return fPathRef->growForRepeatedVerb(verb, numVbs, weights); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Resets the path ref to a new verb and point count. The new verbs and points are |
| 96 | * uninitialized. |
| 97 | */ |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 98 | void resetToSize(int newVerbCnt, int newPointCnt, int newConicCount) { |
| 99 | fPathRef->resetToSize(newVerbCnt, newPointCnt, newConicCount); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 100 | } |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 101 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 102 | /** |
| 103 | * Gets the path ref that is wrapped in the Editor. |
| 104 | */ |
| 105 | SkPathRef* pathRef() { return fPathRef; } |
| 106 | |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 107 | void setIsOval(bool isOval, bool isCCW, unsigned start) { |
| 108 | fPathRef->setIsOval(isOval, isCCW, start); |
| 109 | } |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 110 | |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 111 | void setIsRRect(bool isRRect, bool isCCW, unsigned start) { |
| 112 | fPathRef->setIsRRect(isRRect, isCCW, start); |
| 113 | } |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 114 | |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 115 | void setBounds(const SkRect& rect) { fPathRef->setBounds(rect); } |
| 116 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 117 | private: |
| 118 | SkPathRef* fPathRef; |
| 119 | }; |
| 120 | |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 121 | class SK_API Iter { |
| 122 | public: |
| 123 | Iter(); |
| 124 | Iter(const SkPathRef&); |
| 125 | |
| 126 | void setPathRef(const SkPathRef&); |
| 127 | |
| 128 | /** Return the next verb in this iteration of the path. When all |
| 129 | segments have been visited, return kDone_Verb. |
| 130 | |
Mike Klein | 1170a55 | 2017-09-08 15:00:25 -0400 | [diff] [blame] | 131 | If any point in the path is non-finite, return kDone_Verb immediately. |
| 132 | |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 133 | @param pts The points representing the current verb and/or segment |
| 134 | This must not be NULL. |
| 135 | @return The verb for the current segment |
| 136 | */ |
| 137 | uint8_t next(SkPoint pts[4]); |
caryclark | 2028d7f | 2015-12-09 14:04:46 -0800 | [diff] [blame] | 138 | uint8_t peek() const; |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 139 | |
| 140 | SkScalar conicWeight() const { return *fConicWeights; } |
| 141 | |
| 142 | private: |
| 143 | const SkPoint* fPts; |
| 144 | const uint8_t* fVerbs; |
| 145 | const uint8_t* fVerbStop; |
| 146 | const SkScalar* fConicWeights; |
| 147 | }; |
| 148 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 149 | public: |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 150 | /** |
| 151 | * Gets a path ref with no verbs or points. |
| 152 | */ |
commit-bot@chromium.org | 1f81fd6 | 2013-10-23 14:44:08 +0000 | [diff] [blame] | 153 | static SkPathRef* CreateEmpty(); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 154 | |
| 155 | /** |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 156 | * Returns true if all of the points in this path are finite, meaning there |
| 157 | * are no infinities and no NaNs. |
| 158 | */ |
| 159 | bool isFinite() const { |
| 160 | if (fBoundsIsDirty) { |
| 161 | this->computeBounds(); |
| 162 | } |
| 163 | return SkToBool(fIsFinite); |
| 164 | } |
| 165 | |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 166 | /** |
| 167 | * Returns a mask, where each bit corresponding to a SegmentMask is |
| 168 | * set if the path contains 1 or more segments of that type. |
| 169 | * Returns 0 for an empty path (no segments). |
| 170 | */ |
| 171 | uint32_t getSegmentMasks() const { return fSegmentMask; } |
| 172 | |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 173 | /** Returns true if the path is an oval. |
| 174 | * |
| 175 | * @param rect returns the bounding rect of this oval. It's a circle |
| 176 | * if the height and width are the same. |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 177 | * @param isCCW is the oval CCW (or CW if false). |
| 178 | * @param start indicates where the contour starts on the oval (see |
| 179 | * SkPath::addOval for intepretation of the index). |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 180 | * |
| 181 | * @return true if this path is an oval. |
| 182 | * Tracking whether a path is an oval is considered an |
| 183 | * optimization for performance and so some paths that are in |
| 184 | * fact ovals can report false. |
| 185 | */ |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 186 | bool isOval(SkRect* rect, bool* isCCW, unsigned* start) const { |
| 187 | if (fIsOval) { |
| 188 | if (rect) { |
| 189 | *rect = this->getBounds(); |
| 190 | } |
| 191 | if (isCCW) { |
| 192 | *isCCW = SkToBool(fRRectOrOvalIsCCW); |
| 193 | } |
| 194 | if (start) { |
| 195 | *start = fRRectOrOvalStartIdx; |
| 196 | } |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | return SkToBool(fIsOval); |
| 200 | } |
| 201 | |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 202 | bool isRRect(SkRRect* rrect, bool* isCCW, unsigned* start) const { |
| 203 | if (fIsRRect) { |
| 204 | if (rrect) { |
| 205 | *rrect = this->getRRect(); |
| 206 | } |
| 207 | if (isCCW) { |
| 208 | *isCCW = SkToBool(fRRectOrOvalIsCCW); |
| 209 | } |
| 210 | if (start) { |
| 211 | *start = fRRectOrOvalStartIdx; |
| 212 | } |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 213 | } |
| 214 | return SkToBool(fIsRRect); |
| 215 | } |
| 216 | |
| 217 | |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 218 | bool hasComputedBounds() const { |
| 219 | return !fBoundsIsDirty; |
| 220 | } |
| 221 | |
| 222 | /** Returns the bounds of the path's points. If the path contains 0 or 1 |
| 223 | points, the bounds is set to (0,0,0,0), and isEmpty() will return true. |
| 224 | Note: this bounds may be larger than the actual shape, since curves |
| 225 | do not extend as far as their control points. |
| 226 | */ |
skia.committer@gmail.com | 65caeaf | 2013-09-27 07:01:29 +0000 | [diff] [blame] | 227 | const SkRect& getBounds() const { |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 228 | if (fBoundsIsDirty) { |
| 229 | this->computeBounds(); |
| 230 | } |
| 231 | return fBounds; |
| 232 | } |
| 233 | |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 234 | SkRRect getRRect() const; |
| 235 | |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 236 | /** |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 237 | * Transforms a path ref by a matrix, allocating a new one only if necessary. |
| 238 | */ |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 239 | static void CreateTransformedCopy(sk_sp<SkPathRef>* dst, |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 240 | const SkPathRef& src, |
robertphillips@google.com | 3e292aa | 2013-09-27 17:48:49 +0000 | [diff] [blame] | 241 | const SkMatrix& matrix); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 242 | |
commit-bot@chromium.org | fed2ab6 | 2014-01-23 15:16:05 +0000 | [diff] [blame] | 243 | static SkPathRef* CreateFromBuffer(SkRBuffer* buffer); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 244 | |
| 245 | /** |
| 246 | * Rollsback a path ref to zero verbs and points with the assumption that the path ref will be |
| 247 | * repopulated with approximately the same number of verbs and points. A new path ref is created |
| 248 | * only if necessary. |
| 249 | */ |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 250 | static void Rewind(sk_sp<SkPathRef>* pathRef); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 251 | |
mtklein | b47cd4b | 2016-08-09 12:20:04 -0700 | [diff] [blame] | 252 | ~SkPathRef(); |
Brian Osman | 03776fc | 2017-08-15 16:08:48 -0400 | [diff] [blame] | 253 | int countPoints() const { return fPointCnt; } |
| 254 | int countVerbs() const { return fVerbCnt; } |
| 255 | int countWeights() const { return fConicWeights.count(); } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 256 | |
| 257 | /** |
| 258 | * Returns a pointer one beyond the first logical verb (last verb in memory order). |
| 259 | */ |
Brian Osman | 03776fc | 2017-08-15 16:08:48 -0400 | [diff] [blame] | 260 | const uint8_t* verbs() const { return fVerbs; } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 261 | |
| 262 | /** |
| 263 | * Returns a const pointer to the first verb in memory (which is the last logical verb). |
| 264 | */ |
| 265 | const uint8_t* verbsMemBegin() const { return this->verbs() - fVerbCnt; } |
| 266 | |
| 267 | /** |
| 268 | * Returns a const pointer to the first point. |
| 269 | */ |
Brian Osman | 03776fc | 2017-08-15 16:08:48 -0400 | [diff] [blame] | 270 | const SkPoint* points() const { return fPoints; } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 271 | |
| 272 | /** |
| 273 | * Shortcut for this->points() + this->countPoints() |
| 274 | */ |
| 275 | const SkPoint* pointsEnd() const { return this->points() + this->countPoints(); } |
| 276 | |
Brian Osman | 03776fc | 2017-08-15 16:08:48 -0400 | [diff] [blame] | 277 | const SkScalar* conicWeights() const { return fConicWeights.begin(); } |
| 278 | const SkScalar* conicWeightsEnd() const { return fConicWeights.end(); } |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 279 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 280 | /** |
| 281 | * Convenience methods for getting to a verb or point by index. |
| 282 | */ |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 283 | uint8_t atVerb(int index) const { |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 284 | SkASSERT((unsigned) index < (unsigned) fVerbCnt); |
| 285 | return this->verbs()[~index]; |
| 286 | } |
| 287 | const SkPoint& atPoint(int index) const { |
| 288 | SkASSERT((unsigned) index < (unsigned) fPointCnt); |
| 289 | return this->points()[index]; |
| 290 | } |
| 291 | |
robertphillips@google.com | 3e292aa | 2013-09-27 17:48:49 +0000 | [diff] [blame] | 292 | bool operator== (const SkPathRef& ref) const; |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 293 | |
| 294 | /** |
| 295 | * Writes the path points and verbs to a buffer. |
| 296 | */ |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 297 | void writeToBuffer(SkWBuffer* buffer) const; |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 298 | |
| 299 | /** |
| 300 | * Gets the number of bytes that would be written in writeBuffer() |
| 301 | */ |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 302 | uint32_t writeSize() const; |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 303 | |
caryclark | 8e7b19d | 2016-02-18 04:11:48 -0800 | [diff] [blame] | 304 | void interpolate(const SkPathRef& ending, SkScalar weight, SkPathRef* out) const; |
| 305 | |
commit-bot@chromium.org | 1ab9f73 | 2013-10-30 18:57:55 +0000 | [diff] [blame] | 306 | /** |
| 307 | * Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the |
| 308 | * same ID then they have the same verbs and points. However, two path refs may have the same |
| 309 | * contents but different genIDs. |
| 310 | */ |
| 311 | uint32_t genID() const; |
| 312 | |
Chris Dalton | f30e493 | 2018-10-18 18:56:59 -0600 | [diff] [blame^] | 313 | class GenIDChangeListener : public SkRefCnt { |
| 314 | public: |
| 315 | GenIDChangeListener() : fShouldUnregisterFromPath(false) {} |
senorblanco | 84cd621 | 2015-08-04 10:01:58 -0700 | [diff] [blame] | 316 | virtual ~GenIDChangeListener() {} |
Chris Dalton | f30e493 | 2018-10-18 18:56:59 -0600 | [diff] [blame^] | 317 | |
senorblanco | 84cd621 | 2015-08-04 10:01:58 -0700 | [diff] [blame] | 318 | virtual void onChange() = 0; |
Chris Dalton | f30e493 | 2018-10-18 18:56:59 -0600 | [diff] [blame^] | 319 | |
| 320 | // The caller can use this method to notify the path that it no longer needs to listen. Once |
| 321 | // called, the path will remove this listener from the list at some future point. |
| 322 | void markShouldUnregisterFromPath() { |
| 323 | fShouldUnregisterFromPath.store(true, std::memory_order_relaxed); |
| 324 | } |
| 325 | bool shouldUnregisterFromPath() { |
| 326 | return fShouldUnregisterFromPath.load(std::memory_order_relaxed); |
| 327 | } |
| 328 | |
| 329 | private: |
| 330 | mutable std::atomic<bool> fShouldUnregisterFromPath; |
senorblanco | 84cd621 | 2015-08-04 10:01:58 -0700 | [diff] [blame] | 331 | }; |
| 332 | |
Mike Klein | 0191ed8 | 2018-09-17 17:29:39 -0400 | [diff] [blame] | 333 | void addGenIDChangeListener(sk_sp<GenIDChangeListener>); // Threadsafe. |
senorblanco | 84cd621 | 2015-08-04 10:01:58 -0700 | [diff] [blame] | 334 | |
Adrienne Walker | ad8da8e | 2017-08-10 12:16:37 -0700 | [diff] [blame] | 335 | bool isValid() const; |
| 336 | SkDEBUGCODE(void validate() const { SkASSERT(this->isValid()); } ) |
reed | 5bcbe91 | 2014-12-15 12:28:33 -0800 | [diff] [blame] | 337 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 338 | private: |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 339 | enum SerializationOffsets { |
Brian Salomon | b7d42e3 | 2017-09-21 16:59:17 -0400 | [diff] [blame] | 340 | kLegacyRRectOrOvalStartIdx_SerializationShift = 28, // requires 3 bits, ignored. |
| 341 | kLegacyRRectOrOvalIsCCW_SerializationShift = 27, // requires 1 bit, ignored. |
| 342 | kLegacyIsRRect_SerializationShift = 26, // requires 1 bit, ignored. |
| 343 | kIsFinite_SerializationShift = 25, // requires 1 bit |
| 344 | kLegacyIsOval_SerializationShift = 24, // requires 1 bit, ignored. |
Mike Reed | a3d9e21 | 2018-02-20 09:48:13 -0500 | [diff] [blame] | 345 | kSegmentMask_SerializationShift = 0 // requires 4 bits (deprecated) |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 346 | }; |
| 347 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 348 | SkPathRef() { |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 349 | fBoundsIsDirty = true; // this also invalidates fIsFinite |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 350 | fPointCnt = 0; |
| 351 | fVerbCnt = 0; |
Ben Wagner | a93a14a | 2017-08-28 10:34:05 -0400 | [diff] [blame] | 352 | fVerbs = nullptr; |
| 353 | fPoints = nullptr; |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 354 | fFreeSpace = 0; |
| 355 | fGenerationID = kEmptyGenID; |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 356 | fSegmentMask = 0; |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 357 | fIsOval = false; |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 358 | fIsRRect = false; |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 359 | // The next two values don't matter unless fIsOval or fIsRRect are true. |
senorblanco | 9c1d45d | 2016-07-22 13:51:42 -0700 | [diff] [blame] | 360 | fRRectOrOvalIsCCW = false; |
| 361 | fRRectOrOvalStartIdx = 0xAC; |
commit-bot@chromium.org | f48e475 | 2013-06-27 18:39:39 +0000 | [diff] [blame] | 362 | SkDEBUGCODE(fEditorsAttached = 0;) |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 363 | SkDEBUGCODE(this->validate();) |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 364 | } |
| 365 | |
robertphillips@google.com | 3e292aa | 2013-09-27 17:48:49 +0000 | [diff] [blame] | 366 | void copy(const SkPathRef& ref, int additionalReserveVerbs, int additionalReservePoints); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 367 | |
Mike Reed | a3d9e21 | 2018-02-20 09:48:13 -0500 | [diff] [blame] | 368 | // Doesn't read fSegmentMask, but (re)computes it from the verbs array |
| 369 | unsigned computeSegmentMask() const; |
| 370 | |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 371 | // Return true if the computed bounds are finite. |
| 372 | static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) { |
reed | 91f283b | 2015-07-28 06:00:50 -0700 | [diff] [blame] | 373 | return bounds->setBoundsCheck(ref.points(), ref.countPoints()); |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | // called, if dirty, by getBounds() |
| 377 | void computeBounds() const { |
| 378 | SkDEBUGCODE(this->validate();) |
Mike Klein | 0b4cc89 | 2014-07-16 17:18:20 -0400 | [diff] [blame] | 379 | // TODO(mtklein): remove fBoundsIsDirty and fIsFinite, |
| 380 | // using an inverted rect instead of fBoundsIsDirty and always recalculating fIsFinite. |
mtklein | 5c9c9be | 2014-12-01 06:59:54 -0800 | [diff] [blame] | 381 | SkASSERT(fBoundsIsDirty); |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 382 | |
mtklein | 5c9c9be | 2014-12-01 06:59:54 -0800 | [diff] [blame] | 383 | fIsFinite = ComputePtBounds(&fBounds, *this); |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 384 | fBoundsIsDirty = false; |
| 385 | } |
| 386 | |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 387 | void setBounds(const SkRect& rect) { |
| 388 | SkASSERT(rect.fLeft <= rect.fRight && rect.fTop <= rect.fBottom); |
| 389 | fBounds = rect; |
| 390 | fBoundsIsDirty = false; |
mtklein | 5c9c9be | 2014-12-01 06:59:54 -0800 | [diff] [blame] | 391 | fIsFinite = fBounds.isFinite(); |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 392 | } |
| 393 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 394 | /** Makes additional room but does not change the counts or change the genID */ |
| 395 | void incReserve(int additionalVerbs, int additionalPoints) { |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 396 | SkDEBUGCODE(this->validate();) |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 397 | size_t space = additionalVerbs * sizeof(uint8_t) + additionalPoints * sizeof (SkPoint); |
| 398 | this->makeSpace(space); |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 399 | SkDEBUGCODE(this->validate();) |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 400 | } |
| 401 | |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 402 | /** Resets the path ref with verbCount verbs and pointCount points, all uninitialized. Also |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 403 | * allocates space for reserveVerb additional verbs and reservePoints additional points.*/ |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 404 | void resetToSize(int verbCount, int pointCount, int conicCount, |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 405 | int reserveVerbs = 0, int reservePoints = 0) { |
| 406 | SkDEBUGCODE(this->validate();) |
| 407 | fBoundsIsDirty = true; // this also invalidates fIsFinite |
| 408 | fGenerationID = 0; |
| 409 | |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 410 | fSegmentMask = 0; |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 411 | fIsOval = false; |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 412 | fIsRRect = false; |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 413 | |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 414 | size_t newSize = sizeof(uint8_t) * verbCount + sizeof(SkPoint) * pointCount; |
| 415 | size_t newReserve = sizeof(uint8_t) * reserveVerbs + sizeof(SkPoint) * reservePoints; |
| 416 | size_t minSize = newSize + newReserve; |
| 417 | |
| 418 | ptrdiff_t sizeDelta = this->currSize() - minSize; |
| 419 | |
| 420 | if (sizeDelta < 0 || static_cast<size_t>(sizeDelta) >= 3 * minSize) { |
| 421 | sk_free(fPoints); |
Ben Wagner | a93a14a | 2017-08-28 10:34:05 -0400 | [diff] [blame] | 422 | fPoints = nullptr; |
| 423 | fVerbs = nullptr; |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 424 | fFreeSpace = 0; |
| 425 | fVerbCnt = 0; |
| 426 | fPointCnt = 0; |
Florin Malita | 3d413c5 | 2018-09-11 14:01:42 -0400 | [diff] [blame] | 427 | this->makeSpace(minSize, true); |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 428 | fVerbCnt = verbCount; |
| 429 | fPointCnt = pointCount; |
| 430 | fFreeSpace -= newSize; |
| 431 | } else { |
| 432 | fPointCnt = pointCount; |
| 433 | fVerbCnt = verbCount; |
| 434 | fFreeSpace = this->currSize() - minSize; |
| 435 | } |
| 436 | fConicWeights.setCount(conicCount); |
| 437 | SkDEBUGCODE(this->validate();) |
| 438 | } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 439 | |
| 440 | /** |
skia.committer@gmail.com | 96f5fa0 | 2013-12-16 07:01:40 +0000 | [diff] [blame] | 441 | * Increases the verb count by numVbs and point count by the required amount. |
| 442 | * The new points are uninitialized. All the new verbs are set to the specified |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 443 | * verb. If 'verb' is kConic_Verb, 'weights' will return a pointer to the |
| 444 | * uninitialized conic weights. |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 445 | */ |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 446 | SkPoint* growForRepeatedVerb(int /*SkPath::Verb*/ verb, int numVbs, SkScalar** weights); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 447 | |
| 448 | /** |
| 449 | * Increases the verb count 1, records the new verb, and creates room for the requisite number |
| 450 | * of additional points. A pointer to the first point is returned. Any new points are |
| 451 | * uninitialized. |
| 452 | */ |
robertphillips@google.com | 6b8dbb6 | 2013-12-12 23:03:51 +0000 | [diff] [blame] | 453 | SkPoint* growForVerb(int /*SkPath::Verb*/ verb, SkScalar weight); |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 454 | |
| 455 | /** |
| 456 | * Ensures that the free space available in the path ref is >= size. The verb and point counts |
Florin Malita | 3d413c5 | 2018-09-11 14:01:42 -0400 | [diff] [blame] | 457 | * are not changed. May allocate extra capacity, unless |exact| is true. |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 458 | */ |
Florin Malita | 3d413c5 | 2018-09-11 14:01:42 -0400 | [diff] [blame] | 459 | void makeSpace(size_t size, bool exact = false) { |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 460 | SkDEBUGCODE(this->validate();) |
Ben Wagner | ac32662 | 2017-07-31 16:57:01 -0400 | [diff] [blame] | 461 | if (size <= fFreeSpace) { |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 462 | return; |
| 463 | } |
Ben Wagner | ac32662 | 2017-07-31 16:57:01 -0400 | [diff] [blame] | 464 | size_t growSize = size - fFreeSpace; |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 465 | size_t oldSize = this->currSize(); |
Florin Malita | 3d413c5 | 2018-09-11 14:01:42 -0400 | [diff] [blame] | 466 | |
| 467 | if (!exact) { |
| 468 | // round to next multiple of 8 bytes |
| 469 | growSize = (growSize + 7) & ~static_cast<size_t>(7); |
| 470 | // we always at least double the allocation |
| 471 | if (growSize < oldSize) { |
| 472 | growSize = oldSize; |
| 473 | } |
| 474 | if (growSize < kMinSize) { |
| 475 | growSize = kMinSize; |
| 476 | } |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 477 | } |
Florin Malita | 3d413c5 | 2018-09-11 14:01:42 -0400 | [diff] [blame] | 478 | |
Ben Wagner | ac32662 | 2017-07-31 16:57:01 -0400 | [diff] [blame] | 479 | constexpr size_t maxSize = std::numeric_limits<size_t>::max(); |
| 480 | size_t newSize; |
| 481 | if (growSize <= maxSize - oldSize) { |
| 482 | newSize = oldSize + growSize; |
| 483 | } else { |
| 484 | SK_ABORT("Path too big."); |
| 485 | } |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 486 | // Note that realloc could memcpy more than we need. It seems to be a win anyway. TODO: |
| 487 | // encapsulate this. |
| 488 | fPoints = reinterpret_cast<SkPoint*>(sk_realloc_throw(fPoints, newSize)); |
| 489 | size_t oldVerbSize = fVerbCnt * sizeof(uint8_t); |
Ben Wagner | ac32662 | 2017-07-31 16:57:01 -0400 | [diff] [blame] | 490 | void* newVerbsDst = SkTAddOffset<void>(fPoints, newSize - oldVerbSize); |
| 491 | void* oldVerbsSrc = SkTAddOffset<void>(fPoints, oldSize - oldVerbSize); |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 492 | memmove(newVerbsDst, oldVerbsSrc, oldVerbSize); |
Ben Wagner | ac32662 | 2017-07-31 16:57:01 -0400 | [diff] [blame] | 493 | fVerbs = SkTAddOffset<uint8_t>(fPoints, newSize); |
robertphillips@google.com | aaf3e64 | 2013-10-02 17:49:50 +0000 | [diff] [blame] | 494 | fFreeSpace += growSize; |
| 495 | SkDEBUGCODE(this->validate();) |
| 496 | } |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 497 | |
| 498 | /** |
| 499 | * Private, non-const-ptr version of the public function verbsMemBegin(). |
| 500 | */ |
| 501 | uint8_t* verbsMemWritable() { |
robertphillips@google.com | 0308707 | 2013-10-02 16:42:21 +0000 | [diff] [blame] | 502 | SkDEBUGCODE(this->validate();) |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 503 | return fVerbs - fVerbCnt; |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Gets the total amount of space allocated for verbs, points, and reserve. |
| 508 | */ |
| 509 | size_t currSize() const { |
| 510 | return reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints); |
| 511 | } |
| 512 | |
commit-bot@chromium.org | 1f81fd6 | 2013-10-23 14:44:08 +0000 | [diff] [blame] | 513 | /** |
| 514 | * Called the first time someone calls CreateEmpty to actually create the singleton. |
| 515 | */ |
mtklein | 148ec59 | 2014-10-13 13:17:56 -0700 | [diff] [blame] | 516 | friend SkPathRef* sk_create_empty_pathref(); |
commit-bot@chromium.org | 1f81fd6 | 2013-10-23 14:44:08 +0000 | [diff] [blame] | 517 | |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 518 | void setIsOval(bool isOval, bool isCCW, unsigned start) { |
| 519 | fIsOval = isOval; |
| 520 | fRRectOrOvalIsCCW = isCCW; |
Kaloyan Donev | dfffb39 | 2018-03-20 10:38:31 +0200 | [diff] [blame] | 521 | fRRectOrOvalStartIdx = SkToU8(start); |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 522 | } |
robertphillips@google.com | 466310d | 2013-12-03 16:43:54 +0000 | [diff] [blame] | 523 | |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 524 | void setIsRRect(bool isRRect, bool isCCW, unsigned start) { |
| 525 | fIsRRect = isRRect; |
| 526 | fRRectOrOvalIsCCW = isCCW; |
Kaloyan Donev | dfffb39 | 2018-03-20 10:38:31 +0200 | [diff] [blame] | 527 | fRRectOrOvalStartIdx = SkToU8(start); |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 528 | } |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 529 | |
| 530 | // called only by the editor. Note that this is not a const function. |
skia.committer@gmail.com | 96f5fa0 | 2013-12-16 07:01:40 +0000 | [diff] [blame] | 531 | SkPoint* getPoints() { |
| 532 | SkDEBUGCODE(this->validate();) |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 533 | fIsOval = false; |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 534 | fIsRRect = false; |
| 535 | return fPoints; |
| 536 | } |
| 537 | |
| 538 | const SkPoint* getPoints() const { |
| 539 | SkDEBUGCODE(this->validate();) |
skia.committer@gmail.com | 96f5fa0 | 2013-12-16 07:01:40 +0000 | [diff] [blame] | 540 | return fPoints; |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 541 | } |
| 542 | |
senorblanco | 84cd621 | 2015-08-04 10:01:58 -0700 | [diff] [blame] | 543 | void callGenIDChangeListeners(); |
| 544 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 545 | enum { |
| 546 | kMinSize = 256, |
| 547 | }; |
| 548 | |
mtklein | 5c9c9be | 2014-12-01 06:59:54 -0800 | [diff] [blame] | 549 | mutable SkRect fBounds; |
robertphillips@google.com | ca0c838 | 2013-09-26 12:18:23 +0000 | [diff] [blame] | 550 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 551 | SkPoint* fPoints; // points to begining of the allocation |
| 552 | uint8_t* fVerbs; // points just past the end of the allocation (verbs grow backwards) |
| 553 | int fVerbCnt; |
| 554 | int fPointCnt; |
| 555 | size_t fFreeSpace; // redundant but saves computation |
reed@google.com | 277c3f8 | 2013-05-31 15:17:50 +0000 | [diff] [blame] | 556 | SkTDArray<SkScalar> fConicWeights; |
| 557 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 558 | enum { |
| 559 | kEmptyGenID = 1, // GenID reserved for path ref with zero points and zero verbs. |
| 560 | }; |
commit-bot@chromium.org | 1ab9f73 | 2013-10-30 18:57:55 +0000 | [diff] [blame] | 561 | mutable uint32_t fGenerationID; |
commit-bot@chromium.org | f48e475 | 2013-06-27 18:39:39 +0000 | [diff] [blame] | 562 | SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time. |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 563 | |
Chris Dalton | f30e493 | 2018-10-18 18:56:59 -0600 | [diff] [blame^] | 564 | SkMutex fGenIDChangeListenersMutex; |
| 565 | SkTArray<sk_sp<GenIDChangeListener>> fGenIDChangeListeners; |
senorblanco | 84cd621 | 2015-08-04 10:01:58 -0700 | [diff] [blame] | 566 | |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 567 | mutable uint8_t fBoundsIsDirty; |
Ben Wagner | cee46e5 | 2018-06-12 16:30:29 -0400 | [diff] [blame] | 568 | mutable bool fIsFinite; // only meaningful if bounds are valid |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 569 | |
Ben Wagner | cee46e5 | 2018-06-12 16:30:29 -0400 | [diff] [blame] | 570 | bool fIsOval; |
| 571 | bool fIsRRect; |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 572 | // Both the circle and rrect special cases have a notion of direction and starting point |
| 573 | // The next two variables store that information for either. |
Ben Wagner | cee46e5 | 2018-06-12 16:30:29 -0400 | [diff] [blame] | 574 | bool fRRectOrOvalIsCCW; |
bsalomon | 78d58d1 | 2016-05-27 09:17:04 -0700 | [diff] [blame] | 575 | uint8_t fRRectOrOvalStartIdx; |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 576 | uint8_t fSegmentMask; |
| 577 | |
robertphillips@google.com | 0efb21b | 2013-12-13 19:36:25 +0000 | [diff] [blame] | 578 | friend class PathRefTest_Private; |
caryclark | da707bf | 2015-11-19 14:47:43 -0800 | [diff] [blame] | 579 | friend class ForceIsRRect_Private; // unit test isRRect |
Florin Malita | 3d413c5 | 2018-09-11 14:01:42 -0400 | [diff] [blame] | 580 | friend class SkPath; |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 581 | }; |
| 582 | |
bsalomon@google.com | 1dfe88e | 2012-10-03 13:46:20 +0000 | [diff] [blame] | 583 | #endif |