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

Unified Diff: src/core/SkEnumOperators.h

Issue 2246903002: SkPDF: SkPDFFont class changes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-15 (Monday) 17:11:22 EDT Created 4 years, 4 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
Index: src/core/SkEnumOperators.h
diff --git a/src/core/SkEnumOperators.h b/src/core/SkEnumOperators.h
new file mode 100644
index 0000000000000000000000000000000000000000..ebf5aead2d65dc92b2a266b762a95de4b3844f4f
--- /dev/null
+++ b/src/core/SkEnumOperators.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkEnumOperators_DEFINED
+#define SkEnumOperators_DEFINED
bungeman-skia 2016/08/15 21:41:36 I don't think these are generally desirable enum o
hal.canary 2016/08/16 01:27:38 Done.
+
+#include "SkTLogic.h"
+
+namespace skstd {
+template <typename T> struct is_bitmask_enum : std::false_type {};
+}
+
+template <typename E>
+SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator|(E l, E r) {
bungeman-skia 2016/08/15 21:41:36 nit: I personally prefer lines 16 and 17 here on o
hal.canary 2016/08/16 01:27:38 Done.
+ using U = skstd::underlying_type_t<E>;
+ return static_cast<E>(static_cast<U>(l) | static_cast<U>(r));
+}
+
+template <typename E>
+SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator|=(E& l, E r) {
+ return l = l | r;
+}
+
+template <typename E>
+SK_WHEN(skstd::is_bitmask_enum<E>::value, E) operator&(E l, E r) {
+ using U = skstd::underlying_type_t<E>;
+ return static_cast<E>(static_cast<U>(l) & static_cast<U>(r));
+}
+
+template <typename E>
+SK_WHEN(skstd::is_bitmask_enum<E>::value, E&) operator&=(E& l, E r) {
+ return l = l & r;
+}
+
+#endif // SkEnumOperators_DEFINED

Powered by Google App Engine
This is Rietveld 408576698