summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx
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
parent53628a455bba6448579cbb8e8cedf25de28a8b3f (diff)
downloadqtlocation-mapboxgl-4372ce2b90a26d114fafa555227a5200c421878f.tar.gz
[core] move StencilMode to gfx namespace
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r--src/mbgl/gfx/stencil_mode.hpp56
-rw-r--r--src/mbgl/gfx/types.hpp22
2 files changed, 78 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
diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp
index 264fa67b04..8faa9dc7f9 100644
--- a/src/mbgl/gfx/types.hpp
+++ b/src/mbgl/gfx/types.hpp
@@ -55,5 +55,27 @@ enum class DepthMaskType : bool {
ReadWrite = true,
};
+enum class StencilFunctionType : uint8_t {
+ Never,
+ Less,
+ Equal,
+ LessEqual,
+ Greater,
+ NotEqual,
+ GreaterEqual,
+ Always,
+};
+
+enum class StencilOpType : uint8_t {
+ Zero,
+ Keep,
+ Replace,
+ Increment,
+ Decrement,
+ Invert,
+ IncrementWrap,
+ DecrementWrap,
+};
+
} // namespace gfx
} // namespace mbgl