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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#pragma once
#include <mbgl/map/mode.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/tile/tile_observer.hpp>
#include <mbgl/util/mat4.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/geojson.hpp>
#include <mbgl/util/feature.hpp>
#include <mbgl/style/source_impl.hpp>
#include <mbgl/style/layer_properties.hpp>
#include <unordered_map>
#include <vector>
#include <map>
#include <memory>
namespace mbgl {
class PaintParameters;
class TransformState;
class RenderTile;
class RenderLayer;
class RenderedQueryOptions;
class SourceQueryOptions;
class Tile;
class RenderSourceObserver;
class TileParameters;
class CollisionIndex;
class TransformParameters;
class ImageManager;
class ImageSourceRenderData;
class RenderItem;
namespace gfx {
class UploadPass;
} // namespace gfx
class SourcePrepareParameters {
public:
const TransformParameters& transform;
const MapDebugOptions& debugOptions;
const ImageManager& imageManager;
};
using RenderTiles = std::vector<std::reference_wrapper<const RenderTile>>;
class RenderSource : protected TileObserver {
public:
static std::unique_ptr<RenderSource> create(Immutable<style::Source::Impl>);
virtual ~RenderSource();
bool isEnabled() const;
virtual bool isLoaded() const = 0;
virtual void update(Immutable<style::Source::Impl>,
const std::vector<Immutable<style::LayerProperties>>&,
bool needsRendering,
bool needsRelayout,
const TileParameters&) = 0;
// Note: calling of this method might reset the contained render data.
virtual std::unique_ptr<RenderItem> createRenderItem() = 0;
// Creates the render data to be passed to the render item.
virtual void prepare(const SourcePrepareParameters&) = 0;
virtual void updateFadingTiles() = 0;
virtual bool hasFadingTiles() const = 0;
// Returns a list of RenderTiles, sorted by tile id.
virtual RenderTiles getRenderTiles() = 0;
virtual const ImageSourceRenderData* getImageRenderData() const { return nullptr; }
virtual const Tile* getRenderedTile(const UnwrappedTileID&) const { return nullptr; }
virtual std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
const std::vector<const RenderLayer*>& layers,
const RenderedQueryOptions& options,
const mat4& projMatrix) const = 0;
virtual std::vector<Feature>
querySourceFeatures(const SourceQueryOptions&) const = 0;
virtual FeatureExtensionValue
queryFeatureExtensions(const Feature&,
const std::string&,
const std::string&,
const optional<std::map<std::string, Value>>&) const {
return {};
}
virtual void reduceMemoryUse() = 0;
virtual void dumpDebugLogs() const = 0;
virtual uint8_t getMaxZoom() const;
void setObserver(RenderSourceObserver*);
Immutable<style::Source::Impl> baseImpl;
protected:
RenderSource(Immutable<style::Source::Impl>);
RenderSourceObserver* observer;
bool enabled = false;
void onTileChanged(Tile&) override;
void onTileError(Tile&, std::exception_ptr) final;
};
} // namespace mbgl
|