Clean legacy code (#3469)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/background_program.hpp>
|
||||
@@ -1,48 +0,0 @@
|
||||
#include <mbgl/programs/background_program.hpp>
|
||||
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static_assert(sizeof(BackgroundLayoutVertex) == 4, "expected BackgroundLayoutVertex size");
|
||||
|
||||
BackgroundPatternProgram::LayoutUniformValues BackgroundPatternProgram::layoutUniformValues(
|
||||
mat4 matrix,
|
||||
float opacity,
|
||||
Size atlasSize,
|
||||
const ImagePosition& a,
|
||||
const ImagePosition& b,
|
||||
const CrossfadeParameters& fading,
|
||||
const UnwrappedTileID& tileID,
|
||||
const TransformState& state) {
|
||||
int32_t tileSizeAtNearestZoom = static_cast<int32_t>(util::tileSize_D *
|
||||
state.zoomScale(state.getIntegerZoom() - tileID.canonical.z));
|
||||
int32_t pixelX = static_cast<int32_t>(tileSizeAtNearestZoom *
|
||||
(tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z)));
|
||||
int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y;
|
||||
|
||||
return {
|
||||
uniforms::matrix::Value(matrix),
|
||||
uniforms::opacity::Value(opacity),
|
||||
uniforms::texsize::Value(atlasSize),
|
||||
uniforms::pattern_tl_a::Value(a.tl()),
|
||||
uniforms::pattern_br_a::Value(a.br()),
|
||||
uniforms::pattern_tl_b::Value(b.tl()),
|
||||
uniforms::pattern_br_b::Value(b.br()),
|
||||
uniforms::pattern_size_a::Value(a.displaySize()),
|
||||
uniforms::pattern_size_b::Value(b.displaySize()),
|
||||
uniforms::scale_a::Value(fading.fromScale),
|
||||
uniforms::scale_b::Value(fading.toScale),
|
||||
uniforms::mix::Value(fading.t),
|
||||
uniforms::pixel_coord_upper::Value(
|
||||
std::array<float, 2>{{static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)}}),
|
||||
uniforms::pixel_coord_lower::Value(
|
||||
std::array<float, 2>{{static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)}}),
|
||||
uniforms::tile_units_to_pixels::Value(1.0f / tileID.pixelsToTileUnits(1.0f, state.getIntegerZoom())),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,79 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/size.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ImagePosition;
|
||||
class UnwrappedTileID;
|
||||
class TransformState;
|
||||
template <class>
|
||||
class Faded;
|
||||
|
||||
using BackgroundLayoutAttributes = PositionOnlyLayoutAttributes;
|
||||
|
||||
using BackgroundUniforms = TypeList<uniforms::matrix, uniforms::color, uniforms::opacity>;
|
||||
|
||||
using BackgroundPatternUniforms = TypeList<uniforms::matrix,
|
||||
uniforms::opacity,
|
||||
uniforms::texsize,
|
||||
uniforms::pattern_tl_a,
|
||||
uniforms::pattern_br_a,
|
||||
uniforms::pattern_tl_b,
|
||||
uniforms::pattern_br_b,
|
||||
uniforms::pattern_size_a,
|
||||
uniforms::pattern_size_b,
|
||||
uniforms::scale_a,
|
||||
uniforms::scale_b,
|
||||
uniforms::mix,
|
||||
uniforms::pixel_coord_upper,
|
||||
uniforms::pixel_coord_lower,
|
||||
uniforms::tile_units_to_pixels>;
|
||||
|
||||
class BackgroundProgram final : public Program<BackgroundProgram,
|
||||
shaders::BuiltIn::BackgroundProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
BackgroundLayoutAttributes,
|
||||
BackgroundUniforms,
|
||||
TypeList<>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"BackgroundProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
};
|
||||
|
||||
class BackgroundPatternProgram final : public Program<BackgroundPatternProgram,
|
||||
shaders::BuiltIn::BackgroundPatternProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
BackgroundLayoutAttributes,
|
||||
BackgroundPatternUniforms,
|
||||
TypeList<textures::image>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"BackgroundPatternProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(mat4 matrix,
|
||||
float opacity,
|
||||
Size atlasSize,
|
||||
const ImagePosition&,
|
||||
const ImagePosition&,
|
||||
const CrossfadeParameters&,
|
||||
const UnwrappedTileID&,
|
||||
const TransformState&);
|
||||
};
|
||||
|
||||
using BackgroundLayoutVertex = BackgroundProgram::LayoutVertex;
|
||||
using BackgroundAttributes = BackgroundProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/circle_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(CircleLayoutVertex) == 4, "expected CircleLayoutVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/style/layers/circle_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, scale_with_map);
|
||||
} // namespace uniforms
|
||||
|
||||
class CircleProgram final : public Program<CircleProgram,
|
||||
shaders::BuiltIn::CircleProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeList<attributes::pos>,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::scale_with_map,
|
||||
uniforms::extrude_scale,
|
||||
uniforms::device_pixel_ratio,
|
||||
uniforms::camera_to_center_distance,
|
||||
uniforms::pitch_with_map>,
|
||||
TypeList<>,
|
||||
style::CirclePaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"CircleProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
/*
|
||||
* @param {number} x vertex position
|
||||
* @param {number} y vertex position
|
||||
* @param {number} ex extrude normal
|
||||
* @param {number} ey extrude normal
|
||||
*/
|
||||
static LayoutVertex vertex(Point<int16_t> p, float ex, float ey) {
|
||||
return LayoutVertex{
|
||||
{{static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)), static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))}}};
|
||||
}
|
||||
};
|
||||
|
||||
using CircleLayoutVertex = CircleProgram::LayoutVertex;
|
||||
using CircleAttributes = CircleProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/collision_box_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(CollisionBoxProgram::LayoutVertex) == 24, "expected CollisionBoxVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,168 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/style/properties.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using CollisionBoxLayoutAttributes = TypeList<attributes::pos, attributes::anchor_pos, attributes::extrude>;
|
||||
|
||||
using CollisionBoxDynamicAttributes = TypeList<attributes::placed, attributes::shift>;
|
||||
|
||||
class CollisionBoxProgram final
|
||||
: public Program<CollisionBoxProgram,
|
||||
shaders::BuiltIn::CollisionBoxProgram,
|
||||
gfx::PrimitiveType::Line,
|
||||
TypeListConcat<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>,
|
||||
TypeList<uniforms::matrix, uniforms::extrude_scale, uniforms::camera_to_center_distance>,
|
||||
TypeList<>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"CollisionBoxProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static gfx::Vertex<CollisionBoxLayoutAttributes> layoutVertex(Point<float> a, Point<float> anchor, Point<float> o) {
|
||||
return {{{static_cast<int16_t>(a.x), static_cast<int16_t>(a.y)}},
|
||||
{{static_cast<int16_t>(anchor.x), static_cast<int16_t>(anchor.y)}},
|
||||
{{static_cast<int16_t>(::round(o.x)), static_cast<int16_t>(::round(o.y))}}};
|
||||
}
|
||||
|
||||
static gfx::Vertex<CollisionBoxDynamicAttributes> dynamicVertex(bool placed, bool notUsed, Point<float> shift) {
|
||||
return {{{static_cast<uint16_t>(placed), static_cast<uint16_t>(notUsed)}}, {{shift.x, shift.y}}};
|
||||
}
|
||||
|
||||
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 LayoutUniformValues& layoutUniformValues,
|
||||
const gfx::VertexBuffer<gfx::Vertex<CollisionBoxLayoutAttributes>>& layoutVertexBuffer,
|
||||
const gfx::VertexBuffer<gfx::Vertex<CollisionBoxDynamicAttributes>>& dynamicVertexBuffer,
|
||||
const gfx::IndexBuffer& indexBuffer,
|
||||
const SegmentVector<AttributeList>& segments,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
const TextureBindings& textureBindings,
|
||||
float currentZoom,
|
||||
const std::string& layerID) {
|
||||
UniformValues uniformValues = layoutUniformValues.concat(
|
||||
paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
|
||||
AttributeBindings allAttributeBindings =
|
||||
gfx::AttributeBindings<CollisionBoxLayoutAttributes>(layoutVertexBuffer)
|
||||
.concat(gfx::AttributeBindings<CollisionBoxDynamicAttributes>(dynamicVertexBuffer))
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
|
||||
assert(layoutVertexBuffer.elements == dynamicVertexBuffer.elements);
|
||||
|
||||
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 CollisionCircleProgram final
|
||||
: public Program<CollisionCircleProgram,
|
||||
shaders::BuiltIn::CollisionCircleProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeListConcat<CollisionBoxLayoutAttributes, CollisionBoxDynamicAttributes>,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::extrude_scale,
|
||||
uniforms::overscale_factor,
|
||||
uniforms::camera_to_center_distance>,
|
||||
TypeList<>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"CollisionCircleProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static gfx::Vertex<CollisionBoxLayoutAttributes> vertex(Point<float> a, Point<float> anchor, Point<float> o) {
|
||||
return {{{static_cast<int16_t>(a.x), static_cast<int16_t>(a.y)}},
|
||||
{{static_cast<int16_t>(anchor.x), static_cast<int16_t>(anchor.y)}},
|
||||
{{static_cast<int16_t>(::round(o.x)), static_cast<int16_t>(::round(o.y))}}};
|
||||
}
|
||||
|
||||
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 LayoutUniformValues& layoutUniformValues,
|
||||
const gfx::VertexBuffer<gfx::Vertex<CollisionBoxLayoutAttributes>>& layoutVertexBuffer,
|
||||
const gfx::VertexBuffer<gfx::Vertex<CollisionBoxDynamicAttributes>>& dynamicVertexBuffer,
|
||||
const gfx::IndexBuffer& indexBuffer,
|
||||
const SegmentVector<AttributeList>& segments,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
const TextureBindings& textureBindings,
|
||||
float currentZoom,
|
||||
const std::string& layerID) {
|
||||
UniformValues uniformValues = layoutUniformValues.concat(
|
||||
paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
|
||||
AttributeBindings allAttributeBindings =
|
||||
gfx::AttributeBindings<CollisionBoxLayoutAttributes>(layoutVertexBuffer)
|
||||
.concat(gfx::AttributeBindings<CollisionBoxDynamicAttributes>(dynamicVertexBuffer))
|
||||
.concat(paintPropertyBinders.attributeBindings(currentProperties));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/collision_box_program.hpp>
|
||||
@@ -1,3 +0,0 @@
|
||||
#include <mbgl/programs/debug_program.hpp>
|
||||
|
||||
namespace mbgl {} // namespace mbgl
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/style/properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, overlay_scale);
|
||||
}
|
||||
class DebugProgram final : public Program<DebugProgram,
|
||||
shaders::BuiltIn::DebugProgram,
|
||||
gfx::PrimitiveType::Line,
|
||||
TypeList<attributes::pos>,
|
||||
TypeList<uniforms::matrix, uniforms::color, uniforms::overlay_scale>,
|
||||
TypeList<textures::overlay>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"DebugProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
};
|
||||
|
||||
using DebugLayoutVertex = DebugProgram::LayoutVertex;
|
||||
using DebugAttributes = DebugProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
@@ -1,80 +0,0 @@
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
#include <mbgl/util/mat3.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static_assert(sizeof(FillExtrusionLayoutVertex) == 12, "expected FillExtrusionLayoutVertex size");
|
||||
|
||||
std::array<float, 3> FillExtrusionProgram::lightColor(const EvaluatedLight& light) {
|
||||
const auto color = light.get<LightColor>();
|
||||
return {{color.r, color.g, color.b}};
|
||||
}
|
||||
|
||||
std::array<float, 3> FillExtrusionProgram::lightPosition(const EvaluatedLight& light, const TransformState& state) {
|
||||
auto lightPos = light.get<LightPosition>().getCartesian();
|
||||
mat3 lightMat;
|
||||
matrix::identity(lightMat);
|
||||
if (light.get<LightAnchor>() == LightAnchorType::Viewport) {
|
||||
matrix::rotate(lightMat, lightMat, -state.getBearing());
|
||||
}
|
||||
matrix::transformMat3f(lightPos, lightPos, lightMat);
|
||||
return lightPos;
|
||||
}
|
||||
|
||||
float FillExtrusionProgram::lightIntensity(const EvaluatedLight& light) {
|
||||
return light.get<LightIntensity>();
|
||||
}
|
||||
|
||||
FillExtrusionProgram::LayoutUniformValues FillExtrusionProgram::layoutUniformValues(const mat4& matrix,
|
||||
const TransformState& state,
|
||||
const float opacity,
|
||||
const EvaluatedLight& light,
|
||||
const float verticalGradient) {
|
||||
return {uniforms::matrix::Value(matrix),
|
||||
uniforms::opacity::Value(opacity),
|
||||
uniforms::lightcolor::Value(FillExtrusionProgram::lightColor(light)),
|
||||
uniforms::lightpos::Value(FillExtrusionProgram::lightPosition(light, state)),
|
||||
uniforms::lightintensity::Value(FillExtrusionProgram::lightIntensity(light)),
|
||||
uniforms::vertical_gradient::Value(verticalGradient)};
|
||||
}
|
||||
|
||||
FillExtrusionPatternProgram::LayoutUniformValues FillExtrusionPatternProgram::layoutUniformValues(
|
||||
const mat4& matrix,
|
||||
const Size atlasSize,
|
||||
const CrossfadeParameters& crossfade,
|
||||
const UnwrappedTileID& tileID,
|
||||
const TransformState& state,
|
||||
const float opacity,
|
||||
const float heightFactor,
|
||||
const float pixelRatio,
|
||||
const EvaluatedLight& light,
|
||||
const float verticalGradient) {
|
||||
const auto tileRatio = 1 / tileID.pixelsToTileUnits(1, state.getIntegerZoom());
|
||||
const int32_t tileSizeAtNearestZoom = static_cast<int32_t>(
|
||||
util::tileSize_D * state.zoomScale(state.getIntegerZoom() - tileID.canonical.z));
|
||||
const int32_t pixelX = static_cast<int32_t>(
|
||||
tileSizeAtNearestZoom * (tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z)));
|
||||
const int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y;
|
||||
|
||||
return {uniforms::matrix::Value(matrix),
|
||||
uniforms::opacity::Value(opacity),
|
||||
uniforms::scale::Value({{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}}),
|
||||
uniforms::texsize::Value(atlasSize),
|
||||
uniforms::fade::Value(crossfade.t),
|
||||
uniforms::pixel_coord_upper::Value(
|
||||
std::array<float, 2>{{static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)}}),
|
||||
uniforms::pixel_coord_lower::Value(
|
||||
std::array<float, 2>{{static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)}}),
|
||||
uniforms::height_factor::Value(heightFactor),
|
||||
uniforms::lightcolor::Value(FillExtrusionProgram::lightColor(light)),
|
||||
uniforms::lightpos::Value(FillExtrusionProgram::lightPosition(light, state)),
|
||||
uniforms::lightintensity::Value(FillExtrusionProgram::lightIntensity(light)),
|
||||
uniforms::vertical_gradient::Value(verticalGradient)};
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,118 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/size.hpp>
|
||||
#include <mbgl/style/layers/fill_extrusion_layer_properties.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/renderer/render_light.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ImagePosition;
|
||||
class UnwrappedTileID;
|
||||
class TransformState;
|
||||
template <class>
|
||||
class Faded;
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 3, lightpos);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 3, lightcolor);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, lightintensity);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, vertical_gradient);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, height_factor);
|
||||
} // namespace uniforms
|
||||
|
||||
using FillExtrusionLayoutAttributes = TypeList<attributes::pos, attributes::normal_ed>;
|
||||
|
||||
using FillExtrusionUniforms = TypeList<uniforms::matrix,
|
||||
uniforms::opacity,
|
||||
uniforms::lightcolor,
|
||||
uniforms::lightpos,
|
||||
uniforms::lightintensity,
|
||||
uniforms::vertical_gradient>;
|
||||
|
||||
using FillExtrusionPatternUniforms = TypeList<uniforms::matrix,
|
||||
uniforms::opacity,
|
||||
uniforms::scale,
|
||||
uniforms::texsize,
|
||||
uniforms::fade,
|
||||
uniforms::pixel_coord_upper,
|
||||
uniforms::pixel_coord_lower,
|
||||
uniforms::height_factor,
|
||||
uniforms::lightcolor,
|
||||
uniforms::lightpos,
|
||||
uniforms::lightintensity,
|
||||
uniforms::vertical_gradient>;
|
||||
|
||||
class FillExtrusionProgram final : public Program<FillExtrusionProgram,
|
||||
shaders::BuiltIn::FillExtrusionProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
FillExtrusionLayoutAttributes,
|
||||
FillExtrusionUniforms,
|
||||
TypeList<>,
|
||||
style::FillExtrusionPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"FillExtrusionProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutVertex layoutVertex(Point<int16_t> p, double nx, double ny, double nz, unsigned short t, uint16_t e) {
|
||||
const auto factor = pow(2, 13);
|
||||
|
||||
return LayoutVertex{{{p.x, p.y}},
|
||||
{{// Multiply normal vector components by 2^13 to pack them into
|
||||
// integers We pack a bool (`t`) into the x component indicating
|
||||
// whether it is an upper or lower vertex
|
||||
static_cast<int16_t>(floor(nx * factor) * 2 + t),
|
||||
static_cast<int16_t>(ny * factor * 2),
|
||||
static_cast<int16_t>(nz * factor * 2),
|
||||
// The edgedistance attribute is used for wrapping fill_extrusion patterns
|
||||
static_cast<int16_t>(e)}}};
|
||||
}
|
||||
|
||||
static std::array<float, 3> lightColor(const EvaluatedLight&);
|
||||
static std::array<float, 3> lightPosition(const EvaluatedLight&, const TransformState&);
|
||||
static float lightIntensity(const EvaluatedLight&);
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(
|
||||
const mat4&, const TransformState&, float opacity, const EvaluatedLight&, float verticalGradient);
|
||||
};
|
||||
|
||||
class FillExtrusionPatternProgram final : public Program<FillExtrusionPatternProgram,
|
||||
shaders::BuiltIn::FillExtrusionPatternProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
FillExtrusionLayoutAttributes,
|
||||
FillExtrusionPatternUniforms,
|
||||
TypeList<textures::image>,
|
||||
style::FillExtrusionPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"FillExtrusionPatternProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(const mat4&,
|
||||
Size atlasSize,
|
||||
const CrossfadeParameters&,
|
||||
const UnwrappedTileID&,
|
||||
const TransformState&,
|
||||
float opacity,
|
||||
float heightFactor,
|
||||
float pixelRatio,
|
||||
const EvaluatedLight&,
|
||||
float verticalGradient);
|
||||
};
|
||||
|
||||
using FillExtrusionLayoutVertex = FillExtrusionProgram::LayoutVertex;
|
||||
using FillExtrusionAttributes = FillExtrusionProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
@@ -1,37 +0,0 @@
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static_assert(sizeof(FillLayoutVertex) == 4, "expected FillLayoutVertex size");
|
||||
|
||||
FillPatternProgram::LayoutUniformValues FillPatternProgram::layoutUniformValues(mat4 matrix,
|
||||
Size framebufferSize,
|
||||
Size atlasSize,
|
||||
const CrossfadeParameters& crossfade,
|
||||
const UnwrappedTileID& tileID,
|
||||
const TransformState& state,
|
||||
const float pixelRatio) {
|
||||
const auto tileRatio = 1 / tileID.pixelsToTileUnits(1, state.getIntegerZoom());
|
||||
int32_t tileSizeAtNearestZoom = static_cast<int32_t>(util::tileSize_D *
|
||||
state.zoomScale(state.getIntegerZoom() - tileID.canonical.z));
|
||||
int32_t pixelX = static_cast<int32_t>(tileSizeAtNearestZoom *
|
||||
(tileID.canonical.x + tileID.wrap * state.zoomScale(tileID.canonical.z)));
|
||||
int32_t pixelY = tileSizeAtNearestZoom * tileID.canonical.y;
|
||||
|
||||
return {uniforms::matrix::Value(matrix),
|
||||
uniforms::world::Value(framebufferSize),
|
||||
uniforms::texsize::Value(atlasSize),
|
||||
uniforms::scale::Value({{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}}),
|
||||
uniforms::fade::Value(crossfade.t),
|
||||
uniforms::pixel_coord_upper::Value(
|
||||
std::array<float, 2>{{static_cast<float>(pixelX >> 16), static_cast<float>(pixelY >> 16)}}),
|
||||
uniforms::pixel_coord_lower::Value(
|
||||
std::array<float, 2>{{static_cast<float>(pixelX & 0xFFFF), static_cast<float>(pixelY & 0xFFFF)}})};
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,103 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/size.hpp>
|
||||
#include <mbgl/style/layers/fill_layer_properties.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ImagePosition;
|
||||
class UnwrappedTileID;
|
||||
class TransformState;
|
||||
template <class>
|
||||
class Faded;
|
||||
|
||||
using FillLayoutAttributes = PositionOnlyLayoutAttributes;
|
||||
|
||||
using FillUniforms = TypeList<uniforms::matrix, uniforms::world>;
|
||||
|
||||
using FillPatternUniforms = TypeList<uniforms::matrix,
|
||||
uniforms::world,
|
||||
uniforms::texsize,
|
||||
uniforms::scale,
|
||||
uniforms::fade,
|
||||
uniforms::pixel_coord_upper,
|
||||
uniforms::pixel_coord_lower>;
|
||||
|
||||
class FillProgram final : public Program<FillProgram,
|
||||
shaders::BuiltIn::FillProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
FillLayoutAttributes,
|
||||
FillUniforms,
|
||||
TypeList<>,
|
||||
style::FillPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"FillProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutVertex layoutVertex(Point<int16_t> p) { return LayoutVertex{{{p.x, p.y}}}; }
|
||||
};
|
||||
|
||||
class FillPatternProgram final : public Program<FillPatternProgram,
|
||||
shaders::BuiltIn::FillPatternProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
FillLayoutAttributes,
|
||||
FillPatternUniforms,
|
||||
TypeList<textures::image>,
|
||||
style::FillPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"FillPatternProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(mat4 matrix,
|
||||
Size framebufferSize,
|
||||
Size atlasSize,
|
||||
const CrossfadeParameters& crossfade,
|
||||
const UnwrappedTileID&,
|
||||
const TransformState&,
|
||||
float pixelRatio);
|
||||
};
|
||||
|
||||
class FillOutlineProgram final : public Program<FillOutlineProgram,
|
||||
shaders::BuiltIn::FillOutlineProgram,
|
||||
gfx::PrimitiveType::Line,
|
||||
FillLayoutAttributes,
|
||||
FillUniforms,
|
||||
TypeList<>,
|
||||
style::FillPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"FillOutlineProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
};
|
||||
|
||||
class FillOutlinePatternProgram final : public Program<FillOutlinePatternProgram,
|
||||
shaders::BuiltIn::FillOutlinePatternProgram,
|
||||
gfx::PrimitiveType::Line,
|
||||
FillLayoutAttributes,
|
||||
FillPatternUniforms,
|
||||
TypeList<textures::image>,
|
||||
style::FillPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"FillOutlinePatternProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
};
|
||||
|
||||
using FillLayoutVertex = FillProgram::LayoutVertex;
|
||||
using FillAttributes = FillProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/heatmap_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(HeatmapLayoutVertex) == 4, "expected HeatmapLayoutVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,45 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/heatmap_texture_program.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, intensity);
|
||||
} // namespace uniforms
|
||||
|
||||
class HeatmapProgram final
|
||||
: public Program<HeatmapProgram,
|
||||
shaders::BuiltIn::HeatmapProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeList<attributes::pos>,
|
||||
TypeList<uniforms::intensity, uniforms::matrix, uniforms::heatmap::extrude_scale>,
|
||||
TypeList<>,
|
||||
style::HeatmapPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"HeatmapProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
/*
|
||||
* @param {number} x vertex position
|
||||
* @param {number} y vertex position
|
||||
* @param {number} ex extrude normal
|
||||
* @param {number} ey extrude normal
|
||||
*/
|
||||
static LayoutVertex vertex(Point<int16_t> p, float ex, float ey) {
|
||||
return LayoutVertex{
|
||||
{{static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)), static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))}}};
|
||||
}
|
||||
};
|
||||
|
||||
using HeatmapLayoutVertex = HeatmapProgram::LayoutVertex;
|
||||
using HeatmapAttributes = HeatmapProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/heatmap_texture_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(HeatmapTextureLayoutVertex) == 4, "expected HeatmapTextureLayoutVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/style/properties.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class HeatmapTextureProgram final : public Program<HeatmapTextureProgram,
|
||||
shaders::BuiltIn::HeatmapTextureProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeList<attributes::pos>,
|
||||
TypeList<uniforms::matrix, uniforms::world, uniforms::opacity>,
|
||||
TypeList<textures::image, textures::color_ramp>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"HeatmapTextureProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutVertex layoutVertex(Point<int16_t> p) { return LayoutVertex{{{p.x, p.y}}}; }
|
||||
};
|
||||
|
||||
using HeatmapTextureLayoutVertex = HeatmapTextureProgram::LayoutVertex;
|
||||
using HeatmapTextureAttributes = HeatmapTextureProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/hillshade_prepare_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(HillshadePrepareLayoutVertex) == 8, "expected HillshadeLayoutVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,40 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(uint16_t, 2, dimension);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, maxzoom);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 4, unpack);
|
||||
} // namespace uniforms
|
||||
|
||||
class HillshadePrepareProgram final
|
||||
: public Program<
|
||||
HillshadePrepareProgram,
|
||||
shaders::BuiltIn::HillshadePrepareProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeList<attributes::pos, attributes::texture_pos>,
|
||||
TypeList<uniforms::matrix, uniforms::dimension, uniforms::zoom, uniforms::maxzoom, uniforms::unpack>,
|
||||
TypeList<textures::image>,
|
||||
style::Properties<>> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"HillshadePrepareProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutVertex layoutVertex(Point<int16_t> p, Point<uint16_t> t) {
|
||||
return LayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}};
|
||||
}
|
||||
};
|
||||
|
||||
using HillshadePrepareLayoutVertex = HillshadePrepareProgram::LayoutVertex;
|
||||
using HillshadePrepareAttributes = HillshadePrepareProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/hillshade_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(HillshadeLayoutVertex) == 8, "expected HillshadeLayoutVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,47 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/hillshade_prepare_program.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/style/layers/hillshade_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, shadow);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, highlight);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(Color, accent);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, light);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, latrange);
|
||||
} // namespace uniforms
|
||||
|
||||
class HillshadeProgram final : public Program<HillshadeProgram,
|
||||
shaders::BuiltIn::HillshadeProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeList<attributes::pos, attributes::texture_pos>,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::highlight,
|
||||
uniforms::shadow,
|
||||
uniforms::accent,
|
||||
uniforms::light,
|
||||
uniforms::latrange>,
|
||||
TypeList<textures::image>,
|
||||
style::HillshadePaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"HillshadeProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutVertex layoutVertex(Point<int16_t> p, Point<uint16_t> t) {
|
||||
return LayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}};
|
||||
}
|
||||
};
|
||||
|
||||
using HillshadeLayoutVertex = HillshadeProgram::LayoutVertex;
|
||||
using HillshadeAttributes = HillshadeProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
@@ -1,101 +0,0 @@
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/style/layers/line_layer_properties.hpp>
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
#include <mbgl/util/mat2.hpp>
|
||||
#include <mbgl/geometry/line_atlas.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static_assert(sizeof(LineLayoutVertex) == 8, "expected LineLayoutVertex size");
|
||||
|
||||
template <class Values, class... Args>
|
||||
Values makeValues(const style::LinePaintProperties::PossiblyEvaluated& properties,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const float pixelRatio,
|
||||
Args&&... args) {
|
||||
return Values{uniforms::matrix::Value(tile.translatedMatrix(
|
||||
properties.get<LineTranslate>(), properties.get<LineTranslateAnchor>(), state)),
|
||||
uniforms::ratio::Value(1.0f / tile.id.pixelsToTileUnits(1.0f, static_cast<float>(state.getZoom()))),
|
||||
uniforms::units_to_pixels::Value({{1.0f / pixelsToGLUnits[0], 1.0f / pixelsToGLUnits[1]}}),
|
||||
uniforms::device_pixel_ratio::Value(pixelRatio),
|
||||
std::forward<Args>(args)...};
|
||||
}
|
||||
|
||||
LineProgram::LayoutUniformValues LineProgram::layoutUniformValues(
|
||||
const style::LinePaintProperties::PossiblyEvaluated& properties,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const float pixelRatio) {
|
||||
return makeValues<LineProgram::LayoutUniformValues>(properties, tile, state, pixelsToGLUnits, pixelRatio);
|
||||
}
|
||||
|
||||
LineSDFProgram::LayoutUniformValues LineSDFProgram::layoutUniformValues(
|
||||
const style::LinePaintProperties::PossiblyEvaluated& properties,
|
||||
float pixelRatio,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const LinePatternPos& posA,
|
||||
const LinePatternPos& posB,
|
||||
const CrossfadeParameters& crossfade,
|
||||
float atlasWidth) {
|
||||
const float widthA = posA.width * crossfade.fromScale;
|
||||
const float widthB = posB.width * crossfade.toScale;
|
||||
|
||||
std::array<float, 2> scaleA{
|
||||
{1.0f / tile.id.pixelsToTileUnits(widthA, state.getIntegerZoom()), -posA.height / 2.0f}};
|
||||
|
||||
std::array<float, 2> scaleB{
|
||||
{1.0f / tile.id.pixelsToTileUnits(widthB, state.getIntegerZoom()), -posB.height / 2.0f}};
|
||||
|
||||
return makeValues<LineSDFProgram::LayoutUniformValues>(
|
||||
properties,
|
||||
tile,
|
||||
state,
|
||||
pixelsToGLUnits,
|
||||
pixelRatio,
|
||||
uniforms::patternscale_a::Value(scaleA),
|
||||
uniforms::patternscale_b::Value(scaleB),
|
||||
uniforms::tex_y_a::Value(posA.y),
|
||||
uniforms::tex_y_b::Value(posB.y),
|
||||
uniforms::mix::Value(crossfade.t),
|
||||
uniforms::sdfgamma::Value(atlasWidth / (std::min(widthA, widthB) * 256.0f * pixelRatio) / 2.0f));
|
||||
}
|
||||
|
||||
LinePatternProgram::LayoutUniformValues LinePatternProgram::layoutUniformValues(
|
||||
const style::LinePaintProperties::PossiblyEvaluated& properties,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const float pixelRatio,
|
||||
const Size atlasSize,
|
||||
const CrossfadeParameters& crossfade) {
|
||||
const auto tileRatio = 1 / tile.id.pixelsToTileUnits(1, state.getIntegerZoom());
|
||||
|
||||
return makeValues<LinePatternProgram::LayoutUniformValues>(
|
||||
properties,
|
||||
tile,
|
||||
state,
|
||||
pixelsToGLUnits,
|
||||
pixelRatio,
|
||||
uniforms::scale::Value({{pixelRatio, tileRatio, crossfade.fromScale, crossfade.toScale}}),
|
||||
uniforms::texsize::Value(atlasSize),
|
||||
uniforms::fade::Value(crossfade.t));
|
||||
}
|
||||
|
||||
LineGradientProgram::LayoutUniformValues LineGradientProgram::layoutUniformValues(
|
||||
const style::LinePaintProperties::PossiblyEvaluated& properties,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const float pixelRatio) {
|
||||
return makeValues<LineGradientProgram::LayoutUniformValues>(properties, tile, state, pixelsToGLUnits, pixelRatio);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,180 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/renderer/layers/render_line_layer.hpp>
|
||||
#include <mbgl/renderer/cross_faded_property_evaluator.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class RenderTile;
|
||||
class TransformState;
|
||||
class LinePatternPos;
|
||||
class ImagePosition;
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, ratio);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, tex_y_a);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, tex_y_b);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, sdfgamma);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, patternscale_a);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, patternscale_b);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, units_to_pixels);
|
||||
} // namespace uniforms
|
||||
|
||||
using LineLayoutAttributes = TypeList<attributes::pos_normal, attributes::data<uint8_t, 4>>;
|
||||
|
||||
class LineProgram final
|
||||
: public Program<
|
||||
LineProgram,
|
||||
shaders::BuiltIn::LineProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
LineLayoutAttributes,
|
||||
TypeList<uniforms::matrix, uniforms::ratio, uniforms::units_to_pixels, uniforms::device_pixel_ratio>,
|
||||
TypeList<>,
|
||||
style::LinePaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"LineProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
/*
|
||||
* @param p vertex position
|
||||
* @param e extrude normal
|
||||
* @param round whether the vertex uses a round line cap
|
||||
* @param up whether the line normal points up or down
|
||||
* @param dir direction of the line cap (-1/0/1)
|
||||
*/
|
||||
static LayoutVertex layoutVertex(
|
||||
Point<int16_t> p, Point<double> e, bool round, bool up, int8_t dir, int32_t linesofar = 0) {
|
||||
return LayoutVertex{
|
||||
{{static_cast<int16_t>((p.x * 2) | (round ? 1 : 0)), static_cast<int16_t>((p.y * 2) | (up ? 1 : 0))}},
|
||||
{{// add 128 to store a byte in an unsigned byte
|
||||
static_cast<uint8_t>(util::clamp(::round(extrudeScale * e.x) + 128, 0., 255.)),
|
||||
static_cast<uint8_t>(util::clamp(::round(extrudeScale * e.y) + 128, 0., 255.)),
|
||||
|
||||
// Encode the -1/0/1 direction value into the first two bits of .z
|
||||
// of a_data. Combine it with the lower 6 bits of `linesofar`
|
||||
// (shifted by 2 bites to make room for the direction value). The
|
||||
// upper 8 bits of `linesofar` are placed in the `w` component.
|
||||
// `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that we
|
||||
// can store longer distances while sacrificing precision.
|
||||
|
||||
// Encode the -1/0/1 direction value into .zw coordinates of
|
||||
// a_data, which is normally covered by linesofar, so we need to
|
||||
// merge them. The z component's first bit, as well as the sign
|
||||
// bit is reserved for the direction, so we need to shift the
|
||||
// linesofar.
|
||||
static_cast<uint8_t>(((dir == 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofar & 0x3F) << 2)),
|
||||
static_cast<uint8_t>(linesofar >> 6)}}};
|
||||
}
|
||||
|
||||
/*
|
||||
* Scale the extrusion vector so that the normal length is this value.
|
||||
* Contains the "texture" normals (-1..1). This is distinct from the extrude
|
||||
* normals for line joins, because the x-value remains 0 for the texture
|
||||
* normal array, while the extrude normal actually moves the vertex to
|
||||
* create the acute/bevelled line join.
|
||||
*/
|
||||
static const int8_t extrudeScale = 63;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
float pixelRatio);
|
||||
};
|
||||
|
||||
class LinePatternProgram final : public Program<LinePatternProgram,
|
||||
shaders::BuiltIn::LinePatternProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
LineLayoutAttributes,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::ratio,
|
||||
uniforms::units_to_pixels,
|
||||
uniforms::device_pixel_ratio,
|
||||
uniforms::scale,
|
||||
uniforms::texsize,
|
||||
uniforms::fade>,
|
||||
TypeList<textures::image>,
|
||||
style::LinePaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"LinePatternProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
float pixelRatio,
|
||||
Size atlasSize,
|
||||
const CrossfadeParameters& crossfade);
|
||||
};
|
||||
|
||||
class LineSDFProgram final : public Program<LineSDFProgram,
|
||||
shaders::BuiltIn::LineSDFProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
LineLayoutAttributes,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::ratio,
|
||||
uniforms::units_to_pixels,
|
||||
uniforms::device_pixel_ratio,
|
||||
uniforms::patternscale_a,
|
||||
uniforms::patternscale_b,
|
||||
uniforms::tex_y_a,
|
||||
uniforms::tex_y_b,
|
||||
uniforms::mix,
|
||||
uniforms::sdfgamma>,
|
||||
TypeList<textures::image>,
|
||||
style::LinePaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"LineSDFProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
|
||||
float pixelRatio,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const LinePatternPos& posA,
|
||||
const LinePatternPos& posB,
|
||||
const CrossfadeParameters& crossfade,
|
||||
float atlasWidth);
|
||||
};
|
||||
|
||||
class LineGradientProgram final
|
||||
: public Program<
|
||||
LineGradientProgram,
|
||||
shaders::BuiltIn::LineGradientProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
LineLayoutAttributes,
|
||||
TypeList<uniforms::matrix, uniforms::ratio, uniforms::units_to_pixels, uniforms::device_pixel_ratio>,
|
||||
TypeList<textures::image>,
|
||||
style::LinePaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"LineGradientProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
float pixelRatio);
|
||||
};
|
||||
|
||||
using LineLayoutVertex = LineProgram::LayoutVertex;
|
||||
using LineAttributes = LineProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
const gfx::ColorMode& colorMode,
|
||||
const gfx::CullFaceMode& cullFaceMode,
|
||||
const gfx::IndexBuffer& indexBuffer,
|
||||
const Segment<AttributeList>& segment,
|
||||
const SegmentBase& segment,
|
||||
const UniformValues& uniformValues,
|
||||
const AttributeBindings& allAttributeBindings,
|
||||
const TextureBindings& textureBindings,
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
const gfx::ColorMode& colorMode,
|
||||
const gfx::CullFaceMode& cullFaceMode,
|
||||
const gfx::IndexBuffer& indexBuffer,
|
||||
const SegmentVector<AttributeList>& segments,
|
||||
const SegmentVector& segments,
|
||||
const UniformValues& uniformValues,
|
||||
const AttributeBindings& allAttributeBindings,
|
||||
const TextureBindings& textureBindings,
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/programs/background_program.hpp>
|
||||
#include <mbgl/programs/circle_program.hpp>
|
||||
#include <mbgl/programs/heatmap_program.hpp>
|
||||
#include <mbgl/programs/hillshade_program.hpp>
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <exception>
|
||||
|
||||
@@ -41,7 +32,7 @@ void registerTypes(gfx::ShaderRegistry& registry, const ProgramParameters& progr
|
||||
|
||||
void Programs::registerWith(gfx::ShaderRegistry& registry) {
|
||||
/// The following types will be registered
|
||||
registerTypes<DebugProgram, ClippingMaskProgram>(registry, programParameters);
|
||||
registerTypes<ClippingMaskProgram>(registry, programParameters);
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/clipping_mask_program.hpp>
|
||||
#include <mbgl/programs/debug_program.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/gfx/shader_registry.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class BackgroundLayerPrograms;
|
||||
|
||||
class CircleLayerPrograms;
|
||||
class RasterLayerPrograms;
|
||||
class HeatmapLayerPrograms;
|
||||
class HillshadeLayerPrograms;
|
||||
class FillLayerPrograms;
|
||||
class FillExtrusionLayerPrograms;
|
||||
class LineLayerPrograms;
|
||||
class SymbolLayerPrograms;
|
||||
|
||||
class Programs {
|
||||
public:
|
||||
Programs(const ProgramParameters&);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static_assert(sizeof(RasterLayoutVertex) == 8, "expected RasterLayoutVertex size");
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,55 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/program.hpp>
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/style/layers/raster_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, fade_t);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, buffer_scale);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, brightness_low);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, brightness_high);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, saturation_factor);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, contrast_factor);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, scale_parent);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 3, spin_weights);
|
||||
MBGL_DEFINE_UNIFORM_VECTOR(float, 2, tl_parent);
|
||||
} // namespace uniforms
|
||||
|
||||
class RasterProgram final : public Program<RasterProgram,
|
||||
shaders::BuiltIn::RasterProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
TypeList<attributes::pos, attributes::texture_pos>,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::opacity,
|
||||
uniforms::fade_t,
|
||||
uniforms::brightness_low,
|
||||
uniforms::brightness_high,
|
||||
uniforms::saturation_factor,
|
||||
uniforms::contrast_factor,
|
||||
uniforms::spin_weights,
|
||||
uniforms::buffer_scale,
|
||||
uniforms::scale_parent,
|
||||
uniforms::tl_parent>,
|
||||
TypeList<textures::image0, textures::image1>,
|
||||
style::RasterPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"RasterProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using Program::Program;
|
||||
|
||||
static LayoutVertex layoutVertex(Point<int16_t> p, Point<uint16_t> t) {
|
||||
return LayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}};
|
||||
}
|
||||
};
|
||||
|
||||
using RasterLayoutVertex = RasterProgram::LayoutVertex;
|
||||
using RasterAttributes = RasterProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -47,12 +47,6 @@ public:
|
||||
float sortKey;
|
||||
};
|
||||
|
||||
template <class AttributeList>
|
||||
class Segment : public SegmentBase {
|
||||
using SegmentBase::SegmentBase;
|
||||
};
|
||||
|
||||
template <class AttributeList>
|
||||
using SegmentVector = std::vector<Segment<AttributeList>>;
|
||||
using SegmentVector = std::vector<SegmentBase>;
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
@@ -1,175 +0,0 @@
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_impl.hpp>
|
||||
#include <mbgl/layout/symbol_projection.hpp>
|
||||
#include <mbgl/tile/tile.hpp>
|
||||
#include <mbgl/util/enum.hpp>
|
||||
#include <mbgl/math/clamp.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static_assert(sizeof(SymbolLayoutVertex) == 24, "expected SymbolLayoutVertex size");
|
||||
|
||||
std::unique_ptr<SymbolSizeBinder> SymbolSizeBinder::create(const float tileZoom,
|
||||
const style::PropertyValue<float>& sizeProperty,
|
||||
const float defaultValue) {
|
||||
return sizeProperty.match(
|
||||
[&](const Undefined& value) -> std::unique_ptr<SymbolSizeBinder> {
|
||||
return std::make_unique<ConstantSymbolSizeBinder>(tileZoom, value, defaultValue);
|
||||
},
|
||||
[&](float value) -> std::unique_ptr<SymbolSizeBinder> {
|
||||
return std::make_unique<ConstantSymbolSizeBinder>(tileZoom, value, defaultValue);
|
||||
},
|
||||
[&](const style::PropertyExpression<float>& expression) -> std::unique_ptr<SymbolSizeBinder> {
|
||||
if (expression.isFeatureConstant()) {
|
||||
return std::make_unique<ConstantSymbolSizeBinder>(tileZoom, expression, defaultValue);
|
||||
} else if (expression.isZoomConstant()) {
|
||||
return std::make_unique<SourceFunctionSymbolSizeBinder>(tileZoom, expression, defaultValue);
|
||||
} else {
|
||||
return std::make_unique<CompositeFunctionSymbolSizeBinder>(tileZoom, expression, defaultValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
template <class Values, class... Args>
|
||||
Values makeValues(const bool isText,
|
||||
const bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues& values,
|
||||
const Size& texsize,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const bool alongLine,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const float symbolFadeChange,
|
||||
Args&&... args) {
|
||||
std::array<float, 2> extrudeScale;
|
||||
|
||||
if (values.pitchAlignment == AlignmentType::Map) {
|
||||
extrudeScale.fill(tile.id.pixelsToTileUnits(1.f, static_cast<float>(state.getZoom())));
|
||||
} else {
|
||||
extrudeScale = {{pixelsToGLUnits[0] * state.getCameraToCenterDistance(),
|
||||
pixelsToGLUnits[1] * state.getCameraToCenterDistance()}};
|
||||
}
|
||||
|
||||
const float pixelsToTileUnits = tile.id.pixelsToTileUnits(1.f, static_cast<float>(state.getZoom()));
|
||||
const bool pitchWithMap = values.pitchAlignment == style::AlignmentType::Map;
|
||||
const bool rotateWithMap = values.rotationAlignment == style::AlignmentType::Map;
|
||||
|
||||
// Line label rotation happens in `updateLineLabels`/`reprojectLineLabels``
|
||||
// Pitched point labels are automatically rotated by the labelPlaneMatrix projection
|
||||
// Unpitched point labels need to have their rotation applied after projection
|
||||
const bool rotateInShader = rotateWithMap && !pitchWithMap && !alongLine;
|
||||
|
||||
mat4 labelPlaneMatrix;
|
||||
if (alongLine || hasVariablePacement) {
|
||||
// For labels that follow lines the first part of the projection is
|
||||
// handled on the cpu. Pass an identity matrix because no transformation
|
||||
// needs to be done in the vertex shader.
|
||||
matrix::identity(labelPlaneMatrix);
|
||||
} else {
|
||||
labelPlaneMatrix = getLabelPlaneMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits);
|
||||
}
|
||||
|
||||
mat4 glCoordMatrix = getGlCoordMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits);
|
||||
|
||||
return Values{uniforms::matrix::Value(tile.translatedMatrix(values.translate, values.translateAnchor, state)),
|
||||
uniforms::label_plane_matrix::Value(labelPlaneMatrix),
|
||||
uniforms::coord_matrix::Value(
|
||||
tile.translateVtxMatrix(glCoordMatrix, values.translate, values.translateAnchor, state, true)),
|
||||
uniforms::extrude_scale::Value(extrudeScale),
|
||||
uniforms::texsize::Value(texsize),
|
||||
uniforms::fade_change::Value(symbolFadeChange),
|
||||
uniforms::is_text::Value(isText),
|
||||
uniforms::camera_to_center_distance::Value(state.getCameraToCenterDistance()),
|
||||
uniforms::pitch::Value(state.getPitch()),
|
||||
uniforms::pitch_with_map::Value(pitchWithMap),
|
||||
uniforms::rotate_symbol::Value(rotateInShader),
|
||||
uniforms::aspect_ratio::Value(state.getSize().aspectRatio()),
|
||||
std::forward<Args>(args)...};
|
||||
}
|
||||
|
||||
SymbolIconProgram::LayoutUniformValues SymbolIconProgram::layoutUniformValues(
|
||||
const bool isText,
|
||||
const bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues& values,
|
||||
const Size& texsize,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const bool alongLine,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const float symbolFadeChange) {
|
||||
return makeValues<SymbolIconProgram::LayoutUniformValues>(
|
||||
isText, hasVariablePacement, values, texsize, pixelsToGLUnits, alongLine, tile, state, symbolFadeChange);
|
||||
}
|
||||
|
||||
template <class Name, shaders::BuiltIn ShaderSource, class PaintProperties>
|
||||
typename SymbolSDFProgram<Name, ShaderSource, PaintProperties>::LayoutUniformValues
|
||||
SymbolSDFProgram<Name, ShaderSource, PaintProperties>::layoutUniformValues(const bool isText,
|
||||
const bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues& values,
|
||||
const Size& texsize,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const float pixelRatio,
|
||||
const bool alongLine,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const float symbolFadeChange,
|
||||
const SymbolSDFPart part) {
|
||||
const float gammaScale = (values.pitchAlignment == AlignmentType::Map
|
||||
? static_cast<float>(std::cos(state.getPitch())) * state.getCameraToCenterDistance()
|
||||
: 1.0f);
|
||||
|
||||
return makeValues<SymbolSDFProgram<Name, ShaderSource, PaintProperties>::LayoutUniformValues>(
|
||||
isText,
|
||||
hasVariablePacement,
|
||||
values,
|
||||
texsize,
|
||||
pixelsToGLUnits,
|
||||
alongLine,
|
||||
tile,
|
||||
state,
|
||||
symbolFadeChange,
|
||||
uniforms::gamma_scale::Value(gammaScale),
|
||||
uniforms::device_pixel_ratio::Value(pixelRatio),
|
||||
uniforms::is_halo::Value(part == SymbolSDFPart::Halo));
|
||||
}
|
||||
|
||||
SymbolTextAndIconProgram::LayoutUniformValues SymbolTextAndIconProgram::layoutUniformValues(
|
||||
const bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues& values,
|
||||
const Size& texsize,
|
||||
const Size& texsize_icon,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
const float pixelRatio,
|
||||
const bool alongLine,
|
||||
const RenderTile& tile,
|
||||
const TransformState& state,
|
||||
const float symbolFadeChange,
|
||||
const SymbolSDFPart part) {
|
||||
return {SymbolSDFProgram<SymbolSDFTextProgram,
|
||||
shaders::BuiltIn::SymbolSDFTextProgram,
|
||||
style::TextPaintProperties>::layoutUniformValues(true,
|
||||
hasVariablePacement,
|
||||
values,
|
||||
texsize,
|
||||
pixelsToGLUnits,
|
||||
pixelRatio,
|
||||
alongLine,
|
||||
tile,
|
||||
state,
|
||||
symbolFadeChange,
|
||||
part)
|
||||
.concat(gfx::UniformValues<SymbolTextAndIconProgramUniforms>(uniforms::texsize::Value(texsize_icon)))};
|
||||
}
|
||||
|
||||
template class SymbolSDFProgram<SymbolSDFIconProgram,
|
||||
shaders::BuiltIn::SymbolSDFIconProgram,
|
||||
style::IconPaintProperties>;
|
||||
template class SymbolSDFProgram<SymbolSDFTextProgram,
|
||||
shaders::BuiltIn::SymbolSDFTextProgram,
|
||||
style::TextPaintProperties>;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,551 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/math/clamp.hpp>
|
||||
#include <mbgl/util/interpolate.hpp>
|
||||
|
||||
#include <mbgl/programs/attributes.hpp>
|
||||
#include <mbgl/programs/collision_box_program.hpp>
|
||||
#include <mbgl/programs/uniforms.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/util/size.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_properties.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_impl.hpp>
|
||||
#include <mbgl/renderer/layers/render_symbol_layer.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
|
||||
#include <mbgl/shaders/shader_manifest.hpp>
|
||||
#if MLN_RENDER_BACKEND_OPENGL
|
||||
#include <mbgl/gl/program.hpp>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
const uint16_t MAX_GLYPH_ICON_SIZE = 255;
|
||||
const uint16_t SIZE_PACK_FACTOR = 128;
|
||||
const uint16_t MAX_PACKED_SIZE = MAX_GLYPH_ICON_SIZE * SIZE_PACK_FACTOR;
|
||||
|
||||
namespace style {
|
||||
class SymbolPropertyValues;
|
||||
} // namespace style
|
||||
|
||||
class RenderTile;
|
||||
class TransformState;
|
||||
|
||||
namespace uniforms {
|
||||
MBGL_DEFINE_UNIFORM_MATRIX(double, 4, coord_matrix);
|
||||
MBGL_DEFINE_UNIFORM_MATRIX(double, 4, label_plane_matrix);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, is_halo);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, gamma_scale);
|
||||
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, is_text);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, is_size_zoom_constant);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, is_size_feature_constant);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, size_t);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, size);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(bool, rotate_symbol);
|
||||
MBGL_DEFINE_UNIFORM_SCALAR(float, aspect_ratio);
|
||||
} // namespace uniforms
|
||||
|
||||
using SymbolLayoutAttributes = TypeList<attributes::pos_offset, attributes::data<uint16_t, 4>, attributes::pixeloffset>;
|
||||
|
||||
using SymbolDynamicLayoutAttributes = TypeList<attributes::projected_pos>;
|
||||
|
||||
using SymbolOpacityAttributes = TypeList<attributes::fade_opacity>;
|
||||
|
||||
struct ZoomEvaluatedSize {
|
||||
bool isZoomConstant;
|
||||
bool isFeatureConstant;
|
||||
float sizeT;
|
||||
float size;
|
||||
float layoutSize;
|
||||
};
|
||||
// Mimic the PaintPropertyBinder technique specifically for the {text,icon}-size
|
||||
// layout properties in order to provide a 'custom' scheme for encoding the
|
||||
// necessary attribute data. As with PaintPropertyBinder, SymbolSizeBinder is
|
||||
// an abstract class whose implementations handle the particular attribute &
|
||||
// uniform logic needed by each possible type of the {Text,Icon}Size properties.
|
||||
class SymbolSizeBinder {
|
||||
public:
|
||||
virtual ~SymbolSizeBinder() = default;
|
||||
|
||||
using UniformList =
|
||||
TypeList<uniforms::is_size_zoom_constant, uniforms::is_size_feature_constant, uniforms::size_t, uniforms::size>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
|
||||
static std::unique_ptr<SymbolSizeBinder> create(float tileZoom,
|
||||
const style::PropertyValue<float>& sizeProperty,
|
||||
float defaultValue);
|
||||
|
||||
virtual Range<float> getVertexSizeData(const GeometryTileFeature& feature) = 0;
|
||||
virtual ZoomEvaluatedSize evaluateForZoom(float currentZoom) const = 0;
|
||||
|
||||
UniformValues uniformValues(float currentZoom) const {
|
||||
const ZoomEvaluatedSize u = evaluateForZoom(currentZoom);
|
||||
return UniformValues{uniforms::is_size_zoom_constant::Value(u.isZoomConstant),
|
||||
uniforms::is_size_feature_constant::Value(u.isFeatureConstant),
|
||||
uniforms::size_t::Value(u.sizeT),
|
||||
uniforms::size::Value(u.size)};
|
||||
}
|
||||
};
|
||||
|
||||
class ConstantSymbolSizeBinder final : public SymbolSizeBinder {
|
||||
public:
|
||||
ConstantSymbolSizeBinder(const float /*tileZoom*/, const float& size, const float /*defaultValue*/) noexcept
|
||||
: layoutSize(size) {}
|
||||
|
||||
ConstantSymbolSizeBinder(const float /*tileZoom*/, const style::Undefined&, const float defaultValue) noexcept
|
||||
: layoutSize(defaultValue) {}
|
||||
|
||||
ConstantSymbolSizeBinder(const float tileZoom,
|
||||
const style::PropertyExpression<float>& expression_,
|
||||
const float /*defaultValue*/
|
||||
)
|
||||
: layoutSize(expression_.evaluate(tileZoom + 1)),
|
||||
expression(expression_) {
|
||||
const Range<float> zoomLevels = expression_.getCoveringStops(tileZoom, tileZoom + 1);
|
||||
coveringRanges = std::make_tuple(
|
||||
zoomLevels, Range<float>{expression_.evaluate(zoomLevels.min), expression_.evaluate(zoomLevels.max)});
|
||||
}
|
||||
|
||||
Range<float> getVertexSizeData(const GeometryTileFeature&) noexcept override { return {0.0f, 0.0f}; };
|
||||
|
||||
ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override {
|
||||
float size = layoutSize;
|
||||
bool isZoomConstant = !(coveringRanges || expression);
|
||||
if (coveringRanges) {
|
||||
// Even though we could get the exact value of the camera function
|
||||
// at z = currentZoom, we intentionally do not: instead, we
|
||||
// interpolate between the camera function values at a pair of zoom
|
||||
// stops covering [tileZoom, tileZoom + 1] in order to be consistent
|
||||
// with this restriction on composite functions.
|
||||
const Range<float>& zoomLevels = std::get<0>(*coveringRanges);
|
||||
const Range<float>& sizeLevels = std::get<1>(*coveringRanges);
|
||||
float t = util::clamp(expression->interpolationFactor(zoomLevels, currentZoom), 0.0f, 1.0f);
|
||||
size = sizeLevels.min + t * (sizeLevels.max - sizeLevels.min);
|
||||
} else if (expression) {
|
||||
size = expression->evaluate(currentZoom);
|
||||
}
|
||||
|
||||
const float unused = 0.0f;
|
||||
return {.isZoomConstant = isZoomConstant,
|
||||
.isFeatureConstant = true,
|
||||
.sizeT = unused,
|
||||
.size = size,
|
||||
.layoutSize = layoutSize};
|
||||
}
|
||||
|
||||
float layoutSize;
|
||||
std::optional<std::tuple<Range<float>, Range<float>>> coveringRanges;
|
||||
std::optional<style::PropertyExpression<float>> expression;
|
||||
};
|
||||
|
||||
class SourceFunctionSymbolSizeBinder final : public SymbolSizeBinder {
|
||||
public:
|
||||
SourceFunctionSymbolSizeBinder(const float /*tileZoom*/,
|
||||
style::PropertyExpression<float> expression_,
|
||||
const float defaultValue_) noexcept
|
||||
: expression(std::move(expression_)),
|
||||
defaultValue(defaultValue_) {}
|
||||
|
||||
Range<float> getVertexSizeData(const GeometryTileFeature& feature) override {
|
||||
const float size = expression.evaluate(feature, defaultValue);
|
||||
return {size, size};
|
||||
};
|
||||
|
||||
ZoomEvaluatedSize evaluateForZoom(float) const noexcept override {
|
||||
const float unused = 0.0f;
|
||||
return {
|
||||
.isZoomConstant = true, .isFeatureConstant = false, .sizeT = unused, .size = unused, .layoutSize = unused};
|
||||
}
|
||||
|
||||
style::PropertyExpression<float> expression;
|
||||
const float defaultValue;
|
||||
};
|
||||
|
||||
class CompositeFunctionSymbolSizeBinder final : public SymbolSizeBinder {
|
||||
public:
|
||||
CompositeFunctionSymbolSizeBinder(const float tileZoom,
|
||||
style::PropertyExpression<float> expression_,
|
||||
const float defaultValue_) noexcept
|
||||
: expression(std::move(expression_)),
|
||||
defaultValue(defaultValue_),
|
||||
layoutZoom(tileZoom + 1),
|
||||
coveringZoomStops(expression.getCoveringStops(tileZoom, tileZoom + 1)) {}
|
||||
|
||||
Range<float> getVertexSizeData(const GeometryTileFeature& feature) override {
|
||||
return {expression.evaluate(coveringZoomStops.min, feature, defaultValue),
|
||||
expression.evaluate(coveringZoomStops.max, feature, defaultValue)};
|
||||
};
|
||||
|
||||
ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override {
|
||||
float sizeInterpolationT = util::clamp(
|
||||
expression.interpolationFactor(coveringZoomStops, currentZoom), 0.0f, 1.0f);
|
||||
|
||||
const float unused = 0.0f;
|
||||
return {.isZoomConstant = false,
|
||||
.isFeatureConstant = false,
|
||||
.sizeT = sizeInterpolationT,
|
||||
.size = unused,
|
||||
.layoutSize = unused};
|
||||
}
|
||||
|
||||
style::PropertyExpression<float> expression;
|
||||
const float defaultValue;
|
||||
float layoutZoom;
|
||||
Range<float> coveringZoomStops;
|
||||
};
|
||||
|
||||
class SymbolProgramBase : public gfx::Shader {
|
||||
public:
|
||||
static gfx::Vertex<SymbolLayoutAttributes> layoutVertex(Point<float> labelAnchor,
|
||||
Point<float> o,
|
||||
float glyphOffsetY,
|
||||
uint16_t tx,
|
||||
uint16_t ty,
|
||||
const Range<float>& sizeData,
|
||||
bool isSDF,
|
||||
Point<float> pixelOffset,
|
||||
Point<float> minFontScale) {
|
||||
const uint16_t aSizeMin = (std::min(MAX_PACKED_SIZE, static_cast<uint16_t>(sizeData.min * SIZE_PACK_FACTOR))
|
||||
<< 1) +
|
||||
uint16_t(isSDF);
|
||||
const uint16_t aSizeMax = std::min(MAX_PACKED_SIZE, static_cast<uint16_t>(sizeData.max * SIZE_PACK_FACTOR));
|
||||
return {
|
||||
// combining pos and offset to reduce number of vertex attributes
|
||||
// passed to shader (8 max for some devices)
|
||||
{{static_cast<int16_t>(labelAnchor.x),
|
||||
static_cast<int16_t>(labelAnchor.y),
|
||||
static_cast<int16_t>(std::round(o.x * 32)), // use 1/32 pixels for placement
|
||||
static_cast<int16_t>(std::round((o.y + glyphOffsetY) * 32))}},
|
||||
{{tx, ty, aSizeMin, aSizeMax}},
|
||||
{{static_cast<int16_t>(pixelOffset.x * 16),
|
||||
static_cast<int16_t>(pixelOffset.y * 16),
|
||||
static_cast<int16_t>(minFontScale.x * 256),
|
||||
static_cast<int16_t>(minFontScale.y * 256)}},
|
||||
};
|
||||
}
|
||||
|
||||
static gfx::Vertex<SymbolDynamicLayoutAttributes> dynamicLayoutVertex(Point<float> anchorPoint, float labelAngle) {
|
||||
return {{{anchorPoint.x, anchorPoint.y, labelAngle}}};
|
||||
}
|
||||
|
||||
static gfx::Vertex<SymbolOpacityAttributes> opacityVertex(bool placed, float opacity) {
|
||||
return {{{static_cast<float>((static_cast<uint8_t>(opacity * 127) << 1) | static_cast<uint8_t>(placed))}}};
|
||||
}
|
||||
};
|
||||
|
||||
template <class Name,
|
||||
shaders::BuiltIn ShaderSource,
|
||||
gfx::PrimitiveType Primitive,
|
||||
class LayoutAttributeList,
|
||||
class LayoutUniformList,
|
||||
class Textures,
|
||||
class PaintProps>
|
||||
class SymbolProgram : public SymbolProgramBase {
|
||||
public:
|
||||
using LayoutVertex = gfx::Vertex<LayoutAttributeList>;
|
||||
|
||||
using LayoutAndSizeAttributeList =
|
||||
TypeListConcat<LayoutAttributeList, SymbolDynamicLayoutAttributes, SymbolOpacityAttributes>;
|
||||
|
||||
using PaintProperties = PaintProps;
|
||||
using Binders = PaintPropertyBinders<typename PaintProperties::DataDrivenProperties>;
|
||||
|
||||
using PaintAttributeList = typename Binders::AttributeList;
|
||||
using AttributeList = TypeListConcat<LayoutAndSizeAttributeList, PaintAttributeList>;
|
||||
using AttributeBindings = gfx::AttributeBindings<AttributeList>;
|
||||
|
||||
using LayoutUniformValues = gfx::UniformValues<LayoutUniformList>;
|
||||
using SizeUniformList = typename SymbolSizeBinder::UniformList;
|
||||
using PaintUniformList = typename Binders::UniformList;
|
||||
using UniformList = TypeListConcat<LayoutUniformList, SizeUniformList, PaintUniformList>;
|
||||
using UniformValues = gfx::UniformValues<UniformList>;
|
||||
|
||||
using TextureList = Textures;
|
||||
using TextureBindings = gfx::TextureBindings<TextureList>;
|
||||
|
||||
std::unique_ptr<gfx::Program<Name>> program;
|
||||
|
||||
// NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility)
|
||||
SymbolProgram([[maybe_unused]] const ProgramParameters& programParameters) {
|
||||
switch (gfx::Backend::GetType()) {
|
||||
#if 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 SymbolSizeBinder& symbolSizeBinder,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties,
|
||||
float currentZoom) {
|
||||
return layoutUniformValues.concat(symbolSizeBinder.uniformValues(currentZoom))
|
||||
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
|
||||
}
|
||||
|
||||
static AttributeBindings computeAllAttributeBindings(
|
||||
const gfx::VertexBuffer<LayoutVertex>& layoutVertexBuffer,
|
||||
const gfx::VertexBuffer<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicLayoutVertexBuffer,
|
||||
const gfx::VertexBuffer<gfx::Vertex<SymbolOpacityAttributes>>& opacityVertexBuffer,
|
||||
const Binders& paintPropertyBinders,
|
||||
const typename PaintProperties::PossiblyEvaluated& currentProperties) {
|
||||
assert(layoutVertexBuffer.elements == dynamicLayoutVertexBuffer.elements &&
|
||||
layoutVertexBuffer.elements == opacityVertexBuffer.elements);
|
||||
return gfx::AttributeBindings<LayoutAttributeList>(layoutVertexBuffer)
|
||||
.concat(gfx::AttributeBindings<SymbolDynamicLayoutAttributes>(dynamicLayoutVertexBuffer))
|
||||
.concat(gfx::AttributeBindings<SymbolOpacityAttributes>(opacityVertexBuffer))
|
||||
.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 Segment<AttributeList>& 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<AttributeList>& 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 (const auto& segment : segments) {
|
||||
draw(context,
|
||||
renderPass,
|
||||
drawMode,
|
||||
depthMode,
|
||||
stencilMode,
|
||||
colorMode,
|
||||
cullFaceMode,
|
||||
indexBuffer,
|
||||
segment,
|
||||
uniformValues,
|
||||
allAttributeBindings,
|
||||
textureBindings,
|
||||
layerID);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class SymbolIconProgram final : public SymbolProgram<SymbolIconProgram,
|
||||
shaders::BuiltIn::SymbolIconProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
SymbolLayoutAttributes,
|
||||
TypeList<uniforms::matrix,
|
||||
uniforms::label_plane_matrix,
|
||||
uniforms::coord_matrix,
|
||||
uniforms::extrude_scale,
|
||||
uniforms::texsize,
|
||||
uniforms::fade_change,
|
||||
uniforms::is_text,
|
||||
uniforms::camera_to_center_distance,
|
||||
uniforms::pitch,
|
||||
uniforms::pitch_with_map,
|
||||
uniforms::rotate_symbol,
|
||||
uniforms::aspect_ratio>,
|
||||
TypeList<textures::texture>,
|
||||
style::IconPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"SymbolIconProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using SymbolProgram::SymbolProgram;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(bool isText,
|
||||
bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues&,
|
||||
const Size& texsize,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
bool alongLine,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
float symbolFadeChange);
|
||||
};
|
||||
|
||||
enum class SymbolSDFPart {
|
||||
Fill = 1,
|
||||
Halo = 0
|
||||
};
|
||||
|
||||
using SymbolSDFProgramUniforms = TypeList<uniforms::matrix,
|
||||
uniforms::label_plane_matrix,
|
||||
uniforms::coord_matrix,
|
||||
uniforms::extrude_scale,
|
||||
uniforms::texsize,
|
||||
uniforms::fade_change,
|
||||
uniforms::is_text,
|
||||
uniforms::camera_to_center_distance,
|
||||
uniforms::pitch,
|
||||
uniforms::pitch_with_map,
|
||||
uniforms::rotate_symbol,
|
||||
uniforms::aspect_ratio,
|
||||
uniforms::gamma_scale,
|
||||
uniforms::device_pixel_ratio,
|
||||
uniforms::is_halo>;
|
||||
|
||||
template <class Name, shaders::BuiltIn ShaderSource, class PaintProperties>
|
||||
// NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility)
|
||||
class SymbolSDFProgram : public SymbolProgram<Name,
|
||||
ShaderSource,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
SymbolLayoutAttributes,
|
||||
SymbolSDFProgramUniforms,
|
||||
TypeList<textures::texture>,
|
||||
PaintProperties> {
|
||||
public:
|
||||
using BaseProgram = SymbolProgram<Name,
|
||||
ShaderSource,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
SymbolLayoutAttributes,
|
||||
SymbolSDFProgramUniforms,
|
||||
TypeList<textures::texture>,
|
||||
PaintProperties>;
|
||||
|
||||
using LayoutUniformValues = typename BaseProgram::LayoutUniformValues;
|
||||
|
||||
using BaseProgram::BaseProgram;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(bool isText,
|
||||
bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues&,
|
||||
const Size& texsize,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
float pixelRatio,
|
||||
bool alongLine,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
float SymbolFadeChange,
|
||||
SymbolSDFPart);
|
||||
};
|
||||
|
||||
using SymbolTextAndIconProgramUniforms = TypeList<uniforms::texsize_icon>;
|
||||
|
||||
class SymbolTextAndIconProgram final
|
||||
: public SymbolProgram<SymbolTextAndIconProgram,
|
||||
shaders::BuiltIn::SymbolTextAndIconProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
SymbolLayoutAttributes,
|
||||
TypeListConcat<SymbolSDFProgramUniforms, SymbolTextAndIconProgramUniforms>,
|
||||
TypeList<textures::texture, textures::texture_icon>,
|
||||
style::TextPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"SymbolTextAndIconProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using BaseProgram = SymbolProgram<SymbolTextAndIconProgram,
|
||||
shaders::BuiltIn::SymbolTextAndIconProgram,
|
||||
gfx::PrimitiveType::Triangle,
|
||||
SymbolLayoutAttributes,
|
||||
TypeListConcat<SymbolSDFProgramUniforms, SymbolTextAndIconProgramUniforms>,
|
||||
TypeList<textures::texture, textures::texture_icon>,
|
||||
style::TextPaintProperties>;
|
||||
|
||||
using LayoutUniformValues = typename BaseProgram::LayoutUniformValues;
|
||||
|
||||
using BaseProgram::BaseProgram;
|
||||
|
||||
static LayoutUniformValues layoutUniformValues(bool hasVariablePacement,
|
||||
const style::SymbolPropertyValues&,
|
||||
const Size& texsize,
|
||||
const Size& texsize_icon,
|
||||
const std::array<float, 2>& pixelsToGLUnits,
|
||||
float pixelRatio,
|
||||
bool alongLine,
|
||||
const RenderTile&,
|
||||
const TransformState&,
|
||||
float SymbolFadeChange,
|
||||
SymbolSDFPart);
|
||||
};
|
||||
|
||||
class SymbolSDFIconProgram final : public SymbolSDFProgram<SymbolSDFIconProgram,
|
||||
shaders::BuiltIn::SymbolSDFIconProgram,
|
||||
style::IconPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"SymbolSDFIconProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using SymbolSDFProgram::SymbolSDFProgram;
|
||||
};
|
||||
|
||||
class SymbolSDFTextProgram final : public SymbolSDFProgram<SymbolSDFTextProgram,
|
||||
shaders::BuiltIn::SymbolSDFTextProgram,
|
||||
style::TextPaintProperties> {
|
||||
public:
|
||||
static constexpr std::string_view Name{"SymbolSDFTextProgram"};
|
||||
const std::string_view typeName() const noexcept override { return Name; }
|
||||
|
||||
using SymbolSDFProgram::SymbolSDFProgram;
|
||||
};
|
||||
|
||||
using SymbolLayoutVertex = gfx::Vertex<SymbolLayoutAttributes>;
|
||||
using SymbolIconAttributes = SymbolIconProgram::AttributeList;
|
||||
using SymbolTextAttributes = SymbolSDFTextProgram::AttributeList;
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Alias
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
Reference in New Issue
Block a user