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

Unified Diff: include/core/SkPathRef.h

Issue 2012233002: Make SkPath::isOval() and SkPath::isRRect return the orientation and starting index. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: record mod'ed start indices 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..0002b594b48aa724882e2488509e8fbc927bbadc 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 = SkToBool(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 = SkToBool(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.
+ SkDEBUGCODE(fRRectOrOvalIsCCW = false);
+ 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,10 @@ private:
SkBool8 fIsOval;
SkBool8 fIsRRect;
+ // Both the circle and rrect special cases have a notion of direction and starting point
+ // The next two variables store that information for either.
+ 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