1 #pragma once
2 
3 #include <mbgl/util/mat4.hpp>
4 #include <mbgl/gl/vertex_buffer.hpp>
5 #include <mbgl/programs/symbol_program.hpp>
6 
7 namespace mbgl {
8 
9     class TransformState;
10     class RenderTile;
11     class SymbolSizeBinder;
12     class PlacedSymbol;
13     namespace style {
14         class SymbolPropertyValues;
15     } // end namespace style
16 
17     struct TileDistance {
TileDistancembgl::TileDistance18         TileDistance(float prevTileDistance_, float lastSegmentViewportDistance_)
19             : prevTileDistance(prevTileDistance_), lastSegmentViewportDistance(lastSegmentViewportDistance_)
20         {}
21         float prevTileDistance;
22         float lastSegmentViewportDistance;
23     };
24 
25     struct PlacedGlyph {
26         PlacedGlyph() = default;
27 
PlacedGlyphmbgl::PlacedGlyph28         PlacedGlyph(Point<float> point_, float angle_, optional<TileDistance> tileDistance_)
29             : point(point_), angle(angle_), tileDistance(std::move(tileDistance_))
30         {}
PlacedGlyphmbgl::PlacedGlyph31         PlacedGlyph(PlacedGlyph&& other) noexcept
32             : point(std::move(other.point)), angle(other.angle), tileDistance(std::move(other.tileDistance))
33         {}
PlacedGlyphmbgl::PlacedGlyph34         PlacedGlyph(const PlacedGlyph& other)
35             : point(std::move(other.point)), angle(other.angle), tileDistance(std::move(other.tileDistance))
36         {}
37         Point<float> point;
38         float angle;
39         optional<TileDistance> tileDistance;
40     };
41 
42     float evaluateSizeForFeature(const ZoomEvaluatedSize& zoomEvaluatedSize, const PlacedSymbol& placedSymbol);
43     mat4 getLabelPlaneMatrix(const mat4& posMatrix, const bool pitchWithMap, const bool rotateWithMap, const TransformState& state, const float pixelsToTileUnits);
44     mat4 getGlCoordMatrix(const mat4& posMatrix, const bool pitchWithMap, const bool rotateWithMap, const TransformState& state, const float pixelsToTileUnits);
45 
46     using PointAndCameraDistance = std::pair<Point<float>,float>;
47     PointAndCameraDistance project(const Point<float>& point, const mat4& matrix);
48 
49     void reprojectLineLabels(gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>&, const std::vector<PlacedSymbol>&,
50             const mat4& posMatrix, const style::SymbolPropertyValues&,
51             const RenderTile&, const SymbolSizeBinder& sizeBinder, const TransformState&);
52 
53     optional<std::pair<PlacedGlyph, PlacedGlyph>> placeFirstAndLastGlyph(const float fontScale,
54                                                             const float lineOffsetX,
55                                                             const float lineOffsetY,
56                                                             const bool flip,
57                                                             const Point<float>& anchorPoint,
58                                                             const Point<float>& tileAnchorPoint,
59                                                             const PlacedSymbol& symbol,
60                                                             const mat4& labelPlaneMatrix,
61                                                             const bool returnTileDistance);
62 
63 } // end namespace mbgl
64