Chromium Code Reviews| Index: include/core/SkPathRef.h |
| diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h |
| index 7b662b0a733ad79eb5b358a9f014ce50211f824e..4d7a8d4db722be19b1ebb3e4b54283eda5cceb67 100644 |
| --- a/include/core/SkPathRef.h |
| +++ b/include/core/SkPathRef.h |
| @@ -100,9 +100,13 @@ public: |
| */ |
| SkPathRef* pathRef() { return fPathRef; } |
| - void setIsOval(bool isOval) { fPathRef->setIsOval(isOval); } |
| + void setIsOval(bool isOval, bool isCCW, unsigned start) { |
| + fPathRef->setIsOval(isOval, isCCW, start); |
| + } |
| - void setIsRRect(bool isRRect) { fPathRef->setIsRRect(isRRect); } |
| + void setIsRRect(bool isRRect, bool isCCW, unsigned start) { |
| + fPathRef->setIsRRect(isRRect, isCCW, start); |
| + } |
| void setBounds(const SkRect& rect) { fPathRef->setBounds(rect); } |
| @@ -164,23 +168,42 @@ public: |
| * |
| * @param rect returns the bounding rect of this oval. It's a circle |
| * if the height and width are the same. |
| + * @param isCCW is the oval CCW (or CW if false). |
| + * @param start indicates where the contour starts on the oval (see |
| + * SkPath::addOval for intepretation of the index). |
| * |
| * @return true if this path is an oval. |
| * Tracking whether a path is an oval is considered an |
| * optimization for performance and so some paths that are in |
| * fact ovals can report false. |
| */ |
| - bool isOval(SkRect* rect) const { |
| - if (fIsOval && rect) { |
| - *rect = this->getBounds(); |
| + bool isOval(SkRect* rect, bool* isCCW, unsigned* start) const { |
| + if (fIsOval) { |
| + if (rect) { |
| + *rect = this->getBounds(); |
| + } |
| + if (isCCW) { |
| + *isCCW = fRRectOrOvalIsCCW; |
| + } |
| + if (start) { |
| + *start = fRRectOrOvalStartIdx; |
| + } |
| } |
| return SkToBool(fIsOval); |
| } |
| - bool isRRect(SkRRect* rrect) const { |
| - if (fIsRRect && rrect) { |
| - *rrect = this->getRRect(); |
| + bool isRRect(SkRRect* rrect, bool* isCCW, unsigned* start) const { |
| + if (fIsRRect) { |
| + if (rrect) { |
| + *rrect = this->getRRect(); |
| + } |
| + if (isCCW) { |
| + *isCCW = fRRectOrOvalIsCCW; |
| + } |
| + if (start) { |
| + *start = fRRectOrOvalStartIdx; |
| + } |
| } |
| return SkToBool(fIsRRect); |
| } |
| @@ -292,10 +315,12 @@ public: |
| private: |
| enum SerializationOffsets { |
| - kIsRRect_SerializationShift = 26, // requires 1 bit |
| - kIsFinite_SerializationShift = 25, // requires 1 bit |
| - kIsOval_SerializationShift = 24, // requires 1 bit |
| - kSegmentMask_SerializationShift = 0 // requires 4 bits |
| + kRRectOrOvalStartIdx_SerializationShift = 28, // requires 3 bits |
| + kRRectOrOvalIsCCW_SerializationShift = 27, // requires 1 bit |
| + kIsRRect_SerializationShift = 26, // requires 1 bit |
| + kIsFinite_SerializationShift = 25, // requires 1 bit |
| + kIsOval_SerializationShift = 24, // requires 1 bit |
| + kSegmentMask_SerializationShift = 0 // requires 4 bits |
| }; |
| SkPathRef() { |
| @@ -309,6 +334,9 @@ private: |
| fSegmentMask = 0; |
| fIsOval = false; |
| fIsRRect = false; |
| + // The next two values don't matter unless fIsOval or fIsRRect are true. |
|
robertphillips
2016/05/26 15:57:58
0xAB -> false ?
bsalomon
2016/05/26 18:25:43
Done.
|
| + SkDEBUGCODE(fRRectOrOvalIsCCW = 0xAB); |
| + SkDEBUGCODE(fRRectOrOvalStartIdx = 0xAC); |
| SkDEBUGCODE(fEditorsAttached = 0;) |
| SkDEBUGCODE(this->validate();) |
| } |
| @@ -454,9 +482,17 @@ private: |
| */ |
| friend SkPathRef* sk_create_empty_pathref(); |
| - void setIsOval(bool isOval) { fIsOval = isOval; } |
| + void setIsOval(bool isOval, bool isCCW, unsigned start) { |
| + fIsOval = isOval; |
| + fRRectOrOvalIsCCW = isCCW; |
| + fRRectOrOvalStartIdx = start; |
| + } |
| - void setIsRRect(bool isRRect) { fIsRRect = isRRect; } |
| + void setIsRRect(bool isRRect, bool isCCW, unsigned start) { |
| + fIsRRect = isRRect; |
| + fRRectOrOvalIsCCW = isCCW; |
| + fRRectOrOvalStartIdx = start; |
| + } |
| // called only by the editor. Note that this is not a const function. |
| SkPoint* getPoints() { |
| @@ -499,6 +535,8 @@ private: |
| SkBool8 fIsOval; |
| SkBool8 fIsRRect; |
|
robertphillips
2016/05/26 15:57:58
// Both the circle and rrect special cases have a
bsalomon
2016/05/26 18:25:43
Done
|
| + SkBool8 fRRectOrOvalIsCCW; |
| + uint8_t fRRectOrOvalStartIdx; |
| uint8_t fSegmentMask; |
| friend class PathRefTest_Private; |