Index: include/core/SkDynamicAnnotations.h |
diff --git a/include/core/SkDynamicAnnotations.h b/include/core/SkDynamicAnnotations.h |
index 108dd10f9c8798e0061d1bba9a50677118854b9c..e7710307f5532589a09b1f56d9b976cfdc373de7 100644 |
--- a/include/core/SkDynamicAnnotations.h |
+++ b/include/core/SkDynamicAnnotations.h |
@@ -66,4 +66,23 @@ |
#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 |