fixes #838 instead of rendering ad libitum on the map thread, we are now driving rendering from the UI thread on iOS via the map.renderSync() function. There are still white bars during the rotation, but the general content of the view is kept visible. - upgrades GLFW to 3.1 - removes swapped/needsSwap in favor of a more explicit scheme - View#invalidate() now replaces View#swap() and is called whenever the View needs to trigger a rerender. GLFW and Android to this right away, while iOS goes back to the main thread and does the Map redrawing as part of the GLKView update - sets all iOS deployment targets to 7.0 - disables SQLite3 version check, since the library version changed on iOS 8.2
87 lines
1.9 KiB
C++
87 lines
1.9 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/default/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 notifyMapChange(mbgl::MapChange change, std::chrono::steady_clock::duration delay = std::chrono::steady_clock::duration::zero()) override;
|
|
|
|
mbgl::Map &getMap();
|
|
mbgl::DefaultFileSource &getFileSource();
|
|
|
|
void initializeDisplay();
|
|
void terminateDisplay();
|
|
|
|
void initializeContext();
|
|
void terminateContext();
|
|
|
|
void createSurface(ANativeWindow *window);
|
|
void destroySurface();
|
|
|
|
void start();
|
|
void stop();
|
|
|
|
void resume();
|
|
void pause(bool waitForPause = false);
|
|
|
|
void enableFps(bool enable);
|
|
void updateFps();
|
|
|
|
void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight);
|
|
|
|
private:
|
|
EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs);
|
|
|
|
bool inEmulator();
|
|
|
|
private:
|
|
JavaVM *vm = nullptr;
|
|
jobject obj = nullptr;
|
|
|
|
ANativeWindow *window = nullptr;
|
|
|
|
mbgl::SQLiteCache fileCache;
|
|
mbgl::DefaultFileSource fileSource;
|
|
mbgl::Map map;
|
|
|
|
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;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|