summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx/stencil_mode.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-02-28 12:03:29 +0100
committerKonstantin Käfer <mail@kkaefer.com>2019-03-01 09:33:37 +0100
commit4372ce2b90a26d114fafa555227a5200c421878f (patch)
treed3995b51c4fe4d2fea83ea57ce308de0cd24b89c /src/mbgl/gfx/stencil_mode.hpp
parent53628a455bba6448579cbb8e8cedf25de28a8b3f (diff)
downloadqtlocation-mapboxgl-4372ce2b90a26d114fafa555227a5200c421878f.tar.gz
[core] move StencilMode to gfx namespace
Diffstat (limited to 'src/mbgl/gfx/stencil_mode.hpp')
-rw-r--r--src/mbgl/gfx/stencil_mode.hpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/mbgl/gfx/stencil_mode.hpp b/src/mbgl/gfx/stencil_mode.hpp
new file mode 100644
index 0000000000..3ba2687b8c
--- /dev/null
+++ b/src/mbgl/gfx/stencil_mode.hpp
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <mbgl/gfx/types.hpp>
+#include <mbgl/util/variant.hpp>
+
+namespace mbgl {
+namespace gfx {
+
+class StencilMode {
+public:
+ template <StencilFunctionType F>
+ struct SimpleTest {
+ static constexpr StencilFunctionType func = F;
+ static constexpr uint32_t mask = 0;
+ };
+
+ template <StencilFunctionType F>
+ struct MaskedTest {
+ static constexpr StencilFunctionType func = F;
+ uint32_t mask;
+ };
+
+ using Never = SimpleTest<StencilFunctionType::Never>;
+ using Less = MaskedTest<StencilFunctionType::Less>;
+ using Equal = MaskedTest<StencilFunctionType::Equal>;
+ using LessEqual = MaskedTest<StencilFunctionType::LessEqual>;
+ using Greater = MaskedTest<StencilFunctionType::Greater>;
+ using NotEqual = MaskedTest<StencilFunctionType::NotEqual>;
+ using GreaterEqual = MaskedTest<StencilFunctionType::GreaterEqual>;
+ using Always = SimpleTest<StencilFunctionType::Always>;
+
+ using Test = variant<
+ Never,
+ Less,
+ Equal,
+ LessEqual,
+ Greater,
+ NotEqual,
+ GreaterEqual,
+ Always>;
+
+ Test test;
+ int32_t ref;
+ uint32_t mask;
+
+ StencilOpType fail;
+ StencilOpType depthFail;
+ StencilOpType pass;
+
+ static StencilMode disabled() {
+ return StencilMode { Always(), 0, 0, StencilOpType::Keep, StencilOpType::Keep, StencilOpType::Keep };
+ }
+};
+
+} // namespace gfx
+} // namespace mbgl