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

Unified Diff: src/core/SkPixelRef.cpp

Issue 1266883002: unify pixelref and image ID space, so we can share IDs when we share pixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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 | « src/core/SkNextID.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPixelRef.cpp
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 8e0f21280c0da11087d105a358360dd4c54f689a..0edad83028a3f684715af7ceb605524688ff4f77 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -59,15 +59,16 @@ static SkBaseMutex* get_default_mutex() {
}
///////////////////////////////////////////////////////////////////////////////
+#include "SkNextID.h"
-static uint32_t next_gen_id() {
- static uint32_t gNextGenID = 0;
- uint32_t genID;
+uint32_t SkNextID::ImageID() {
+ static uint32_t gID = 0;
+ uint32_t id;
// Loop in case our global wraps around, as we never want to return a 0.
do {
- genID = sk_atomic_fetch_add(&gNextGenID, 2u) + 2; // Never set the low bit.
- } while (0 == genID);
- return genID;
+ id = sk_atomic_fetch_add(&gID, 2u) + 2; // Never set the low bit.
+ } while (0 == id);
+ return id;
}
///////////////////////////////////////////////////////////////////////////////
@@ -300,7 +301,7 @@ bool SkPixelRef::onLockPixelsAreWritable() const {
uint32_t SkPixelRef::getGenerationID() const {
uint32_t id = fTaggedGenID.load();
if (0 == id) {
- uint32_t next = next_gen_id() | 1u;
+ uint32_t next = SkNextID::ImageID() | 1u;
if (fTaggedGenID.compare_exchange(&id, next)) {
id = next; // There was no race or we won the race. fTaggedGenID is next now.
} else {
« no previous file with comments | « src/core/SkNextID.h ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698