We're now using nudgeTransitions() to tell the Map view that we want to update it. However, if we're on a gesture movement, the update() call can get called too fast and causing general slowdown. This check ensures we only call for nudgeTransitions() after all gesture events are finished. Fixes the issue pointed out by #1548 on Android.
99 lines
2.2 KiB
C++
99 lines
2.2 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, float pixelRatio);
|
|
virtual ~NativeMapView();
|
|
|
|
float getPixelRatio() const override;
|
|
std::array<uint16_t, 2> getSize() const override;
|
|
std::array<uint16_t, 2> getFramebufferSize() const override;
|
|
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(bool inProgress);
|
|
|
|
void resizeView(int width, int height);
|
|
void resizeFramebuffer(int width, int height);
|
|
|
|
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;
|
|
|
|
int width = 0;
|
|
int height = 0;
|
|
int fbWidth = 0;
|
|
int fbHeight = 0;
|
|
const float pixelRatio;
|
|
|
|
// Ensure these are initialised last
|
|
mbgl::SQLiteCache fileCache;
|
|
mbgl::DefaultFileSource fileSource;
|
|
mbgl::Map map;
|
|
|
|
std::atomic_flag clean = ATOMIC_FLAG_INIT;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|