2013-09-26 12:18:23 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkBuffer.h"
|
2016-05-05 23:05:56 +00:00
|
|
|
#include "SkOnce.h"
|
2013-09-26 12:18:23 +00:00
|
|
|
#include "SkPath.h"
|
|
|
|
#include "SkPathRef.h"
|
2016-02-02 14:14:47 +00:00
|
|
|
#include <limits>
|
2013-09-26 12:18:23 +00:00
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
|
|
|
|
int incReserveVerbs,
|
|
|
|
int incReservePoints)
|
|
|
|
{
|
|
|
|
if ((*pathRef)->unique()) {
|
|
|
|
(*pathRef)->incReserve(incReserveVerbs, incReservePoints);
|
|
|
|
} else {
|
2015-08-26 20:07:48 +00:00
|
|
|
SkPathRef* copy = new SkPathRef;
|
2013-09-27 17:48:49 +00:00
|
|
|
copy->copy(**pathRef, incReserveVerbs, incReservePoints);
|
|
|
|
pathRef->reset(copy);
|
|
|
|
}
|
|
|
|
fPathRef = *pathRef;
|
2015-08-04 17:01:58 +00:00
|
|
|
fPathRef->callGenIDChangeListeners();
|
2013-09-27 17:48:49 +00:00
|
|
|
fPathRef->fGenerationID = 0;
|
|
|
|
SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);)
|
2013-09-26 12:18:23 +00:00
|
|
|
}
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2014-01-24 22:38:39 +00:00
|
|
|
|
2015-08-04 17:01:58 +00:00
|
|
|
SkPathRef::~SkPathRef() {
|
|
|
|
this->callGenIDChangeListeners();
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
sk_free(fPoints);
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
SkDEBUGCODE(fPoints = nullptr;)
|
|
|
|
SkDEBUGCODE(fVerbs = nullptr;)
|
2015-08-04 17:01:58 +00:00
|
|
|
SkDEBUGCODE(fVerbCnt = 0x9999999;)
|
|
|
|
SkDEBUGCODE(fPointCnt = 0xAAAAAAA;)
|
|
|
|
SkDEBUGCODE(fPointCnt = 0xBBBBBBB;)
|
|
|
|
SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;)
|
|
|
|
SkDEBUGCODE(fEditorsAttached = 0x7777777;)
|
|
|
|
}
|
|
|
|
|
2016-05-05 23:05:56 +00:00
|
|
|
static SkPathRef* gEmpty = nullptr;
|
|
|
|
|
2013-10-23 14:44:08 +00:00
|
|
|
SkPathRef* SkPathRef::CreateEmpty() {
|
2016-05-05 23:05:56 +00:00
|
|
|
static SkOnce once;
|
|
|
|
once([]{
|
|
|
|
gEmpty = new SkPathRef;
|
|
|
|
gEmpty->computeBounds(); // Avoids races later to be the first to do this.
|
|
|
|
});
|
|
|
|
return SkRef(gEmpty);
|
2013-10-23 14:44:08 +00:00
|
|
|
}
|
|
|
|
|
2016-05-27 16:17:04 +00:00
|
|
|
static void transform_dir_and_start(const SkMatrix& matrix, bool isRRect, bool* isCCW,
|
|
|
|
unsigned* start) {
|
|
|
|
int inStart = *start;
|
|
|
|
int rm = 0;
|
|
|
|
if (isRRect) {
|
|
|
|
// Degenerate rrect indices to oval indices and remember the remainder.
|
|
|
|
// Ovals have one index per side whereas rrects have two.
|
|
|
|
rm = inStart & 0b1;
|
|
|
|
inStart /= 2;
|
|
|
|
}
|
|
|
|
// Is the antidiagonal non-zero (otherwise the diagonal is zero)
|
|
|
|
int antiDiag;
|
|
|
|
// Is the non-zero value in the top row (either kMScaleX or kMSkewX) negative
|
|
|
|
int topNeg;
|
|
|
|
// Are the two non-zero diagonal or antidiagonal values the same sign.
|
|
|
|
int sameSign;
|
|
|
|
if (matrix.get(SkMatrix::kMScaleX) != 0) {
|
|
|
|
antiDiag = 0b00;
|
|
|
|
if (matrix.get(SkMatrix::kMScaleX) > 0) {
|
|
|
|
topNeg = 0b00;
|
|
|
|
sameSign = matrix.get(SkMatrix::kMScaleY) > 0 ? 0b01 : 0b00;
|
|
|
|
} else {
|
|
|
|
topNeg = 0b10;
|
|
|
|
sameSign = matrix.get(SkMatrix::kMScaleY) > 0 ? 0b00 : 0b01;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
antiDiag = 0b01;
|
|
|
|
if (matrix.get(SkMatrix::kMSkewX) > 0) {
|
|
|
|
topNeg = 0b00;
|
|
|
|
sameSign = matrix.get(SkMatrix::kMSkewY) > 0 ? 0b01 : 0b00;
|
|
|
|
} else {
|
|
|
|
topNeg = 0b10;
|
|
|
|
sameSign = matrix.get(SkMatrix::kMSkewY) > 0 ? 0b00 : 0b01;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sameSign != antiDiag) {
|
|
|
|
// This is a rotation (and maybe scale). The direction is unchanged.
|
|
|
|
// Trust me on the start computation (or draw yourself some pictures)
|
|
|
|
*start = (inStart + 4 - (topNeg | antiDiag)) % 4;
|
|
|
|
SkASSERT(*start < 4);
|
|
|
|
if (isRRect) {
|
|
|
|
*start = 2 * *start + rm;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// This is a mirror (and maybe scale). The direction is reversed.
|
|
|
|
*isCCW = !*isCCW;
|
|
|
|
// Trust me on the start computation (or draw yourself some pictures)
|
|
|
|
*start = (6 + (topNeg | antiDiag) - inStart) % 4;
|
|
|
|
SkASSERT(*start < 4);
|
|
|
|
if (isRRect) {
|
|
|
|
*start = 2 * *start + (rm ? 0 : 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
|
|
|
|
const SkPathRef& src,
|
|
|
|
const SkMatrix& matrix) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(src.validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
if (matrix.isIdentity()) {
|
|
|
|
if (*dst != &src) {
|
|
|
|
src.ref();
|
|
|
|
dst->reset(const_cast<SkPathRef*>(&src));
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE((*dst)->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
}
|
|
|
|
return;
|
2013-09-26 12:18:23 +00:00
|
|
|
}
|
2013-09-27 17:48:49 +00:00
|
|
|
|
2013-12-03 17:15:36 +00:00
|
|
|
if (!(*dst)->unique()) {
|
2015-08-26 20:07:48 +00:00
|
|
|
dst->reset(new SkPathRef);
|
2013-12-03 17:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*dst != &src) {
|
2013-09-27 17:48:49 +00:00
|
|
|
(*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count());
|
2015-12-08 19:55:17 +00:00
|
|
|
sk_careful_memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(),
|
|
|
|
src.fVerbCnt * sizeof(uint8_t));
|
2013-09-27 17:48:49 +00:00
|
|
|
(*dst)->fConicWeights = src.fConicWeights;
|
|
|
|
}
|
|
|
|
|
2013-12-03 17:15:36 +00:00
|
|
|
SkASSERT((*dst)->countPoints() == src.countPoints());
|
|
|
|
SkASSERT((*dst)->countVerbs() == src.countVerbs());
|
|
|
|
SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count());
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
// Need to check this here in case (&src == dst)
|
|
|
|
bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.countPoints() > 1;
|
|
|
|
|
|
|
|
matrix.mapPoints((*dst)->fPoints, src.points(), src.fPointCnt);
|
|
|
|
|
|
|
|
/*
|
2016-05-27 16:17:04 +00:00
|
|
|
* Here we optimize the bounds computation, by noting if the bounds are
|
|
|
|
* already known, and if so, we just transform those as well and mark
|
|
|
|
* them as "known", rather than force the transformed path to have to
|
|
|
|
* recompute them.
|
|
|
|
*
|
|
|
|
* Special gotchas if the path is effectively empty (<= 1 point) or
|
|
|
|
* if it is non-finite. In those cases bounds need to stay empty,
|
|
|
|
* regardless of the matrix.
|
|
|
|
*/
|
2013-09-27 17:48:49 +00:00
|
|
|
if (canXformBounds) {
|
|
|
|
(*dst)->fBoundsIsDirty = false;
|
|
|
|
if (src.fIsFinite) {
|
2014-12-01 14:59:54 +00:00
|
|
|
matrix.mapRect(&(*dst)->fBounds, src.fBounds);
|
|
|
|
if (!((*dst)->fIsFinite = (*dst)->fBounds.isFinite())) {
|
|
|
|
(*dst)->fBounds.setEmpty();
|
2013-09-27 17:48:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
(*dst)->fIsFinite = false;
|
2014-12-01 14:59:54 +00:00
|
|
|
(*dst)->fBounds.setEmpty();
|
2013-09-27 17:48:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
(*dst)->fBoundsIsDirty = true;
|
|
|
|
}
|
|
|
|
|
2013-12-12 23:03:51 +00:00
|
|
|
(*dst)->fSegmentMask = src.fSegmentMask;
|
|
|
|
|
2013-12-03 16:43:54 +00:00
|
|
|
// It's an oval only if it stays a rect.
|
2015-11-19 22:47:43 +00:00
|
|
|
bool rectStaysRect = matrix.rectStaysRect();
|
|
|
|
(*dst)->fIsOval = src.fIsOval && rectStaysRect;
|
|
|
|
(*dst)->fIsRRect = src.fIsRRect && rectStaysRect;
|
2016-05-27 16:17:04 +00:00
|
|
|
if ((*dst)->fIsOval || (*dst)->fIsRRect) {
|
|
|
|
unsigned start = src.fRRectOrOvalStartIdx;
|
|
|
|
bool isCCW = SkToBool(src.fRRectOrOvalIsCCW);
|
|
|
|
transform_dir_and_start(matrix, (*dst)->fIsRRect, &isCCW, &start);
|
|
|
|
(*dst)->fRRectOrOvalIsCCW = isCCW;
|
|
|
|
(*dst)->fRRectOrOvalStartIdx = start;
|
|
|
|
}
|
2013-12-03 16:43:54 +00:00
|
|
|
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE((*dst)->validate();)
|
2013-09-26 12:18:23 +00:00
|
|
|
}
|
|
|
|
|
2014-01-23 15:16:05 +00:00
|
|
|
SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) {
|
2015-08-26 20:07:48 +00:00
|
|
|
SkPathRef* ref = new SkPathRef;
|
2013-12-03 16:43:54 +00:00
|
|
|
|
|
|
|
int32_t packed;
|
|
|
|
if (!buffer->readS32(&packed)) {
|
2015-08-26 20:07:48 +00:00
|
|
|
delete ref;
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2013-12-03 16:43:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1;
|
2015-11-19 22:47:43 +00:00
|
|
|
uint8_t segmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF;
|
|
|
|
bool isOval = (packed >> kIsOval_SerializationShift) & 1;
|
|
|
|
bool isRRect = (packed >> kIsRRect_SerializationShift) & 1;
|
2016-05-27 16:17:04 +00:00
|
|
|
bool rrectOrOvalIsCCW = (packed >> kRRectOrOvalIsCCW_SerializationShift) & 1;
|
|
|
|
unsigned rrectOrOvalStartIdx = (packed >> kRRectOrOvalStartIdx_SerializationShift) & 0x7;
|
2013-09-26 12:18:23 +00:00
|
|
|
|
2013-11-08 19:22:57 +00:00
|
|
|
int32_t verbCount, pointCount, conicCount;
|
2016-02-02 14:14:47 +00:00
|
|
|
ptrdiff_t maxPtrDiff = std::numeric_limits<ptrdiff_t>::max();
|
2013-11-08 19:22:57 +00:00
|
|
|
if (!buffer->readU32(&(ref->fGenerationID)) ||
|
|
|
|
!buffer->readS32(&verbCount) ||
|
2016-01-13 21:46:31 +00:00
|
|
|
verbCount < 0 ||
|
2016-02-02 14:14:47 +00:00
|
|
|
static_cast<uint32_t>(verbCount) > maxPtrDiff/sizeof(uint8_t) ||
|
2013-11-08 19:22:57 +00:00
|
|
|
!buffer->readS32(&pointCount) ||
|
2016-01-13 21:46:31 +00:00
|
|
|
pointCount < 0 ||
|
2016-02-02 14:14:47 +00:00
|
|
|
static_cast<uint32_t>(pointCount) > maxPtrDiff/sizeof(SkPoint) ||
|
|
|
|
sizeof(uint8_t) * verbCount + sizeof(SkPoint) * pointCount >
|
|
|
|
static_cast<size_t>(maxPtrDiff) ||
|
2016-01-13 21:46:31 +00:00
|
|
|
!buffer->readS32(&conicCount) ||
|
|
|
|
conicCount < 0) {
|
2015-08-26 20:07:48 +00:00
|
|
|
delete ref;
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2013-11-08 19:22:57 +00:00
|
|
|
}
|
2013-09-26 12:18:23 +00:00
|
|
|
|
2013-11-08 19:22:57 +00:00
|
|
|
ref->resetToSize(verbCount, pointCount, conicCount);
|
2013-09-26 12:18:23 +00:00
|
|
|
SkASSERT(verbCount == ref->countVerbs());
|
|
|
|
SkASSERT(pointCount == ref->countPoints());
|
|
|
|
SkASSERT(conicCount == ref->fConicWeights.count());
|
2013-11-08 19:22:57 +00:00
|
|
|
|
|
|
|
if (!buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)) ||
|
|
|
|
!buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) ||
|
|
|
|
!buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)) ||
|
|
|
|
!buffer->read(&ref->fBounds, sizeof(SkRect))) {
|
2015-08-26 20:07:48 +00:00
|
|
|
delete ref;
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2013-11-08 19:22:57 +00:00
|
|
|
}
|
2013-09-26 12:18:23 +00:00
|
|
|
ref->fBoundsIsDirty = false;
|
2013-12-12 23:03:51 +00:00
|
|
|
|
|
|
|
// resetToSize clears fSegmentMask and fIsOval
|
|
|
|
ref->fSegmentMask = segmentMask;
|
2013-12-03 16:43:54 +00:00
|
|
|
ref->fIsOval = isOval;
|
2015-11-19 22:47:43 +00:00
|
|
|
ref->fIsRRect = isRRect;
|
2016-05-27 16:17:04 +00:00
|
|
|
ref->fRRectOrOvalIsCCW = rrectOrOvalIsCCW;
|
|
|
|
ref->fRRectOrOvalStartIdx = rrectOrOvalStartIdx;
|
2013-09-26 12:18:23 +00:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) {
|
|
|
|
if ((*pathRef)->unique()) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE((*pathRef)->validate();)
|
2015-08-04 17:01:58 +00:00
|
|
|
(*pathRef)->callGenIDChangeListeners();
|
2013-09-27 17:48:49 +00:00
|
|
|
(*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
|
|
(*pathRef)->fVerbCnt = 0;
|
|
|
|
(*pathRef)->fPointCnt = 0;
|
|
|
|
(*pathRef)->fFreeSpace = (*pathRef)->currSize();
|
|
|
|
(*pathRef)->fGenerationID = 0;
|
|
|
|
(*pathRef)->fConicWeights.rewind();
|
2013-12-12 23:03:51 +00:00
|
|
|
(*pathRef)->fSegmentMask = 0;
|
2013-12-03 16:43:54 +00:00
|
|
|
(*pathRef)->fIsOval = false;
|
2015-11-19 22:47:43 +00:00
|
|
|
(*pathRef)->fIsRRect = false;
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE((*pathRef)->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
} else {
|
|
|
|
int oldVCnt = (*pathRef)->countVerbs();
|
|
|
|
int oldPCnt = (*pathRef)->countPoints();
|
2015-08-26 20:07:48 +00:00
|
|
|
pathRef->reset(new SkPathRef);
|
2013-09-27 17:48:49 +00:00
|
|
|
(*pathRef)->resetToSize(0, 0, 0, oldVCnt, oldPCnt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkPathRef::operator== (const SkPathRef& ref) const {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
SkDEBUGCODE(ref.validate();)
|
2013-12-12 23:03:51 +00:00
|
|
|
|
|
|
|
// We explicitly check fSegmentMask as a quick-reject. We could skip it,
|
|
|
|
// since it is only a cache of info in the fVerbs, but its a fast way to
|
|
|
|
// notice a difference
|
|
|
|
if (fSegmentMask != ref.fSegmentMask) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:48:49 +00:00
|
|
|
bool genIDMatch = fGenerationID && fGenerationID == ref.fGenerationID;
|
|
|
|
#ifdef SK_RELEASE
|
|
|
|
if (genIDMatch) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (fPointCnt != ref.fPointCnt ||
|
|
|
|
fVerbCnt != ref.fVerbCnt) {
|
|
|
|
SkASSERT(!genIDMatch);
|
|
|
|
return false;
|
|
|
|
}
|
2014-11-14 17:22:40 +00:00
|
|
|
if (0 == ref.fVerbCnt) {
|
|
|
|
SkASSERT(0 == ref.fPointCnt);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
SkASSERT(this->verbsMemBegin() && ref.verbsMemBegin());
|
2013-09-27 17:48:49 +00:00
|
|
|
if (0 != memcmp(this->verbsMemBegin(),
|
|
|
|
ref.verbsMemBegin(),
|
|
|
|
ref.fVerbCnt * sizeof(uint8_t))) {
|
|
|
|
SkASSERT(!genIDMatch);
|
|
|
|
return false;
|
|
|
|
}
|
2014-11-14 17:22:40 +00:00
|
|
|
SkASSERT(this->points() && ref.points());
|
2013-09-27 17:48:49 +00:00
|
|
|
if (0 != memcmp(this->points(),
|
|
|
|
ref.points(),
|
|
|
|
ref.fPointCnt * sizeof(SkPoint))) {
|
|
|
|
SkASSERT(!genIDMatch);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (fConicWeights != ref.fConicWeights) {
|
|
|
|
SkASSERT(!genIDMatch);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-12 23:03:51 +00:00
|
|
|
void SkPathRef::writeToBuffer(SkWBuffer* buffer) const {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2013-09-26 12:18:23 +00:00
|
|
|
SkDEBUGCODE(size_t beforePos = buffer->pos();)
|
|
|
|
|
|
|
|
// Call getBounds() to ensure (as a side-effect) that fBounds
|
|
|
|
// and fIsFinite are computed.
|
|
|
|
const SkRect& bounds = this->getBounds();
|
|
|
|
|
2016-05-27 16:17:04 +00:00
|
|
|
int32_t packed = ((fRRectOrOvalStartIdx & 7) << kRRectOrOvalStartIdx_SerializationShift) |
|
|
|
|
((fRRectOrOvalIsCCW & 1) << kRRectOrOvalIsCCW_SerializationShift) |
|
|
|
|
((fIsFinite & 1) << kIsFinite_SerializationShift) |
|
2013-12-12 23:03:51 +00:00
|
|
|
((fIsOval & 1) << kIsOval_SerializationShift) |
|
2015-11-19 22:47:43 +00:00
|
|
|
((fIsRRect & 1) << kIsRRect_SerializationShift) |
|
2013-12-12 23:03:51 +00:00
|
|
|
(fSegmentMask << kSegmentMask_SerializationShift);
|
2013-09-26 12:18:23 +00:00
|
|
|
buffer->write32(packed);
|
|
|
|
|
|
|
|
// TODO: write gen ID here. Problem: We don't know if we're cross process or not from
|
|
|
|
// SkWBuffer. Until this is fixed we write 0.
|
|
|
|
buffer->write32(0);
|
|
|
|
buffer->write32(fVerbCnt);
|
|
|
|
buffer->write32(fPointCnt);
|
|
|
|
buffer->write32(fConicWeights.count());
|
|
|
|
buffer->write(verbsMemBegin(), fVerbCnt * sizeof(uint8_t));
|
|
|
|
buffer->write(fPoints, fPointCnt * sizeof(SkPoint));
|
|
|
|
buffer->write(fConicWeights.begin(), fConicWeights.bytes());
|
|
|
|
buffer->write(&bounds, sizeof(bounds));
|
|
|
|
|
|
|
|
SkASSERT(buffer->pos() - beforePos == (size_t) this->writeSize());
|
|
|
|
}
|
2013-09-27 17:48:49 +00:00
|
|
|
|
2013-12-12 23:03:51 +00:00
|
|
|
uint32_t SkPathRef::writeSize() const {
|
2013-09-27 17:48:49 +00:00
|
|
|
return uint32_t(5 * sizeof(uint32_t) +
|
|
|
|
fVerbCnt * sizeof(uint8_t) +
|
|
|
|
fPointCnt * sizeof(SkPoint) +
|
|
|
|
fConicWeights.bytes() +
|
|
|
|
sizeof(SkRect));
|
|
|
|
}
|
|
|
|
|
2013-09-28 07:01:33 +00:00
|
|
|
void SkPathRef::copy(const SkPathRef& ref,
|
|
|
|
int additionalReserveVerbs,
|
2013-09-27 17:48:49 +00:00
|
|
|
int additionalReservePoints) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(),
|
|
|
|
additionalReserveVerbs, additionalReservePoints);
|
2015-12-08 19:55:17 +00:00
|
|
|
sk_careful_memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt*sizeof(uint8_t));
|
|
|
|
sk_careful_memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint));
|
2013-09-27 17:48:49 +00:00
|
|
|
fConicWeights = ref.fConicWeights;
|
|
|
|
fBoundsIsDirty = ref.fBoundsIsDirty;
|
|
|
|
if (!fBoundsIsDirty) {
|
|
|
|
fBounds = ref.fBounds;
|
|
|
|
fIsFinite = ref.fIsFinite;
|
|
|
|
}
|
2013-12-12 23:03:51 +00:00
|
|
|
fSegmentMask = ref.fSegmentMask;
|
2013-12-03 16:43:54 +00:00
|
|
|
fIsOval = ref.fIsOval;
|
2015-11-19 22:47:43 +00:00
|
|
|
fIsRRect = ref.fIsRRect;
|
2016-05-27 16:17:04 +00:00
|
|
|
fRRectOrOvalIsCCW = ref.fRRectOrOvalIsCCW;
|
|
|
|
fRRectOrOvalStartIdx = ref.fRRectOrOvalStartIdx;
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
}
|
|
|
|
|
2016-02-18 12:11:48 +00:00
|
|
|
|
|
|
|
void SkPathRef::interpolate(const SkPathRef& ending, SkScalar weight, SkPathRef* out) const {
|
|
|
|
const SkScalar* inValues = &ending.getPoints()->fX;
|
|
|
|
SkScalar* outValues = &out->getPoints()->fX;
|
|
|
|
int count = out->countPoints() * 2;
|
|
|
|
for (int index = 0; index < count; ++index) {
|
|
|
|
outValues[index] = outValues[index] * weight + inValues[index] * (1 - weight);
|
|
|
|
}
|
|
|
|
out->fBoundsIsDirty = true;
|
|
|
|
out->fIsOval = false;
|
|
|
|
out->fIsRRect = false;
|
|
|
|
}
|
|
|
|
|
2013-12-16 07:01:40 +00:00
|
|
|
SkPoint* SkPathRef::growForRepeatedVerb(int /*SkPath::Verb*/ verb,
|
|
|
|
int numVbs,
|
2013-12-12 23:03:51 +00:00
|
|
|
SkScalar** weights) {
|
|
|
|
// This value is just made-up for now. When count is 4, calling memset was much
|
|
|
|
// slower than just writing the loop. This seems odd, and hopefully in the
|
|
|
|
// future this will appear to have been a fluke...
|
|
|
|
static const unsigned int kMIN_COUNT_FOR_MEMSET_TO_BE_FAST = 16;
|
|
|
|
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
int pCnt;
|
|
|
|
bool dirtyAfterEdit = true;
|
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kMove_Verb:
|
|
|
|
pCnt = numVbs;
|
|
|
|
dirtyAfterEdit = false;
|
|
|
|
break;
|
|
|
|
case SkPath::kLine_Verb:
|
|
|
|
fSegmentMask |= SkPath::kLine_SegmentMask;
|
|
|
|
pCnt = numVbs;
|
|
|
|
break;
|
|
|
|
case SkPath::kQuad_Verb:
|
|
|
|
fSegmentMask |= SkPath::kQuad_SegmentMask;
|
|
|
|
pCnt = 2 * numVbs;
|
|
|
|
break;
|
|
|
|
case SkPath::kConic_Verb:
|
|
|
|
fSegmentMask |= SkPath::kConic_SegmentMask;
|
|
|
|
pCnt = 2 * numVbs;
|
|
|
|
break;
|
|
|
|
case SkPath::kCubic_Verb:
|
|
|
|
fSegmentMask |= SkPath::kCubic_SegmentMask;
|
|
|
|
pCnt = 3 * numVbs;
|
|
|
|
break;
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
SkDEBUGFAIL("growForRepeatedVerb called for kClose_Verb");
|
|
|
|
pCnt = 0;
|
|
|
|
dirtyAfterEdit = false;
|
|
|
|
break;
|
|
|
|
case SkPath::kDone_Verb:
|
|
|
|
SkDEBUGFAIL("growForRepeatedVerb called for kDone");
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
SkDEBUGFAIL("default should not be reached");
|
|
|
|
pCnt = 0;
|
|
|
|
dirtyAfterEdit = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t space = numVbs * sizeof(uint8_t) + pCnt * sizeof (SkPoint);
|
|
|
|
this->makeSpace(space);
|
|
|
|
|
|
|
|
SkPoint* ret = fPoints + fPointCnt;
|
|
|
|
uint8_t* vb = fVerbs - fVerbCnt;
|
|
|
|
|
|
|
|
// cast to unsigned, so if kMIN_COUNT_FOR_MEMSET_TO_BE_FAST is defined to
|
|
|
|
// be 0, the compiler will remove the test/branch entirely.
|
|
|
|
if ((unsigned)numVbs >= kMIN_COUNT_FOR_MEMSET_TO_BE_FAST) {
|
|
|
|
memset(vb - numVbs, verb, numVbs);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < numVbs; ++i) {
|
|
|
|
vb[~i] = verb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fVerbCnt += numVbs;
|
|
|
|
fPointCnt += pCnt;
|
|
|
|
fFreeSpace -= space;
|
|
|
|
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
|
|
|
if (dirtyAfterEdit) {
|
|
|
|
fIsOval = false;
|
2015-11-19 22:47:43 +00:00
|
|
|
fIsRRect = false;
|
2013-12-12 23:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SkPath::kConic_Verb == verb) {
|
2014-09-05 20:34:00 +00:00
|
|
|
SkASSERT(weights);
|
2013-12-12 23:03:51 +00:00
|
|
|
*weights = fConicWeights.append(numVbs);
|
|
|
|
}
|
|
|
|
|
|
|
|
SkDEBUGCODE(this->validate();)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkPoint* SkPathRef::growForVerb(int /* SkPath::Verb*/ verb, SkScalar weight) {
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
int pCnt;
|
2013-12-03 16:43:54 +00:00
|
|
|
bool dirtyAfterEdit = true;
|
2013-09-27 17:48:49 +00:00
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kMove_Verb:
|
|
|
|
pCnt = 1;
|
2013-12-03 16:43:54 +00:00
|
|
|
dirtyAfterEdit = false;
|
2013-09-27 17:48:49 +00:00
|
|
|
break;
|
|
|
|
case SkPath::kLine_Verb:
|
2013-12-12 23:03:51 +00:00
|
|
|
fSegmentMask |= SkPath::kLine_SegmentMask;
|
2013-09-27 17:48:49 +00:00
|
|
|
pCnt = 1;
|
|
|
|
break;
|
|
|
|
case SkPath::kQuad_Verb:
|
2013-12-12 23:03:51 +00:00
|
|
|
fSegmentMask |= SkPath::kQuad_SegmentMask;
|
|
|
|
pCnt = 2;
|
|
|
|
break;
|
2013-09-27 17:48:49 +00:00
|
|
|
case SkPath::kConic_Verb:
|
2013-12-12 23:03:51 +00:00
|
|
|
fSegmentMask |= SkPath::kConic_SegmentMask;
|
2013-09-27 17:48:49 +00:00
|
|
|
pCnt = 2;
|
|
|
|
break;
|
|
|
|
case SkPath::kCubic_Verb:
|
2013-12-12 23:03:51 +00:00
|
|
|
fSegmentMask |= SkPath::kCubic_SegmentMask;
|
2013-09-27 17:48:49 +00:00
|
|
|
pCnt = 3;
|
|
|
|
break;
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
pCnt = 0;
|
2013-12-03 16:43:54 +00:00
|
|
|
dirtyAfterEdit = false;
|
2013-09-27 17:48:49 +00:00
|
|
|
break;
|
|
|
|
case SkPath::kDone_Verb:
|
|
|
|
SkDEBUGFAIL("growForVerb called for kDone");
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
SkDEBUGFAIL("default is not reached");
|
2013-12-03 16:43:54 +00:00
|
|
|
dirtyAfterEdit = false;
|
2013-09-27 17:48:49 +00:00
|
|
|
pCnt = 0;
|
|
|
|
}
|
|
|
|
size_t space = sizeof(uint8_t) + pCnt * sizeof (SkPoint);
|
|
|
|
this->makeSpace(space);
|
|
|
|
this->fVerbs[~fVerbCnt] = verb;
|
|
|
|
SkPoint* ret = fPoints + fPointCnt;
|
|
|
|
fVerbCnt += 1;
|
|
|
|
fPointCnt += pCnt;
|
|
|
|
fFreeSpace -= space;
|
|
|
|
fBoundsIsDirty = true; // this also invalidates fIsFinite
|
2013-12-03 16:43:54 +00:00
|
|
|
if (dirtyAfterEdit) {
|
|
|
|
fIsOval = false;
|
2015-11-19 22:47:43 +00:00
|
|
|
fIsRRect = false;
|
2013-12-03 16:43:54 +00:00
|
|
|
}
|
2013-12-12 23:03:51 +00:00
|
|
|
|
|
|
|
if (SkPath::kConic_Verb == verb) {
|
|
|
|
*fConicWeights.append() = weight;
|
|
|
|
}
|
|
|
|
|
2013-10-02 16:42:21 +00:00
|
|
|
SkDEBUGCODE(this->validate();)
|
2013-09-27 17:48:49 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-30 18:57:55 +00:00
|
|
|
uint32_t SkPathRef::genID() const {
|
2013-09-27 17:48:49 +00:00
|
|
|
SkASSERT(!fEditorsAttached);
|
2013-10-30 18:57:55 +00:00
|
|
|
static const uint32_t kMask = (static_cast<int64_t>(1) << SkPath::kPathRefGenIDBitCnt) - 1;
|
2013-09-27 17:48:49 +00:00
|
|
|
if (!fGenerationID) {
|
|
|
|
if (0 == fPointCnt && 0 == fVerbCnt) {
|
|
|
|
fGenerationID = kEmptyGenID;
|
|
|
|
} else {
|
|
|
|
static int32_t gPathRefGenerationID;
|
|
|
|
// do a loop in case our global wraps around, as we never want to return a 0 or the
|
|
|
|
// empty ID
|
|
|
|
do {
|
2013-10-30 18:57:55 +00:00
|
|
|
fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMask;
|
2013-09-27 17:48:49 +00:00
|
|
|
} while (fGenerationID <= kEmptyGenID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fGenerationID;
|
|
|
|
}
|
|
|
|
|
2015-08-04 17:01:58 +00:00
|
|
|
void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) {
|
2016-05-05 23:05:56 +00:00
|
|
|
if (nullptr == listener || this == gEmpty) {
|
2015-08-26 20:07:48 +00:00
|
|
|
delete listener;
|
2015-08-04 17:01:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
*fGenIDChangeListeners.append() = listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we need to be called *before* the genID gets changed or zerod
|
|
|
|
void SkPathRef::callGenIDChangeListeners() {
|
|
|
|
for (int i = 0; i < fGenIDChangeListeners.count(); i++) {
|
|
|
|
fGenIDChangeListeners[i]->onChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Listeners get at most one shot, so whether these triggered or not, blow them away.
|
|
|
|
fGenIDChangeListeners.deleteAll();
|
|
|
|
}
|
|
|
|
|
2015-11-19 22:47:43 +00:00
|
|
|
SkRRect SkPathRef::getRRect() const {
|
|
|
|
const SkRect& bounds = this->getBounds();
|
|
|
|
SkVector radii[4] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}};
|
|
|
|
Iter iter(*this);
|
|
|
|
SkPoint pts[4];
|
|
|
|
uint8_t verb = iter.next(pts);
|
|
|
|
SkASSERT(SkPath::kMove_Verb == verb);
|
|
|
|
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
|
|
|
if (SkPath::kConic_Verb == verb) {
|
|
|
|
SkVector v1_0 = pts[1] - pts[0];
|
|
|
|
SkVector v2_1 = pts[2] - pts[1];
|
|
|
|
SkVector dxdy;
|
|
|
|
if (v1_0.fX) {
|
|
|
|
SkASSERT(!v2_1.fX && !v1_0.fY);
|
|
|
|
dxdy.set(SkScalarAbs(v1_0.fX), SkScalarAbs(v2_1.fY));
|
|
|
|
} else if (!v1_0.fY) {
|
|
|
|
SkASSERT(!v2_1.fX || !v2_1.fY);
|
|
|
|
dxdy.set(SkScalarAbs(v2_1.fX), SkScalarAbs(v2_1.fY));
|
|
|
|
} else {
|
|
|
|
SkASSERT(!v2_1.fY);
|
|
|
|
dxdy.set(SkScalarAbs(v2_1.fX), SkScalarAbs(v1_0.fY));
|
|
|
|
}
|
|
|
|
SkRRect::Corner corner =
|
|
|
|
pts[1].fX == bounds.fLeft ?
|
|
|
|
pts[1].fY == bounds.fTop ?
|
|
|
|
SkRRect::kUpperLeft_Corner : SkRRect::kLowerLeft_Corner :
|
|
|
|
pts[1].fY == bounds.fTop ?
|
|
|
|
SkRRect::kUpperRight_Corner : SkRRect::kLowerRight_Corner;
|
|
|
|
SkASSERT(!radii[corner].fX && !radii[corner].fY);
|
|
|
|
radii[corner] = dxdy;
|
|
|
|
} else {
|
|
|
|
SkASSERT((verb == SkPath::kLine_Verb
|
|
|
|
&& (!(pts[1].fX - pts[0].fX) || !(pts[1].fY - pts[0].fY)))
|
|
|
|
|| verb == SkPath::kClose_Verb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii(bounds, radii);
|
|
|
|
return rrect;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
SkPathRef::Iter::Iter() {
|
|
|
|
#ifdef SK_DEBUG
|
|
|
|
fPts = nullptr;
|
|
|
|
fConicWeights = nullptr;
|
|
|
|
#endif
|
|
|
|
// need to init enough to make next() harmlessly return kDone_Verb
|
|
|
|
fVerbs = nullptr;
|
|
|
|
fVerbStop = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkPathRef::Iter::Iter(const SkPathRef& path) {
|
|
|
|
this->setPathRef(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkPathRef::Iter::setPathRef(const SkPathRef& path) {
|
|
|
|
fPts = path.points();
|
|
|
|
fVerbs = path.verbs();
|
|
|
|
fVerbStop = path.verbsMemBegin();
|
|
|
|
fConicWeights = path.conicWeights() - 1; // begin one behind
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t SkPathRef::Iter::next(SkPoint pts[4]) {
|
|
|
|
SkASSERT(pts);
|
|
|
|
if (fVerbs == fVerbStop) {
|
|
|
|
return (uint8_t) SkPath::kDone_Verb;
|
|
|
|
}
|
|
|
|
|
|
|
|
// fVerbs points one beyond next verb so decrement first.
|
|
|
|
unsigned verb = *(--fVerbs);
|
|
|
|
const SkPoint* srcPts = fPts;
|
|
|
|
|
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kMove_Verb:
|
|
|
|
pts[0] = srcPts[0];
|
|
|
|
srcPts += 1;
|
|
|
|
break;
|
|
|
|
case SkPath::kLine_Verb:
|
|
|
|
pts[0] = srcPts[-1];
|
|
|
|
pts[1] = srcPts[0];
|
|
|
|
srcPts += 1;
|
|
|
|
break;
|
|
|
|
case SkPath::kConic_Verb:
|
|
|
|
fConicWeights += 1;
|
|
|
|
// fall-through
|
|
|
|
case SkPath::kQuad_Verb:
|
|
|
|
pts[0] = srcPts[-1];
|
|
|
|
pts[1] = srcPts[0];
|
|
|
|
pts[2] = srcPts[1];
|
|
|
|
srcPts += 2;
|
|
|
|
break;
|
|
|
|
case SkPath::kCubic_Verb:
|
|
|
|
pts[0] = srcPts[-1];
|
|
|
|
pts[1] = srcPts[0];
|
|
|
|
pts[2] = srcPts[1];
|
|
|
|
pts[3] = srcPts[2];
|
|
|
|
srcPts += 3;
|
|
|
|
break;
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
break;
|
|
|
|
case SkPath::kDone_Verb:
|
|
|
|
SkASSERT(fVerbs == fVerbStop);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fPts = srcPts;
|
|
|
|
return (uint8_t) verb;
|
|
|
|
}
|
|
|
|
|
2015-12-09 22:04:46 +00:00
|
|
|
uint8_t SkPathRef::Iter::peek() const {
|
|
|
|
const uint8_t* next = fVerbs - 1;
|
|
|
|
return next <= fVerbStop ? (uint8_t) SkPath::kDone_Verb : *next;
|
|
|
|
}
|
|
|
|
|
2013-10-02 16:42:21 +00:00
|
|
|
#ifdef SK_DEBUG
|
2013-09-27 17:48:49 +00:00
|
|
|
void SkPathRef::validate() const {
|
|
|
|
SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0);
|
|
|
|
SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints) >= 0);
|
2015-08-27 14:41:13 +00:00
|
|
|
SkASSERT((nullptr == fPoints) == (nullptr == fVerbs));
|
|
|
|
SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace));
|
|
|
|
SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace));
|
|
|
|
SkASSERT(!(nullptr == fPoints && fPointCnt));
|
|
|
|
SkASSERT(!(nullptr == fVerbs && fVerbCnt));
|
2013-09-27 17:48:49 +00:00
|
|
|
SkASSERT(this->currSize() ==
|
|
|
|
fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVerbCnt);
|
|
|
|
|
2016-05-27 16:17:04 +00:00
|
|
|
if (fIsOval || fIsRRect) {
|
|
|
|
// Currently we don't allow both of these to be set, even though ovals are round rects.
|
|
|
|
SkASSERT(fIsOval != fIsRRect);
|
|
|
|
if (fIsOval) {
|
|
|
|
SkASSERT(fRRectOrOvalStartIdx < 4);
|
|
|
|
} else {
|
|
|
|
SkASSERT(fRRectOrOvalStartIdx < 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-01 14:59:54 +00:00
|
|
|
if (!fBoundsIsDirty && !fBounds.isEmpty()) {
|
2013-09-27 17:48:49 +00:00
|
|
|
bool isFinite = true;
|
|
|
|
for (int i = 0; i < fPointCnt; ++i) {
|
2015-01-05 17:20:04 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
if (fPoints[i].isFinite() &&
|
|
|
|
(fPoints[i].fX < fBounds.fLeft || fPoints[i].fX > fBounds.fRight ||
|
|
|
|
fPoints[i].fY < fBounds.fTop || fPoints[i].fY > fBounds.fBottom)) {
|
|
|
|
SkDebugf("bounds: %f %f %f %f\n",
|
|
|
|
fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom);
|
|
|
|
for (int j = 0; j < fPointCnt; ++j) {
|
|
|
|
if (i == j) {
|
|
|
|
SkDebugf("*");
|
|
|
|
}
|
|
|
|
SkDebugf("%f %f\n", fPoints[j].fX, fPoints[j].fY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-12 20:47:59 +00:00
|
|
|
SkASSERT(!fPoints[i].isFinite() ||
|
|
|
|
(fPoints[i].fX >= fBounds.fLeft && fPoints[i].fX <= fBounds.fRight &&
|
|
|
|
fPoints[i].fY >= fBounds.fTop && fPoints[i].fY <= fBounds.fBottom));
|
2013-09-27 17:48:49 +00:00
|
|
|
if (!fPoints[i].isFinite()) {
|
|
|
|
isFinite = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkASSERT(SkToBool(fIsFinite) == isFinite);
|
|
|
|
}
|
2013-12-12 23:03:51 +00:00
|
|
|
|
|
|
|
#ifdef SK_DEBUG_PATH
|
|
|
|
uint32_t mask = 0;
|
|
|
|
for (int i = 0; i < fVerbCnt; ++i) {
|
|
|
|
switch (fVerbs[~i]) {
|
|
|
|
case SkPath::kMove_Verb:
|
|
|
|
break;
|
|
|
|
case SkPath::kLine_Verb:
|
|
|
|
mask |= SkPath::kLine_SegmentMask;
|
|
|
|
break;
|
|
|
|
case SkPath::kQuad_Verb:
|
|
|
|
mask |= SkPath::kQuad_SegmentMask;
|
|
|
|
break;
|
|
|
|
case SkPath::kConic_Verb:
|
|
|
|
mask |= SkPath::kConic_SegmentMask;
|
|
|
|
break;
|
|
|
|
case SkPath::kCubic_Verb:
|
|
|
|
mask |= SkPath::kCubic_SegmentMask;
|
|
|
|
break;
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
break;
|
|
|
|
case SkPath::kDone_Verb:
|
|
|
|
SkDEBUGFAIL("Done verb shouldn't be recorded.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkDEBUGFAIL("Unknown Verb");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SkASSERT(mask == fSegmentMask);
|
|
|
|
#endif // SK_DEBUG_PATH
|
2013-09-27 17:48:49 +00:00
|
|
|
}
|
2013-10-02 16:42:21 +00:00
|
|
|
#endif
|