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

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: fixed comment 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 12546)
+++ include/core/SkPathRef.h (working copy)
@@ -71,22 +71,10 @@
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 additional lines and returns a pointer to the new
+ * 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* growForLines(int numLines) { return fPathRef->growForLines(numLines); }
bsalomon 2013/12/09 16:16:04 This feels a little weirdly specialized in SkPathR
robertphillips 2013/12/09 19:01:52 Done.
/**
* Resets the path ref to a new verb and point count. The new verbs and points are
@@ -123,6 +111,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
@@ -226,7 +221,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 +235,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 +253,7 @@
enum SerializationOffsets {
kIsFinite_SerializationShift = 25, // requires 1 bit
kIsOval_SerializationShift = 24, // requires 1 bit
+ kSegmentMask_SerializationShift = 0 // requires 4 bits
};
SkPathRef() {
@@ -268,6 +264,7 @@
fPoints = NULL;
fFreeSpace = 0;
fGenerationID = kEmptyGenID;
+ fSegmentMask = 0;
fIsOval = false;
SkDEBUGCODE(fEditorsAttached = 0;)
SkDEBUGCODE(this->validate();)
@@ -311,6 +308,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 +338,10 @@
}
/**
- * Increases the verb count by newVerbs and the point count be newPoints. New verbs and points
- * are uninitialized.
+ * Increases the verb and point count by numLines. The new points
+ * are uninitialized. All the new verbs are set to kLine_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* growForLines(int numLines);
/**
* Increases the verb count 1, records the new verb, and creates room for the requisite number
@@ -425,6 +414,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