Files
MapLibreParticleLab/include/mbgl/android/native_map_view.hpp
Leith Bade 703e0bc2ee Ignore deactivate when no valid EGL display. Fixes #1435
Initialise NativeMapView's EGL variables before Map

Fix hang

Add check for double pause

Add test for double pause
2015-05-09 12:02:39 +10:00

83 lines
1.8 KiB
C++

#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(std::function<void()> render) override;
void notifyMapChange(mbgl::MapChange change, Duration delay = Duration::zero()) 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();
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;
};
}
}
#endif