Skip to content

Commit

Permalink
mbgl::variant -> std::variant in line_atlas
Browse files Browse the repository at this point in the history
  • Loading branch information
bencsikandrei committed Apr 17, 2023
1 parent 66c2808 commit aac58c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/mbgl/geometry/line_atlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <mbgl/math/minmax.hpp>
#include <mbgl/util/hash.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/overloaded.hpp>
#include <mbgl/util/platform.hpp>

namespace mbgl {
Expand Down Expand Up @@ -203,23 +204,23 @@ DashPatternTexture::DashPatternTexture(const std::vector<float>& from_,
}

void DashPatternTexture::upload(gfx::UploadPass& uploadPass) {
if (texture.is<AlphaImage>()) {
texture = uploadPass.createTexture(texture.get<AlphaImage>());
if (std::holds_alternative<AlphaImage>(texture)) {
texture = uploadPass.createTexture(std::get<AlphaImage>(texture));
}
}

gfx::TextureBinding DashPatternTexture::textureBinding() const {
// The texture needs to have been uploaded already.
assert(texture.is<gfx::Texture>());
return {texture.get<gfx::Texture>().getResource(),
assert(std::holds_alternative<gfx::Texture>(texture));
return {std::get<gfx::Texture>(texture).getResource(),
gfx::TextureFilterType::Linear,
gfx::TextureMipMapType::No,
gfx::TextureWrapType::Repeat,
gfx::TextureWrapType::Clamp};
}

Size DashPatternTexture::getSize() const {
return texture.match([](const auto& obj) { return obj.size; });
return std::visit([](const auto& obj) { return obj.size; }, texture);
}

LineAtlas::LineAtlas() = default;
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/geometry/line_atlas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <mbgl/gfx/texture.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/variant.hpp>

#include <map>
#include <memory>
#include <vector>
#include <optional>
#include <variant>
#include <vector>

namespace mbgl {

Expand Down Expand Up @@ -53,7 +53,7 @@ class DashPatternTexture {

private:
LinePatternPos from, to;
variant<AlphaImage, gfx::Texture> texture;
std::variant<AlphaImage, gfx::Texture> texture;
};

class LineAtlas {
Expand Down

0 comments on commit aac58c8

Please sign in to comment.