gfx/skia/trunk/src/core/SkPathRef.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2013 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #include "SkBuffer.h"
michael@0 9 #include "SkOnce.h"
michael@0 10 #include "SkPath.h"
michael@0 11 #include "SkPathRef.h"
michael@0 12
michael@0 13 //////////////////////////////////////////////////////////////////////////////
michael@0 14 SkPathRef::Editor::Editor(SkAutoTUnref<SkPathRef>* pathRef,
michael@0 15 int incReserveVerbs,
michael@0 16 int incReservePoints)
michael@0 17 {
michael@0 18 if ((*pathRef)->unique()) {
michael@0 19 (*pathRef)->incReserve(incReserveVerbs, incReservePoints);
michael@0 20 } else {
michael@0 21 SkPathRef* copy = SkNEW(SkPathRef);
michael@0 22 copy->copy(**pathRef, incReserveVerbs, incReservePoints);
michael@0 23 pathRef->reset(copy);
michael@0 24 }
michael@0 25 fPathRef = *pathRef;
michael@0 26 fPathRef->fGenerationID = 0;
michael@0 27 SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);)
michael@0 28 }
michael@0 29
michael@0 30 //////////////////////////////////////////////////////////////////////////////
michael@0 31 static SkPathRef* gEmptyPathRef = NULL;
michael@0 32 static void cleanup_gEmptyPathRef() { gEmptyPathRef->unref(); }
michael@0 33
michael@0 34 void SkPathRef::CreateEmptyImpl(int) {
michael@0 35 gEmptyPathRef = SkNEW(SkPathRef);
michael@0 36 gEmptyPathRef->computeBounds(); // Preemptively avoid a race to clear fBoundsIsDirty.
michael@0 37 }
michael@0 38
michael@0 39 SkPathRef* SkPathRef::CreateEmpty() {
michael@0 40 SK_DECLARE_STATIC_ONCE(once);
michael@0 41 SkOnce(&once, SkPathRef::CreateEmptyImpl, 0, cleanup_gEmptyPathRef);
michael@0 42 return SkRef(gEmptyPathRef);
michael@0 43 }
michael@0 44
michael@0 45 void SkPathRef::CreateTransformedCopy(SkAutoTUnref<SkPathRef>* dst,
michael@0 46 const SkPathRef& src,
michael@0 47 const SkMatrix& matrix) {
michael@0 48 SkDEBUGCODE(src.validate();)
michael@0 49 if (matrix.isIdentity()) {
michael@0 50 if (*dst != &src) {
michael@0 51 src.ref();
michael@0 52 dst->reset(const_cast<SkPathRef*>(&src));
michael@0 53 SkDEBUGCODE((*dst)->validate();)
michael@0 54 }
michael@0 55 return;
michael@0 56 }
michael@0 57
michael@0 58 if (!(*dst)->unique()) {
michael@0 59 dst->reset(SkNEW(SkPathRef));
michael@0 60 }
michael@0 61
michael@0 62 if (*dst != &src) {
michael@0 63 (*dst)->resetToSize(src.fVerbCnt, src.fPointCnt, src.fConicWeights.count());
michael@0 64 memcpy((*dst)->verbsMemWritable(), src.verbsMemBegin(), src.fVerbCnt * sizeof(uint8_t));
michael@0 65 (*dst)->fConicWeights = src.fConicWeights;
michael@0 66 }
michael@0 67
michael@0 68 SkASSERT((*dst)->countPoints() == src.countPoints());
michael@0 69 SkASSERT((*dst)->countVerbs() == src.countVerbs());
michael@0 70 SkASSERT((*dst)->fConicWeights.count() == src.fConicWeights.count());
michael@0 71
michael@0 72 // Need to check this here in case (&src == dst)
michael@0 73 bool canXformBounds = !src.fBoundsIsDirty && matrix.rectStaysRect() && src.countPoints() > 1;
michael@0 74
michael@0 75 matrix.mapPoints((*dst)->fPoints, src.points(), src.fPointCnt);
michael@0 76
michael@0 77 /*
michael@0 78 * Here we optimize the bounds computation, by noting if the bounds are
michael@0 79 * already known, and if so, we just transform those as well and mark
michael@0 80 * them as "known", rather than force the transformed path to have to
michael@0 81 * recompute them.
michael@0 82 *
michael@0 83 * Special gotchas if the path is effectively empty (<= 1 point) or
michael@0 84 * if it is non-finite. In those cases bounds need to stay empty,
michael@0 85 * regardless of the matrix.
michael@0 86 */
michael@0 87 if (canXformBounds) {
michael@0 88 (*dst)->fBoundsIsDirty = false;
michael@0 89 if (src.fIsFinite) {
michael@0 90 matrix.mapRect(&(*dst)->fBounds, src.fBounds);
michael@0 91 if (!((*dst)->fIsFinite = (*dst)->fBounds.isFinite())) {
michael@0 92 (*dst)->fBounds.setEmpty();
michael@0 93 }
michael@0 94 } else {
michael@0 95 (*dst)->fIsFinite = false;
michael@0 96 (*dst)->fBounds.setEmpty();
michael@0 97 }
michael@0 98 } else {
michael@0 99 (*dst)->fBoundsIsDirty = true;
michael@0 100 }
michael@0 101
michael@0 102 (*dst)->fSegmentMask = src.fSegmentMask;
michael@0 103
michael@0 104 // It's an oval only if it stays a rect.
michael@0 105 (*dst)->fIsOval = src.fIsOval && matrix.rectStaysRect();
michael@0 106
michael@0 107 SkDEBUGCODE((*dst)->validate();)
michael@0 108 }
michael@0 109
michael@0 110 SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) {
michael@0 111 SkPathRef* ref = SkNEW(SkPathRef);
michael@0 112 bool isOval;
michael@0 113 uint8_t segmentMask;
michael@0 114
michael@0 115 int32_t packed;
michael@0 116 if (!buffer->readS32(&packed)) {
michael@0 117 SkDELETE(ref);
michael@0 118 return NULL;
michael@0 119 }
michael@0 120
michael@0 121 ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1;
michael@0 122 segmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF;
michael@0 123 isOval = (packed >> kIsOval_SerializationShift) & 1;
michael@0 124
michael@0 125 int32_t verbCount, pointCount, conicCount;
michael@0 126 if (!buffer->readU32(&(ref->fGenerationID)) ||
michael@0 127 !buffer->readS32(&verbCount) ||
michael@0 128 !buffer->readS32(&pointCount) ||
michael@0 129 !buffer->readS32(&conicCount)) {
michael@0 130 SkDELETE(ref);
michael@0 131 return NULL;
michael@0 132 }
michael@0 133
michael@0 134 ref->resetToSize(verbCount, pointCount, conicCount);
michael@0 135 SkASSERT(verbCount == ref->countVerbs());
michael@0 136 SkASSERT(pointCount == ref->countPoints());
michael@0 137 SkASSERT(conicCount == ref->fConicWeights.count());
michael@0 138
michael@0 139 if (!buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)) ||
michael@0 140 !buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) ||
michael@0 141 !buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)) ||
michael@0 142 !buffer->read(&ref->fBounds, sizeof(SkRect))) {
michael@0 143 SkDELETE(ref);
michael@0 144 return NULL;
michael@0 145 }
michael@0 146 ref->fBoundsIsDirty = false;
michael@0 147
michael@0 148 // resetToSize clears fSegmentMask and fIsOval
michael@0 149 ref->fSegmentMask = segmentMask;
michael@0 150 ref->fIsOval = isOval;
michael@0 151 return ref;
michael@0 152 }
michael@0 153
michael@0 154 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) {
michael@0 155 if ((*pathRef)->unique()) {
michael@0 156 SkDEBUGCODE((*pathRef)->validate();)
michael@0 157 (*pathRef)->fBoundsIsDirty = true; // this also invalidates fIsFinite
michael@0 158 (*pathRef)->fVerbCnt = 0;
michael@0 159 (*pathRef)->fPointCnt = 0;
michael@0 160 (*pathRef)->fFreeSpace = (*pathRef)->currSize();
michael@0 161 (*pathRef)->fGenerationID = 0;
michael@0 162 (*pathRef)->fConicWeights.rewind();
michael@0 163 (*pathRef)->fSegmentMask = 0;
michael@0 164 (*pathRef)->fIsOval = false;
michael@0 165 SkDEBUGCODE((*pathRef)->validate();)
michael@0 166 } else {
michael@0 167 int oldVCnt = (*pathRef)->countVerbs();
michael@0 168 int oldPCnt = (*pathRef)->countPoints();
michael@0 169 pathRef->reset(SkNEW(SkPathRef));
michael@0 170 (*pathRef)->resetToSize(0, 0, 0, oldVCnt, oldPCnt);
michael@0 171 }
michael@0 172 }
michael@0 173
michael@0 174 bool SkPathRef::operator== (const SkPathRef& ref) const {
michael@0 175 SkDEBUGCODE(this->validate();)
michael@0 176 SkDEBUGCODE(ref.validate();)
michael@0 177
michael@0 178 // We explicitly check fSegmentMask as a quick-reject. We could skip it,
michael@0 179 // since it is only a cache of info in the fVerbs, but its a fast way to
michael@0 180 // notice a difference
michael@0 181 if (fSegmentMask != ref.fSegmentMask) {
michael@0 182 return false;
michael@0 183 }
michael@0 184
michael@0 185 bool genIDMatch = fGenerationID && fGenerationID == ref.fGenerationID;
michael@0 186 #ifdef SK_RELEASE
michael@0 187 if (genIDMatch) {
michael@0 188 return true;
michael@0 189 }
michael@0 190 #endif
michael@0 191 if (fPointCnt != ref.fPointCnt ||
michael@0 192 fVerbCnt != ref.fVerbCnt) {
michael@0 193 SkASSERT(!genIDMatch);
michael@0 194 return false;
michael@0 195 }
michael@0 196 if (0 != memcmp(this->verbsMemBegin(),
michael@0 197 ref.verbsMemBegin(),
michael@0 198 ref.fVerbCnt * sizeof(uint8_t))) {
michael@0 199 SkASSERT(!genIDMatch);
michael@0 200 return false;
michael@0 201 }
michael@0 202 if (0 != memcmp(this->points(),
michael@0 203 ref.points(),
michael@0 204 ref.fPointCnt * sizeof(SkPoint))) {
michael@0 205 SkASSERT(!genIDMatch);
michael@0 206 return false;
michael@0 207 }
michael@0 208 if (fConicWeights != ref.fConicWeights) {
michael@0 209 SkASSERT(!genIDMatch);
michael@0 210 return false;
michael@0 211 }
michael@0 212 // We've done the work to determine that these are equal. If either has a zero genID, copy
michael@0 213 // the other's. If both are 0 then genID() will compute the next ID.
michael@0 214 if (0 == fGenerationID) {
michael@0 215 fGenerationID = ref.genID();
michael@0 216 } else if (0 == ref.fGenerationID) {
michael@0 217 ref.fGenerationID = this->genID();
michael@0 218 }
michael@0 219 return true;
michael@0 220 }
michael@0 221
michael@0 222 void SkPathRef::writeToBuffer(SkWBuffer* buffer) const {
michael@0 223 SkDEBUGCODE(this->validate();)
michael@0 224 SkDEBUGCODE(size_t beforePos = buffer->pos();)
michael@0 225
michael@0 226 // Call getBounds() to ensure (as a side-effect) that fBounds
michael@0 227 // and fIsFinite are computed.
michael@0 228 const SkRect& bounds = this->getBounds();
michael@0 229
michael@0 230 int32_t packed = ((fIsFinite & 1) << kIsFinite_SerializationShift) |
michael@0 231 ((fIsOval & 1) << kIsOval_SerializationShift) |
michael@0 232 (fSegmentMask << kSegmentMask_SerializationShift);
michael@0 233 buffer->write32(packed);
michael@0 234
michael@0 235 // TODO: write gen ID here. Problem: We don't know if we're cross process or not from
michael@0 236 // SkWBuffer. Until this is fixed we write 0.
michael@0 237 buffer->write32(0);
michael@0 238 buffer->write32(fVerbCnt);
michael@0 239 buffer->write32(fPointCnt);
michael@0 240 buffer->write32(fConicWeights.count());
michael@0 241 buffer->write(verbsMemBegin(), fVerbCnt * sizeof(uint8_t));
michael@0 242 buffer->write(fPoints, fPointCnt * sizeof(SkPoint));
michael@0 243 buffer->write(fConicWeights.begin(), fConicWeights.bytes());
michael@0 244 buffer->write(&bounds, sizeof(bounds));
michael@0 245
michael@0 246 SkASSERT(buffer->pos() - beforePos == (size_t) this->writeSize());
michael@0 247 }
michael@0 248
michael@0 249 uint32_t SkPathRef::writeSize() const {
michael@0 250 return uint32_t(5 * sizeof(uint32_t) +
michael@0 251 fVerbCnt * sizeof(uint8_t) +
michael@0 252 fPointCnt * sizeof(SkPoint) +
michael@0 253 fConicWeights.bytes() +
michael@0 254 sizeof(SkRect));
michael@0 255 }
michael@0 256
michael@0 257 void SkPathRef::copy(const SkPathRef& ref,
michael@0 258 int additionalReserveVerbs,
michael@0 259 int additionalReservePoints) {
michael@0 260 SkDEBUGCODE(this->validate();)
michael@0 261 this->resetToSize(ref.fVerbCnt, ref.fPointCnt, ref.fConicWeights.count(),
michael@0 262 additionalReserveVerbs, additionalReservePoints);
michael@0 263 memcpy(this->verbsMemWritable(), ref.verbsMemBegin(), ref.fVerbCnt * sizeof(uint8_t));
michael@0 264 memcpy(this->fPoints, ref.fPoints, ref.fPointCnt * sizeof(SkPoint));
michael@0 265 fConicWeights = ref.fConicWeights;
michael@0 266 // We could call genID() here to force a real ID (instead of 0). However, if we're making
michael@0 267 // a copy then presumably we intend to make a modification immediately afterwards.
michael@0 268 fGenerationID = ref.fGenerationID;
michael@0 269 fBoundsIsDirty = ref.fBoundsIsDirty;
michael@0 270 if (!fBoundsIsDirty) {
michael@0 271 fBounds = ref.fBounds;
michael@0 272 fIsFinite = ref.fIsFinite;
michael@0 273 }
michael@0 274 fSegmentMask = ref.fSegmentMask;
michael@0 275 fIsOval = ref.fIsOval;
michael@0 276 SkDEBUGCODE(this->validate();)
michael@0 277 }
michael@0 278
michael@0 279 SkPoint* SkPathRef::growForRepeatedVerb(int /*SkPath::Verb*/ verb,
michael@0 280 int numVbs,
michael@0 281 SkScalar** weights) {
michael@0 282 // This value is just made-up for now. When count is 4, calling memset was much
michael@0 283 // slower than just writing the loop. This seems odd, and hopefully in the
michael@0 284 // future this will appear to have been a fluke...
michael@0 285 static const unsigned int kMIN_COUNT_FOR_MEMSET_TO_BE_FAST = 16;
michael@0 286
michael@0 287 SkDEBUGCODE(this->validate();)
michael@0 288 int pCnt;
michael@0 289 bool dirtyAfterEdit = true;
michael@0 290 switch (verb) {
michael@0 291 case SkPath::kMove_Verb:
michael@0 292 pCnt = numVbs;
michael@0 293 dirtyAfterEdit = false;
michael@0 294 break;
michael@0 295 case SkPath::kLine_Verb:
michael@0 296 fSegmentMask |= SkPath::kLine_SegmentMask;
michael@0 297 pCnt = numVbs;
michael@0 298 break;
michael@0 299 case SkPath::kQuad_Verb:
michael@0 300 fSegmentMask |= SkPath::kQuad_SegmentMask;
michael@0 301 pCnt = 2 * numVbs;
michael@0 302 break;
michael@0 303 case SkPath::kConic_Verb:
michael@0 304 fSegmentMask |= SkPath::kConic_SegmentMask;
michael@0 305 pCnt = 2 * numVbs;
michael@0 306 break;
michael@0 307 case SkPath::kCubic_Verb:
michael@0 308 fSegmentMask |= SkPath::kCubic_SegmentMask;
michael@0 309 pCnt = 3 * numVbs;
michael@0 310 break;
michael@0 311 case SkPath::kClose_Verb:
michael@0 312 SkDEBUGFAIL("growForRepeatedVerb called for kClose_Verb");
michael@0 313 pCnt = 0;
michael@0 314 dirtyAfterEdit = false;
michael@0 315 break;
michael@0 316 case SkPath::kDone_Verb:
michael@0 317 SkDEBUGFAIL("growForRepeatedVerb called for kDone");
michael@0 318 // fall through
michael@0 319 default:
michael@0 320 SkDEBUGFAIL("default should not be reached");
michael@0 321 pCnt = 0;
michael@0 322 dirtyAfterEdit = false;
michael@0 323 }
michael@0 324
michael@0 325 size_t space = numVbs * sizeof(uint8_t) + pCnt * sizeof (SkPoint);
michael@0 326 this->makeSpace(space);
michael@0 327
michael@0 328 SkPoint* ret = fPoints + fPointCnt;
michael@0 329 uint8_t* vb = fVerbs - fVerbCnt;
michael@0 330
michael@0 331 // cast to unsigned, so if kMIN_COUNT_FOR_MEMSET_TO_BE_FAST is defined to
michael@0 332 // be 0, the compiler will remove the test/branch entirely.
michael@0 333 if ((unsigned)numVbs >= kMIN_COUNT_FOR_MEMSET_TO_BE_FAST) {
michael@0 334 memset(vb - numVbs, verb, numVbs);
michael@0 335 } else {
michael@0 336 for (int i = 0; i < numVbs; ++i) {
michael@0 337 vb[~i] = verb;
michael@0 338 }
michael@0 339 }
michael@0 340
michael@0 341 fVerbCnt += numVbs;
michael@0 342 fPointCnt += pCnt;
michael@0 343 fFreeSpace -= space;
michael@0 344 fBoundsIsDirty = true; // this also invalidates fIsFinite
michael@0 345 if (dirtyAfterEdit) {
michael@0 346 fIsOval = false;
michael@0 347 }
michael@0 348
michael@0 349 if (SkPath::kConic_Verb == verb) {
michael@0 350 SkASSERT(NULL != weights);
michael@0 351 *weights = fConicWeights.append(numVbs);
michael@0 352 }
michael@0 353
michael@0 354 SkDEBUGCODE(this->validate();)
michael@0 355 return ret;
michael@0 356 }
michael@0 357
michael@0 358 SkPoint* SkPathRef::growForVerb(int /* SkPath::Verb*/ verb, SkScalar weight) {
michael@0 359 SkDEBUGCODE(this->validate();)
michael@0 360 int pCnt;
michael@0 361 bool dirtyAfterEdit = true;
michael@0 362 switch (verb) {
michael@0 363 case SkPath::kMove_Verb:
michael@0 364 pCnt = 1;
michael@0 365 dirtyAfterEdit = false;
michael@0 366 break;
michael@0 367 case SkPath::kLine_Verb:
michael@0 368 fSegmentMask |= SkPath::kLine_SegmentMask;
michael@0 369 pCnt = 1;
michael@0 370 break;
michael@0 371 case SkPath::kQuad_Verb:
michael@0 372 fSegmentMask |= SkPath::kQuad_SegmentMask;
michael@0 373 pCnt = 2;
michael@0 374 break;
michael@0 375 case SkPath::kConic_Verb:
michael@0 376 fSegmentMask |= SkPath::kConic_SegmentMask;
michael@0 377 pCnt = 2;
michael@0 378 break;
michael@0 379 case SkPath::kCubic_Verb:
michael@0 380 fSegmentMask |= SkPath::kCubic_SegmentMask;
michael@0 381 pCnt = 3;
michael@0 382 break;
michael@0 383 case SkPath::kClose_Verb:
michael@0 384 pCnt = 0;
michael@0 385 dirtyAfterEdit = false;
michael@0 386 break;
michael@0 387 case SkPath::kDone_Verb:
michael@0 388 SkDEBUGFAIL("growForVerb called for kDone");
michael@0 389 // fall through
michael@0 390 default:
michael@0 391 SkDEBUGFAIL("default is not reached");
michael@0 392 dirtyAfterEdit = false;
michael@0 393 pCnt = 0;
michael@0 394 }
michael@0 395 size_t space = sizeof(uint8_t) + pCnt * sizeof (SkPoint);
michael@0 396 this->makeSpace(space);
michael@0 397 this->fVerbs[~fVerbCnt] = verb;
michael@0 398 SkPoint* ret = fPoints + fPointCnt;
michael@0 399 fVerbCnt += 1;
michael@0 400 fPointCnt += pCnt;
michael@0 401 fFreeSpace -= space;
michael@0 402 fBoundsIsDirty = true; // this also invalidates fIsFinite
michael@0 403 if (dirtyAfterEdit) {
michael@0 404 fIsOval = false;
michael@0 405 }
michael@0 406
michael@0 407 if (SkPath::kConic_Verb == verb) {
michael@0 408 *fConicWeights.append() = weight;
michael@0 409 }
michael@0 410
michael@0 411 SkDEBUGCODE(this->validate();)
michael@0 412 return ret;
michael@0 413 }
michael@0 414
michael@0 415 uint32_t SkPathRef::genID() const {
michael@0 416 SkASSERT(!fEditorsAttached);
michael@0 417 static const uint32_t kMask = (static_cast<int64_t>(1) << SkPath::kPathRefGenIDBitCnt) - 1;
michael@0 418 if (!fGenerationID) {
michael@0 419 if (0 == fPointCnt && 0 == fVerbCnt) {
michael@0 420 fGenerationID = kEmptyGenID;
michael@0 421 } else {
michael@0 422 static int32_t gPathRefGenerationID;
michael@0 423 // do a loop in case our global wraps around, as we never want to return a 0 or the
michael@0 424 // empty ID
michael@0 425 do {
michael@0 426 fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMask;
michael@0 427 } while (fGenerationID <= kEmptyGenID);
michael@0 428 }
michael@0 429 }
michael@0 430 return fGenerationID;
michael@0 431 }
michael@0 432
michael@0 433 #ifdef SK_DEBUG
michael@0 434 void SkPathRef::validate() const {
michael@0 435 this->INHERITED::validate();
michael@0 436 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0);
michael@0 437 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPoints) >= 0);
michael@0 438 SkASSERT((NULL == fPoints) == (NULL == fVerbs));
michael@0 439 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace));
michael@0 440 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace));
michael@0 441 SkASSERT(!(NULL == fPoints && fPointCnt));
michael@0 442 SkASSERT(!(NULL == fVerbs && fVerbCnt));
michael@0 443 SkASSERT(this->currSize() ==
michael@0 444 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVerbCnt);
michael@0 445
michael@0 446 if (!fBoundsIsDirty && !fBounds.isEmpty()) {
michael@0 447 bool isFinite = true;
michael@0 448 for (int i = 0; i < fPointCnt; ++i) {
michael@0 449 SkASSERT(!fPoints[i].isFinite() || (
michael@0 450 fBounds.fLeft - fPoints[i].fX < SK_ScalarNearlyZero &&
michael@0 451 fPoints[i].fX - fBounds.fRight < SK_ScalarNearlyZero &&
michael@0 452 fBounds.fTop - fPoints[i].fY < SK_ScalarNearlyZero &&
michael@0 453 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero));
michael@0 454 if (!fPoints[i].isFinite()) {
michael@0 455 isFinite = false;
michael@0 456 }
michael@0 457 }
michael@0 458 SkASSERT(SkToBool(fIsFinite) == isFinite);
michael@0 459 }
michael@0 460
michael@0 461 #ifdef SK_DEBUG_PATH
michael@0 462 uint32_t mask = 0;
michael@0 463 for (int i = 0; i < fVerbCnt; ++i) {
michael@0 464 switch (fVerbs[~i]) {
michael@0 465 case SkPath::kMove_Verb:
michael@0 466 break;
michael@0 467 case SkPath::kLine_Verb:
michael@0 468 mask |= SkPath::kLine_SegmentMask;
michael@0 469 break;
michael@0 470 case SkPath::kQuad_Verb:
michael@0 471 mask |= SkPath::kQuad_SegmentMask;
michael@0 472 break;
michael@0 473 case SkPath::kConic_Verb:
michael@0 474 mask |= SkPath::kConic_SegmentMask;
michael@0 475 break;
michael@0 476 case SkPath::kCubic_Verb:
michael@0 477 mask |= SkPath::kCubic_SegmentMask;
michael@0 478 break;
michael@0 479 case SkPath::kClose_Verb:
michael@0 480 break;
michael@0 481 case SkPath::kDone_Verb:
michael@0 482 SkDEBUGFAIL("Done verb shouldn't be recorded.");
michael@0 483 break;
michael@0 484 default:
michael@0 485 SkDEBUGFAIL("Unknown Verb");
michael@0 486 break;
michael@0 487 }
michael@0 488 }
michael@0 489 SkASSERT(mask == fSegmentMask);
michael@0 490 #endif // SK_DEBUG_PATH
michael@0 491 }
michael@0 492 #endif

mercurial