summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2019-03-07 14:29:19 +0200
committerSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2019-03-08 18:20:55 +0200
commit5e2b6bf636472a4464e6ab3ae0d9d01c68de041b (patch)
treed4a924f2ac4174a034448388fb65b033b801a83d /platform
parentc4115f0539be1834db40b318eb4ebb9e27d1eafb (diff)
downloadqtlocation-mapboxgl-5e2b6bf636472a4464e6ab3ae0d9d01c68de041b.tar.gz
[core] Add MapOptions to define properties of Map
To simplify the Map constructor, introduce MapOptions interface to define the properties that can be set on a Map.
Diffstat (limited to 'platform')
-rwxr-xr-xplatform/android/src/native_map_view.cpp11
-rw-r--r--platform/default/src/mbgl/map/map_snapshotter.cpp3
-rw-r--r--platform/glfw/main.cpp2
-rw-r--r--platform/ios/src/MGLMapView.mm11
-rw-r--r--platform/macos/src/MGLMapView.mm9
-rw-r--r--platform/node/src/node_map.cpp18
-rw-r--r--platform/qt/src/qmapboxgl.cpp9
7 files changed, 45 insertions, 18 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index d8eba09e9a..2f23f0b7d9 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -13,6 +13,7 @@
#include <jni/jni.hpp>
+#include <mbgl/map/map_options.hpp>
#include <mbgl/math/minmax.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/event.hpp>
@@ -79,12 +80,18 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
// Create a renderer frontend
rendererFrontend = std::make_unique<AndroidRendererFrontend>(mapRenderer);
+ // Create Map options
+ MapOptions options;
+ options.withMapMode(MapMode::Continuous)
+ .withConstrainMode(ConstrainMode::HeightOnly)
+ .withViewportMode(ViewportMode::Default)
+ .withCrossSourceCollisions(_crossSourceCollisions);
+
// Create the core map
map = std::make_unique<mbgl::Map>(*rendererFrontend, *this,
mbgl::Size{ static_cast<uint32_t>(width),
static_cast<uint32_t>(height) }, pixelRatio,
- fileSource, *threadPool, MapMode::Continuous,
- ConstrainMode::HeightOnly, ViewportMode::Default, _crossSourceCollisions);
+ fileSource, *threadPool, options);
}
/**
diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp
index 926c51b60f..56bc9bdb88 100644
--- a/platform/default/src/mbgl/map/map_snapshotter.cpp
+++ b/platform/default/src/mbgl/map/map_snapshotter.cpp
@@ -3,6 +3,7 @@
#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/map/map.hpp>
+#include <mbgl/map/map_options.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/style/style.hpp>
@@ -57,7 +58,7 @@ MapSnapshotter::Impl::Impl(FileSource* fileSource,
const optional<std::string> localFontFamily)
: scheduler(std::move(scheduler_))
, frontend(size, pixelRatio, *fileSource, *scheduler, programCacheDir, GLContextMode::Unique, localFontFamily)
- , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, *scheduler, MapMode::Static) {
+ , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, *scheduler, MapOptions().withMapMode(MapMode::Static)) {
if (style.first) {
map.getStyle().loadJSON(style.second);
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index c52ea92512..8e6905f948 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
mbgl::ThreadPool threadPool(4);
GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), fileSource, threadPool), backend };
- mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool);
+ mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool, mbgl::MapOptions());
backend.setMap(&map);
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 0c6632f229..59bb1c6666 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -4,6 +4,7 @@
#import <OpenGLES/EAGL.h>
#include <mbgl/map/map.hpp>
+#include <mbgl/map/map_options.hpp>
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/map/camera.hpp>
#include <mbgl/map/mode.hpp>
@@ -472,9 +473,15 @@ public:
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView);
-
+
+ mbgl::MapOptions mapOptions;
+ mapOptions.withMapMode(mbgl::MapMode::Continuous)
+ .withConstrainMode(mbgl::ConstrainMode::None)
+ .withViewportMode(mbgl::ViewportMode::Default)
+ .withCrossSourceCollisions(enableCrossSourceCollisions);
+
NSAssert(!_mbglMap, @"_mbglMap should be NULL");
- _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, enableCrossSourceCollisions);
+ _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mapOptions);
// start paused if in IB
if (_isTargetingInterfaceBuilder || background) {
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 8ebf6356cb..045a0c9f98 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -26,6 +26,7 @@
#import "MGLImageSource.h"
#import <mbgl/map/map.hpp>
+#import <mbgl/map/map_options.hpp>
#import <mbgl/style/style.hpp>
#import <mbgl/annotation/annotation.hpp>
#import <mbgl/map/camera.hpp>
@@ -288,7 +289,13 @@ public:
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(std::move(renderer), self, *_mbglView, true);
- _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, enableCrossSourceCollisions);
+
+ mbgl::MapOptions mapOptions;
+ mapOptions.withMapMode(mbgl::MapMode::Continuous)
+ .withConstrainMode(mbgl::ConstrainMode::None)
+ .withViewportMode(mbgl::ViewportMode::Default)
+ .withCrossSourceCollisions(enableCrossSourceCollisions);
+ _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mapOptions);
// 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.
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index 533399a47c..b12d3552a4 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -616,11 +616,13 @@ void NodeMap::cancel() {
});
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool);
+ mbgl::MapOptions options;
+ options.withMapMode(mode)
+ .withConstrainMode(mbgl::ConstrainMode::HeightOnly)
+ .withViewportMode(mbgl::ViewportMode::Default)
+ .withCrossSourceCollisions(crossSourceCollisions);
map = std::make_unique<mbgl::Map>(*frontend, mapObserver, frontend->getSize(), pixelRatio,
- *this, threadpool, mode,
- mbgl::ConstrainMode::HeightOnly,
- mbgl::ViewportMode::Default,
- crossSourceCollisions);
+ *this, threadpool, options);
// FIXME: Reload the style after recreating the map. We need to find
// a better way of canceling an ongoing rendering on the core level
@@ -1205,10 +1207,10 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
pixelRatio,
*this,
threadpool,
- mode,
- mbgl::ConstrainMode::HeightOnly,
- mbgl::ViewportMode::Default,
- crossSourceCollisions)),
+ mbgl::MapOptions().withMapMode(mode)
+ .withConstrainMode(mbgl::ConstrainMode::HeightOnly)
+ .withViewportMode(mbgl::ViewportMode::Default)
+ .withCrossSourceCollisions(crossSourceCollisions))),
async(new uv_async_t) {
async->data = this;
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index fd4a210229..49b0dc021c 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -1767,15 +1767,18 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
connect(m_mapObserver.get(), SIGNAL(mapLoadingFailed(QMapboxGL::MapLoadingFailure,QString)), q, SIGNAL(mapLoadingFailed(QMapboxGL::MapLoadingFailure,QString)));
connect(m_mapObserver.get(), SIGNAL(copyrightsChanged(QString)), q, SIGNAL(copyrightsChanged(QString)));
+ mbgl::MapOptions options;
+ options.withMapMode(static_cast<mbgl::MapMode>(settings.mapMode()))
+ .withConstrainMode(static_cast<mbgl::ConstrainMode>(settings.constrainMode()))
+ .withViewportMode(static_cast<mbgl::ViewportMode>(settings.viewportMode()));
+
// Setup the Map object
mapObj = std::make_unique<mbgl::Map>(
*this, // RendererFrontend
*m_mapObserver,
sanitizedSize(size),
m_pixelRatio, *m_fileSourceObj, *m_threadPool,
- static_cast<mbgl::MapMode>(settings.mapMode()),
- static_cast<mbgl::ConstrainMode>(settings.constrainMode()),
- static_cast<mbgl::ViewportMode>(settings.viewportMode()));
+ options);
// Needs to be Queued to give time to discard redundant draw calls via the `renderQueued` flag.
connect(this, SIGNAL(needsRendering()), q, SIGNAL(needsRendering()), Qt::QueuedConnection);