blob: af8f76bd74184aeec2206a24f55ffbd6a1a9a1fa (
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
|
#ifndef MBGL_ANDROID_NATIVE_MAP_VIEW
#define MBGL_ANDROID_NATIVE_MAP_VIEW
#include <mbgl/map/map.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/storage/sqlite_cache.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <string>
#include <jni.h>
#include <android/native_window.h>
#include <EGL/egl.h>
namespace mbgl {
namespace android {
class NativeMapView : public mbgl::View, private mbgl::util::noncopyable {
public:
NativeMapView(JNIEnv *env, jobject obj);
virtual ~NativeMapView();
void activate() override;
void deactivate() override;
void notify() override;
void invalidate() override;
void swap() override;
void notifyMapChange(mbgl::MapChange) override;
mbgl::Map &getMap();
mbgl::DefaultFileSource &getFileSource();
void initializeDisplay();
void terminateDisplay();
void initializeContext();
void terminateContext();
void createSurface(ANativeWindow *window);
void destroySurface();
void resume();
void pause();
void enableFps(bool enable);
void updateFps();
void onInvalidate();
private:
EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs);
bool inEmulator();
private:
JavaVM *vm = nullptr;
jobject obj = nullptr;
ANativeWindow *window = nullptr;
EGLDisplay display = EGL_NO_DISPLAY;
EGLSurface surface = EGL_NO_SURFACE;
EGLContext context = EGL_NO_CONTEXT;
EGLConfig config = nullptr;
EGLint format = -1;
std::string styleUrl;
std::string apiKey;
bool firstTime = false;
bool fpsEnabled = false;
double fps = 0.0;
// Ensure these are initialised last
mbgl::SQLiteCache fileCache;
mbgl::DefaultFileSource fileSource;
mbgl::Map map;
std::atomic_flag clean = ATOMIC_FLAG_INIT;
};
}
}
#endif
|