blob: 75aba6985bd94ea32ee0252ccadf6cc811ff40c4 (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#ifndef MAP_VIEW_HPP
#define MAP_VIEW_HPP
#include <string>
#include <jni.h>
#include <android/native_window.h>
#include <EGL/egl.h>
#include <mbgl/mbgl.hpp>
namespace mbgl {
namespace android {
extern std::string cache_path;
extern std::string data_path;
extern jmethodID on_map_changed_id;
extern jclass lon_lat_class;
extern jmethodID lon_lat_constructor_id;
extern jfieldID lon_lat_lon_id;
extern jfieldID lon_lat_lat_id;
extern jclass lon_lat_zoom_class;
extern jmethodID lon_lat_zoom_constructor_id;
extern jfieldID lon_lat_zoom_lon_id;
extern jfieldID lon_lat_zoom_lat_id;
extern jfieldID lon_lat_zoom_zoom_id;
extern jclass runtime_exception_class;
extern jmethodID list_to_array_id;
extern jclass array_list_class;
extern jmethodID array_list_constructor_id;
extern jmethodID array_list_add_id;
class MBGLView;
class NativeMapView {
friend class MBGLView;
public:
NativeMapView(JNIEnv* env, jobject obj);
~NativeMapView();
mbgl::Map* getMap() const {
return map;
}
bool initializeDisplay();
void terminateDisplay();
bool initializeContext();
void terminateContext();
bool createSurface(ANativeWindow* window);
void destroySurface();
void start();
void stop();
void resume();
void pause(bool wait_for_pause = false);
void notifyMapChange();
private:
EGLConfig chooseConfig(const EGLConfig configs[], EGLint num_configs,
bool use565) const;
void loadExtensions();
private:
JavaVM* vm = nullptr;
jobject obj = nullptr;
ANativeWindow* window = nullptr;
mbgl::Map* map = nullptr;
MBGLView* view = nullptr;
EGLDisplay display = EGL_NO_DISPLAY;
EGLSurface surface = EGL_NO_SURFACE;
EGLContext context = EGL_NO_CONTEXT;
EGLConfig config = nullptr;
EGLint format = -1;
std::string style_url;
std::string api_key;
bool first_time = false;
};
class MBGLView: public mbgl::View {
public:
MBGLView(NativeMapView* nativeView_) :
nativeView(nativeView_) {
}
virtual ~MBGLView() {
}
void make_active() override;
void make_inactive() override;
void swap() override;
void notify() override;
void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay = 0) override;
private:
NativeMapView* nativeView = nullptr;
};
} // namespace android
} // namespace mbgl
#endif // MAP_VIEW_HPP
|