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:
@@ -203,8 +203,8 @@ void DrawableBuilder::Impl::setupForWideVectors(gfx::Context& context, gfx::Draw
|
||||
}
|
||||
|
||||
// segments
|
||||
SegmentVector<VertexTriWideVecB> triangleSegments;
|
||||
triangleSegments.emplace_back(Segment<VertexTriWideVecB>{0, 0, 12, 18});
|
||||
SegmentVector triangleSegments;
|
||||
triangleSegments.emplace_back(0, 0, 12, 18);
|
||||
|
||||
// add to builder
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace {
|
||||
|
||||
std::size_t addRingVertices(gfx::VertexVector<FillLayoutVertex>& vertices, const GeometryCoordinates& ring) {
|
||||
for (auto& point : ring) {
|
||||
vertices.emplace_back(FillProgram::layoutVertex(point));
|
||||
vertices.emplace_back(FillBucket::layoutVertex(point));
|
||||
}
|
||||
return ring.size();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ std::size_t totalVerticesCheck(const GeometryCollection& polygon) {
|
||||
return totalVertices;
|
||||
}
|
||||
|
||||
void addFillIndices(SegmentVector<FillAttributes>& fillSegments,
|
||||
void addFillIndices(SegmentVector& fillSegments,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
std::vector<uint32_t>& indices,
|
||||
std::size_t startVertices,
|
||||
@@ -80,7 +80,7 @@ void addFillIndices(SegmentVector<FillAttributes>& fillSegments,
|
||||
|
||||
void addOutlineIndices(std::size_t base,
|
||||
std::size_t nVertices,
|
||||
SegmentVector<FillAttributes>& lineSegments,
|
||||
SegmentVector& lineSegments,
|
||||
gfx::IndexVector<gfx::Lines>& lineIndexes) {
|
||||
if (nVertices == 0) return;
|
||||
|
||||
@@ -106,7 +106,7 @@ void addOutlineIndices(std::size_t base,
|
||||
void generateFillBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& fillVertices,
|
||||
gfx::IndexVector<Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments) {
|
||||
SegmentVector& fillSegments) {
|
||||
for (auto& polygon : classifyRings(geometry)) {
|
||||
// Optimize polygons with many interior rings for earcut tesselation.
|
||||
limitHoles(polygon, 500);
|
||||
@@ -126,9 +126,9 @@ void generateFillBuffers(const GeometryCollection& geometry,
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& vertices,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments,
|
||||
SegmentVector& fillSegments,
|
||||
gfx::IndexVector<gfx::Lines>& lineIndexes,
|
||||
SegmentVector<FillAttributes>& lineSegments) {
|
||||
SegmentVector& lineSegments) {
|
||||
for (auto& polygon : classifyRings(geometry)) {
|
||||
// Optimize polygons with many interior rings for earcut tesselation.
|
||||
limitHoles(polygon, 500);
|
||||
@@ -150,18 +150,18 @@ void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& fillVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments,
|
||||
SegmentVector& fillSegments,
|
||||
gfx::VertexVector<LineLayoutVertex>& lineVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& lineIndexes,
|
||||
SegmentVector<LineAttributes>& lineSegments) {
|
||||
gfx::PolylineGenerator<LineLayoutVertex, Segment<LineAttributes>> lineGenerator(
|
||||
SegmentVector& lineSegments) {
|
||||
gfx::PolylineGenerator<LineLayoutVertex, SegmentBase> lineGenerator(
|
||||
lineVertices,
|
||||
LineProgram::layoutVertex,
|
||||
LineBucket::layoutVertex,
|
||||
lineSegments,
|
||||
[](std::size_t vertexOffset, std::size_t indexOffset) -> Segment<LineAttributes> {
|
||||
return Segment<LineAttributes>(vertexOffset, indexOffset);
|
||||
[](std::size_t vertexOffset, std::size_t indexOffset) -> SegmentBase {
|
||||
return SegmentBase(vertexOffset, indexOffset);
|
||||
},
|
||||
[](auto& seg) -> Segment<LineAttributes>& { return seg; },
|
||||
[](auto& seg) -> SegmentBase& { return seg; },
|
||||
lineIndexes);
|
||||
|
||||
gfx::PolylineGeneratorOptions lineOptions;
|
||||
@@ -187,20 +187,20 @@ void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& fillVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& fillIndexes,
|
||||
SegmentVector<FillAttributes>& fillSegments,
|
||||
SegmentVector& fillSegments,
|
||||
gfx::VertexVector<LineLayoutVertex>& lineVertices,
|
||||
gfx::IndexVector<gfx::Triangles>& lineIndexes,
|
||||
SegmentVector<LineAttributes>& lineSegments,
|
||||
SegmentVector& lineSegments,
|
||||
gfx::IndexVector<gfx::Lines>& basicLineIndexes,
|
||||
SegmentVector<FillAttributes>& basicLineSegments) {
|
||||
gfx::PolylineGenerator<LineLayoutVertex, Segment<LineAttributes>> lineGenerator(
|
||||
SegmentVector& basicLineSegments) {
|
||||
gfx::PolylineGenerator<LineLayoutVertex, SegmentBase> lineGenerator(
|
||||
lineVertices,
|
||||
LineProgram::layoutVertex,
|
||||
LineBucket::layoutVertex,
|
||||
lineSegments,
|
||||
[](std::size_t vertexOffset, std::size_t indexOffset) -> Segment<LineAttributes> {
|
||||
return Segment<LineAttributes>(vertexOffset, indexOffset);
|
||||
[](std::size_t vertexOffset, std::size_t indexOffset) -> SegmentBase {
|
||||
return SegmentBase(vertexOffset, indexOffset);
|
||||
},
|
||||
[](auto& seg) -> Segment<LineAttributes>& { return seg; },
|
||||
[](auto& seg) -> SegmentBase& { return seg; },
|
||||
lineIndexes);
|
||||
|
||||
gfx::PolylineGeneratorOptions lineOptions;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/renderer/buckets/line_bucket.hpp>
|
||||
#include <mbgl/gfx/drawable_builder.hpp>
|
||||
#include <mbgl/gfx/drawable_builder_impl.hpp>
|
||||
#include <mbgl/gfx/drawable_impl.hpp>
|
||||
@@ -637,7 +637,7 @@ void PolylineGenerator<PLV, PS>::addPieSliceVertex(const GeometryCoordinate& cur
|
||||
template class PolylineGenerator<gfx::DrawableBuilder::Impl::LineLayoutVertex,
|
||||
std::unique_ptr<gfx::Drawable::DrawSegment>>;
|
||||
|
||||
template class PolylineGenerator<LineLayoutVertex, Segment<LineAttributes>>;
|
||||
template class PolylineGenerator<LineLayoutVertex, SegmentBase>;
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -126,10 +126,10 @@ private:
|
||||
// │ 1 2 │
|
||||
// └─────────┘
|
||||
//
|
||||
vertices.emplace_back(CircleProgram::vertex(point, -1, -1)); // 1
|
||||
vertices.emplace_back(CircleProgram::vertex(point, 1, -1)); // 2
|
||||
vertices.emplace_back(CircleProgram::vertex(point, 1, 1)); // 3
|
||||
vertices.emplace_back(CircleProgram::vertex(point, -1, 1)); // 4
|
||||
vertices.emplace_back(CircleBucket::vertex(point, -1, -1)); // 1
|
||||
vertices.emplace_back(CircleBucket::vertex(point, 1, -1)); // 2
|
||||
vertices.emplace_back(CircleBucket::vertex(point, 1, 1)); // 3
|
||||
vertices.emplace_back(CircleBucket::vertex(point, -1, 1)); // 4
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
|
||||
@@ -1087,53 +1087,53 @@ size_t SymbolLayout::addSymbol(SymbolBucket::Buffer& buffer,
|
||||
|
||||
// coordinates (2 triangles)
|
||||
auto& vertices = buffer.vertices();
|
||||
vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point,
|
||||
tl,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x,
|
||||
tex.y,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
pixelOffsetTL,
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point,
|
||||
tr,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x + tex.w,
|
||||
tex.y,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
{pixelOffsetBR.x, pixelOffsetTL.y},
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point,
|
||||
bl,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x,
|
||||
tex.y + tex.h,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
{pixelOffsetTL.x, pixelOffsetBR.y},
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point,
|
||||
br,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x + tex.w,
|
||||
tex.y + tex.h,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
pixelOffsetBR,
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point,
|
||||
tl,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x,
|
||||
tex.y,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
pixelOffsetTL,
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point,
|
||||
tr,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x + tex.w,
|
||||
tex.y,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
{pixelOffsetBR.x, pixelOffsetTL.y},
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point,
|
||||
bl,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x,
|
||||
tex.y + tex.h,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
{pixelOffsetTL.x, pixelOffsetBR.y},
|
||||
minFontScale));
|
||||
vertices.emplace_back(SymbolBucket::layoutVertex(labelAnchor.point,
|
||||
br,
|
||||
symbol.glyphOffset.y,
|
||||
tex.x + tex.w,
|
||||
tex.y + tex.h,
|
||||
sizeData,
|
||||
symbol.isSDF,
|
||||
pixelOffsetBR,
|
||||
minFontScale));
|
||||
|
||||
// Dynamic/Opacity vertices are initialized so that the vertex count always
|
||||
// agrees with the layout vertex buffer, but they will always be updated
|
||||
// before rendering happens
|
||||
auto dynamicVertex = SymbolSDFIconProgram::dynamicLayoutVertex(labelAnchor.point, 0);
|
||||
auto dynamicVertex = SymbolBucket::dynamicLayoutVertex(labelAnchor.point, 0);
|
||||
buffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
buffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
buffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
buffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
|
||||
auto opacityVertex = SymbolSDFIconProgram::opacityVertex(true, 1.0);
|
||||
auto opacityVertex = SymbolBucket::opacityVertex(true, 1.0);
|
||||
buffer.opacityVertices().emplace_back(opacityVertex);
|
||||
buffer.opacityVertices().emplace_back(opacityVertex);
|
||||
buffer.opacityVertices().emplace_back(opacityVertex);
|
||||
@@ -1209,18 +1209,18 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) {
|
||||
auto index = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
collisionBuffer.vertices().emplace_back(
|
||||
CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, tl));
|
||||
SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, tl));
|
||||
collisionBuffer.vertices().emplace_back(
|
||||
CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, tr));
|
||||
SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, tr));
|
||||
collisionBuffer.vertices().emplace_back(
|
||||
CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, br));
|
||||
SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, br));
|
||||
collisionBuffer.vertices().emplace_back(
|
||||
CollisionBoxProgram::layoutVertex(anchor, symbolInstance.getAnchor().point, bl));
|
||||
SymbolBucket::collisionLayoutVertex(anchor, symbolInstance.getAnchor().point, bl));
|
||||
|
||||
// Dynamic vertices are initialized so that the vertex count
|
||||
// always agrees with the layout vertex buffer, but they will
|
||||
// always be updated before rendering happens
|
||||
auto dynamicVertex = CollisionBoxProgram::dynamicVertex(false, false, {});
|
||||
auto dynamicVertex = SymbolBucket::collisionDynamicVertex(false, false, {});
|
||||
collisionBuffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
collisionBuffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
collisionBuffer.dynamicVertices().emplace_back(dynamicVertex);
|
||||
|
||||
@@ -141,7 +141,7 @@ bool isVisible(const vec4& anchorPos, const std::array<double, 2>& clippingBuffe
|
||||
void addDynamicAttributes(const Point<float>& anchorPoint,
|
||||
const float angle,
|
||||
gfx::VertexVector<gfx::Vertex<SymbolDynamicLayoutAttributes>>& dynamicVertexArray) {
|
||||
auto dynamicVertex = SymbolSDFIconProgram::dynamicLayoutVertex(anchorPoint, angle);
|
||||
auto dynamicVertex = SymbolBucket::dynamicLayoutVertex(anchorPoint, angle);
|
||||
dynamicVertexArray.emplace_back(dynamicVertex);
|
||||
dynamicVertexArray.emplace_back(dynamicVertex);
|
||||
dynamicVertexArray.emplace_back(dynamicVertex);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
#include <mbgl/renderer/buckets/symbol_bucket.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <mbgl/renderer/buckets/circle_bucket.hpp>
|
||||
#include <mbgl/renderer/bucket_parameters.hpp>
|
||||
#include <mbgl/programs/circle_program.hpp>
|
||||
#include <mbgl/style/layers/circle_layer_impl.hpp>
|
||||
#include <mbgl/renderer/layers/render_circle_layer.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
@@ -36,7 +35,7 @@ bool CircleBucket::hasData() const {
|
||||
template <class Property>
|
||||
static float get(const CirclePaintProperties::PossiblyEvaluated& evaluated,
|
||||
const std::string& id,
|
||||
const std::map<std::string, CircleProgram::Binders>& paintPropertyBinders) {
|
||||
const std::map<std::string, CircleBinders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(id);
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/circle_program.hpp>
|
||||
#include <mbgl/style/layers/circle_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class BucketParameters;
|
||||
|
||||
using CircleBinders = PaintPropertyBinders<style::CirclePaintProperties::DataDrivenProperties>;
|
||||
using CircleLayoutVertex = gfx::Vertex<TypeList<attributes::pos>>;
|
||||
|
||||
class CircleBucket final : public Bucket {
|
||||
public:
|
||||
using PossiblyEvaluatedLayoutProperties = style::CircleLayoutProperties::PossiblyEvaluated;
|
||||
@@ -30,6 +33,17 @@ public:
|
||||
|
||||
void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override;
|
||||
|
||||
/*
|
||||
* @param {number} x vertex position
|
||||
* @param {number} y vertex position
|
||||
* @param {number} ex extrude normal
|
||||
* @param {number} ey extrude normal
|
||||
*/
|
||||
static CircleLayoutVertex vertex(Point<int16_t> p, float ex, float ey) {
|
||||
return CircleLayoutVertex{
|
||||
{{static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)), static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))}}};
|
||||
}
|
||||
|
||||
using VertexVector = gfx::VertexVector<CircleLayoutVertex>;
|
||||
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||
VertexVector& vertices = *sharedVertices;
|
||||
@@ -38,9 +52,9 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<CircleAttributes> segments;
|
||||
SegmentVector segments;
|
||||
|
||||
std::map<std::string, CircleProgram::Binders> paintPropertyBinders;
|
||||
std::map<std::string, CircleBinders> paintPropertyBinders;
|
||||
|
||||
const MapMode mode;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
|
||||
Point<int16_t> p{int16_t(::round(left + glyph.data[j] * scale)),
|
||||
int16_t(::round(baseline - glyph.data[j + 1] * scale))};
|
||||
|
||||
vertices.emplace_back(FillProgram::layoutVertex(p));
|
||||
vertices.emplace_back(FillBucket::layoutVertex(p));
|
||||
|
||||
if (prev) {
|
||||
indices.emplace_back(static_cast<uint16_t>(vertices.elements() - 2),
|
||||
|
||||
@@ -6,13 +6,16 @@
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/programs/debug_program.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/textures.hpp>
|
||||
#include <mbgl/renderer/buckets/fill_bucket.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class OverscaledTileID;
|
||||
|
||||
using DebugLayoutVertex = gfx::Vertex<TypeList<attributes::pos>>;
|
||||
|
||||
class DebugBucket : private util::noncopyable {
|
||||
public:
|
||||
DebugBucket(const OverscaledTileID& id,
|
||||
@@ -33,8 +36,8 @@ public:
|
||||
gfx::VertexVector<FillLayoutVertex> vertices;
|
||||
gfx::IndexVector<gfx::Lines> indices;
|
||||
|
||||
SegmentVector<DebugAttributes> segments;
|
||||
SegmentVector<DebugAttributes> tileBorderSegments;
|
||||
SegmentVector segments;
|
||||
SegmentVector tileBorderSegments;
|
||||
std::optional<gfx::VertexBuffer<DebugLayoutVertex>> vertexBuffer;
|
||||
std::optional<gfx::IndexBuffer> indexBuffer;
|
||||
std::optional<gfx::Texture> texture;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <mbgl/renderer/buckets/fill_bucket.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/renderer/bucket_parameters.hpp>
|
||||
#include <mbgl/style/layers/fill_layer_impl.hpp>
|
||||
#include <mbgl/renderer/layers/render_fill_layer.hpp>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/style/layers/fill_layer_properties.hpp>
|
||||
|
||||
/**
|
||||
@@ -16,7 +16,7 @@
|
||||
#define MLN_TRIANGULATE_FILL_OUTLINES (MLN_RENDER_BACKEND_METAL)
|
||||
|
||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/renderer/buckets/line_bucket.hpp>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
@@ -24,6 +24,9 @@ namespace mbgl {
|
||||
class BucketParameters;
|
||||
class RenderFillLayer;
|
||||
|
||||
using FillBinders = PaintPropertyBinders<style::FillPaintProperties::DataDrivenProperties>;
|
||||
using FillLayoutVertex = gfx::Vertex<TypeList<attributes::pos>>;
|
||||
|
||||
class FillBucket final : public Bucket {
|
||||
public:
|
||||
~FillBucket() override;
|
||||
@@ -49,6 +52,8 @@ public:
|
||||
|
||||
void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override;
|
||||
|
||||
static FillLayoutVertex layoutVertex(Point<int16_t> p) { return FillLayoutVertex{{{p.x, p.y}}}; }
|
||||
|
||||
#if MLN_TRIANGULATE_FILL_OUTLINES
|
||||
using LineVertexVector = gfx::VertexVector<LineLayoutVertex>;
|
||||
const std::shared_ptr<LineVertexVector> sharedLineVertices = std::make_shared<LineVertexVector>();
|
||||
@@ -58,14 +63,14 @@ public:
|
||||
const std::shared_ptr<LineIndexVector> sharedLineIndexes = std::make_shared<LineIndexVector>();
|
||||
LineIndexVector& lineIndexes = *sharedLineIndexes;
|
||||
|
||||
SegmentVector<LineAttributes> lineSegments;
|
||||
SegmentVector lineSegments;
|
||||
#endif // MLN_TRIANGULATE_FILL_OUTLINES
|
||||
|
||||
using BasicLineIndexVector = gfx::IndexVector<gfx::Lines>;
|
||||
const std::shared_ptr<BasicLineIndexVector> sharedBasicLineIndexes = std::make_shared<BasicLineIndexVector>();
|
||||
BasicLineIndexVector& basicLines = *sharedBasicLineIndexes;
|
||||
|
||||
SegmentVector<FillAttributes> basicLineSegments;
|
||||
SegmentVector basicLineSegments;
|
||||
|
||||
using VertexVector = gfx::VertexVector<FillLayoutVertex>;
|
||||
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||
@@ -75,9 +80,9 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<FillAttributes> triangleSegments;
|
||||
SegmentVector triangleSegments;
|
||||
|
||||
std::map<std::string, FillProgram::Binders> paintPropertyBinders;
|
||||
std::map<std::string, FillBinders> paintPropertyBinders;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <mbgl/renderer/buckets/fill_extrusion_bucket.hpp>
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
#include <mbgl/renderer/bucket_parameters.hpp>
|
||||
#include <mbgl/style/layers/fill_extrusion_layer_impl.hpp>
|
||||
#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp>
|
||||
#include <mbgl/map/transform_state.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
|
||||
@@ -102,7 +102,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
|
||||
const auto& p1 = ring[i];
|
||||
|
||||
vertices.emplace_back(
|
||||
FillExtrusionProgram::layoutVertex(p1, 0, 0, 1, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
FillExtrusionBucket::layoutVertex(p1, 0, 0, 1, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
flatIndices.emplace_back(triangleIndex);
|
||||
triangleIndex++;
|
||||
|
||||
@@ -118,16 +118,16 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
|
||||
edgeDistance = 0;
|
||||
}
|
||||
|
||||
vertices.emplace_back(FillExtrusionProgram::layoutVertex(
|
||||
vertices.emplace_back(FillExtrusionBucket::layoutVertex(
|
||||
p1, perp.x, perp.y, 0, 0, static_cast<uint16_t>(edgeDistance)));
|
||||
vertices.emplace_back(FillExtrusionProgram::layoutVertex(
|
||||
vertices.emplace_back(FillExtrusionBucket::layoutVertex(
|
||||
p1, perp.x, perp.y, 0, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
|
||||
edgeDistance += dist;
|
||||
|
||||
vertices.emplace_back(FillExtrusionProgram::layoutVertex(
|
||||
vertices.emplace_back(FillExtrusionBucket::layoutVertex(
|
||||
p2, perp.x, perp.y, 0, 0, static_cast<uint16_t>(edgeDistance)));
|
||||
vertices.emplace_back(FillExtrusionProgram::layoutVertex(
|
||||
vertices.emplace_back(FillExtrusionBucket::layoutVertex(
|
||||
p2, perp.x, perp.y, 0, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
|
||||
// ┌──────┐
|
||||
@@ -198,4 +198,24 @@ void FillExtrusionBucket::update(const FeatureStates& states,
|
||||
}
|
||||
}
|
||||
|
||||
std::array<float, 3> FillExtrusionBucket::lightColor(const EvaluatedLight& light) {
|
||||
const auto color = light.get<LightColor>();
|
||||
return {{color.r, color.g, color.b}};
|
||||
}
|
||||
|
||||
std::array<float, 3> FillExtrusionBucket::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 FillExtrusionBucket::lightIntensity(const EvaluatedLight& light) {
|
||||
return light.get<LightIntensity>();
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/renderer/render_light.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
#include <mbgl/style/layers/fill_extrusion_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -13,6 +14,9 @@ namespace mbgl {
|
||||
class BucketParameters;
|
||||
class RenderFillExtrusionLayer;
|
||||
|
||||
using FillExtrusionBinders = PaintPropertyBinders<style::FillExtrusionPaintProperties::DataDrivenProperties>;
|
||||
using FillExtrusionLayoutVertex = gfx::Vertex<TypeList<attributes::pos, attributes::normal_ed>>;
|
||||
|
||||
class FillExtrusionBucket final : public Bucket {
|
||||
public:
|
||||
~FillExtrusionBucket() override;
|
||||
@@ -39,6 +43,25 @@ public:
|
||||
|
||||
void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override;
|
||||
|
||||
static FillExtrusionLayoutVertex layoutVertex(
|
||||
Point<int16_t> p, double nx, double ny, double nz, unsigned short t, uint16_t e) {
|
||||
const auto factor = pow(2, 13);
|
||||
|
||||
return FillExtrusionLayoutVertex{{{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&);
|
||||
|
||||
using VertexVector = gfx::VertexVector<FillExtrusionLayoutVertex>;
|
||||
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||
VertexVector& vertices = *sharedVertices;
|
||||
@@ -47,9 +70,9 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<FillExtrusionAttributes> triangleSegments;
|
||||
SegmentVector triangleSegments;
|
||||
|
||||
std::unordered_map<std::string, FillExtrusionProgram::Binders> paintPropertyBinders;
|
||||
std::unordered_map<std::string, FillExtrusionBinders> paintPropertyBinders;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <mbgl/renderer/buckets/heatmap_bucket.hpp>
|
||||
#include <mbgl/renderer/bucket_parameters.hpp>
|
||||
#include <mbgl/programs/heatmap_program.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_impl.hpp>
|
||||
#include <mbgl/renderer/layers/render_heatmap_layer.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
@@ -66,10 +65,10 @@ void HeatmapBucket::addFeature(const GeometryTileFeature& feature,
|
||||
// │ 1 2 │
|
||||
// └─────────┘
|
||||
//
|
||||
vertices.emplace_back(HeatmapProgram::vertex(point, -1, -1)); // 1
|
||||
vertices.emplace_back(HeatmapProgram::vertex(point, 1, -1)); // 2
|
||||
vertices.emplace_back(HeatmapProgram::vertex(point, 1, 1)); // 3
|
||||
vertices.emplace_back(HeatmapProgram::vertex(point, -1, 1)); // 4
|
||||
vertices.emplace_back(HeatmapBucket::vertex(point, -1, -1)); // 1
|
||||
vertices.emplace_back(HeatmapBucket::vertex(point, 1, -1)); // 2
|
||||
vertices.emplace_back(HeatmapBucket::vertex(point, 1, 1)); // 3
|
||||
vertices.emplace_back(HeatmapBucket::vertex(point, -1, 1)); // 4
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/heatmap_program.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class BucketParameters;
|
||||
|
||||
using HeatmapBinders = PaintPropertyBinders<style::HeatmapPaintProperties::DataDrivenProperties>;
|
||||
using HeatmapLayoutVertex = gfx::Vertex<TypeList<attributes::pos>>;
|
||||
using HeatmapTextureLayoutVertex = gfx::Vertex<TypeList<attributes::pos>>;
|
||||
|
||||
class HeatmapBucket final : public Bucket {
|
||||
public:
|
||||
HeatmapBucket(const BucketParameters&, const std::vector<Immutable<style::LayerProperties>>&);
|
||||
@@ -30,6 +34,21 @@ public:
|
||||
|
||||
float getQueryRadius(const RenderLayer&) const override;
|
||||
|
||||
/*
|
||||
* @param {number} x vertex position
|
||||
* @param {number} y vertex position
|
||||
* @param {number} ex extrude normal
|
||||
* @param {number} ey extrude normal
|
||||
*/
|
||||
static HeatmapLayoutVertex vertex(Point<int16_t> p, float ex, float ey) {
|
||||
return HeatmapLayoutVertex{
|
||||
{{static_cast<int16_t>((p.x * 2) + ((ex + 1) / 2)), static_cast<int16_t>((p.y * 2) + ((ey + 1) / 2))}}};
|
||||
}
|
||||
|
||||
static HeatmapTextureLayoutVertex textureVertex(Point<int16_t> p) {
|
||||
return HeatmapTextureLayoutVertex{{{p.x, p.y}}};
|
||||
}
|
||||
|
||||
using VertexVector = gfx::VertexVector<HeatmapLayoutVertex>;
|
||||
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||
VertexVector& vertices = *sharedVertices;
|
||||
@@ -38,9 +57,9 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<HeatmapAttributes> segments;
|
||||
SegmentVector segments;
|
||||
|
||||
std::map<std::string, HeatmapProgram::Binders> paintPropertyBinders;
|
||||
std::map<std::string, HeatmapBinders> paintPropertyBinders;
|
||||
|
||||
const MapMode mode;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include <mbgl/renderer/buckets/hillshade_bucket.hpp>
|
||||
#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
|
||||
#include <mbgl/programs/hillshade_program.hpp>
|
||||
#include <mbgl/programs/hillshade_prepare_program.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -80,13 +78,13 @@ void HillshadeBucket::setMask(TileMask&& mask_) {
|
||||
segments.emplace_back(vertices.elements(), indices.elements());
|
||||
}
|
||||
|
||||
vertices.emplace_back(HillshadeProgram::layoutVertex(
|
||||
vertices.emplace_back(HillshadeBucket::layoutVertex(
|
||||
{tlVertex.x, tlVertex.y}, {static_cast<uint16_t>(tlVertex.x), static_cast<uint16_t>(tlVertex.y)}));
|
||||
vertices.emplace_back(HillshadeProgram::layoutVertex(
|
||||
vertices.emplace_back(HillshadeBucket::layoutVertex(
|
||||
{brVertex.x, tlVertex.y}, {static_cast<uint16_t>(brVertex.x), static_cast<uint16_t>(tlVertex.y)}));
|
||||
vertices.emplace_back(HillshadeProgram::layoutVertex(
|
||||
vertices.emplace_back(HillshadeBucket::layoutVertex(
|
||||
{tlVertex.x, brVertex.y}, {static_cast<uint16_t>(tlVertex.x), static_cast<uint16_t>(brVertex.y)}));
|
||||
vertices.emplace_back(HillshadeProgram::layoutVertex(
|
||||
vertices.emplace_back(HillshadeBucket::layoutVertex(
|
||||
{brVertex.x, brVertex.y}, {static_cast<uint16_t>(brVertex.x), static_cast<uint16_t>(brVertex.y)}));
|
||||
|
||||
auto& segment = segments.back();
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/programs/hillshade_program.hpp>
|
||||
#include <mbgl/programs/hillshade_prepare_program.hpp>
|
||||
#include <mbgl/geometry/dem_data.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/tile_mask.hpp>
|
||||
#include <mbgl/geometry/dem_data.hpp>
|
||||
#include <mbgl/style/layers/hillshade_layer_properties.hpp>
|
||||
#include <mbgl/util/tileset.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using HillshadeBinders = PaintPropertyBinders<style::HillshadePaintProperties::DataDrivenProperties>;
|
||||
using HillshadeLayoutVertex = gfx::Vertex<TypeList<attributes::pos, attributes::texture_pos>>;
|
||||
|
||||
class HillshadeBucket final : public Bucket {
|
||||
public:
|
||||
HillshadeBucket(PremultipliedImage&&, Tileset::DEMEncoding encoding);
|
||||
@@ -42,6 +46,10 @@ public:
|
||||
|
||||
void setPrepared(bool preparedState) { prepared = preparedState; }
|
||||
|
||||
static HillshadeLayoutVertex layoutVertex(Point<int16_t> p, Point<uint16_t> t) {
|
||||
return HillshadeLayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}};
|
||||
}
|
||||
|
||||
// Raster-DEM Tile Sources use the default buffers from Painter
|
||||
using VertexVector = gfx::VertexVector<HillshadeLayoutVertex>;
|
||||
std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
|
||||
@@ -51,7 +59,7 @@ public:
|
||||
std::shared_ptr<IndexVector> sharedIndices = std::make_shared<IndexVector>();
|
||||
IndexVector& indices = *sharedIndices;
|
||||
|
||||
SegmentVector<HillshadeAttributes> segments;
|
||||
SegmentVector segments;
|
||||
|
||||
private:
|
||||
DEMData demdata;
|
||||
|
||||
@@ -54,14 +54,14 @@ void LineBucket::addFeature(const GeometryTileFeature& feature,
|
||||
void LineBucket::addGeometry(const GeometryCoordinates& coordinates,
|
||||
const GeometryTileFeature& feature,
|
||||
const CanonicalTileID& canonical) {
|
||||
gfx::PolylineGenerator<LineLayoutVertex, Segment<LineAttributes>> generator(
|
||||
gfx::PolylineGenerator<LineLayoutVertex, SegmentBase> generator(
|
||||
vertices,
|
||||
LineProgram::layoutVertex,
|
||||
LineBucket::layoutVertex,
|
||||
segments,
|
||||
[](std::size_t vertexOffset, std::size_t indexOffset) -> Segment<LineAttributes> {
|
||||
return Segment<LineAttributes>(vertexOffset, indexOffset);
|
||||
[](std::size_t vertexOffset, std::size_t indexOffset) -> SegmentBase {
|
||||
return SegmentBase(vertexOffset, indexOffset);
|
||||
},
|
||||
[](auto& seg) -> Segment<LineAttributes>& { return seg; },
|
||||
[](auto& seg) -> SegmentBase& { return seg; },
|
||||
triangles);
|
||||
|
||||
gfx::PolylineGeneratorOptions options;
|
||||
@@ -137,7 +137,7 @@ bool LineBucket::hasData() const {
|
||||
template <class Property>
|
||||
static float get(const LinePaintProperties::PossiblyEvaluated& evaluated,
|
||||
const std::string& id,
|
||||
const std::map<std::string, LineProgram::Binders>& paintPropertyBinders) {
|
||||
const std::map<std::string, LineBinders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(id);
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/style/layers/line_layer_properties.hpp>
|
||||
#include <mbgl/style/image_impl.hpp>
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace mbgl {
|
||||
class BucketParameters;
|
||||
class RenderLineLayer;
|
||||
|
||||
using LineBinders = PaintPropertyBinders<style::LinePaintProperties::DataDrivenProperties>;
|
||||
using LineLayoutVertex = gfx::Vertex<TypeList<attributes::pos_normal, attributes::data<uint8_t, 4>>>;
|
||||
|
||||
class LineBucket final : public Bucket {
|
||||
public:
|
||||
using PossiblyEvaluatedLayoutProperties = style::LineLayoutProperties::PossiblyEvaluated;
|
||||
@@ -38,6 +41,46 @@ public:
|
||||
|
||||
void update(const FeatureStates&, const GeometryTileLayer&, const std::string&, const ImagePositions&) override;
|
||||
|
||||
/*
|
||||
* @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 LineLayoutVertex layoutVertex(
|
||||
Point<int16_t> p, Point<double> e, bool round, bool up, int8_t dir, int32_t linesofar = 0) {
|
||||
return LineLayoutVertex{
|
||||
{{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;
|
||||
|
||||
PossiblyEvaluatedLayoutProperties layout;
|
||||
|
||||
using VertexVector = gfx::VertexVector<LineLayoutVertex>;
|
||||
@@ -48,9 +91,9 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<LineAttributes> segments;
|
||||
SegmentVector segments;
|
||||
|
||||
std::map<std::string, LineProgram::Binders> paintPropertyBinders;
|
||||
std::map<std::string, LineBinders> paintPropertyBinders;
|
||||
|
||||
private:
|
||||
void addGeometry(const GeometryCoordinates&, const GeometryTileFeature&, const CanonicalTileID&);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <mbgl/renderer/buckets/raster_bucket.hpp>
|
||||
#include <mbgl/renderer/layers/render_raster_layer.hpp>
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
#include <mbgl/gfx/upload_pass.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -78,13 +77,13 @@ void RasterBucket::setMask(TileMask&& mask_) {
|
||||
segments.emplace_back(vertices.elements(), indices.elements());
|
||||
}
|
||||
|
||||
vertices.emplace_back(RasterProgram::layoutVertex(
|
||||
vertices.emplace_back(RasterBucket::layoutVertex(
|
||||
{tlVertex.x, tlVertex.y}, {static_cast<uint16_t>(tlVertex.x), static_cast<uint16_t>(tlVertex.y)}));
|
||||
vertices.emplace_back(RasterProgram::layoutVertex(
|
||||
vertices.emplace_back(RasterBucket::layoutVertex(
|
||||
{brVertex.x, tlVertex.y}, {static_cast<uint16_t>(brVertex.x), static_cast<uint16_t>(tlVertex.y)}));
|
||||
vertices.emplace_back(RasterProgram::layoutVertex(
|
||||
vertices.emplace_back(RasterBucket::layoutVertex(
|
||||
{tlVertex.x, brVertex.y}, {static_cast<uint16_t>(tlVertex.x), static_cast<uint16_t>(brVertex.y)}));
|
||||
vertices.emplace_back(RasterProgram::layoutVertex(
|
||||
vertices.emplace_back(RasterBucket::layoutVertex(
|
||||
{brVertex.x, brVertex.y}, {static_cast<uint16_t>(brVertex.x), static_cast<uint16_t>(brVertex.y)}));
|
||||
|
||||
auto& segment = segments.back();
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/renderer/tile_mask.hpp>
|
||||
#include <mbgl/style/layers/raster_layer_properties.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
@@ -19,6 +21,9 @@ class Texture2D;
|
||||
using Texture2DPtr = std::shared_ptr<Texture2D>;
|
||||
} // namespace gfx
|
||||
|
||||
using RasterBinders = PaintPropertyBinders<style::RasterPaintProperties::DataDrivenProperties>;
|
||||
using RasterLayoutVertex = gfx::Vertex<TypeList<attributes::pos, attributes::texture_pos>>;
|
||||
|
||||
class RasterBucket final : public Bucket {
|
||||
public:
|
||||
RasterBucket(PremultipliedImage&&);
|
||||
@@ -32,6 +37,10 @@ public:
|
||||
void setImage(std::shared_ptr<PremultipliedImage>);
|
||||
void setMask(TileMask&&);
|
||||
|
||||
static RasterLayoutVertex layoutVertex(Point<int16_t> p, Point<uint16_t> t) {
|
||||
return RasterLayoutVertex{{{p.x, p.y}}, {{t.x, t.y}}};
|
||||
}
|
||||
|
||||
std::shared_ptr<PremultipliedImage> image;
|
||||
std::optional<gfx::Texture> texture;
|
||||
gfx::Texture2DPtr texture2d;
|
||||
@@ -47,7 +56,7 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& indices = *sharedTriangles;
|
||||
|
||||
SegmentVector<RasterAttributes> segments;
|
||||
SegmentVector segments;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -15,6 +15,27 @@ namespace {
|
||||
std::atomic<uint32_t> maxBucketInstanceId;
|
||||
} // namespace
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SymbolBucket::SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout_,
|
||||
const std::map<std::string, Immutable<style::LayerProperties>>& paintProperties_,
|
||||
const style::PropertyValue<float>& textSize,
|
||||
|
||||
@@ -5,13 +5,12 @@
|
||||
#include <mbgl/layout/symbol_feature.hpp>
|
||||
#include <mbgl/layout/symbol_instance.hpp>
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/programs/collision_box_program.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
#include <mbgl/renderer/paint_property_binder.hpp>
|
||||
#include <mbgl/renderer/layers/render_symbol_layer.hpp>
|
||||
#include <mbgl/style/layers/symbol_layer_properties.hpp>
|
||||
#include <mbgl/text/glyph_range.hpp>
|
||||
#include <mbgl/text/placement.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -20,6 +19,162 @@ namespace mbgl {
|
||||
|
||||
class CrossTileSymbolLayerIndex;
|
||||
|
||||
using SymbolIconBinders = PaintPropertyBinders<style::IconPaintProperties::DataDrivenProperties>;
|
||||
using SymbolTextBinders = PaintPropertyBinders<style::TextPaintProperties::DataDrivenProperties>;
|
||||
using SymbolLayoutVertex =
|
||||
gfx::Vertex<TypeList<attributes::pos_offset, attributes::data<uint16_t, 4>, attributes::pixeloffset>>;
|
||||
using SymbolDynamicLayoutAttributes = TypeList<attributes::projected_pos>;
|
||||
using SymbolOpacityAttributes = TypeList<attributes::fade_opacity>;
|
||||
|
||||
using CollisionBoxLayoutAttributes = TypeList<attributes::pos, attributes::anchor_pos, attributes::extrude>;
|
||||
using CollisionBoxDynamicAttributes = TypeList<attributes::placed, attributes::shift>;
|
||||
|
||||
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;
|
||||
|
||||
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 PlacedSymbol {
|
||||
public:
|
||||
PlacedSymbol(Point<float> anchorPoint_,
|
||||
@@ -110,6 +265,42 @@ public:
|
||||
bool check(std::source_location) override;
|
||||
#endif
|
||||
|
||||
static SymbolLayoutVertex 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))}}};
|
||||
}
|
||||
|
||||
Immutable<style::SymbolLayoutProperties::PossiblyEvaluated> layout;
|
||||
const std::string bucketLeaderID;
|
||||
float sortedAngle = std::numeric_limits<float>::max();
|
||||
@@ -131,8 +322,8 @@ public:
|
||||
const std::vector<SortKeyRange> sortKeyRanges;
|
||||
|
||||
struct PaintProperties {
|
||||
SymbolIconProgram::Binders iconBinders;
|
||||
SymbolSDFTextProgram::Binders textBinders;
|
||||
SymbolIconBinders iconBinders;
|
||||
SymbolTextBinders textBinders;
|
||||
};
|
||||
std::map<std::string, PaintProperties> paintProperties;
|
||||
|
||||
@@ -180,7 +371,7 @@ public:
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<SymbolTextAttributes> segments;
|
||||
SegmentVector segments;
|
||||
std::vector<PlacedSymbol> placedSymbols;
|
||||
} text;
|
||||
|
||||
@@ -202,7 +393,7 @@ public:
|
||||
CollisionDynamicVertexVector& dynamicVertices() { return *sharedDynamicVertices; }
|
||||
const CollisionDynamicVertexVector& dynamicVertices() const { return *sharedDynamicVertices; }
|
||||
|
||||
SegmentVector<CollisionBoxProgram::AttributeList> segments;
|
||||
SegmentVector segments;
|
||||
};
|
||||
|
||||
struct CollisionBoxBuffer : public CollisionBuffer {
|
||||
@@ -241,6 +432,20 @@ public:
|
||||
return *textCollisionCircle;
|
||||
}
|
||||
|
||||
static gfx::Vertex<CollisionBoxLayoutAttributes> collisionLayoutVertex(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> collisionDynamicVertex(bool placed,
|
||||
bool notUsed,
|
||||
Point<float> shift) {
|
||||
return {{{static_cast<uint16_t>(placed), static_cast<uint16_t>(notUsed)}}, {{shift.x, shift.y}}};
|
||||
}
|
||||
|
||||
const float tilePixelRatio;
|
||||
uint32_t bucketInstanceId;
|
||||
const bool allowVerticalPlacement;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/programs/circle_program.hpp>
|
||||
#include <mbgl/renderer/buckets/circle_bucket.hpp>
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/renderer/render_tree.hpp>
|
||||
@@ -70,7 +70,7 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
|
||||
}
|
||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||
|
||||
auto* binders = static_cast<CircleProgram::Binders*>(drawable.getBinders());
|
||||
auto* binders = static_cast<CircleBinders*>(drawable.getBinders());
|
||||
if (!binders) {
|
||||
assert(false);
|
||||
return;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/renderable.hpp>
|
||||
#include <mbgl/gfx/renderer_backend.hpp>
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
#include <mbgl/renderer/buckets/fill_extrusion_bucket.hpp>
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/renderer/render_tree.hpp>
|
||||
@@ -43,12 +43,12 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP
|
||||
// but the resulting buffer can be shared across all the drawables from the layer.
|
||||
const FillExtrusionPropsUBO propsUBO = {
|
||||
.color = constOrDefault<FillExtrusionColor>(evaluated),
|
||||
.light_color = FillExtrusionProgram::lightColor(parameters.evaluatedLight),
|
||||
.light_color = FillExtrusionBucket::lightColor(parameters.evaluatedLight),
|
||||
.pad1 = 0,
|
||||
.light_position = FillExtrusionProgram::lightPosition(parameters.evaluatedLight, state),
|
||||
.light_position = FillExtrusionBucket::lightPosition(parameters.evaluatedLight, state),
|
||||
.base = constOrDefault<FillExtrusionBase>(evaluated),
|
||||
.height = constOrDefault<FillExtrusionHeight>(evaluated),
|
||||
.light_intensity = FillExtrusionProgram::lightIntensity(parameters.evaluatedLight),
|
||||
.light_intensity = FillExtrusionBucket::lightIntensity(parameters.evaluatedLight),
|
||||
.vertical_gradient = evaluated.get<FillExtrusionVerticalGradient>() ? 1.0f : 0.0f,
|
||||
.opacity = evaluated.get<FillExtrusionOpacity>(),
|
||||
.fade = crossfade.t,
|
||||
@@ -75,7 +75,7 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP
|
||||
return;
|
||||
}
|
||||
|
||||
auto* binders = static_cast<FillExtrusionProgram::Binders*>(drawable.getBinders());
|
||||
auto* binders = static_cast<FillExtrusionBinders*>(drawable.getBinders());
|
||||
const auto* tile = drawable.getRenderTile();
|
||||
if (!binders || !tile) {
|
||||
assert(false);
|
||||
|
||||
@@ -70,7 +70,7 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
|
||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||
|
||||
auto* binders = static_cast<FillProgram::Binders*>(drawable.getBinders());
|
||||
auto* binders = static_cast<FillBinders*>(drawable.getBinders());
|
||||
const auto* tile = drawable.getRenderTile();
|
||||
if (!binders || !tile) {
|
||||
assert(false);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/programs/heatmap_program.hpp>
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/renderer/render_static_data.hpp>
|
||||
@@ -58,7 +57,7 @@ void HeatmapLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamet
|
||||
|
||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||
|
||||
auto* binders = static_cast<HeatmapProgram::Binders*>(drawable.getBinders());
|
||||
auto* binders = static_cast<HeatmapBinders*>(drawable.getBinders());
|
||||
const auto* tile = drawable.getRenderTile();
|
||||
if (!binders || !tile) {
|
||||
assert(false);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/line_drawable_data.hpp>
|
||||
#include <mbgl/geometry/line_atlas.hpp>
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/renderer/buckets/line_bucket.hpp>
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
@@ -175,7 +175,7 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters
|
||||
|
||||
const UnwrappedTileID tileID = drawable.getTileID()->toUnwrapped();
|
||||
|
||||
auto* binders = static_cast<LineProgram::Binders*>(drawable.getBinders());
|
||||
auto* binders = static_cast<LineBinders*>(drawable.getBinders());
|
||||
const auto* tile = drawable.getRenderTile();
|
||||
if (!binders || !tile) {
|
||||
assert(false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/programs/background_program.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/style/layers/background_layer_impl.hpp>
|
||||
#include <mbgl/style/layers/background_layer_properties.hpp>
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
|
||||
// Paint properties
|
||||
style::BackgroundPaintProperties::Unevaluated unevaluated;
|
||||
SegmentVector<BackgroundAttributes> segments;
|
||||
SegmentVector segments;
|
||||
|
||||
// Drawable shaders
|
||||
gfx::ShaderProgramBasePtr plainShader;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/gfx/shader_group.hpp>
|
||||
#include <mbgl/gfx/shader_registry.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/programs/circle_program.hpp>
|
||||
#include <mbgl/renderer/buckets/circle_bucket.hpp>
|
||||
#include <mbgl/renderer/render_tile.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/gfx/render_pass.hpp>
|
||||
#include <mbgl/gfx/renderer_backend.hpp>
|
||||
#include <mbgl/gfx/shader_registry.hpp>
|
||||
#include <mbgl/programs/fill_extrusion_program.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/renderer/buckets/fill_extrusion_bucket.hpp>
|
||||
#include <mbgl/renderer/image_manager.hpp>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/gfx/cull_face_mode.hpp>
|
||||
#include <mbgl/gfx/renderable.hpp>
|
||||
#include <mbgl/gfx/renderer_backend.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/renderer/buckets/fill_bucket.hpp>
|
||||
#include <mbgl/renderer/image_manager.hpp>
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class FillBucket;
|
||||
class FillProgram;
|
||||
class FillPatternProgram;
|
||||
class FillOutlineProgram;
|
||||
class FillOutlinePatternProgram;
|
||||
|
||||
class FillLayerTweaker;
|
||||
using FillLayerTweakerPtr = std::shared_ptr<FillLayerTweaker>;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/gfx/offscreen_texture.hpp>
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/programs/heatmap_program.hpp>
|
||||
#include <mbgl/renderer/buckets/heatmap_bucket.hpp>
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_impl.hpp>
|
||||
#include <mbgl/style/layers/heatmap_layer_properties.hpp>
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
std::shared_ptr<PremultipliedImage> colorRamp;
|
||||
std::unique_ptr<gfx::OffscreenTexture> renderTexture;
|
||||
std::optional<gfx::Texture> colorRampTexture;
|
||||
SegmentVector<HeatmapTextureAttributes> segments;
|
||||
SegmentVector segments;
|
||||
|
||||
gfx::ShaderGroupPtr heatmapShaderGroup;
|
||||
gfx::ShaderProgramBasePtr heatmapTextureShader;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/programs/hillshade_program.hpp>
|
||||
#include <mbgl/programs/hillshade_prepare_program.hpp>
|
||||
#include <mbgl/renderer/buckets/hillshade_bucket.hpp>
|
||||
#include <mbgl/style/layers/hillshade_layer_impl.hpp>
|
||||
#include <mbgl/style/layers/hillshade_layer_properties.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/geometry/feature_index.hpp>
|
||||
#include <mbgl/geometry/line_atlas.hpp>
|
||||
#include <mbgl/gfx/cull_face_mode.hpp>
|
||||
#include <mbgl/programs/line_program.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/renderer/buckets/line_bucket.hpp>
|
||||
#include <mbgl/renderer/image_manager.hpp>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/renderer/render_static_data.hpp>
|
||||
#include <mbgl/renderer/sources/render_image_source.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
#include <mbgl/tile/tile.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
#include <mbgl/gfx/cull_face_mode.hpp>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/renderer/render_layer.hpp>
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
#include <mbgl/renderer/buckets/raster_bucket.hpp>
|
||||
#include <mbgl/style/layers/raster_layer_impl.hpp>
|
||||
#include <mbgl/style/layers/raster_layer_properties.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
@@ -9,7 +9,6 @@
|
||||
namespace mbgl {
|
||||
|
||||
class ImageSourceRenderData;
|
||||
class RasterProgram;
|
||||
|
||||
class RenderRasterLayer final : public RenderLayer {
|
||||
public:
|
||||
@@ -62,7 +61,7 @@ private:
|
||||
using TriangleIndexVectorPtr = std::shared_ptr<TriangleIndexVector>;
|
||||
TriangleIndexVectorPtr staticDataIndices;
|
||||
|
||||
using RasterSegmentVector = SegmentVector<RasterAttributes>;
|
||||
using RasterSegmentVector = SegmentVector;
|
||||
using RasterSegmentVectorPtr = std::shared_ptr<RasterSegmentVector>;
|
||||
std::shared_ptr<RasterSegmentVector> staticDataSegments;
|
||||
};
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
#include <mbgl/gfx/cull_face_mode.hpp>
|
||||
#include <mbgl/layout/symbol_layout.hpp>
|
||||
#include <mbgl/programs/collision_box_program.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
#include <mbgl/renderer/bucket_parameters.hpp>
|
||||
#include <mbgl/renderer/buckets/symbol_bucket.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
@@ -73,8 +71,8 @@ style::SymbolPropertyValues textPropertyValues(const style::SymbolPaintPropertie
|
||||
.hasFill = evaluated_.get<style::TextColor>().constantOr(Color::black()).a > 0};
|
||||
}
|
||||
|
||||
using SegmentWrapper = std::reference_wrapper<const Segment<SymbolTextAttributes>>;
|
||||
using SegmentVectorWrapper = std::reference_wrapper<const SegmentVector<SymbolTextAttributes>>;
|
||||
using SegmentWrapper = std::reference_wrapper<const SegmentBase>;
|
||||
using SegmentVectorWrapper = std::reference_wrapper<const SegmentVector>;
|
||||
using SegmentsWrapper = variant<SegmentWrapper, SegmentVectorWrapper>;
|
||||
|
||||
struct RenderableSegment {
|
||||
@@ -258,7 +256,7 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
|
||||
}
|
||||
|
||||
namespace {
|
||||
const SegmentVector<SymbolTextAttributes> emptySegmentVector;
|
||||
const SegmentVector emptySegmentVector;
|
||||
constexpr auto posOffsetAttribName = "a_pos_offset";
|
||||
|
||||
void updateTileAttributes(const SymbolBucket::Buffer& buffer,
|
||||
|
||||
@@ -56,27 +56,10 @@ enum class SymbolType : uint8_t {
|
||||
|
||||
} // namespace style
|
||||
|
||||
class SymbolIconProgram;
|
||||
class SymbolSDFIconProgram;
|
||||
class SymbolSDFTextProgram;
|
||||
class SymbolTextAndIconProgram;
|
||||
class CollisionBoxProgram;
|
||||
class CollisionCircleProgram;
|
||||
|
||||
class SymbolLayerTweaker;
|
||||
using SymbolLayerTweakerPtr = std::shared_ptr<SymbolLayerTweaker>;
|
||||
|
||||
class RenderSymbolLayer final : public RenderLayer {
|
||||
public:
|
||||
struct Programs {
|
||||
std::shared_ptr<SymbolIconProgram> symbolIconProgram;
|
||||
std::shared_ptr<SymbolSDFIconProgram> symbolSDFIconProgram;
|
||||
std::shared_ptr<SymbolSDFTextProgram> symbolSDFTextProgram;
|
||||
std::shared_ptr<SymbolTextAndIconProgram> symbolTextAndIconProgram;
|
||||
std::shared_ptr<CollisionBoxProgram> collisionBoxProgram;
|
||||
std::shared_ptr<CollisionCircleProgram> collisionCircleProgram;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit RenderSymbolLayer(Immutable<style::SymbolLayer::Impl>);
|
||||
~RenderSymbolLayer() override;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <mbgl/gfx/renderer_backend.hpp>
|
||||
#include <mbgl/gfx/symbol_drawable_data.hpp>
|
||||
#include <mbgl/layout/symbol_projection.hpp>
|
||||
#include <mbgl/programs/symbol_program.hpp>
|
||||
#include <mbgl/renderer/buckets/symbol_bucket.hpp>
|
||||
#include <mbgl/renderer/layer_group.hpp>
|
||||
#include <mbgl/renderer/paint_parameters.hpp>
|
||||
@@ -104,8 +103,8 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete
|
||||
const auto& symbolData = static_cast<gfx::SymbolDrawableData&>(*drawable.getData());
|
||||
const auto isText = (symbolData.symbolType == SymbolType::Text);
|
||||
|
||||
const auto* textBinders = isText ? static_cast<SymbolSDFTextProgram::Binders*>(drawable.getBinders()) : nullptr;
|
||||
const auto* iconBinders = isText ? nullptr : static_cast<SymbolIconProgram::Binders*>(drawable.getBinders());
|
||||
const auto* textBinders = isText ? static_cast<SymbolTextBinders*>(drawable.getBinders()) : nullptr;
|
||||
const auto* iconBinders = isText ? nullptr : static_cast<SymbolIconBinders*>(drawable.getBinders());
|
||||
|
||||
const auto bucket = std::static_pointer_cast<SymbolBucket>(drawable.getBucket());
|
||||
const auto* tile = drawable.getRenderTile();
|
||||
|
||||
@@ -33,19 +33,19 @@ gfx::IndexVector<gfx::LineStrip> RenderStaticData::tileLineStripIndices() {
|
||||
|
||||
gfx::VertexVector<RasterLayoutVertex> RenderStaticData::rasterVertices() {
|
||||
gfx::VertexVector<RasterLayoutVertex> result;
|
||||
result.emplace_back(RasterProgram::layoutVertex({0, 0}, {0, 0}));
|
||||
result.emplace_back(RasterProgram::layoutVertex({util::EXTENT, 0}, {util::EXTENT, 0}));
|
||||
result.emplace_back(RasterProgram::layoutVertex({0, util::EXTENT}, {0, util::EXTENT}));
|
||||
result.emplace_back(RasterProgram::layoutVertex({util::EXTENT, util::EXTENT}, {util::EXTENT, util::EXTENT}));
|
||||
result.emplace_back(RasterBucket::layoutVertex({0, 0}, {0, 0}));
|
||||
result.emplace_back(RasterBucket::layoutVertex({util::EXTENT, 0}, {util::EXTENT, 0}));
|
||||
result.emplace_back(RasterBucket::layoutVertex({0, util::EXTENT}, {0, util::EXTENT}));
|
||||
result.emplace_back(RasterBucket::layoutVertex({util::EXTENT, util::EXTENT}, {util::EXTENT, util::EXTENT}));
|
||||
return result;
|
||||
}
|
||||
|
||||
gfx::VertexVector<HeatmapTextureLayoutVertex> RenderStaticData::heatmapTextureVertices() {
|
||||
gfx::VertexVector<HeatmapTextureLayoutVertex> result;
|
||||
result.emplace_back(HeatmapTextureProgram::layoutVertex({0, 0}));
|
||||
result.emplace_back(HeatmapTextureProgram::layoutVertex({1, 0}));
|
||||
result.emplace_back(HeatmapTextureProgram::layoutVertex({0, 1}));
|
||||
result.emplace_back(HeatmapTextureProgram::layoutVertex({1, 1}));
|
||||
result.emplace_back(HeatmapBucket::textureVertex({0, 0}));
|
||||
result.emplace_back(HeatmapBucket::textureVertex({1, 0}));
|
||||
result.emplace_back(HeatmapBucket::textureVertex({0, 1}));
|
||||
result.emplace_back(HeatmapBucket::textureVertex({1, 1}));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -60,26 +60,26 @@ RenderStaticData::RenderStaticData(float pixelRatio, std::unique_ptr<gfx::Shader
|
||||
{
|
||||
}
|
||||
|
||||
SegmentVector<BackgroundAttributes> RenderStaticData::tileTriangleSegments() {
|
||||
SegmentVector<BackgroundAttributes> segments;
|
||||
SegmentVector RenderStaticData::tileTriangleSegments() {
|
||||
SegmentVector segments;
|
||||
segments.emplace_back(0, 0, 4, 6);
|
||||
return segments;
|
||||
}
|
||||
|
||||
SegmentVector<DebugAttributes> RenderStaticData::tileBorderSegments() {
|
||||
SegmentVector<DebugAttributes> segments;
|
||||
SegmentVector RenderStaticData::tileBorderSegments() {
|
||||
SegmentVector segments;
|
||||
segments.emplace_back(0, 0, 4, 5);
|
||||
return segments;
|
||||
}
|
||||
|
||||
SegmentVector<RasterAttributes> RenderStaticData::rasterSegments() {
|
||||
SegmentVector<RasterAttributes> segments;
|
||||
SegmentVector RenderStaticData::rasterSegments() {
|
||||
SegmentVector segments;
|
||||
segments.emplace_back(0, 0, 4, 6);
|
||||
return segments;
|
||||
}
|
||||
|
||||
SegmentVector<HeatmapTextureAttributes> RenderStaticData::heatmapTextureSegments() {
|
||||
SegmentVector<HeatmapTextureAttributes> segments;
|
||||
SegmentVector RenderStaticData::heatmapTextureSegments() {
|
||||
SegmentVector segments;
|
||||
segments.emplace_back(0, 0, 4, 6);
|
||||
return segments;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/gfx/renderbuffer.hpp>
|
||||
#include <mbgl/gfx/shader_registry.hpp>
|
||||
#include <mbgl/programs/background_program.hpp>
|
||||
#include <mbgl/programs/heatmap_texture_program.hpp>
|
||||
#include <mbgl/programs/programs.hpp>
|
||||
#include <mbgl/programs/raster_program.hpp>
|
||||
#include <mbgl/renderer/buckets/heatmap_bucket.hpp>
|
||||
#include <mbgl/renderer/buckets/raster_bucket.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
@@ -37,10 +36,10 @@ public:
|
||||
static gfx::VertexVector<RasterLayoutVertex> rasterVertices();
|
||||
static gfx::VertexVector<HeatmapTextureLayoutVertex> heatmapTextureVertices();
|
||||
|
||||
static SegmentVector<BackgroundAttributes> tileTriangleSegments();
|
||||
static SegmentVector<DebugAttributes> tileBorderSegments();
|
||||
static SegmentVector<RasterAttributes> rasterSegments();
|
||||
static SegmentVector<HeatmapTextureAttributes> heatmapTextureSegments();
|
||||
static SegmentVector tileTriangleSegments();
|
||||
static SegmentVector tileBorderSegments();
|
||||
static SegmentVector rasterSegments();
|
||||
static SegmentVector heatmapTextureSegments();
|
||||
|
||||
std::optional<gfx::Renderbuffer<gfx::RenderbufferPixelType::Depth>> depthRenderbuffer;
|
||||
bool has3D = false;
|
||||
@@ -52,7 +51,7 @@ public:
|
||||
|
||||
std::unique_ptr<gfx::ShaderRegistry> shaders;
|
||||
|
||||
const SegmentVector<BackgroundAttributes> clippingMaskSegments;
|
||||
const SegmentVector clippingMaskSegments;
|
||||
|
||||
#ifndef NDEBUG
|
||||
Programs overdrawPrograms;
|
||||
|
||||
@@ -137,91 +137,6 @@ void RenderTile::prepare(const SourcePrepareParameters& parameters) {
|
||||
matrix::multiply(nearClippedMatrix, transform.nearClippedProjMatrix, nearClippedMatrix);
|
||||
}
|
||||
|
||||
void RenderTile::finishRender(PaintParameters& parameters) const {
|
||||
if (!needsRendering || parameters.debugOptions == MapDebugOptions::NoDebug) return;
|
||||
|
||||
static const style::Properties<>::PossiblyEvaluated properties{};
|
||||
static const DebugProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto program = parameters.shaders.getLegacyGroup().get<DebugProgram>();
|
||||
if (!program) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameters.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) {
|
||||
assert(debugBucket);
|
||||
const auto allAttributeBindings = DebugProgram::computeAllAttributeBindings(
|
||||
*debugBucket->vertexBuffer, paintAttributeData, properties);
|
||||
|
||||
program->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::Lines{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::white()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text-outline");
|
||||
|
||||
program->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::Lines{2.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*debugBucket->indexBuffer,
|
||||
debugBucket->segments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::black()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
allAttributeBindings,
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"text");
|
||||
}
|
||||
|
||||
if (parameters.debugOptions & MapDebugOptions::TileBorders) {
|
||||
assert(debugBucket);
|
||||
if (debugBucket->tileBorderSegments.empty()) {
|
||||
debugBucket->tileBorderSegments = RenderStaticData::tileBorderSegments();
|
||||
}
|
||||
program->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::LineStrip{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*parameters.staticData.tileBorderIndexBuffer,
|
||||
debugBucket->tileBorderSegments,
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::red()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
DebugProgram::computeAllAttributeBindings(
|
||||
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties),
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}},
|
||||
"border");
|
||||
}
|
||||
}
|
||||
|
||||
void RenderTile::setFeatureState(const LayerFeatureStates& states) {
|
||||
tile.setFeatureState(states);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ public:
|
||||
|
||||
void upload(gfx::UploadPass&) const;
|
||||
void prepare(const SourcePrepareParameters&);
|
||||
void finishRender(PaintParameters&) const;
|
||||
|
||||
static mat4 translateVtxMatrix(const UnwrappedTileID& id,
|
||||
const mat4& tileMatrix,
|
||||
|
||||
@@ -26,43 +26,6 @@ void ImageSourceRenderData::upload(gfx::UploadPass& uploadPass) const {
|
||||
}
|
||||
}
|
||||
|
||||
void ImageSourceRenderData::render(PaintParameters& parameters) const {
|
||||
if (!bucket || !(parameters.debugOptions & MapDebugOptions::TileBorders)) {
|
||||
return;
|
||||
}
|
||||
assert(debugTexture);
|
||||
static const style::Properties<>::PossiblyEvaluated properties{};
|
||||
static const DebugProgram::Binders paintAttributeData(properties, 0);
|
||||
|
||||
auto programInstance = parameters.shaders.getLegacyGroup().get<DebugProgram>();
|
||||
if (!programInstance) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto matrix : matrices) {
|
||||
programInstance->draw(parameters.context,
|
||||
*parameters.renderPass,
|
||||
gfx::LineStrip{4.0f * parameters.pixelRatio},
|
||||
gfx::DepthMode::disabled(),
|
||||
gfx::StencilMode::disabled(),
|
||||
gfx::ColorMode::unblended(),
|
||||
gfx::CullFaceMode::disabled(),
|
||||
*parameters.staticData.tileBorderIndexBuffer,
|
||||
RenderStaticData::tileBorderSegments(),
|
||||
DebugProgram::computeAllUniformValues(
|
||||
DebugProgram::LayoutUniformValues{uniforms::matrix::Value(matrix),
|
||||
uniforms::color::Value(Color::red()),
|
||||
uniforms::overlay_scale::Value(1.0f)},
|
||||
paintAttributeData,
|
||||
properties,
|
||||
static_cast<float>(parameters.state.getZoom())),
|
||||
DebugProgram::computeAllAttributeBindings(
|
||||
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties),
|
||||
DebugProgram::TextureBindings{textures::image::Value{debugTexture->getResource()}},
|
||||
"image");
|
||||
}
|
||||
}
|
||||
|
||||
RenderImageSource::RenderImageSource(Immutable<style::ImageSource::Impl> impl_)
|
||||
: RenderSource(std::move(impl_)) {}
|
||||
|
||||
@@ -207,11 +170,11 @@ void RenderImageSource::update(Immutable<style::Source::Impl> baseImpl_,
|
||||
}
|
||||
|
||||
// Set Bucket Vertices, Indices, and segments
|
||||
bucket->vertices.emplace_back(RasterProgram::layoutVertex({geomCoords[0].x, geomCoords[0].y}, {0, 0}));
|
||||
bucket->vertices.emplace_back(RasterProgram::layoutVertex({geomCoords[1].x, geomCoords[1].y}, {util::EXTENT, 0}));
|
||||
bucket->vertices.emplace_back(RasterProgram::layoutVertex({geomCoords[3].x, geomCoords[3].y}, {0, util::EXTENT}));
|
||||
bucket->vertices.emplace_back(RasterBucket::layoutVertex({geomCoords[0].x, geomCoords[0].y}, {0, 0}));
|
||||
bucket->vertices.emplace_back(RasterBucket::layoutVertex({geomCoords[1].x, geomCoords[1].y}, {util::EXTENT, 0}));
|
||||
bucket->vertices.emplace_back(RasterBucket::layoutVertex({geomCoords[3].x, geomCoords[3].y}, {0, util::EXTENT}));
|
||||
bucket->vertices.emplace_back(
|
||||
RasterProgram::layoutVertex({geomCoords[2].x, geomCoords[2].y}, {util::EXTENT, util::EXTENT}));
|
||||
RasterBucket::layoutVertex({geomCoords[2].x, geomCoords[2].y}, {util::EXTENT, util::EXTENT}));
|
||||
|
||||
bucket->indices.emplace_back(0, 1, 2);
|
||||
bucket->indices.emplace_back(1, 2, 3);
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
private:
|
||||
void upload(gfx::UploadPass&) const override;
|
||||
void render(PaintParameters&) const override;
|
||||
void render(PaintParameters&) const override {}
|
||||
bool hasRenderPass(RenderPass) const override { return false; }
|
||||
const std::string& getName() const override { return name; }
|
||||
std::string name;
|
||||
|
||||
@@ -43,12 +43,6 @@ void TileSourceRenderItem::upload(gfx::UploadPass& parameters) const {
|
||||
}
|
||||
}
|
||||
|
||||
void TileSourceRenderItem::render(PaintParameters& parameters) const {
|
||||
for (auto& tile : *renderTiles) {
|
||||
tile.finishRender(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
#if MLN_ENABLE_POLYLINE_DRAWABLES
|
||||
class PolylineLayerImpl : public Layer::Impl {
|
||||
public:
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
private:
|
||||
void upload(gfx::UploadPass&) const override;
|
||||
void render(PaintParameters&) const override;
|
||||
void render(PaintParameters&) const override {}
|
||||
bool hasRenderPass(RenderPass) const override { return false; }
|
||||
const std::string& getName() const override { return name; }
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <mbgl/shaders/line_layer_ubo.hpp>
|
||||
#include <mbgl/util/convert.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
#include <mbgl/shaders/fill_layer_ubo.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
@@ -582,7 +581,7 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addFill(const GeometryC
|
||||
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
|
||||
TriangleIndexVector& triangles = *sharedTriangles;
|
||||
|
||||
SegmentVector<FillAttributes> triangleSegments;
|
||||
SegmentVector triangleSegments;
|
||||
|
||||
// generate fill geometry into buffers
|
||||
gfx::generateFillBuffers(geometry, vertices, triangles, triangleSegments);
|
||||
@@ -642,8 +641,8 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addSymbol(
|
||||
|
||||
triangles.emplace_back(0, 1, 2, 1, 2, 3);
|
||||
|
||||
SegmentVector<CustomSymbolIcon> triangleSegments;
|
||||
triangleSegments.emplace_back(Segment<CustomSymbolIcon>{0, 0, 4, 6});
|
||||
SegmentVector triangleSegments;
|
||||
triangleSegments.emplace_back(0, 0, 4, 6);
|
||||
|
||||
// add to builder
|
||||
auto attrs = context.createVertexAttributeArray();
|
||||
@@ -697,8 +696,8 @@ util::SimpleIdentity CustomDrawableLayerHost::Interface::addGeometry(
|
||||
// geographic coordinates require tile {0, 0, 0}
|
||||
setTileID({0, 0, 0});
|
||||
|
||||
SegmentVector<GeometryVertex> triangleSegments;
|
||||
triangleSegments.emplace_back(Segment<GeometryVertex>{0, 0, vertices->elements(), indices->elements()});
|
||||
SegmentVector triangleSegments;
|
||||
triangleSegments.emplace_back(0, 0, vertices->elements(), indices->elements());
|
||||
|
||||
// add to builder
|
||||
auto attrs = context.createVertexAttributeArray();
|
||||
|
||||
@@ -1011,8 +1011,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
}
|
||||
if (symbolInstance.hasText()) {
|
||||
size_t textOpacityVerticesSize = 0u;
|
||||
const auto& opacityVertex = SymbolSDFTextProgram::opacityVertex(opacityState.text.placed,
|
||||
opacityState.text.opacity);
|
||||
const auto& opacityVertex = SymbolBucket::opacityVertex(opacityState.text.placed,
|
||||
opacityState.text.opacity);
|
||||
if (symbolInstance.getPlacedRightTextIndex()) {
|
||||
textOpacityVerticesSize += symbolInstance.getRightJustifiedGlyphQuadsSize() * 4;
|
||||
PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.getPlacedRightTextIndex()];
|
||||
@@ -1052,8 +1052,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
}
|
||||
if (symbolInstance.hasIcon()) {
|
||||
size_t iconOpacityVerticesSize = 0u;
|
||||
const auto& opacityVertex = SymbolIconProgram::opacityVertex(opacityState.icon.placed,
|
||||
opacityState.icon.opacity);
|
||||
const auto& opacityVertex = SymbolBucket::opacityVertex(opacityState.icon.placed,
|
||||
opacityState.icon.opacity);
|
||||
auto& iconBuffer = symbolInstance.hasSdfIcon() ? bucket.sdfIcon : bucket.icon;
|
||||
|
||||
if (symbolInstance.getPlacedIconIndex()) {
|
||||
@@ -1073,7 +1073,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
if (feature.alongLine) {
|
||||
return;
|
||||
}
|
||||
const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false, shift);
|
||||
const auto& dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, false, shift);
|
||||
bucket.iconCollisionBox->dynamicVertices().extend(feature.boxes.size() * 4, dynamicVertex);
|
||||
};
|
||||
|
||||
@@ -1109,7 +1109,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
used = false;
|
||||
}
|
||||
}
|
||||
const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !used, shift);
|
||||
const auto& dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, !used, shift);
|
||||
bucket.textCollisionBox->dynamicVertices().extend(feature.boxes.size() * 4, dynamicVertex);
|
||||
return shift;
|
||||
};
|
||||
@@ -1121,14 +1121,14 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
auto circles = collisionCircles.find(&feature);
|
||||
if (circles != collisionCircles.end()) {
|
||||
for (const auto& circle : circles->second) {
|
||||
const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !circle.isCircle(), {});
|
||||
const auto& dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, !circle.isCircle(), {});
|
||||
isText ? bucket.textCollisionCircle->dynamicVertices().extend(4, dynamicVertex)
|
||||
: bucket.iconCollisionCircle->dynamicVertices().extend(4, dynamicVertex);
|
||||
}
|
||||
} else {
|
||||
// This feature was not placed, because it was not loaded or
|
||||
// from a fading tile. Apply default values.
|
||||
static const auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false /*not used*/, {});
|
||||
static const auto dynamicVertex = SymbolBucket::collisionDynamicVertex(placed, false /*not used*/, {});
|
||||
isText ? bucket.textCollisionCircle->dynamicVertices().extend(4 * feature.boxes.size(), dynamicVertex)
|
||||
: bucket.iconCollisionCircle->dynamicVertices().extend(4 * feature.boxes.size(), dynamicVertex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user