diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-26 00:00:37 +0200 |
---|---|---|
committer | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-28 16:41:15 +0200 |
commit | 1cc1d4ea08ae02c3cc9b4dd1474845456c17d1bc (patch) | |
tree | d7de92e01ef1b1bf654ff8784534e534608a352f /platform | |
parent | 11afef7825d622a237fa026e45e6d61b4de94068 (diff) | |
download | qtlocation-mapboxgl-1cc1d4ea08ae02c3cc9b4dd1474845456c17d1bc.tar.gz |
[core] Add setter/getter for size property in MapOptions
Diffstat (limited to 'platform')
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 5 | ||||
-rw-r--r-- | platform/default/src/mbgl/map/map_snapshotter.cpp | 4 | ||||
-rw-r--r-- | platform/glfw/main.cpp | 2 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 3 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 3 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 12 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 9 |
7 files changed, 23 insertions, 15 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 1eb4c56728..d30a216353 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -81,14 +81,15 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, // Create Map options MapOptions options; options.withMapMode(MapMode::Continuous) + .withSize(mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) }) .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, *threadPool, options, mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource)); + *rendererFrontend, *this, pixelRatio, *threadPool, options, + mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource)); } /** diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp index ca5eadafbc..d5a71a5508 100644 --- a/platform/default/src/mbgl/map/map_snapshotter.cpp +++ b/platform/default/src/mbgl/map/map_snapshotter.cpp @@ -58,7 +58,7 @@ MapSnapshotter::Impl::Impl(std::shared_ptr<Scheduler> scheduler_, const ResourceOptions& resourceOptions) : scheduler(std::move(scheduler_)) , frontend(size, pixelRatio, *scheduler, programCacheDir, GLContextMode::Unique, localFontFamily) - , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *scheduler, MapOptions().withMapMode(MapMode::Static), resourceOptions) { + , map(frontend, MapObserver::nullObserver(), pixelRatio, *scheduler, MapOptions().withMapMode(MapMode::Static).withSize(size), resourceOptions) { if (style.first) { map.getStyle().loadJSON(style.second); } else{ @@ -141,7 +141,7 @@ void MapSnapshotter::Impl::setSize(Size size) { } Size MapSnapshotter::Impl::getSize() const { - return map.getSize(); + return map.getMapOptions().size(); } void MapSnapshotter::Impl::setCameraOptions(CameraOptions cameraOptions) { diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index c27e5fe8ce..9f87e579a7 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) { mbgl::ThreadPool threadPool(4); GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), threadPool), backend }; - mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), threadPool, mbgl::MapOptions(), resourceOptions); + mbgl::Map map(rendererFrontend, backend, view->getPixelRatio(), threadPool, mbgl::MapOptions().withSize(view->getSize()), resourceOptions); backend.setMap(&map); diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f885f67a10..036cfd5756 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -479,6 +479,7 @@ public: mbgl::MapOptions mapOptions; mapOptions.withMapMode(mbgl::MapMode::Continuous) + .withSize(self.size) .withConstrainMode(mbgl::ConstrainMode::None) .withViewportMode(mbgl::ViewportMode::Default) .withCrossSourceCollisions(enableCrossSourceCollisions); @@ -488,7 +489,7 @@ public: .withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String); NSAssert(!_mbglMap, @"_mbglMap should be NULL"); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions); // start paused if in IB if (_isTargetingInterfaceBuilder || background) { diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index c5d3279c81..fdcc2090b1 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -292,6 +292,7 @@ public: mbgl::MapOptions mapOptions; mapOptions.withMapMode(mbgl::MapMode::Continuous) + .withSize(self.size) .withConstrainMode(mbgl::ConstrainMode::None) .withViewportMode(mbgl::ViewportMode::Default) .withCrossSourceCollisions(enableCrossSourceCollisions); @@ -300,7 +301,7 @@ public: resourceOptions.withCachePath([[MGLOfflineStorage sharedOfflineStorage] mbglCachePath]) .withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions); // 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 7ad9c362bf..bcd5fb1c16 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -631,8 +631,10 @@ void NodeMap::cancel() { }); frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, threadpool); - map = std::make_unique<mbgl::Map>(*frontend, mapObserver, frontend->getSize(), pixelRatio, threadpool, - mbgl::MapOptions().withMapMode(mode).withCrossSourceCollisions(crossSourceCollisions), + map = std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool, + mbgl::MapOptions().withSize(frontend->getSize()) + .withMapMode(mode) + .withCrossSourceCollisions(crossSourceCollisions), mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this))); // FIXME: Reload the style after recreating the map. We need to find @@ -1212,8 +1214,10 @@ NodeMap::NodeMap(v8::Local<v8::Object> options) }()) , mapObserver(NodeMapObserver()) , frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size { 256, 256 }, pixelRatio, threadpool)) - , map(std::make_unique<mbgl::Map>(*frontend, mapObserver, frontend->getSize(), pixelRatio, threadpool, - mbgl::MapOptions().withMapMode(mode).withCrossSourceCollisions(crossSourceCollisions), + , map(std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool, + mbgl::MapOptions().withSize(frontend->getSize()) + .withMapMode(mode) + .withCrossSourceCollisions(crossSourceCollisions), mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)))) , async(new uv_async_t) { async->data = this; diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 313860890c..ff6a4498dc 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1127,7 +1127,7 @@ void QMapboxGL::resize(const QSize& size_) { auto size = sanitizedSize(size_); - if (d_ptr->mapObj->getSize() == size) + if (d_ptr->mapObj->getMapOptions().size() == size) return; d_ptr->mapObj->setSize(size); @@ -1705,8 +1705,9 @@ void QMapboxGL::connectionEstablished() \a copyrightsHtml is a string with a HTML snippet. */ -mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings) { +mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings, const QSize &size) { return std::move(mbgl::MapOptions() + .withSize(sanitizedSize(size)) .withMapMode(static_cast<mbgl::MapMode>(settings.mapMode())) .withConstrainMode(static_cast<mbgl::ConstrainMode>(settings.constrainMode())) .withViewportMode(static_cast<mbgl::ViewportMode>(settings.viewportMode()))); @@ -1740,8 +1741,8 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin auto resourceOptions = resourceOptionsFromQMapboxGLSettings(settings); // Setup the Map object. - mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, sanitizedSize(size), m_pixelRatio, *m_threadPool, - mapOptionsFromQMapboxGLSettings(settings), resourceOptions); + mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, m_pixelRatio, *m_threadPool, + mapOptionsFromQMapboxGLSettings(settings, size), resourceOptions); if (settings.resourceTransform()) { m_resourceTransform = std::make_unique<mbgl::Actor<mbgl::ResourceTransform>>(*mbgl::Scheduler::GetCurrent(), |