| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkDynamicAnnotations_DEFINED | 8 #ifndef SkDynamicAnnotations_DEFINED |
| 9 #define SkDynamicAnnotations_DEFINED | 9 #define SkDynamicAnnotations_DEFINED |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 #else // !DYNAMIC_ANNOTATIONS_ENABLED | 61 #else // !DYNAMIC_ANNOTATIONS_ENABLED |
| 62 | 62 |
| 63 #define SK_ANNOTATE_UNPROTECTED_READ(x) (x) | 63 #define SK_ANNOTATE_UNPROTECTED_READ(x) (x) |
| 64 #define SK_ANNOTATE_UNPROTECTED_WRITE(ptr, val) *(ptr) = (val) | 64 #define SK_ANNOTATE_UNPROTECTED_WRITE(ptr, val) *(ptr) = (val) |
| 65 #define SK_ANNOTATE_BENIGN_RACE(ptr) | 65 #define SK_ANNOTATE_BENIGN_RACE(ptr) |
| 66 | 66 |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 // Can be used to wrap values that are intentionally racy, usually small mutable
cached values, e.g. |
| 70 // - SkMatrix type mask |
| 71 // - SkPixelRef genIDs |
| 72 template <typename T> |
| 73 class SkTRacy { |
| 74 public: |
| 75 operator const T() const { |
| 76 return SK_ANNOTATE_UNPROTECTED_READ(fVal); |
| 77 } |
| 78 |
| 79 SkTRacy& operator=(const T& val) { |
| 80 SK_ANNOTATE_UNPROTECTED_WRITE(&fVal, val); |
| 81 return *this; |
| 82 } |
| 83 |
| 84 private: |
| 85 T fVal; |
| 86 }; |
| 87 |
| 69 #endif//SkDynamicAnnotations_DEFINED | 88 #endif//SkDynamicAnnotations_DEFINED |
| OLD | NEW |