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

Side by Side Diff: src/core/SkPathRef.cpp

Issue 49693002: Use SkPathRef gen id for SkPath::getGenerationID (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: upload again, rietveld diff failed. Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkPath.cpp ('k') | tests/PathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBuffer.h" 8 #include "SkBuffer.h"
9 #include "SkOnce.h" 9 #include "SkOnce.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 this->fVerbs[~fVerbCnt] = verb; 282 this->fVerbs[~fVerbCnt] = verb;
283 SkPoint* ret = fPoints + fPointCnt; 283 SkPoint* ret = fPoints + fPointCnt;
284 fVerbCnt += 1; 284 fVerbCnt += 1;
285 fPointCnt += pCnt; 285 fPointCnt += pCnt;
286 fFreeSpace -= space; 286 fFreeSpace -= space;
287 fBoundsIsDirty = true; // this also invalidates fIsFinite 287 fBoundsIsDirty = true; // this also invalidates fIsFinite
288 SkDEBUGCODE(this->validate();) 288 SkDEBUGCODE(this->validate();)
289 return ret; 289 return ret;
290 } 290 }
291 291
292 int32_t SkPathRef::genID() const { 292 uint32_t SkPathRef::genID() const {
293 SkASSERT(!fEditorsAttached); 293 SkASSERT(!fEditorsAttached);
294 static const uint32_t kMask = (static_cast<int64_t>(1) << SkPath::kPathRefGe nIDBitCnt) - 1;
294 if (!fGenerationID) { 295 if (!fGenerationID) {
295 if (0 == fPointCnt && 0 == fVerbCnt) { 296 if (0 == fPointCnt && 0 == fVerbCnt) {
296 fGenerationID = kEmptyGenID; 297 fGenerationID = kEmptyGenID;
297 } else { 298 } else {
298 static int32_t gPathRefGenerationID; 299 static int32_t gPathRefGenerationID;
299 // do a loop in case our global wraps around, as we never want to re turn a 0 or the 300 // do a loop in case our global wraps around, as we never want to re turn a 0 or the
300 // empty ID 301 // empty ID
301 do { 302 do {
302 fGenerationID = sk_atomic_inc(&gPathRefGenerationID) + 1; 303 fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMa sk;
303 } while (fGenerationID <= kEmptyGenID); 304 } while (fGenerationID <= kEmptyGenID);
304 } 305 }
305 } 306 }
306 return fGenerationID; 307 return fGenerationID;
307 } 308 }
308 309
309 #ifdef SK_DEBUG 310 #ifdef SK_DEBUG
310 void SkPathRef::validate() const { 311 void SkPathRef::validate() const {
311 this->INHERITED::validate(); 312 this->INHERITED::validate();
312 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); 313 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0);
(...skipping 16 matching lines...) Expand all
329 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero); 330 fPoints[i].fY - fBounds.fBottom < SK_ScalarNearlyZero);
330 if (!fPoints[i].isFinite()) { 331 if (!fPoints[i].isFinite()) {
331 isFinite = false; 332 isFinite = false;
332 } 333 }
333 } 334 }
334 SkASSERT(SkToBool(fIsFinite) == isFinite); 335 SkASSERT(SkToBool(fIsFinite) == isFinite);
335 } 336 }
336 #endif 337 #endif
337 } 338 }
338 #endif 339 #endif
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698