2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPathRef_DEFINED
|
|
|
|
#define SkPathRef_DEFINED
|
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
#include "SkMatrix.h"
|
|
|
|
#include "SkPoint.h"
|
|
|
|
#include "SkRect.h"
|
2012-10-03 13:46:20 +00:00
|
|
|
#include "SkRefCnt.h"
|
2013-09-26 12:18:23 +00:00
|
|
|
#include "SkTDArray.h"
|
2012-10-03 13:46:20 +00:00
|
|
|
#include <stddef.h> // ptrdiff_t
|
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
class SkRBuffer;
|
|
|
|
class SkWBuffer;
|
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
/**
|
|
|
|
* Holds the path verbs and points. It is versioned by a generation ID. None of its public methods
|
|
|
|
* modify the contents. To modify or append to the verbs/points wrap the SkPathRef in an
|
|
|
|
* SkPathRef::Editor object. Installing the editor resets the generation ID. It also performs
|
|
|
|
* copy-on-write if the SkPathRef is shared by multipls SkPaths. The caller passes the Editor's
|
|
|
|
* constructor a SkAutoTUnref, which may be updated to point to a new SkPathRef after the editor's
|
|
|
|
* constructor returns.
|
|
|
|
*
|
|
|
|
* The points and verbs are stored in a single allocation. The points are at the begining of the
|
|
|
|
* allocation while the verbs are stored at end of the allocation, in reverse order. Thus the points
|
|
|
|
* and verbs both grow into the middle of the allocation until the meet. To access verb i in the
|
|
|
|
* verb array use ref.verbs()[~i] (because verbs() returns a pointer just beyond the first
|
|
|
|
* logical verb or the last verb in memory).
|
|
|
|
*/
|
2012-10-03 19:57:01 +00:00
|
|
|
|
2013-09-29 14:48:38 +00:00
|
|
|
class SK_API SkPathRef : public ::SkRefCnt {
|
2012-10-03 13:46:20 +00:00
|
|
|
public:
|
|
|
|
SK_DECLARE_INST_COUNT(SkPathRef);
|
|
|
|
|
|
|
|
class Editor {
|
|
|
|
public:
|
2013-06-27 18:39:39 +00:00
|
|
|
Editor(SkAutoTUnref<SkPathRef>* pathRef,
|
2012-10-03 13:46:20 +00:00
|
|
|
int incReserveVerbs = 0,
|
2013-09-27 17:48:49 +00:00
|
|
|
int incReservePoints = 0);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
2013-06-27 18:39:39 +00:00
|
|
|
~Editor() { SkDEBUGCODE(sk_atomic_dec(&fPathRef->fEditorsAttached);) }
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the array of points.
|
|
|
|
*/
|
|
|
|
SkPoint* points() { return fPathRef->fPoints; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the ith point. Shortcut for this->points() + i
|
|
|
|
*/
|
|
|
|
SkPoint* atPoint(int i) {
|
|
|
|
SkASSERT((unsigned) i < (unsigned) fPathRef->fPointCnt);
|
|
|
|
return this->points() + i;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the verb and allocates space for the number of points indicated by the verb. The
|
|
|
|
* return value is a pointer to where the points for the verb should be written.
|
|
|
|
*/
|
2013-09-27 17:48:49 +00:00
|
|
|
SkPoint* growForVerb(int /*SkPath::Verb*/ verb) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(fPathRef->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
return fPathRef->growForVerb(verb);
|
|
|
|
}
|
2012-10-03 13:46:20 +00:00
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
SkPoint* growForConic(SkScalar w);
|
2013-05-31 15:17:50 +00:00
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
/**
|
|
|
|
* 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>]).
|
|
|
|
*/
|
|
|
|
void grow(int newVerbs, int newPts, uint8_t** verbs, SkPoint** pts) {
|
|
|
|
SkASSERT(NULL != verbs);
|
|
|
|
SkASSERT(NULL != pts);
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(fPathRef->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
int oldVerbCnt = fPathRef->fVerbCnt;
|
|
|
|
int oldPointCnt = fPathRef->fPointCnt;
|
|
|
|
SkASSERT(verbs && pts);
|
|
|
|
fPathRef->grow(newVerbs, newPts);
|
|
|
|
*verbs = fPathRef->fVerbs - oldVerbCnt;
|
|
|
|
*pts = fPathRef->fPoints + oldPointCnt;
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(fPathRef->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the path ref to a new verb and point count. The new verbs and points are
|
|
|
|
* uninitialized.
|
|
|
|
*/
|
2013-05-31 15:17:50 +00:00
|
|
|
void resetToSize(int newVerbCnt, int newPointCnt, int newConicCount) {
|
|
|
|
fPathRef->resetToSize(newVerbCnt, newPointCnt, newConicCount);
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Gets the path ref that is wrapped in the Editor.
|
|
|
|
*/
|
|
|
|
SkPathRef* pathRef() { return fPathRef; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkPathRef* fPathRef;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Gets a path ref with no verbs or points.
|
|
|
|
*/
|
|
|
|
static SkPathRef* CreateEmpty() {
|
2013-06-27 18:39:39 +00:00
|
|
|
static SkPathRef* gEmptyPathRef;
|
2012-10-03 19:57:01 +00:00
|
|
|
if (!gEmptyPathRef) {
|
|
|
|
gEmptyPathRef = SkNEW(SkPathRef); // leak!
|
2013-10-02 16:42:58 +00:00
|
|
|
gEmptyPathRef->computeBounds(); // Premptively avoid a race to clear fBoundsIsDirty.
|
2012-10-03 19:57:01 +00:00
|
|
|
}
|
|
|
|
return SkRef(gEmptyPathRef);
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasComputedBounds() const {
|
|
|
|
return !fBoundsIsDirty;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Returns the bounds of the path's points. If the path contains 0 or 1
|
|
|
|
points, the bounds is set to (0,0,0,0), and isEmpty() will return true.
|
|
|
|
Note: this bounds may be larger than the actual shape, since curves
|
|
|
|
do not extend as far as their control points.
|
|
|
|
*/
|
2013-09-27 07:01:29 +00:00
|
|
|
const SkRect& getBounds() const {
|
2013-09-26 12:18:23 +00:00
|
|
|
if (fBoundsIsDirty) {
|
|
|
|
this->computeBounds();
|
|
|
|
}
|
|
|
|
return fBounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBounds(const SkRect& rect) {
|
|
|
|
SkASSERT(rect.fLeft <= rect.fRight && rect.fTop <= rect.fBottom);
|
|
|
|
fBounds = rect;
|
|
|
|
fBoundsIsDirty = false;
|
|
|
|
fIsFinite = fBounds.isFinite();
|
|
|
|
}
|
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
/**
|
|
|
|
* Transforms a path ref by a matrix, allocating a new one only if necessary.
|
|
|
|
*/
|
2013-06-27 18:39:39 +00:00
|
|
|
static void CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
|
2012-10-03 13:46:20 +00:00
|
|
|
const SkPathRef& src,
|
2013-09-27 17:48:49 +00:00
|
|
|
const SkMatrix& matrix);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
static SkPathRef* CreateFromBuffer(SkRBuffer* buffer
|
|
|
|
#ifndef DELETE_THIS_CODE_WHEN_SKPS_ARE_REBUILT_AT_V14_AND_ALL_OTHER_INSTANCES_TOO
|
|
|
|
, bool newFormat, int32_t oldPacked
|
|
|
|
#endif
|
|
|
|
);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rollsback a path ref to zero verbs and points with the assumption that the path ref will be
|
|
|
|
* repopulated with approximately the same number of verbs and points. A new path ref is created
|
|
|
|
* only if necessary.
|
|
|
|
*/
|
2013-09-27 17:48:49 +00:00
|
|
|
static void Rewind(SkAutoTUnref<SkPathRef>* pathRef);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
virtual ~SkPathRef() {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
sk_free(fPoints);
|
2012-10-03 19:57:01 +00:00
|
|
|
|
2013-06-27 18:39:39 +00:00
|
|
|
SkDEBUGCODE(fPoints = NULL;)
|
|
|
|
SkDEBUGCODE(fVerbs = NULL;)
|
|
|
|
SkDEBUGCODE(fVerbCnt = 0x9999999;)
|
|
|
|
SkDEBUGCODE(fPointCnt = 0xAAAAAAA;)
|
|
|
|
SkDEBUGCODE(fPointCnt = 0xBBBBBBB;)
|
|
|
|
SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;)
|
|
|
|
SkDEBUGCODE(fEditorsAttached = 0x7777777;)
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 16:42:21 +00:00
|
|
|
int countPoints() const { SkDEBUGCODE(this->validate();) return fPointCnt; }
|
|
|
|
int countVerbs() const { SkDEBUGCODE(this->validate();) return fVerbCnt; }
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a pointer one beyond the first logical verb (last verb in memory order).
|
|
|
|
*/
|
2013-10-02 16:42:21 +00:00
|
|
|
const uint8_t* verbs() const { SkDEBUGCODE(this->validate();) return fVerbs; }
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a const pointer to the first verb in memory (which is the last logical verb).
|
|
|
|
*/
|
|
|
|
const uint8_t* verbsMemBegin() const { return this->verbs() - fVerbCnt; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a const pointer to the first point.
|
|
|
|
*/
|
2013-10-02 16:42:21 +00:00
|
|
|
const SkPoint* points() const { SkDEBUGCODE(this->validate();) return fPoints; }
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shortcut for this->points() + this->countPoints()
|
|
|
|
*/
|
|
|
|
const SkPoint* pointsEnd() const { return this->points() + this->countPoints(); }
|
|
|
|
|
2013-10-02 16:42:21 +00:00
|
|
|
const SkScalar* conicWeights() const { SkDEBUGCODE(this->validate();) return fConicWeights.begin(); }
|
|
|
|
const SkScalar* conicWeightsEnd() const { SkDEBUGCODE(this->validate();) return fConicWeights.end(); }
|
2013-05-31 15:17:50 +00:00
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
/**
|
|
|
|
* Convenience methods for getting to a verb or point by index.
|
|
|
|
*/
|
|
|
|
uint8_t atVerb(int index) {
|
|
|
|
SkASSERT((unsigned) index < (unsigned) fVerbCnt);
|
|
|
|
return this->verbs()[~index];
|
|
|
|
}
|
|
|
|
const SkPoint& atPoint(int index) const {
|
|
|
|
SkASSERT((unsigned) index < (unsigned) fPointCnt);
|
|
|
|
return this->points()[index];
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
bool operator== (const SkPathRef& ref) const;
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes the path points and verbs to a buffer.
|
|
|
|
*/
|
2013-09-26 12:18:23 +00:00
|
|
|
void writeToBuffer(SkWBuffer* buffer);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the number of bytes that would be written in writeBuffer()
|
|
|
|
*/
|
2013-09-27 17:48:49 +00:00
|
|
|
uint32_t writeSize();
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
private:
|
2013-09-26 12:18:23 +00:00
|
|
|
enum SerializationOffsets {
|
|
|
|
kIsFinite_SerializationShift = 25, // requires 1 bit
|
|
|
|
};
|
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
SkPathRef() {
|
2013-09-26 12:18:23 +00:00
|
|
|
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
2012-10-03 13:46:20 +00:00
|
|
|
fPointCnt = 0;
|
|
|
|
fVerbCnt = 0;
|
|
|
|
fVerbs = NULL;
|
|
|
|
fPoints = NULL;
|
|
|
|
fFreeSpace = 0;
|
|
|
|
fGenerationID = kEmptyGenID;
|
2013-06-27 18:39:39 +00:00
|
|
|
SkDEBUGCODE(fEditorsAttached = 0;)
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
void copy(const SkPathRef& ref, int additionalReserveVerbs, int additionalReservePoints);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
// Return true if the computed bounds are finite.
|
|
|
|
static bool ComputePtBounds(SkRect* bounds, const SkPathRef& ref) {
|
|
|
|
int count = ref.countPoints();
|
|
|
|
if (count <= 1) { // we ignore just 1 point (moveto)
|
|
|
|
bounds->setEmpty();
|
|
|
|
return count ? ref.points()->isFinite() : true;
|
|
|
|
} else {
|
|
|
|
return bounds->setBoundsCheck(ref.points(), count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// called, if dirty, by getBounds()
|
|
|
|
void computeBounds() const {
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
SkASSERT(fBoundsIsDirty);
|
|
|
|
|
|
|
|
fIsFinite = ComputePtBounds(&fBounds, *this);
|
|
|
|
fBoundsIsDirty = false;
|
|
|
|
}
|
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
/** Makes additional room but does not change the counts or change the genID */
|
|
|
|
void incReserve(int additionalVerbs, int additionalPoints) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
size_t space = additionalVerbs * sizeof(uint8_t) + additionalPoints * sizeof (SkPoint);
|
|
|
|
this->makeSpace(space);
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
/** Resets the path ref with verbCount verbs and pointCount points, all uninitialized. Also
|
2012-10-03 13:46:20 +00:00
|
|
|
* allocates space for reserveVerb additional verbs and reservePoints additional points.*/
|
2013-05-31 15:17:50 +00:00
|
|
|
void resetToSize(int verbCount, int pointCount, int conicCount,
|
2013-10-02 17:49:50 +00:00
|
|
|
int reserveVerbs = 0, int reservePoints = 0) {
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
|
|
fGenerationID = 0;
|
|
|
|
|
|
|
|
size_t newSize = sizeof(uint8_t) * verbCount + sizeof(SkPoint) * pointCount;
|
|
|
|
size_t newReserve = sizeof(uint8_t) * reserveVerbs + sizeof(SkPoint) * reservePoints;
|
|
|
|
size_t minSize = newSize + newReserve;
|
|
|
|
|
|
|
|
ptrdiff_t sizeDelta = this->currSize() - minSize;
|
|
|
|
|
|
|
|
if (sizeDelta < 0 || static_cast<size_t>(sizeDelta) >= 3 * minSize) {
|
|
|
|
sk_free(fPoints);
|
|
|
|
fPoints = NULL;
|
|
|
|
fVerbs = NULL;
|
|
|
|
fFreeSpace = 0;
|
|
|
|
fVerbCnt = 0;
|
|
|
|
fPointCnt = 0;
|
|
|
|
this->makeSpace(minSize);
|
|
|
|
fVerbCnt = verbCount;
|
|
|
|
fPointCnt = pointCount;
|
|
|
|
fFreeSpace -= newSize;
|
|
|
|
} else {
|
|
|
|
fPointCnt = pointCount;
|
|
|
|
fVerbCnt = verbCount;
|
|
|
|
fFreeSpace = this->currSize() - minSize;
|
|
|
|
}
|
|
|
|
fConicWeights.setCount(conicCount);
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
}
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Increases the verb count by newVerbs and the point count be newPoints. New verbs and points
|
|
|
|
* are uninitialized.
|
|
|
|
*/
|
|
|
|
void grow(int newVerbs, int newPoints) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
size_t space = newVerbs * sizeof(uint8_t) + newPoints * sizeof (SkPoint);
|
|
|
|
this->makeSpace(space);
|
|
|
|
fVerbCnt += newVerbs;
|
|
|
|
fPointCnt += newPoints;
|
|
|
|
fFreeSpace -= space;
|
2013-09-26 12:18:23 +00:00
|
|
|
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Increases the verb count 1, records the new verb, and creates room for the requisite number
|
|
|
|
* of additional points. A pointer to the first point is returned. Any new points are
|
|
|
|
* uninitialized.
|
|
|
|
*/
|
2013-09-26 12:18:23 +00:00
|
|
|
SkPoint* growForVerb(int /*SkPath::Verb*/ verb);
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that the free space available in the path ref is >= size. The verb and point counts
|
|
|
|
* are not changed.
|
|
|
|
*/
|
2013-10-02 17:49:50 +00:00
|
|
|
void makeSpace(size_t size) {
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
ptrdiff_t growSize = size - fFreeSpace;
|
|
|
|
if (growSize <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
size_t oldSize = this->currSize();
|
|
|
|
// round to next multiple of 8 bytes
|
|
|
|
growSize = (growSize + 7) & ~static_cast<size_t>(7);
|
|
|
|
// we always at least double the allocation
|
|
|
|
if (static_cast<size_t>(growSize) < oldSize) {
|
|
|
|
growSize = oldSize;
|
|
|
|
}
|
|
|
|
if (growSize < kMinSize) {
|
|
|
|
growSize = kMinSize;
|
|
|
|
}
|
|
|
|
size_t newSize = oldSize + growSize;
|
|
|
|
// Note that realloc could memcpy more than we need. It seems to be a win anyway. TODO:
|
|
|
|
// encapsulate this.
|
|
|
|
fPoints = reinterpret_cast<SkPoint*>(sk_realloc_throw(fPoints, newSize));
|
|
|
|
size_t oldVerbSize = fVerbCnt * sizeof(uint8_t);
|
|
|
|
void* newVerbsDst = reinterpret_cast<void*>(
|
|
|
|
reinterpret_cast<intptr_t>(fPoints) + newSize - oldVerbSize);
|
|
|
|
void* oldVerbsSrc = reinterpret_cast<void*>(
|
|
|
|
reinterpret_cast<intptr_t>(fPoints) + oldSize - oldVerbSize);
|
|
|
|
memmove(newVerbsDst, oldVerbsSrc, oldVerbSize);
|
|
|
|
fVerbs = reinterpret_cast<uint8_t*>(reinterpret_cast<intptr_t>(fPoints) + newSize);
|
|
|
|
fFreeSpace += growSize;
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
}
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Private, non-const-ptr version of the public function verbsMemBegin().
|
|
|
|
*/
|
|
|
|
uint8_t* verbsMemWritable() {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2012-10-03 13:46:20 +00:00
|
|
|
return fVerbs - fVerbCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the total amount of space allocated for verbs, points, and reserve.
|
|
|
|
*/
|
|
|
|
size_t currSize() const {
|
|
|
|
return reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an ID that uniquely identifies the contents of the path ref. If two path refs have the
|
|
|
|
* same ID then they have the same verbs and points. However, two path refs may have the same
|
|
|
|
* contents but different genIDs. Zero is reserved and means an ID has not yet been determined
|
|
|
|
* for the path ref.
|
|
|
|
*/
|
2013-09-27 17:48:49 +00:00
|
|
|
int32_t genID() const;
|
2012-10-03 13:46:20 +00:00
|
|
|
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(void validate() const;)
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kMinSize = 256,
|
|
|
|
};
|
|
|
|
|
2013-09-26 12:18:23 +00:00
|
|
|
mutable SkRect fBounds;
|
|
|
|
mutable uint8_t fBoundsIsDirty;
|
|
|
|
mutable SkBool8 fIsFinite; // only meaningful if bounds are valid
|
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
SkPoint* fPoints; // points to begining of the allocation
|
|
|
|
uint8_t* fVerbs; // points just past the end of the allocation (verbs grow backwards)
|
|
|
|
int fVerbCnt;
|
|
|
|
int fPointCnt;
|
|
|
|
size_t fFreeSpace; // redundant but saves computation
|
2013-05-31 15:17:50 +00:00
|
|
|
SkTDArray<SkScalar> fConicWeights;
|
|
|
|
|
2012-10-03 13:46:20 +00:00
|
|
|
enum {
|
|
|
|
kEmptyGenID = 1, // GenID reserved for path ref with zero points and zero verbs.
|
|
|
|
};
|
|
|
|
mutable int32_t fGenerationID;
|
2013-06-27 18:39:39 +00:00
|
|
|
SkDEBUGCODE(int32_t fEditorsAttached;) // assert that only one editor in use at any time.
|
2012-10-03 13:46:20 +00:00
|
|
|
|
|
|
|
typedef SkRefCnt INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|