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

Unified Diff: include/core/SkPath.h

Issue 25787002: Move more of SkPath into SkPathRef (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleaned up Created 7 years, 2 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 | « no previous file | include/core/SkPathRef.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkPath.h
===================================================================
--- include/core/SkPath.h (revision 11888)
+++ include/core/SkPath.h (working copy)
@@ -93,7 +93,7 @@
void toggleInverseFillType() {
fFillType ^= 2;
GEN_ID_INC;
- }
+ }
enum Convexity {
kUnknown_Convexity,
@@ -106,11 +106,7 @@
* then this function will attempt to compute the convexity (and cache the result).
*/
Convexity getConvexity() const {
- if (kUnknown_Convexity != fConvexity) {
- return static_cast<Convexity>(fConvexity);
- } else {
- return this->internalGetConvexity();
- }
+ return static_cast<Convexity>(fPathRef->getConvexity());
}
/**
@@ -119,7 +115,9 @@
* ComputeConvexity and cache its return value if the current setting is
* kUnknown.
*/
- Convexity getConvexityOrUnknown() const { return (Convexity)fConvexity; }
+ Convexity getConvexityOrUnknown() const {
+ return static_cast<Convexity>(fPathRef->getConvexityOrUnknown());
+ }
/**
* Store a convexity setting in the path. There is no automatic check to
@@ -162,7 +160,7 @@
* optimization for performance and so some paths that are in
* fact ovals can report false.
*/
- bool isOval(SkRect* rect) const;
+ bool isOval(SkRect* rect) const { return fPathRef->isOval(rect); }
/** Clear any lines and curves from the path, making it empty. This frees up
internal storage associated with those segments.
@@ -457,8 +455,8 @@
@param dy3 The amount to add to the y-coordinate of the last point on
this contour, to specify the end point of a cubic curve
*/
- void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
- SkScalar x3, SkScalar y3);
+ void rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2,
+ SkScalar x3, SkScalar y3);
/** Append the specified arc to the path as a new contour. If the start of
the path is different from the path's current last point, then an
@@ -472,8 +470,8 @@
treated mod 360.
@param forceMoveTo If true, always begin a new contour with the arc
*/
- void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
- bool forceMoveTo);
+ void arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
+ bool forceMoveTo);
/** Append a line and arc to the current path. This is the same as the
PostScript call "arct".
@@ -552,7 +550,17 @@
* the dir parameter. If the direction was determined, it is cached to make
* subsequent calls return quickly.
*/
- bool cheapComputeDirection(Direction* dir) const;
+ bool cheapComputeDirection(Direction* dir) const {
+ bool result;
+ if (NULL != dir) {
+ int intDir = *dir;
+ result = fPathRef->cheapComputeDirection(&intDir);
+ *dir = static_cast<Direction>(intDir);
+ } else {
+ result = fPathRef->cheapComputeDirection(NULL);
+ }
+ return result;
+ }
/**
* Returns true if the path's direction can be computed via
@@ -789,7 +797,7 @@
* set if the path contains 1 or more segments of that type.
* Returns 0 for an empty path (no segments).
*/
- uint32_t getSegmentMasks() const { return fSegmentMask; }
+ uint32_t getSegmentMasks() const { return fPathRef->getSegmentMasks(); }
enum Verb {
kMove_Verb, //!< iter.next returns 1 point
@@ -814,8 +822,10 @@
public:
Iter();
Iter(const SkPath&, bool forceClose);
+ Iter(const SkPathRef*, bool forceClose);
void setPath(const SkPath&, bool forceClose);
+ void setPathRef(const SkPathRef*, bool forceClose);
/** Return the next verb in this iteration of the path. When all
segments have been visited, return kDone_Verb.
@@ -932,26 +942,21 @@
enum SerializationOffsets {
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
kNewFormat_SerializationShift = 28, // requires 1 bit
-#endif
- kDirection_SerializationShift = 26, // requires 2 bits
-#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
- // rename to kUnused_SerializationShift
+ kOldDirection_SerializationShift = 26, // requires 2 bits
kOldIsFinite_SerializationShift = 25, // 1 bit
-#endif
- kIsOval_SerializationShift = 24, // requires 1 bit
- kConvexity_SerializationShift = 16, // requires 8 bits
+ kOldIsOval_SerializationShift = 24, // requires 1 bit
+ kOldConvexity_SerializationShift = 16, // requires 8 bits
+#endif
+ // TODO: make this shift be 0
kFillType_SerializationShift = 8, // requires 8 bits
- kSegmentMask_SerializationShift = 0 // requires 4 bits
+#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
+ kOldSegmentMask_SerializationShift = 0 // requires 4 bits
+#endif
};
SkAutoTUnref<SkPathRef> fPathRef;
- int fLastMoveToIndex;
uint8_t fFillType;
- uint8_t fSegmentMask;
- mutable uint8_t fConvexity;
- mutable uint8_t fDirection;
- mutable SkBool8 fIsOval;
#ifdef SK_BUILD_FOR_ANDROID
uint32_t fGenerationID;
const SkPath* fSourcePath;
@@ -984,18 +989,8 @@
*/
void reversePathTo(const SkPath&);
- // called before we add points for lineTo, quadTo, cubicTo, checking to see
- // if we need to inject a leading moveTo first
- //
- // SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
- // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
- //
- inline void injectMoveToIfNeeded();
-
inline bool hasOnlyMoveTos() const;
- Convexity internalGetConvexity() const;
-
bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts,
bool* isClosed, Direction* direction) const;
@@ -1007,18 +1002,10 @@
return fPathRef->hasComputedBounds();
}
-
- // 'rect' needs to be sorted
- void setBounds(const SkRect& rect) {
- fPathRef->setBounds(rect);
- }
-
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
friend class SkPathRef; // just for SerializationOffsets
#endif
friend class SkAutoPathBoundsUpdate;
- friend class SkAutoDisableOvalCheck;
- friend class SkAutoDisableDirectionCheck;
friend class SkBench_AddPathTest; // perf test pathTo/reversePathTo
};
« no previous file with comments | « no previous file | include/core/SkPathRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698