Chromium Code Reviews| Index: include/core/SkPath.h |
| =================================================================== |
| --- include/core/SkPath.h (revision 11438) |
| +++ include/core/SkPath.h (working copy) |
| @@ -12,6 +12,7 @@ |
| #include "SkInstCnt.h" |
| #include "SkMatrix.h" |
| +#include "SkPathRef.h" |
|
reed1
2013/09/24 17:32:17
// TODO: refactor this header to move more the imp
robertphillips
2013/09/26 12:18:44
Done - although I put the TODO in SkPathRef.h not
|
| #include "SkTDArray.h" |
| #include "SkRefCnt.h" |
| @@ -27,7 +28,6 @@ |
| class SkWriter32; |
| class SkAutoPathBoundsUpdate; |
| class SkString; |
| -class SkPathRef; |
| class SkRRect; |
| /** \class SkPath |
| @@ -181,17 +181,18 @@ |
| @return true if the path is empty (contains no lines or curves) |
| */ |
| - bool isEmpty() const; |
| + bool isEmpty() const { |
| + SkDEBUGCODE(this->validate();) |
| + return 0 == fPathRef->countVerbs(); |
| + } |
| /** |
| * Returns true if all of the points in this path are finite, meaning there |
| * are no infinities and no NaNs. |
| */ |
| bool isFinite() const { |
| - if (fBoundsIsDirty) { |
| - this->computeBounds(); |
| - } |
| - return SkToBool(fIsFinite); |
| + SkDEBUGCODE(this->validate();) |
| + return fPathRef->isFinite(); |
| } |
| /** Test a line for zero length |
| @@ -281,10 +282,7 @@ |
| do not extend as far as their control points. |
| */ |
| const SkRect& getBounds() const { |
| - if (fBoundsIsDirty) { |
| - this->computeBounds(); |
| - } |
| - return fBounds; |
| + return fPathRef->getBounds(); |
| } |
| /** Calling this will, if the internal cache of the bounds is out of date, |
| @@ -932,24 +930,27 @@ |
| private: |
| 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 |
| - kIsFinite_SerializationShift = 25, // requires 1 bit |
| +#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO |
| + // rename to kUnused_SerializationShift |
| + kOldIsFinite_SerializationShift = 25, // 1 bit |
| +#endif |
| kIsOval_SerializationShift = 24, // requires 1 bit |
| - kConvexity_SerializationShift = 16, // requires 2 bits |
| - kFillType_SerializationShift = 8, // requires 2 bits |
| + kConvexity_SerializationShift = 16, // requires 8 bits |
| + kFillType_SerializationShift = 8, // requires 8 bits |
| kSegmentMask_SerializationShift = 0 // requires 4 bits |
| }; |
| SkAutoTUnref<SkPathRef> fPathRef; |
| - mutable SkRect fBounds; |
| int fLastMoveToIndex; |
| uint8_t fFillType; |
| uint8_t fSegmentMask; |
| - mutable uint8_t fBoundsIsDirty; |
| mutable uint8_t fConvexity; |
| mutable uint8_t fDirection; |
| - mutable SkBool8 fIsFinite; // only meaningful if bounds are valid |
| mutable SkBool8 fIsOval; |
| #ifdef SK_BUILD_FOR_ANDROID |
| uint32_t fGenerationID; |
| @@ -968,9 +969,6 @@ |
| */ |
| void copyFields(const SkPath& that); |
| - // called, if dirty, by getBounds() |
| - void computeBounds() const; |
| - |
| friend class Iter; |
| friend class SkPathStroker; |
| @@ -1001,6 +999,23 @@ |
| bool isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts, |
| bool* isClosed, Direction* direction) const; |
| + /** Returns if the path can return a bound at no cost (true) or will have to |
| + perform some computation (false). |
| + */ |
| + bool hasComputedBounds() const { |
| + SkDEBUGCODE(this->validate();) |
| + 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; |