Clean more legacy code (#3478)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/attribute.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace attributes {
|
||||
|
||||
// Layout attributes
|
||||
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, pos);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, extrude);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, pos_offset);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, pos_normal);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 3, projected_pos);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, pixeloffset);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, label_pos);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 2, anchor_pos);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, texture_pos);
|
||||
MBGL_DEFINE_ATTRIBUTE(int16_t, 4, normal_ed);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, fade_opacity);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, placed);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 3, size);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, offset);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, shift);
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
struct data {
|
||||
using Type = gfx::AttributeType<T, N>;
|
||||
static constexpr auto name() { return "data"; }
|
||||
};
|
||||
|
||||
// Paint attributes
|
||||
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, fill_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, halo_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, stroke_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 2, outline_color);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, opacity);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, stroke_opacity);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, blur);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, radius);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, width);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, floorwidth);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, height);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, base);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, gapwidth);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, stroke_width);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, halo_width);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, halo_blur);
|
||||
MBGL_DEFINE_ATTRIBUTE(float, 1, weight);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 4, pattern_to);
|
||||
MBGL_DEFINE_ATTRIBUTE(uint16_t, 4, pattern_from);
|
||||
|
||||
} // namespace attributes
|
||||
|
||||
using PositionOnlyLayoutAttributes = TypeList<attributes::pos>;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,3 +0,0 @@
|
||||
#include <mbgl/programs/clipping_mask_program.hpp>
|
||||
|
||||
namespace mbgl {} // namespace mbgl
|
||||
@@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/style/properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ClippingMaskProgram final : public Program<ClippingMaskProgram,
|
||||
shaders::BuiltIn::ClippingMaskProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
PositionOnlyLayoutAttributes,
|
||||
TypeList<uniforms::matrix>,
|
||||
TypeList<>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"ClippingMaskProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
};
|
||||
|
||||
using ClippingMaskLayoutVertex = ClippingMaskProgram::LayoutVertex;
|
||||
using ClippingMaskAttributes = ClippingMaskProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,190 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/attribute.hpp>
|
||||
#include <mbgl/gfx/shader.hpp>
|
||||
#include <mbgl/gfx/uniform.hpp>
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/style/paint_property.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <mbgl/shaders/shader_manifest.hpp>
|
||||
#if MLN_RENDER_BACKEND_OPENGL
|
||||
#include <mbgl/gl/program.hpp>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace gfx {
|
||||
class RenderPass;
|
||||
} // namespace gfx
|
||||
|
||||
template <class Name,
|
||||
shaders::BuiltIn ShaderSource,
|
||||
gfx::PrimitiveType Primitive,
|
||||
class LayoutAttributeList,
|
||||
class LayoutUniformList,
|
||||
class Textures,
|
||||
class PaintProps>
|
||||
class Program : public gfx::Shader {
|
||||
public:
|
||||
using LayoutVertex = gfx::Vertex<LayoutAttributeList>;
|
||||
|
||||
using PaintProperties = PaintProps;
|
||||
using Binders = PaintPropertyBinders<typename PaintProperties::DataDrivenProperties>;
|
||||
|
||||
using PaintAttributeList = typename Binders::AttributeList;
|
||||
using AttributeList = TypeListConcat<LayoutAttributeList, PaintAttributeList>;
|
||||
using AttributeBindings = gfx::AttributeBindings<AttributeList>;
|
||||
|
||||
using PaintUniformList = typename Binders::UniformList;
|
||||
using UniformList = TypeListConcat<LayoutUniformList, PaintUniformList>;
|
||||
using LayoutUniformValues = gfx::UniformValues<LayoutUniformList>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
|
||||
using TextureList = Textures;
|
||||
using TextureBindings = gfx::TextureBindings<TextureList>;
|
||||
|
||||
std::unique_ptr<gfx::Program<Name>> program;
|
||||
|
||||
Program([[maybe_unused]] const ProgramParameters& programParameters) {
|
||||
switch (gfx::Backend::GetType()) {
|
||||
#if MLN_RENDER_BACKEND_METAL
|
||||
case gfx::Backend::Type::Metal: {
|
||||
break;
|
||||
}
|
||||
#elif MLN_RENDER_BACKEND_VULKAN
|
||||
case gfx::Backend::Type::Vulkan: {
|
||||
break;
|
||||
}
|
||||
#else // MLN_RENDER_BACKEND_OPENGL
|
||||
case gfx::Backend::Type::OpenGL: {
|
||||
program = std::make_unique<gl::Program<Name>>(programParameters.withDefaultSource(
|
||||
{gfx::Backend::Type::OpenGL,
|
||||
shaders::ShaderSource<ShaderSource, gfx::Backend::Type::OpenGL>::vertex,
|
||||
shaders::ShaderSource<ShaderSource, gfx::Backend::Type::OpenGL>::fragment}));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default: {
|
||||
throw std::runtime_error("Unsupported rendering backend!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static UniformValues computeAllUniformValues(const LayoutUniformValues& layoutUniformValues,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
float currentZoom) {
|
||||
return layoutUniformValues.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
}
|
||||
|
||||
static AttributeBindings computeAllAttributeBindings(
|
||||
const gfx::VertexBuffer<LayoutVertex>& layoutVertexBuffer,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties) {
|
||||
return gfx::AttributeBindings<LayoutAttributeList>(layoutVertexBuffer)
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
}
|
||||
|
||||
static uint32_t activeBindingCount(const AttributeBindings& allAttributeBindings) {
|
||||
return allAttributeBindings.activeCount();
|
||||
}
|
||||
|
||||
template <class DrawMode>
|
||||
void draw(gfx::Context& context,
|
||||
gfx::RenderPass& renderPass,
|
||||
const DrawMode& drawMode,
|
||||
const gfx::DepthMode& depthMode,
|
||||
const gfx::StencilMode& stencilMode,
|
||||
const gfx::ColorMode& colorMode,
|
||||
const gfx::CullFaceMode& cullFaceMode,
|
||||
const gfx::IndexBuffer& indexBuffer,
|
||||
const SegmentBase& segment,
|
||||
const UniformValues& uniformValues,
|
||||
const AttributeBindings& allAttributeBindings,
|
||||
const TextureBindings& textureBindings,
|
||||
const std::string& layerID) {
|
||||
static_assert(Primitive == gfx::PrimitiveTypeOf<DrawMode>::value, "incompatible draw mode");
|
||||
|
||||
if (!program) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto drawScopeIt = segment.drawScopes.find(layerID);
|
||||
if (drawScopeIt == segment.drawScopes.end()) {
|
||||
drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first;
|
||||
}
|
||||
|
||||
program->draw(context,
|
||||
renderPass,
|
||||
drawMode,
|
||||
depthMode,
|
||||
stencilMode,
|
||||
colorMode,
|
||||
cullFaceMode,
|
||||
uniformValues,
|
||||
drawScopeIt->second,
|
||||
allAttributeBindings.offset(segment.vertexOffset),
|
||||
textureBindings,
|
||||
indexBuffer,
|
||||
segment.indexOffset,
|
||||
segment.indexLength);
|
||||
}
|
||||
|
||||
template <class DrawMode>
|
||||
void draw(gfx::Context& context,
|
||||
gfx::RenderPass& renderPass,
|
||||
const DrawMode& drawMode,
|
||||
const gfx::DepthMode& depthMode,
|
||||
const gfx::StencilMode& stencilMode,
|
||||
const gfx::ColorMode& colorMode,
|
||||
const gfx::CullFaceMode& cullFaceMode,
|
||||
const gfx::IndexBuffer& indexBuffer,
|
||||
const SegmentVector& segments,
|
||||
const UniformValues& uniformValues,
|
||||
const AttributeBindings& allAttributeBindings,
|
||||
const TextureBindings& textureBindings,
|
||||
const std::string& layerID) {
|
||||
static_assert(Primitive == gfx::PrimitiveTypeOf<DrawMode>::value, "incompatible draw mode");
|
||||
|
||||
if (!program) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& segment : segments) {
|
||||
auto drawScopeIt = segment.drawScopes.find(layerID);
|
||||
|
||||
if (drawScopeIt == segment.drawScopes.end()) {
|
||||
drawScopeIt = segment.drawScopes.emplace(layerID, context.createDrawScope()).first;
|
||||
}
|
||||
|
||||
program->draw(context,
|
||||
renderPass,
|
||||
drawMode,
|
||||
depthMode,
|
||||
stencilMode,
|
||||
colorMode,
|
||||
cullFaceMode,
|
||||
uniformValues,
|
||||
drawScopeIt->second,
|
||||
allAttributeBindings.offset(segment.vertexOffset),
|
||||
textureBindings,
|
||||
indexBuffer,
|
||||
segment.indexOffset,
|
||||
segment.indexLength);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class LayerTypePrograms {
|
||||
public:
|
||||
virtual ~LayerTypePrograms() = default;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,82 +0,0 @@
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
|
||||
#include <mbgl/util/hash.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
|
||||
#include <string_view>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
ProgramParameters::ProgramParameters(const float pixelRatio, const bool overdraw)
|
||||
: defines(2),
|
||||
overdrawInspector(overdraw) {
|
||||
defines["DEVICE_PIXEL_RATIO"] = util::toString(pixelRatio, true);
|
||||
if (overdraw) {
|
||||
defines["OVERDRAW_INSPECTOR"] = std::string();
|
||||
}
|
||||
definesHash = util::hash(getDefinesString());
|
||||
}
|
||||
|
||||
ProgramParameters ProgramParameters::withShaderSource(const ProgramSource& source) const noexcept {
|
||||
assert(gfx::Backend::Type::TYPE_MAX != source.backend);
|
||||
|
||||
ProgramParameters params = *this;
|
||||
params.userSources[static_cast<size_t>(source.backend)] = source;
|
||||
return params;
|
||||
}
|
||||
|
||||
ProgramParameters ProgramParameters::withDefaultSource(const ProgramSource& source) const noexcept {
|
||||
assert(gfx::Backend::Type::TYPE_MAX != source.backend);
|
||||
|
||||
ProgramParameters params = *this;
|
||||
params.defaultSources[static_cast<size_t>(source.backend)] = source;
|
||||
return params;
|
||||
}
|
||||
|
||||
ProgramParameters ProgramParameters::withProgramType(shaders::BuiltIn type) const noexcept {
|
||||
ProgramParameters params = *this;
|
||||
params.programType = type;
|
||||
return params;
|
||||
}
|
||||
|
||||
const std::string& ProgramParameters::getDefinesString() const {
|
||||
if (definesStr.empty() && !defines.empty()) {
|
||||
definesStr.assign(defines.size() * 32, '\0');
|
||||
definesStr.clear();
|
||||
for (const auto& pair : defines) {
|
||||
definesStr.append("#define ").append(pair.first);
|
||||
if (!pair.second.empty()) {
|
||||
definesStr.append(" ").append(pair.second);
|
||||
}
|
||||
definesStr.append("\n");
|
||||
}
|
||||
}
|
||||
return definesStr;
|
||||
}
|
||||
|
||||
const std::string& ProgramParameters::vertexSource(gfx::Backend::Type backend) const {
|
||||
assert(gfx::Backend::Type::TYPE_MAX != backend);
|
||||
|
||||
if (userSources[static_cast<size_t>(backend)].vertex.length() > 0) {
|
||||
return userSources[static_cast<size_t>(backend)].vertex;
|
||||
} else if (defaultSources[static_cast<size_t>(backend)].vertex.length() > 0) {
|
||||
return defaultSources[static_cast<size_t>(backend)].vertex;
|
||||
} else {
|
||||
throw std::runtime_error("No vertex shader source provided for selected backend!");
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& ProgramParameters::fragmentSource(gfx::Backend::Type backend) const {
|
||||
assert(gfx::Backend::Type::TYPE_MAX != backend);
|
||||
|
||||
if (userSources[static_cast<size_t>(backend)].fragment.length() > 0) {
|
||||
return userSources[static_cast<size_t>(backend)].fragment;
|
||||
} else if (defaultSources[static_cast<size_t>(backend)].fragment.length() > 0) {
|
||||
return defaultSources[static_cast<size_t>(backend)].fragment;
|
||||
} else {
|
||||
throw std::runtime_error("No fragment shader source provided for selected backend!");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,89 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/backend.hpp>
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ProgramParameters {
|
||||
public:
|
||||
struct ProgramSource {
|
||||
gfx::Backend::Type backend{gfx::Backend::Type::TYPE_MAX};
|
||||
std::string vertex;
|
||||
std::string fragment;
|
||||
|
||||
ProgramSource() = default;
|
||||
|
||||
/// @brief Construct a new ProgramSource object
|
||||
/// @param forBackend The provided source code is intended for use with the given rendering backend.
|
||||
/// @param vertex_ The vertex shader source code, or empty string if not provided.
|
||||
/// @param fragment_ The fragment shader source code, or empty string if not provided.
|
||||
ProgramSource(gfx::Backend::Type forBackend, const std::string& vertex_, const std::string& fragment_)
|
||||
: backend(forBackend),
|
||||
vertex(vertex_),
|
||||
fragment(fragment_) {
|
||||
assert(gfx::Backend::Type::TYPE_MAX != forBackend);
|
||||
}
|
||||
};
|
||||
|
||||
ProgramParameters(float pixelRatio, bool overdraw);
|
||||
|
||||
/// @brief Provide custom shader code which overrides any default source present
|
||||
/// @param source ProgramSource
|
||||
/// @return Mutated ProgramParameters
|
||||
ProgramParameters withShaderSource(const ProgramSource& source) const noexcept;
|
||||
|
||||
/// @brief Provide default shader source
|
||||
/// @param source ProgramSource
|
||||
/// @return Mutated ProgramParameters
|
||||
ProgramParameters withDefaultSource(const ProgramSource& source) const noexcept;
|
||||
|
||||
/// @brief Provide a `BuiltIn` value used to indicate the program type
|
||||
/// @param source ProgramSource
|
||||
/// @return Mutated ProgramParameters
|
||||
ProgramParameters withProgramType(shaders::BuiltIn type) const noexcept;
|
||||
|
||||
shaders::BuiltIn getProgramType() const noexcept { return programType; }
|
||||
|
||||
/// @brief Get a list of built-in shader preprocessor defines
|
||||
/// @return Shader source string
|
||||
/// @todo With the addition of future backends, defines should also be backend-aware
|
||||
const std::string& getDefinesString() const;
|
||||
|
||||
/// @brief Get a list of built-in shader preprocessor defines
|
||||
/// @return Map of key-value pairs representing preprocessor definitions
|
||||
const std::unordered_map<std::string, std::string>& getDefines() const { return defines; }
|
||||
|
||||
/// @brief Get source code for the vertex shader compatible with the requested backend
|
||||
/// @param backend Backend type
|
||||
/// @return Shader source string
|
||||
const std::string& vertexSource(gfx::Backend::Type backend) const;
|
||||
|
||||
/// @brief Get source code for the fragment shader compatible with the requested backend
|
||||
/// @param backend Backend type
|
||||
/// @return Shader source string
|
||||
const std::string& fragmentSource(gfx::Backend::Type backend) const;
|
||||
|
||||
bool getOverdrawInspectorEnabled() const { return overdrawInspector; }
|
||||
std::uint64_t getDefinesHash() const { return definesHash; }
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> defines;
|
||||
std::uint64_t definesHash;
|
||||
shaders::BuiltIn programType = shaders::BuiltIn::None;
|
||||
|
||||
// cached value of `defines` converted to string format
|
||||
mutable std::string definesStr;
|
||||
|
||||
std::array<ProgramSource, static_cast<size_t>(gfx::Backend::Type::TYPE_MAX)> defaultSources;
|
||||
std::array<ProgramSource, static_cast<size_t>(gfx::Backend::Type::TYPE_MAX)> userSources;
|
||||
|
||||
bool overdrawInspector;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,38 +0,0 @@
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <exception>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
Programs::Programs(const ProgramParameters& programParameters_)
|
||||
: programParameters(programParameters_) {}
|
||||
|
||||
Programs::~Programs() = default;
|
||||
|
||||
/// @brief Register a list of types with a shader registry instance
|
||||
/// @tparam ...T Type list parameter pack
|
||||
/// @param registry A shader registry instance
|
||||
/// programParameters_ ProgramParameters used to initialize each instance
|
||||
template <typename... T>
|
||||
void registerTypes(gfx::ShaderRegistry& registry, const ProgramParameters& programParameters_) {
|
||||
/// The following fold expression will create a shared_ptr for every type
|
||||
/// in the parameter pack and register it with the shader registry.
|
||||
|
||||
/// Registration calls are wrapped in a lambda that throws on registration
|
||||
/// failure, we shouldn't expect registration to faill unless the shader
|
||||
/// registry instance provided already has conflicting programs present.
|
||||
(
|
||||
[](bool expr) {
|
||||
if (!expr) {
|
||||
throw std::runtime_error("Failed to register " + std::string(T::Name) + " with shader registry!");
|
||||
}
|
||||
}(registry.getLegacyGroup().registerShader(std::make_shared<T>(programParameters_))),
|
||||
...);
|
||||
}
|
||||
|
||||
void Programs::registerWith(gfx::ShaderRegistry& registry) {
|
||||
/// The following types will be registered
|
||||
registerTypes<ClippingMaskProgram>(registry, programParameters);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/clipping_mask_program.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/gfx/shader_registry.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class Programs {
|
||||
public:
|
||||
Programs(const ProgramParameters&);
|
||||
~Programs();
|
||||
|
||||
/// @brief Registers built-in programs with the provided registry.
|
||||
/// @param registry gfx::ShaderRegistry to populate with built-in programs.
|
||||
void registerWith(gfx::ShaderRegistry& registry);
|
||||
|
||||
private:
|
||||
ProgramParameters programParameters;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/draw_scope.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class SegmentBase {
|
||||
public:
|
||||
SegmentBase(std::size_t vertexOffset_,
|
||||
std::size_t indexOffset_,
|
||||
std::size_t vertexLength_ = 0,
|
||||
std::size_t indexLength_ = 0,
|
||||
float sortKey_ = 0.0f)
|
||||
: vertexOffset(vertexOffset_),
|
||||
indexOffset(indexOffset_),
|
||||
vertexLength(vertexLength_),
|
||||
indexLength(indexLength_),
|
||||
sortKey(sortKey_) {}
|
||||
|
||||
// FIXME: clang-tidy-8 still complains here and clang-cl
|
||||
// on Windows gives the error: "exception specification of
|
||||
// explicitly defaulted move constructor does not match
|
||||
// the calculated one" when marking this 'noexcept'.
|
||||
// NOLINTNEXTLINE(performance-noexcept-move-constructor)
|
||||
SegmentBase(SegmentBase&&) = default;
|
||||
|
||||
const std::size_t vertexOffset;
|
||||
const std::size_t indexOffset;
|
||||
|
||||
std::size_t vertexLength;
|
||||
std::size_t indexLength;
|
||||
|
||||
// One DrawScope per layer ID. This minimizes rebinding in cases where
|
||||
// several layers share buckets but have different sets of active
|
||||
// attributes. This can happen:
|
||||
// * when two layers have the same layout properties, but differing
|
||||
// data-driven paint properties
|
||||
// * when two fill layers have the same layout properties, but one
|
||||
// uses fill-color and the other uses fill-pattern
|
||||
mutable std::map<std::string, gfx::DrawScope> drawScopes;
|
||||
|
||||
float sortKey;
|
||||
};
|
||||
|
||||
using SegmentVector = std::vector<SegmentBase>;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,17 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace textures {
|
||||
|
||||
MBGL_DEFINE_TEXTURE(image);
|
||||
MBGL_DEFINE_TEXTURE(image0);
|
||||
MBGL_DEFINE_TEXTURE(image1);
|
||||
MBGL_DEFINE_TEXTURE(color_ramp);
|
||||
MBGL_DEFINE_TEXTURE(texture);
|
||||
MBGL_DEFINE_TEXTURE(texture_icon);
|
||||
MBGL_DEFINE_TEXTURE(overlay);
|
||||
|
||||
} // namespace textures
|
||||
} // namespace mbgl
|
||||
@@ -1,71 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/uniform.hpp>
|
||||
#include <mbgl/util/size.hpp>
|
||||
#include <mbgl/util/color.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace uniforms {
|
||||
|
||||
// Uniforms common to several shaders.
|
||||
|
||||
MBGL_DEFINE_UNIFORM_MATRIX(double, 4, matrix);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, opacity);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, color);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, blur);
|
||||
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, zoom);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, collision_y_stretch);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, pitch);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, bearing);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, radius);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, stroke_width);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, stroke_color);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, stroke_opacity);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, fill_color);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, halo_color);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, halo_width);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, halo_blur);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, outline_color);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, height);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, base);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, width);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, floorwidth);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, gapwidth);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, offset);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Size, world);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Size, texsize);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Size, texsize_icon);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, pitch_with_map);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, camera_to_center_distance);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, device_pixel_ratio);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, fade);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, fade_change);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, weight);
|
||||
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, extrude_scale);
|
||||
|
||||
namespace heatmap {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, extrude_scale);
|
||||
} // namespace heatmap
|
||||
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 4, pattern_from);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 4, pattern_to);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 4, scale);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, pattern_tl_a);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, pattern_br_a);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, pattern_tl_b);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, pattern_br_b);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, pattern_size_a);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, pattern_size_b);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, pixel_coord_upper);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, pixel_coord_lower);
|
||||
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, mix);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, scale_a);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, scale_b);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, tile_units_to_pixels);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, overscale_factor);
|
||||
|
||||
} // namespace uniforms
|
||||
} // namespace mbgl
|
||||
Reference in New Issue
Block a user