summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-06-13 10:50:16 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-07-18 10:45:12 +0200
commit39a732d7ae3cb1b927d94c4b1154b42d9565356a (patch)
tree5f33317467cb3dbdf19be3a8264818ff34f859eb
parent57351c068b133ed140ac7b991181672019fe5c24 (diff)
downloadqtlocation-mapboxgl-39a732d7ae3cb1b927d94c4b1154b42d9565356a.tar.gz
[android][glfw][ios][macos][node][qt] split backend from mapobserver
-rwxr-xr-xplatform/android/src/native_map_view.cpp2
-rwxr-xr-xplatform/android/src/native_map_view.hpp2
-rw-r--r--platform/glfw/glfw_view.hpp2
-rw-r--r--platform/glfw/main.cpp4
-rw-r--r--platform/ios/src/MGLMapView.mm4
-rw-r--r--platform/macos/src/MGLMapView.mm4
-rw-r--r--platform/node/src/node_map.cpp6
-rw-r--r--platform/node/src/node_map.hpp6
-rw-r--r--platform/qt/src/qmapboxgl.cpp2
-rw-r--r--platform/qt/src/qmapboxgl_p.hpp2
10 files changed, 20 insertions, 14 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 79e7c3c82f..986cc73f0b 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -69,7 +69,7 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
// Create the core map
map = std::make_unique<mbgl::Map>(
- *this, mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) },
+ *this, *this, mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) },
pixelRatio, mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource), *threadPool,
MapMode::Continuous, GLContextMode::Unique, ConstrainMode::HeightOnly,
ViewportMode::Default, jni::Make<std::string>(_env, _programCacheDir));
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 393a2c913f..ed752f94ab 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -36,7 +36,7 @@
namespace mbgl {
namespace android {
-class NativeMapView : public View, public Backend {
+class NativeMapView : public View, public Backend, public MapObserver {
public:
static constexpr auto Name() { return "com/mapbox/mapboxsdk/maps/NativeMapView"; };
diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp
index 366fe4fd68..3b0c31009c 100644
--- a/platform/glfw/glfw_view.hpp
+++ b/platform/glfw/glfw_view.hpp
@@ -9,7 +9,7 @@
struct GLFWwindow;
-class GLFWView : public mbgl::View, public mbgl::Backend {
+class GLFWView : public mbgl::View, public mbgl::Backend, public mbgl::MapObserver {
public:
GLFWView(bool fullscreen = false, bool benchmark = false);
~GLFWView() override;
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index 7192475835..0cd9543f9c 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
mbgl::ThreadPool threadPool(4);
- mbgl::Map map(backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool);
+ mbgl::Map map(backend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool);
backend.setMap(&map);
@@ -200,4 +200,4 @@ int main(int argc, char *argv[]) {
view = nullptr;
return 0;
-} \ No newline at end of file
+}
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 1444fc3cb0..9789e4ac64 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -444,7 +444,7 @@ public:
mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource;
const float scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [[UIScreen mainScreen] nativeScale] : [[UIScreen mainScreen] scale];
_mbglThreadPool = mbgl::sharedThreadPool();
- _mbglMap = new mbgl::Map(*_mbglView, self.size, scaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
+ _mbglMap = new mbgl::Map(*_mbglView, *_mbglView, self.size, scaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
// start paused if in IB
if (_isTargetingInterfaceBuilder || background) {
@@ -5408,7 +5408,7 @@ public:
return _annotationViewReuseQueueByIdentifier[identifier];
}
-class MBGLView : public mbgl::View, public mbgl::Backend
+class MBGLView : public mbgl::View, public mbgl::Backend, public mbgl::MapObserver
{
public:
MBGLView(MGLMapView* nativeView_) : nativeView(nativeView_) {
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 70198c6432..7efe8a463d 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -270,7 +270,7 @@ public:
mbgl::DefaultFileSource* mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource;
_mbglThreadPool = mbgl::sharedThreadPool();
- _mbglMap = new mbgl::Map(*_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
+ _mbglMap = new mbgl::Map(*_mbglView, *_mbglView, self.size, [NSScreen mainScreen].backingScaleFactor, *mbglFileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default);
// Install the OpenGL layer. Interface Builder’s synchronous drawing means
// we can’t display a map, so don’t even bother to have a map layer.
@@ -2756,7 +2756,7 @@ public:
}
/// Adapter responsible for bridging calls from mbgl to MGLMapView and Cocoa.
-class MGLMapViewImpl : public mbgl::View, public mbgl::Backend {
+class MGLMapViewImpl : public mbgl::View, public mbgl::Backend, public mbgl::MapObserver {
public:
MGLMapViewImpl(MGLMapView *nativeView_)
: nativeView(nativeView_) {}
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index 9ba88193c9..78e98e2a28 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -45,7 +45,7 @@ static const char* releasedMessage() {
NodeBackend::NodeBackend()
: HeadlessBackend(sharedDisplay()) {}
-void NodeBackend::onDidFailLoadingMap(std::exception_ptr error) {
+void NodeMapObserver::onDidFailLoadingMap(std::exception_ptr error) {
std::rethrow_exception(error);
}
@@ -530,7 +530,7 @@ void NodeMap::Cancel(const Nan::FunctionCallbackInfo<v8::Value>& info) {
void NodeMap::cancel() {
auto style = map->getStyle().getJSON();
- map = std::make_unique<mbgl::Map>(backend, mbgl::Size{ 256, 256 },
+ map = std::make_unique<mbgl::Map>(backend, mapObserver, mbgl::Size{ 256, 256 },
pixelRatio, *this, threadpool, mbgl::MapMode::Still);
// FIXME: Reload the style after recreating the map. We need to find
@@ -982,7 +982,9 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
->NumberValue()
: 1.0;
}()),
+ mapObserver(NodeMapObserver()),
map(std::make_unique<mbgl::Map>(backend,
+ mapObserver,
mbgl::Size{ 256, 256 },
pixelRatio,
*this,
diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp
index 7b81ecd894..b8645e8d11 100644
--- a/platform/node/src/node_map.hpp
+++ b/platform/node/src/node_map.hpp
@@ -20,7 +20,10 @@ namespace node_mbgl {
class NodeBackend : public mbgl::HeadlessBackend {
public:
NodeBackend();
- void onDidFailLoadingMap(std::exception_ptr) final;
+};
+
+class NodeMapObserver : public mbgl::MapObserver {
+ void onDidFailLoadingMap(std::exception_ptr) override;
};
class NodeMap : public Nan::ObjectWrap,
@@ -71,6 +74,7 @@ public:
NodeBackend backend;
std::unique_ptr<mbgl::OffscreenView> view;
NodeThreadPool threadpool;
+ NodeMapObserver mapObserver;
std::unique_ptr<mbgl::Map> map;
std::exception_ptr error;
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 46385bc3e3..ee08ba5730 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -1498,7 +1498,7 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
, threadPool(mbgl::sharedThreadPool())
{
mapObj = std::make_unique<mbgl::Map>(
- *this, sanitizedSize(size),
+ *this, *this, sanitizedSize(size),
pixelRatio, *fileSourceObj, *threadPool,
mbgl::MapMode::Continuous,
static_cast<mbgl::GLContextMode>(settings.contextMode()),
diff --git a/platform/qt/src/qmapboxgl_p.hpp b/platform/qt/src/qmapboxgl_p.hpp
index 3c8a6cf09e..d89234531b 100644
--- a/platform/qt/src/qmapboxgl_p.hpp
+++ b/platform/qt/src/qmapboxgl_p.hpp
@@ -12,7 +12,7 @@
#include <QObject>
#include <QSize>
-class QMapboxGLPrivate : public QObject, public mbgl::View, public mbgl::Backend
+class QMapboxGLPrivate : public QObject, public mbgl::View, public mbgl::Backend, public mbgl::MapObserver
{
Q_OBJECT