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

Unified Diff: include/core/SkPathRef.h

Issue 105083003: Move segment mask from SkPath to SkPathRef (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Moved growForLines to growForRepeatedVerb Created 7 years 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
===================================================================
--- include/core/SkPathRef.h (revision 12570)
+++ include/core/SkPathRef.h (working copy)
@@ -71,23 +71,16 @@
SkPoint* growForConic(SkScalar w);
/**
- * Allocates space for additional verbs and points and returns pointers to the new verbs and
- * points. verbs will point one beyond the first new verb (index it using [~<i>]). pts points
- * at the first new point (indexed normally [<i>]).
+ * Allocates space for multiple instances of a particular verb and the
+ * requisite points.
+ * The return pointer points at the first new point (indexed normally [<i>]).
*/
- void grow(int newVerbs, int newPts, uint8_t** verbs, SkPoint** pts) {
- SkASSERT(NULL != verbs);
- SkASSERT(NULL != pts);
- SkDEBUGCODE(fPathRef->validate();)
- int oldVerbCnt = fPathRef->fVerbCnt;
- int oldPointCnt = fPathRef->fPointCnt;
- SkASSERT(verbs && pts);
- fPathRef->grow(newVerbs, newPts);
- *verbs = fPathRef->fVerbs - oldVerbCnt;
- *pts = fPathRef->fPoints + oldPointCnt;
- SkDEBUGCODE(fPathRef->validate();)
+ SkPoint* growForRepeatedVerb(int /*SkPath::Verb*/ verb, int numVbs) {
bsalomon 2013/12/09 20:51:21 One more request around this: Since this is publi
robertphillips 2013/12/10 15:30:51 Done.
+ return fPathRef->growForRepeatedVerb(verb, numVbs);
}
+ SkPoint* growForConics(int numConics, SkScalar* weights);
+
/**
* Resets the path ref to a new verb and point count. The new verbs and points are
* uninitialized.
@@ -123,6 +116,13 @@
return SkToBool(fIsFinite);
}
+ /**
+ * Returns a mask, where each bit corresponding to a SegmentMask is
+ * 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; }
+
/** Returns true if the path is an oval.
*
* @param rect returns the bounding rect of this oval. It's a circle
@@ -199,6 +199,7 @@
int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; }
int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; }
+ int countWeights() const { SkDEBUGCODE(this->validate();) return fConicWeights.count(); }
/**
* Returns a pointer one beyond the first logical verb (last verb in memory order).
@@ -226,7 +227,7 @@
/**
* Convenience methods for getting to a verb or point by index.
*/
- uint8_t atVerb(int index) {
+ uint8_t atVerb(int index) const {
SkASSERT((unsigned) index < (unsigned) fVerbCnt);
return this->verbs()[~index];
}
@@ -240,12 +241,12 @@
/**
* Writes the path points and verbs to a buffer.
*/
- void writeToBuffer(SkWBuffer* buffer);
+ void writeToBuffer(SkWBuffer* buffer) const;
/**
* Gets the number of bytes that would be written in writeBuffer()
*/
- uint32_t writeSize();
+ uint32_t writeSize() const;
/**
* Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
@@ -258,6 +259,7 @@
enum SerializationOffsets {
kIsFinite_SerializationShift = 25, // requires 1 bit
kIsOval_SerializationShift = 24, // requires 1 bit
+ kSegmentMask_SerializationShift = 0 // requires 4 bits
};
SkPathRef() {
@@ -268,6 +270,7 @@
fPoints = NULL;
fFreeSpace = 0;
fGenerationID = kEmptyGenID;
+ fSegmentMask = 0;
fIsOval = false;
SkDEBUGCODE(fEditorsAttached = 0;)
SkDEBUGCODE(this->validate();)
@@ -311,6 +314,7 @@
fBoundsIsDirty = true; // this also invalidates fIsFinite
fGenerationID = 0;
+ fSegmentMask = 0;
fIsOval = false;
size_t newSize = sizeof(uint8_t) * verbCount + sizeof(SkPoint) * pointCount;
@@ -340,19 +344,11 @@
}
/**
- * Increases the verb count by newVerbs and the point count be newPoints. New verbs and points
- * are uninitialized.
+ * 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
+ * verb.
*/
- void grow(int newVerbs, int newPoints) {
- SkDEBUGCODE(this->validate();)
- size_t space = newVerbs * sizeof(uint8_t) + newPoints * sizeof (SkPoint);
- this->makeSpace(space);
- fVerbCnt += newVerbs;
- fPointCnt += newPoints;
- fFreeSpace -= space;
- fBoundsIsDirty = true; // this also invalidates fIsFinite
- SkDEBUGCODE(this->validate();)
- }
+ SkPoint* growForRepeatedVerb(int /*SkPath::Verb*/ verb, int numVbs);
/**
* Increases the verb count 1, records the new verb, and creates room for the requisite number
@@ -425,6 +421,7 @@
};
mutable SkRect fBounds;
+ uint8_t fSegmentMask;
mutable uint8_t fBoundsIsDirty;
mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
mutable SkBool8 fIsOval;
« 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