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

Unified Diff: include/core/SkPathRef.h

Issue 1461763004: add SkPath::isRRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: incorporated Rob's comments Created 5 years, 1 month 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 c09f6e87e471c1d8320a11156ef9dc64d0dbb92a..86f55c9bcae2aec63bcc5e6c529bca2969496d52 100644
--- a/include/core/SkPathRef.h
+++ b/include/core/SkPathRef.h
@@ -11,6 +11,7 @@
#include "SkMatrix.h"
#include "SkPoint.h"
+#include "SkRRect.h"
#include "SkRect.h"
#include "SkRefCnt.h"
#include "SkTDArray.h"
@@ -100,12 +101,39 @@ public:
void setIsOval(bool isOval) { fPathRef->setIsOval(isOval); }
+ void setIsRRect(bool isRRect) { fPathRef->setIsRRect(isRRect); }
+
void setBounds(const SkRect& rect) { fPathRef->setBounds(rect); }
private:
SkPathRef* fPathRef;
};
+ class SK_API Iter {
+ public:
+ Iter();
+ Iter(const SkPathRef&);
+
+ void setPathRef(const SkPathRef&);
+
+ /** Return the next verb in this iteration of the path. When all
+ segments have been visited, return kDone_Verb.
+
+ @param pts The points representing the current verb and/or segment
+ This must not be NULL.
+ @return The verb for the current segment
+ */
+ uint8_t next(SkPoint pts[4]);
+
+ SkScalar conicWeight() const { return *fConicWeights; }
+
+ private:
+ const SkPoint* fPts;
+ const uint8_t* fVerbs;
+ const uint8_t* fVerbStop;
+ const SkScalar* fConicWeights;
+ };
+
public:
/**
* Gets a path ref with no verbs or points.
@@ -142,12 +170,20 @@ public:
*/
bool isOval(SkRect* rect) const {
if (fIsOval && rect) {
- *rect = getBounds();
+ *rect = this->getBounds();
}
return SkToBool(fIsOval);
}
+ bool isRRect(SkRRect* rrect) const {
+ if (fIsRRect && rrect) {
+ *rrect = this->getRRect();
+ }
+ return SkToBool(fIsRRect);
+ }
+
+
bool hasComputedBounds() const {
return !fBoundsIsDirty;
}
@@ -164,6 +200,8 @@ public:
return fBounds;
}
+ SkRRect getRRect() const;
+
/**
* Transforms a path ref by a matrix, allocating a new one only if necessary.
*/
@@ -250,6 +288,7 @@ 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
@@ -265,6 +304,7 @@ private:
fGenerationID = kEmptyGenID;
fSegmentMask = 0;
fIsOval = false;
+ fIsRRect = false;
SkDEBUGCODE(fEditorsAttached = 0;)
SkDEBUGCODE(this->validate();)
}
@@ -312,6 +352,7 @@ private:
fSegmentMask = 0;
fIsOval = false;
+ fIsRRect = false;
size_t newSize = sizeof(uint8_t) * verbCount + sizeof(SkPoint) * pointCount;
size_t newReserve = sizeof(uint8_t) * reserveVerbs + sizeof(SkPoint) * reservePoints;
@@ -411,9 +452,18 @@ private:
void setIsOval(bool isOval) { fIsOval = isOval; }
+ void setIsRRect(bool isRRect) { fIsRRect = isRRect; }
+
+ // called only by the editor. Note that this is not a const function.
SkPoint* getPoints() {
SkDEBUGCODE(this->validate();)
fIsOval = false;
+ fIsRRect = false;
+ return fPoints;
+ }
+
+ const SkPoint* getPoints() const {
+ SkDEBUGCODE(this->validate();)
return fPoints;
}
@@ -424,11 +474,6 @@ private:
};
mutable SkRect fBounds;
- mutable uint8_t fBoundsIsDirty;
- mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
-
- SkBool8 fIsOval;
- uint8_t fSegmentMask;
SkPoint* fPoints; // points to begining of the allocation
uint8_t* fVerbs; // points just past the end of the allocation (verbs grow backwards)
@@ -445,7 +490,15 @@ private:
SkTDArray<GenIDChangeListener*> fGenIDChangeListeners; // pointers are owned
+ mutable uint8_t fBoundsIsDirty;
+ mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
+
+ SkBool8 fIsOval;
+ SkBool8 fIsRRect;
+ uint8_t fSegmentMask;
+
friend class PathRefTest_Private;
+ friend class ForceIsRRect_Private; // unit test isRRect
typedef SkRefCnt INHERITED;
};
« 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