blob: 9c90e63c83255c32ac36262279bd0d2c14620bc3 (
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
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
|
#pragma once
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/renderer/renderer_backend.hpp>
#include <mbgl/renderer/renderer_frontend.hpp>
#include <mbgl/util/async_task.hpp>
#include <mbgl/util/geo.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/run_loop.hpp>
#include <functional>
#include <memory>
#include <vector>
#include <string>
namespace mbgl {
class Renderer;
class FileSource;
class Scheduler;
class RenderedQueryOptions;
class SourceQueryOptions;
namespace util {
template <class> class Thread;
} // namespace util
namespace android {
class AndroidRendererBackend;
class AndroidRendererFrontend : public RendererFrontend {
public:
using InvalidateCallback = std::function<void ()>;
AndroidRendererFrontend(float pixelRatio,
mbgl::FileSource&,
mbgl::Scheduler&,
std::string programCacheDir,
InvalidateCallback);
~AndroidRendererFrontend() override;
void initialise();
void reset() override;
void setObserver(RendererObserver&) override;
void update(std::shared_ptr<UpdateParameters>) override;
// Called from OpenGL Thread
void render();
// Feature querying
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate&, const RenderedQueryOptions&) const;
std::vector<Feature> queryRenderedFeatures(const ScreenBox&, const RenderedQueryOptions&) const;
std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions&) const;
AnnotationIDs queryPointAnnotations(const ScreenBox& box) const;
// RenderBackend proxy - Called from OpenGL Thread
void resizeFramebuffer(int width, int height);
// Memory
void onLowMemory();
// Snapshot - Callback will be called on calling thread through RunLoop
using SnapshotCallback = std::function<void (PremultipliedImage)>;
void requestSnapshot(SnapshotCallback);
private:
float pixelRatio;
FileSource& fileSource;
Scheduler& scheduler;
std::string programCacheDir;
std::unique_ptr<AndroidRendererBackend> backend;
std::unique_ptr<util::Thread<Renderer>> renderer;
std::unique_ptr<RendererObserver> rendererObserver;
std::mutex updateMutex;
std::shared_ptr<UpdateParameters> updateParameters;
std::mutex intitialisationMutex;
util::AsyncTask asyncInvalidate;
util::RunLoop* mapRunLoop;
bool framebufferSizeChanged = true;
std::unique_ptr<SnapshotCallback> snapshotCallback;
};
} // namespace android
} // namespace mbgl
|