diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-02-27 18:43:48 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-01 09:33:37 +0100 |
commit | fde7c20f36ce2ecfdd79d2722fc2f0bee72e7e99 (patch) | |
tree | e47f97900d812d438fb67f811c6e9fb00d2bd52b /src/mbgl/gfx | |
parent | da6e1390c68e01e02652104586c759d46e04c7fd (diff) | |
download | qtlocation-mapboxgl-fde7c20f36ce2ecfdd79d2722fc2f0bee72e7e99.tar.gz |
[core] move GL enum conversions to separate file
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r-- | src/mbgl/gfx/color_mode.hpp | 57 | ||||
-rw-r--r-- | src/mbgl/gfx/types.hpp | 24 |
2 files changed, 41 insertions, 40 deletions
diff --git a/src/mbgl/gfx/color_mode.hpp b/src/mbgl/gfx/color_mode.hpp index 97bbc24096..077c7771bd 100644 --- a/src/mbgl/gfx/color_mode.hpp +++ b/src/mbgl/gfx/color_mode.hpp @@ -1,5 +1,6 @@ #pragma once +#include <mbgl/gfx/types.hpp> #include <mbgl/util/variant.hpp> #include <mbgl/util/color.hpp> @@ -8,53 +9,29 @@ namespace gfx { class ColorMode { public: - enum class BlendEquation { - Add, - Subtract, - ReverseSubtract - }; - - enum class BlendFactor { - Zero, - One, - SrcColor, - OneMinusSrcColor, - SrcAlpha, - OneMinusSrcAlpha, - DstAlpha, - OneMinusDstAlpha, - DstColor, - OneMinusDstColor, - SrcAlphaSaturate, - ConstantColor, - OneMinusConstantColor, - ConstantAlpha, - OneMinusConstantAlpha - }; - - template <BlendEquation E> + template <ColorBlendEquationType E> struct ConstantBlend { - static constexpr BlendEquation equation = E; - static constexpr BlendFactor srcFactor = BlendFactor::One; - static constexpr BlendFactor dstFactor = BlendFactor::One; + static constexpr ColorBlendEquationType equation = E; + static constexpr ColorBlendFactorType srcFactor = ColorBlendFactorType::One; + static constexpr ColorBlendFactorType dstFactor = ColorBlendFactorType::One; }; - template <BlendEquation E> + template <ColorBlendEquationType E> struct LinearBlend { - static constexpr BlendEquation equation = E; - BlendFactor srcFactor; - BlendFactor dstFactor; + static constexpr ColorBlendEquationType equation = E; + ColorBlendFactorType srcFactor; + ColorBlendFactorType dstFactor; }; struct Replace { - static constexpr BlendEquation equation = BlendEquation::Add; - static constexpr BlendFactor srcFactor = BlendFactor::One; - static constexpr BlendFactor dstFactor = BlendFactor::Zero; + static constexpr ColorBlendEquationType equation = ColorBlendEquationType::Add; + static constexpr ColorBlendFactorType srcFactor = ColorBlendFactorType::One; + static constexpr ColorBlendFactorType dstFactor = ColorBlendFactorType::Zero; }; - using Add = LinearBlend<BlendEquation::Add>; - using Subtract = LinearBlend<BlendEquation::Subtract>; - using ReverseSubtract = LinearBlend<BlendEquation::ReverseSubtract>; + using Add = LinearBlend<ColorBlendEquationType::Add>; + using Subtract = LinearBlend<ColorBlendEquationType::Subtract>; + using ReverseSubtract = LinearBlend<ColorBlendEquationType::ReverseSubtract>; using BlendFunction = variant< Replace, @@ -83,11 +60,11 @@ public: } static ColorMode alphaBlended() { - return { Add{ BlendFactor::One, BlendFactor::OneMinusSrcAlpha }, {}, { true, true, true, true } }; + return { Add{ ColorBlendFactorType::One, ColorBlendFactorType::OneMinusSrcAlpha }, {}, { true, true, true, true } }; } static ColorMode additive() { - return { Add{ BlendFactor::One, BlendFactor::One }, {}, { true, true, true, true } }; + return { Add{ ColorBlendFactorType::One, ColorBlendFactorType::One }, {}, { true, true, true, true } }; } }; diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp index ea7b2da5dc..adf3395db0 100644 --- a/src/mbgl/gfx/types.hpp +++ b/src/mbgl/gfx/types.hpp @@ -15,5 +15,29 @@ enum class PrimitiveType : uint8_t { TriangleFan }; +enum class ColorBlendEquationType : uint8_t { + Add, + Subtract, + ReverseSubtract +}; + +enum class ColorBlendFactorType : uint8_t { + Zero, + One, + SrcColor, + OneMinusSrcColor, + SrcAlpha, + OneMinusSrcAlpha, + DstAlpha, + OneMinusDstAlpha, + DstColor, + OneMinusDstColor, + SrcAlphaSaturate, + ConstantColor, + OneMinusConstantColor, + ConstantAlpha, + OneMinusConstantAlpha +}; + } // namespace gfx } // namespace mbgl |