MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
renderer.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 #include <mbgl/util/geo.hpp>
6 #include <mbgl/util/geojson.hpp>
7 
8 #include <functional>
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 namespace mbgl {
14 
15 class RendererObserver;
16 class RenderedQueryOptions;
17 class SourceQueryOptions;
18 class UpdateParameters;
19 
20 namespace gfx {
21 class RendererBackend;
22 } // namespace gfx
23 
26  std::u16string key;
28  std::optional<mapbox::geometry::box<float>> textCollisionBox;
30  std::optional<mapbox::geometry::box<float>> iconCollisionBox;
32  bool textPlaced;
34  bool iconPlaced;
41 };
42 
43 class Renderer {
44 public:
45  Renderer(gfx::RendererBackend&, float pixelRatio_, const std::optional<std::string>& localFontFamily = std::nullopt);
47 
49 
51 
52  void render(const std::shared_ptr<UpdateParameters>&);
53 
55  std::vector<Feature> queryRenderedFeatures(const ScreenLineString&, const RenderedQueryOptions& options = {}) const;
56  std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate& point, const RenderedQueryOptions& options = {}) const;
57  std::vector<Feature> queryRenderedFeatures(const ScreenBox& box, const RenderedQueryOptions& options = {}) const;
58  std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions& options = {}) const;
61  AnnotationIDs getAnnotationIDs(const std::vector<Feature>&) const;
62 
65  const Feature& feature,
66  const std::string& extension,
67  const std::string& extensionField,
68  const std::optional<std::map<std::string, Value>>& args = std::nullopt) const;
69 
70  void setFeatureState(const std::string& sourceID, const std::optional<std::string>& sourceLayerID,
71  const std::string& featureID, const FeatureState& state);
72 
74  const std::string& sourceID,
75  const std::optional<std::string>& sourceLayerID,
76  const std::string& featureID) const;
77 
78  void removeFeatureState(const std::string& sourceID,
79  const std::optional<std::string>& sourceLayerID,
80  const std::optional<std::string>& featureID,
81  const std::optional<std::string>& stateKey);
82 
83  // Debug
84  void dumpDebugLogs();
85 
92  void collectPlacedSymbolData(bool enable);
93 
102  const std::vector<PlacedSymbolData>& getPlacedSymbolsData() const;
103 
104  // Memory
106  void clearData();
107 
108 private:
109  class Impl;
110  std::unique_ptr<Impl> impl;
111 };
112 
113 } // namespace mbgl
void removeFeatureState(const std::string &sourceID, const std::optional< std::string > &sourceLayerID, const std::optional< std::string > &featureID, const std::optional< std::string > &stateKey)
AnnotationIDs queryShapeAnnotations(const ScreenBox &box) const
std::vector< Feature > querySourceFeatures(const std::string &sourceID, const SourceQueryOptions &options={}) const
std::vector< Feature > queryRenderedFeatures(const ScreenLineString &, const RenderedQueryOptions &options={}) const
Feature queries.
void render(const std::shared_ptr< UpdateParameters > &)
void markContextLost()
void getFeatureState(FeatureState &state, const std::string &sourceID, const std::optional< std::string > &sourceLayerID, const std::string &featureID) const
void setObserver(RendererObserver *)
void setFeatureState(const std::string &sourceID, const std::optional< std::string > &sourceLayerID, const std::string &featureID, const FeatureState &state)
void collectPlacedSymbolData(bool enable)
In Tile map mode, enables or disables collecting of the placed symbols data, which can be obtained wi...
void dumpDebugLogs()
Renderer(gfx::RendererBackend &, float pixelRatio_, const std::optional< std::string > &localFontFamily=std::nullopt)
FeatureExtensionValue queryFeatureExtensions(const std::string &sourceID, const Feature &feature, const std::string &extension, const std::string &extensionField, const std::optional< std::map< std::string, Value >> &args=std::nullopt) const
Feature extension query.
std::vector< Feature > queryRenderedFeatures(const ScreenCoordinate &point, const RenderedQueryOptions &options={}) const
std::vector< Feature > queryRenderedFeatures(const ScreenBox &box, const RenderedQueryOptions &options={}) const
void reduceMemoryUse()
AnnotationIDs getAnnotationIDs(const std::vector< Feature > &) const
AnnotationIDs queryPointAnnotations(const ScreenBox &box) const
const std::vector< PlacedSymbolData > & getPlacedSymbolsData() const
If collecting of the placed symbols data is enabled, returns the reference to the PlacedSymbolData ve...
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
Definition: actor.hpp:15
mapbox::geometry::box< double > ScreenBox
Definition: geo.hpp:22
mapbox::geometry::point< double > ScreenCoordinate
Definition: geo.hpp:20
std::vector< AnnotationID > AnnotationIDs
Definition: annotation.hpp:15
mapbox::util::variant< Value, FeatureCollection > FeatureExtensionValue
Definition: geojson.hpp:10
mapbox::geometry::line_string< double > ScreenLineString
Definition: geo.hpp:21
mapbox::base::ValueObject FeatureState
Definition: feature.hpp:16
std::optional< mapbox::geometry::box< float > > textCollisionBox
If symbol contains text, text collision box in viewport coordinates.
Definition: renderer.hpp:28
bool textPlaced
Symbol text was placed.
Definition: renderer.hpp:32
float viewportPadding
Viewport padding ({viewportPadding, viewportPadding} is a coordinate of the tile's top-left corner)
Definition: renderer.hpp:38
bool iconPlaced
Symbol icon was placed.
Definition: renderer.hpp:34
std::string layer
Layer id (leader of the symbol layout group)
Definition: renderer.hpp:40
bool intersectsTileBorder
Symbol text or icon collision box intersects tile borders.
Definition: renderer.hpp:36
std::u16string key
Contents of the label.
Definition: renderer.hpp:26
std::optional< mapbox::geometry::box< float > > iconCollisionBox
If symbol contains icon, icon collision box in viewport coordinates.
Definition: renderer.hpp:30