Skip to content

Commit

Permalink
mbgl::variant -> std::variant
Browse files Browse the repository at this point in the history
  • Loading branch information
bencsikandrei committed Apr 17, 2023
1 parent 30c220d commit 66c2808
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/mbgl/gfx/color_mode.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include <mbgl/gfx/types.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/util/color.hpp>

#include <variant>

namespace mbgl {
namespace gfx {

Expand Down Expand Up @@ -33,7 +34,7 @@ class ColorMode {
using Subtract = LinearBlend<ColorBlendEquationType::Subtract>;
using ReverseSubtract = LinearBlend<ColorBlendEquationType::ReverseSubtract>;

using BlendFunction = variant<
using BlendFunction = std::variant<
Replace,
Add,
Subtract,
Expand Down
5 changes: 3 additions & 2 deletions src/mbgl/gfx/stencil_mode.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <mbgl/gfx/types.hpp>
#include <mbgl/util/variant.hpp>

#include <variant>

namespace mbgl {
namespace gfx {
Expand Down Expand Up @@ -29,7 +30,7 @@ class StencilMode {
using GreaterEqual = MaskedTest<StencilFunctionType::GreaterEqual>;
using Always = SimpleTest<StencilFunctionType::Always>;

using Test = variant<
using Test = std::variant<
Never,
Less,
Equal,
Expand Down
18 changes: 10 additions & 8 deletions src/mbgl/gl/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
#include <mbgl/gl/command_encoder.hpp>
#include <mbgl/gl/debugging_extension.hpp>
#include <mbgl/gl/vertex_array_extension.hpp>
#include <mbgl/util/traits.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/overloaded.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/traits.hpp>

#include <cstring>
#include <iterator>
#include <variant>

namespace mbgl {
namespace gl {
Expand Down Expand Up @@ -558,28 +560,28 @@ void Context::setDepthMode(const gfx::DepthMode& depth) {
}

void Context::setStencilMode(const gfx::StencilMode& stencil) {
if (stencil.test.is<gfx::StencilMode::Always>() && !stencil.mask) {
if (std::holds_alternative<gfx::StencilMode::Always>(stencil.test) && !stencil.mask) {
stencilTest = false;
} else {
stencilTest = true;
stencilMask = stencil.mask;
stencilOp = { stencil.fail, stencil.depthFail, stencil.pass };
apply_visitor([&] (const auto& test) {
std::visit(util::Overloaded{[&](const auto& test) {
stencilFunc = { test.func, stencil.ref, test.mask };
}, stencil.test);
}}, stencil.test);
}
}

void Context::setColorMode(const gfx::ColorMode& color) {
if (color.blendFunction.is<gfx::ColorMode::Replace>()) {
if (std::holds_alternative<gfx::ColorMode::Replace>(color.blendFunction)) {
blend = false;
} else {
blend = true;
blendColor = color.blendColor;
apply_visitor([&] (const auto& blendFunction) {
std::visit(util::Overloaded{[&] (const auto& blendFunction) {
blendEquation = gfx::ColorBlendEquationType(blendFunction.equation);
blendFunc = { blendFunction.srcFactor, blendFunction.dstFactor };
}, color.blendFunction);
}}, color.blendFunction);
}

colorMask = color.mask;
Expand Down
1 change: 0 additions & 1 deletion src/mbgl/renderer/paint_property_binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <mbgl/renderer/possibly_evaluated_property_value.hpp>
#include <mbgl/renderer/paint_property_statistics.hpp>
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
#include <mbgl/util/variant.hpp>
#include <mbgl/renderer/image_atlas.hpp>
#include <mbgl/util/indexed_tuple.hpp>
#include <mbgl/layout/pattern_layout.hpp>
Expand Down

0 comments on commit 66c2808

Please sign in to comment.