Index: include/gpu/GrTypes.h |
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h |
index a0f13aa6febcbf35f8909ac486e44d3eef5f5f5b..7bc949d73c366a5f19c534d5ed0e858d2147867d 100644 |
--- a/include/gpu/GrTypes.h |
+++ b/include/gpu/GrTypes.h |
@@ -49,6 +49,27 @@ |
\ |
template <typename T> \ |
friend X operator & (X a, T b); \ |
+ |
+/** |
+ * Defines bitwise operators that make it possible to use an enum class as a |
+ * very basic bitfield. |
+ */ |
+#define GR_MAKE_BITFIELD_CLASS_OPS(X) \ |
+ inline X operator | (X a, X b) { \ |
+ return (X) ((int)a | (int)b); \ |
+ } \ |
+ inline X& operator |= (X& a, X b) { \ |
+ return (a = a | b); \ |
+ } \ |
+ inline bool operator & (X a, X b) { \ |
+ return SkToBool((int)a & (int)b); \ |
+ } |
+ |
+#define GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(X) \ |
+ friend X operator | (X a, X b); \ |
+ friend X& operator |= (X& a, X b); \ |
+ friend bool operator & (X a, X b); |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// compile time versions of min/max |