aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkDynamicAnnotations.h19
-rw-r--r--include/core/SkPixelRef.h4
2 files changed, 21 insertions, 2 deletions
diff --git a/include/core/SkDynamicAnnotations.h b/include/core/SkDynamicAnnotations.h
index 108dd10f9c..e7710307f5 100644
--- a/include/core/SkDynamicAnnotations.h
+++ b/include/core/SkDynamicAnnotations.h
@@ -66,4 +66,23 @@ void SK_ANNOTATE_BENIGN_RACE(T* ptr) {
#endif
+// Can be used to wrap values that are intentionally racy, usually small mutable cached values, e.g.
+// - SkMatrix type mask
+// - SkPixelRef genIDs
+template <typename T>
+class SkTRacy {
+public:
+ operator const T() const {
+ return SK_ANNOTATE_UNPROTECTED_READ(fVal);
+ }
+
+ SkTRacy& operator=(const T& val) {
+ SK_ANNOTATE_UNPROTECTED_WRITE(&fVal, val);
+ return *this;
+ }
+
+private:
+ T fVal;
+};
+
#endif//SkDynamicAnnotations_DEFINED
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 9b98ebdf10..2a5e7ecbdc 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -353,8 +353,8 @@ private:
LockRec fRec;
int fLockCount;
- mutable uint32_t fGenerationID;
- mutable bool fUniqueGenerationID;
+ mutable SkTRacy<uint32_t> fGenerationID;
+ mutable SkTRacy<bool> fUniqueGenerationID;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
const uint32_t fStableID;
#endif