Merge classes
This commit is contained in:
@@ -47,49 +47,7 @@ void log_gl_string(GLenum name, const char* label) {
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::make_active() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "MBGLView::make_active");
|
||||
if ((nativeView.display != EGL_NO_DISPLAY) && (nativeView.surface != EGL_NO_SURFACE) && (nativeView.context != EGL_NO_CONTEXT)) {
|
||||
if (!eglMakeCurrent(nativeView.display, nativeView.surface, nativeView.surface, nativeView.context)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent() returned error %d", eglGetError());
|
||||
}
|
||||
} else {
|
||||
mbgl::Log::Info(mbgl::Event::Android, "Not activating as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::make_inactive() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "MBGLView::make_inactive");
|
||||
if (!eglMakeCurrent(nativeView.display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::swap() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "MBGLView::swap");
|
||||
|
||||
if (map->needsSwap() && (nativeView.display != EGL_NO_DISPLAY) && (nativeView.surface != EGL_NO_SURFACE)) {
|
||||
if (!eglSwapBuffers(nativeView.display, nativeView.surface)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglSwapBuffers() returned error %d", eglGetError());
|
||||
}
|
||||
map->swapped();
|
||||
nativeView.updateFps();
|
||||
} else {
|
||||
mbgl::Log::Info(mbgl::Event::Android, "Not swapping as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void MBGLView::notify() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "MBGLView::notify()");
|
||||
// noop
|
||||
}
|
||||
|
||||
void MBGLView::notify_map_change(mbgl::MapChange /* change */, mbgl::timestamp /* delay */) {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "MBGLView::notify_map_change()");
|
||||
nativeView.notifyMapChange();
|
||||
}
|
||||
|
||||
NativeMapView::NativeMapView(JNIEnv* env, jobject obj_) : view(*this), fileSource(mbgl::platform::defaultCacheDatabase()), map(view, fileSource) {
|
||||
NativeMapView::NativeMapView(JNIEnv* env, jobject obj_) : mbgl::View(*this), fileSource(mbgl::platform::defaultCacheDatabase()), map(*this, fileSource) {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::NativeMapView");
|
||||
|
||||
assert(env != nullptr);
|
||||
@@ -128,6 +86,51 @@ NativeMapView::~NativeMapView() {
|
||||
vm = nullptr;
|
||||
}
|
||||
|
||||
void NativeMapView::make_active() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::make_active");
|
||||
if ((display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE) && (context != EGL_NO_CONTEXT)) {
|
||||
if (!eglMakeCurrent(display, surface, surface, context)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent() returned error %d", eglGetError());
|
||||
}
|
||||
} else {
|
||||
mbgl::Log::Info(mbgl::Event::Android, "Not activating as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::make_inactive() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::make_inactive");
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::swap() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::swap");
|
||||
|
||||
if (map.needsSwap() && (display != EGL_NO_DISPLAY) && (surface != EGL_NO_SURFACE)) {
|
||||
if (!eglSwapBuffers(display, surface)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglSwapBuffers() returned error %d", eglGetError());
|
||||
}
|
||||
map.swapped();
|
||||
updateFps();
|
||||
} else {
|
||||
mbgl::Log::Info(mbgl::Event::Android, "Not swapping as we are not ready");
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::notify() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::notify()");
|
||||
// noop
|
||||
}
|
||||
|
||||
mbgl::Map& NativeMapView::getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
mbgl::CachingHTTPFileSource& NativeMapView::getFileSource() {
|
||||
return fileSource;
|
||||
}
|
||||
|
||||
bool NativeMapView::initializeDisplay() {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::initializeDisplay");
|
||||
|
||||
@@ -622,7 +625,7 @@ void NativeMapView::resume() {
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::notifyMapChange() {
|
||||
void NativeMapView::notify_map_change(mbgl::MapChange, mbgl::timestamp) {
|
||||
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::notify_map_change()");
|
||||
|
||||
assert(vm != nullptr);
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
|
||||
class NativeMapView;
|
||||
|
||||
class MBGLView: public mbgl::View, private mbgl::util::noncopyable {
|
||||
class NativeMapView : public mbgl::View, private mbgl::util::noncopyable {
|
||||
public:
|
||||
explicit MBGLView(NativeMapView& nativeView_) : nativeView(nativeView_) {
|
||||
}
|
||||
NativeMapView(JNIEnv* env, jobject obj);
|
||||
virtual ~NativeMapView();
|
||||
|
||||
void make_active() override;
|
||||
void make_inactive() override;
|
||||
@@ -27,26 +25,10 @@ public:
|
||||
void swap() override;
|
||||
|
||||
void notify() override;
|
||||
void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay = 0) override;
|
||||
void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay) override;
|
||||
|
||||
private:
|
||||
NativeMapView& nativeView;
|
||||
};
|
||||
|
||||
class NativeMapView : private mbgl::util::noncopyable {
|
||||
friend class MBGLView;
|
||||
|
||||
public:
|
||||
NativeMapView(JNIEnv* env, jobject obj);
|
||||
~NativeMapView();
|
||||
|
||||
mbgl::Map& getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
mbgl::CachingHTTPFileSource& getFileSource() {
|
||||
return fileSource;
|
||||
}
|
||||
mbgl::Map& getMap();
|
||||
mbgl::CachingHTTPFileSource& getFileSource();
|
||||
|
||||
bool initializeDisplay();
|
||||
void terminateDisplay();
|
||||
@@ -63,8 +45,6 @@ public:
|
||||
void resume();
|
||||
void pause(bool waitForPause = false);
|
||||
|
||||
void notifyMapChange();
|
||||
|
||||
void enableFps(bool enable);
|
||||
void updateFps();
|
||||
|
||||
@@ -79,7 +59,6 @@ private:
|
||||
|
||||
ANativeWindow* window = nullptr;
|
||||
|
||||
MBGLView view; // Must be before map
|
||||
mbgl::CachingHTTPFileSource fileSource;
|
||||
mbgl::Map map;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user