Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Unified Diff: include/core/SkPathRef.h

Issue 2006383002: preserve rrect/oval dir (Closed) Base URL: https://chromium.googlesource.com/skia.git@SkTypes
Patch Set: Improve tests Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPathRef.h
diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h
index 7b662b0a733ad79eb5b358a9f014ce50211f824e..2c63904ae38fa10407adb901ab22c90f61db9a6f 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,8 @@ private:
fSegmentMask = 0;
fIsOval = false;
fIsRRect = false;
+ SkDEBUGCODE(fRRectOrOvalIsCCW = 0xAB);
+ SkDEBUGCODE(fRRectOrOvalStartIdx = 0xAC);
SkDEBUGCODE(fEditorsAttached = 0;)
SkDEBUGCODE(this->validate();)
}
@@ -454,9 +481,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 +534,8 @@ private:
SkBool8 fIsOval;
SkBool8 fIsRRect;
+ SkBool8 fRRectOrOvalIsCCW;
+ uint8_t fRRectOrOvalStartIdx;
uint8_t fSegmentMask;
friend class PathRefTest_Private;
« no previous file with comments | « include/core/SkPath.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698