aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-10 13:51:32 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-10 13:51:32 +0000
commitf66cf72c6810766234d06bb96696b594a99dcd02 (patch)
treef2b69e7436603f6e8219a6390de9028b7ca3310a /include
parent2693eb95233f16ed58b7b37c6b497fb8991b0396 (diff)
Move fLastMoveToIndex from SkPath to SkPathRef
Diffstat (limited to 'include')
-rw-r--r--include/core/SkPath.h6
-rw-r--r--include/core/SkPathRef.h14
2 files changed, 18 insertions, 2 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index dd7a672cdd..2d63bb2353 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -962,7 +962,6 @@ private:
SkAutoTUnref<SkPathRef> fPathRef;
- int fLastMoveToIndex;
uint8_t fFillType;
mutable uint8_t fConvexity;
mutable uint8_t fDirection;
@@ -998,7 +997,10 @@ private:
// SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
// SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
//
- inline void injectMoveToIfNeeded();
+ void injectMoveToIfNeeded() {
+ SkPathRef::Editor ed(&fPathRef);
+ ed.injectMoveToIfNeeded();
+ }
inline bool hasOnlyMoveTos() const;
diff --git a/include/core/SkPathRef.h b/include/core/SkPathRef.h
index 8802714243..3c663f7f7d 100644
--- a/include/core/SkPathRef.h
+++ b/include/core/SkPathRef.h
@@ -104,6 +104,13 @@ public:
void setBounds(const SkRect& rect) { fPathRef->setBounds(rect); }
+ // In some cases we need to inject a leading moveTo before we add points
+ // for lineTo, quadTo, conicTo, cubicTo
+ //
+ // SkPath path; path.lineTo(...); <--- need a leading moveTo(0, 0)
+ // SkPath path; ... path.close(); path.lineTo(...) <-- need a moveTo(previous moveTo)
+ void injectMoveToIfNeeded() { fPathRef->injectMoveToIfNeeded(); }
+
private:
SkPathRef* fPathRef;
};
@@ -254,6 +261,9 @@ public:
uint32_t genID() const;
private:
+ // flag to require a moveTo if we begin with something else, like lineTo etc.
+ static const int kINITIAL_LASTMOVETOINDEX_VALUE = ~0;
+
enum SerializationOffsets {
kIsFinite_SerializationShift = 25, // requires 1 bit
kIsOval_SerializationShift = 24, // requires 1 bit
@@ -261,6 +271,7 @@ private:
};
SkPathRef() {
+ fLastMoveToIndex = kINITIAL_LASTMOVETOINDEX_VALUE;
fBoundsIsDirty = true; // this also invalidates fIsFinite
fPointCnt = 0;
fVerbCnt = 0;
@@ -348,6 +359,8 @@ private:
SkDEBUGCODE(this->validate();)
}
+ void injectMoveToIfNeeded();
+
/**
* Increases the verb count by numVbs and point count by the required amount.
* The new points are uninitialized. All the new verbs are set to the specified
@@ -433,6 +446,7 @@ private:
};
mutable SkRect fBounds;
+ int fLastMoveToIndex;
uint8_t fSegmentMask;
mutable uint8_t fBoundsIsDirty;
mutable SkBool8 fIsFinite; // only meaningful if bounds are valid