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