diff options
author | reed <reed@google.com> | 2014-11-21 08:07:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-21 08:07:41 -0800 |
commit | 41d2c2e434d11e73f66c597913c29ea1fb3fa879 (patch) | |
tree | a57defd795d6813f9245342432ccb81b52c35b6a /src | |
parent | 8f81b69ed763777a922bce27b5f05f4179b76157 (diff) |
simplify uniqueID code in picture
patch from issue 750003002 at patchset 1 (http://crrev.com/750003002#ps1)
BUG=skia:
Review URL: https://codereview.chromium.org/752573002
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicture.cpp | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 7f4b33afac..4848345e51 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -45,6 +45,18 @@ template <typename T> int SafeCount(const T* obj) { return obj ? obj->count() : 0; } +static int32_t gPictureGenerationID; + +// never returns a 0 +static int32_t next_picture_generation_id() { + // Loop in case our global wraps around. + int32_t genID; + do { + genID = sk_atomic_inc(&gPictureGenerationID) + 1; + } while (0 == genID); + return genID; +} + /////////////////////////////////////////////////////////////////////////////// namespace { @@ -512,33 +524,15 @@ bool SkPicture::hasText() const { return fAnalysis.fHasText; } bool SkPicture::willPlayBackBitmaps() const { return fAnalysis.fWillPlaybackBitmaps; } int SkPicture::approximateOpCount() const { return fRecord->count(); } -static int32_t gPictureGenerationID = SK_InvalidGenID; // This will be set at link time. - -static int32_t next_picture_generation_id() { - // Loop in case our global wraps around. - int32_t genID; - do { - genID = sk_atomic_inc(&gPictureGenerationID) + 1; - } while (SK_InvalidGenID == genID); - return genID; -} - -uint32_t SkPicture::uniqueID() const { - if (SK_InvalidGenID == fUniqueID) { - fUniqueID = next_picture_generation_id(); - } - return fUniqueID; -} - SkPicture::SkPicture(const SkRect& cullRect, SkRecord* record, SkData* drawablePicts, SkBBoxHierarchy* bbh) - : fCullRect(cullRect) + : fUniqueID(next_picture_generation_id()) + , fCullRect(cullRect) , fRecord(record) , fBBH(SkSafeRef(bbh)) , fDrawablePicts(SkSafeRef(drawablePicts)) - , fAnalysis(*fRecord) { - this->needsNewGenID(); -} + , fAnalysis(*fRecord) +{} // Note that we are assuming that this entry point will only be called from // one thread. Currently the only client of this method is |