Use SkPathRef gen id for SkPath::getGenerationID
R=mtklein@google.com, robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/49693002
git-svn-id: http://skia.googlecode.com/svn/trunk@12029 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index f635c2a..f811b24 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -289,8 +289,9 @@
return ret;
}
-int32_t SkPathRef::genID() const {
+uint32_t SkPathRef::genID() const {
SkASSERT(!fEditorsAttached);
+ static const uint32_t kMask = (static_cast<int64_t>(1) << SkPath::kPathRefGenIDBitCnt) - 1;
if (!fGenerationID) {
if (0 == fPointCnt && 0 == fVerbCnt) {
fGenerationID = kEmptyGenID;
@@ -299,7 +300,7 @@
// do a loop in case our global wraps around, as we never want to return a 0 or the
// empty ID
do {
- fGenerationID = sk_atomic_inc(&gPathRefGenerationID) + 1;
+ fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMask;
} while (fGenerationID <= kEmptyGenID);
}
}