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

Unified Diff: src/core/SkTextBlob.cpp

Issue 1036613002: simple patch to always init SkTextBlob uniqueID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 5 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkTextBlob.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTextBlob.cpp
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index bf620328d61a94eb2a4cc569f9b1e8a9396bc871..3ffc41e9ba6677b5eb1904da834a4281b26800f4 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -108,9 +108,19 @@ private:
SkDEBUGCODE(unsigned fMagic;)
};
+static int32_t gNextID = 1;
+static int32_t next_id() {
+ int32_t id;
+ do {
+ id = sk_atomic_inc(&gNextID);
+ } while (id == SK_InvalidGenID);
+ return id;
+}
+
SkTextBlob::SkTextBlob(int runCount, const SkRect& bounds)
: fRunCount(runCount)
- , fBounds(bounds) {
+ , fBounds(bounds)
+ , fUniqueID(next_id()) {
}
SkTextBlob::~SkTextBlob() {
@@ -123,17 +133,6 @@ SkTextBlob::~SkTextBlob() {
}
}
-uint32_t SkTextBlob::uniqueID() const {
- static int32_t gTextBlobGenerationID; // = 0;
-
- // loop in case our global wraps around, as we never want to return SK_InvalidGenID
- while (SK_InvalidGenID == fUniqueID) {
- fUniqueID = sk_atomic_inc(&gTextBlobGenerationID) + 1;
- }
-
- return fUniqueID;
-}
-
void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
int runCount = fRunCount;
« no previous file with comments | « include/core/SkTextBlob.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698