summaryrefslogtreecommitdiff
path: root/src/mbgl/layout/symbol_projection.hpp
blob: 8535014f223c73c02c99fc390a20e0018ef09a6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

#include <mbgl/util/mat4.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/programs/symbol_program.hpp>

namespace mbgl {

    class TransformState;
    class RenderTile;
    class SymbolSizeBinder;
    class PlacedSymbol;
    namespace style {
        class SymbolPropertyValues;
    } // end namespace style
    
    struct TileDistance {
        TileDistance(float prevTileDistance_, float lastSegmentViewportDistance_)
            : prevTileDistance(prevTileDistance_), lastSegmentViewportDistance(lastSegmentViewportDistance_)
        {}
        float prevTileDistance;
        float lastSegmentViewportDistance;
    };
    
    struct PlacedGlyph {
        PlacedGlyph(Point<float> point_, float angle_, optional<TileDistance> tileDistance_)
            : point(point_), angle(angle_), tileDistance(std::move(tileDistance_))
        {}
        Point<float> point;
        float angle;
        optional<TileDistance> tileDistance;
    };

    float evaluateSizeForFeature(const ZoomEvaluatedSize& zoomEvaluatedSize, const PlacedSymbol& placedSymbol);
    mat4 getLabelPlaneMatrix(const mat4& posMatrix, const bool pitchWithMap, const bool rotateWithMap, const TransformState& state, const float pixelsToTileUnits);
    mat4 getGlCoordMatrix(const mat4& posMatrix, const bool pitchWithMap, const bool rotateWithMap, const TransformState& state, const float pixelsToTileUnits);
    
    using PointAndCameraDistance = std::pair<Point<float>,float>;
    PointAndCameraDistance project(const Point<float>& point, const mat4& matrix);

    void reprojectLineLabels(gl::VertexVector<SymbolDynamicLayoutAttributes::Vertex>&, const std::vector<PlacedSymbol>&,
            const mat4& posMatrix, const style::SymbolPropertyValues&,
            const RenderTile&, const SymbolSizeBinder& sizeBinder, const TransformState&);
    
    optional<std::pair<PlacedGlyph, PlacedGlyph>> placeFirstAndLastGlyph(const float fontScale,
                                                            const float lineOffsetX,
                                                            const float lineOffsetY,
                                                            const bool flip,
                                                            const Point<float>& anchorPoint,
                                                            const Point<float>& tileAnchorPoint,
                                                            const PlacedSymbol& symbol,
                                                            const mat4& labelPlaneMatrix,
                                                            const bool returnTileDistance);

} // end namespace mbgl