diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-27 19:17:04 +0200 |
---|---|---|
committer | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-28 16:41:15 +0200 |
commit | 7af00a404f22742fed4a83e9a36d023d7515025f (patch) | |
tree | ac050d12346d81030969f88607dbfd59ca33be11 /platform | |
parent | f5064e710884d5b822e59d05e51c127c8b3e852b (diff) | |
download | qtlocation-mapboxgl-7af00a404f22742fed4a83e9a36d023d7515025f.tar.gz |
[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
Diffstat (limited to 'platform')
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 3 | ||||
-rw-r--r-- | platform/default/src/mbgl/map/map_snapshotter.cpp | 4 | ||||
-rw-r--r-- | platform/glfw/main.cpp | 6 | ||||
-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 | 6 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 8 |
7 files changed, 23 insertions, 10 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index d30a216353..e74e4c3bbc 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -82,13 +82,14 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, MapOptions options; options.withMapMode(MapMode::Continuous) .withSize(mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) }) + .withPixelRatio(pixelRatio) .withConstrainMode(ConstrainMode::HeightOnly) .withViewportMode(ViewportMode::Default) .withCrossSourceCollisions(_crossSourceCollisions); // Create the core map map = std::make_unique<mbgl::Map>( - *rendererFrontend, *this, pixelRatio, *threadPool, options, + *rendererFrontend, *this, *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 d5a71a5508..227a61d272 100644 --- a/platform/default/src/mbgl/map/map_snapshotter.cpp +++ b/platform/default/src/mbgl/map/map_snapshotter.cpp @@ -58,7 +58,9 @@ 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(), pixelRatio, *scheduler, MapOptions().withMapMode(MapMode::Static).withSize(size), resourceOptions) { + , map(frontend, MapObserver::nullObserver(), *scheduler, + MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio), + resourceOptions) { if (style.first) { map.getStyle().loadJSON(style.second); } else{ diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 9f87e579a7..cb3f9b8578 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -110,7 +110,11 @@ 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->getPixelRatio(), threadPool, mbgl::MapOptions().withSize(view->getSize()), resourceOptions); + + mbgl::Map map1(rendererFrontend, backend, threadPool,mbgl::MapOptions(), resourceOptions); + + mbgl::Map map(rendererFrontend, backend, threadPool, + mbgl::MapOptions().withSize(view->getSize()).withPixelRatio(view->getPixelRatio()), resourceOptions); backend.setMap(&map); diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 036cfd5756..c94cf477ef 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -480,6 +480,7 @@ public: mbgl::MapOptions mapOptions; mapOptions.withMapMode(mbgl::MapMode::Continuous) .withSize(self.size) + .withPixelRatio(config.scaleFactor) .withConstrainMode(mbgl::ConstrainMode::None) .withViewportMode(mbgl::ViewportMode::Default) .withCrossSourceCollisions(enableCrossSourceCollisions); @@ -489,7 +490,7 @@ public: .withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String); NSAssert(!_mbglMap, @"_mbglMap should be NULL"); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, *_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 fdcc2090b1..091ba462cc 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -293,6 +293,7 @@ public: mbgl::MapOptions mapOptions; mapOptions.withMapMode(mbgl::MapMode::Continuous) .withSize(self.size) + .withPixelRatio(config.scaleFactor) .withConstrainMode(mbgl::ConstrainMode::None) .withViewportMode(mbgl::ViewportMode::Default) .withCrossSourceCollisions(enableCrossSourceCollisions); @@ -301,7 +302,7 @@ public: resourceOptions.withCachePath([[MGLOfflineStorage sharedOfflineStorage] mbglCachePath]) .withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, *_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 bcd5fb1c16..291dea6bb7 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -631,8 +631,9 @@ void NodeMap::cancel() { }); frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, threadpool); - map = std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool, + map = std::make_unique<mbgl::Map>(*frontend, mapObserver, threadpool, mbgl::MapOptions().withSize(frontend->getSize()) + .withPixelRatio(pixelRatio) .withMapMode(mode) .withCrossSourceCollisions(crossSourceCollisions), mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this))); @@ -1214,8 +1215,9 @@ 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, pixelRatio, threadpool, + , map(std::make_unique<mbgl::Map>(*frontend, mapObserver, threadpool, mbgl::MapOptions().withSize(frontend->getSize()) + .withPixelRatio(pixelRatio) .withMapMode(mode) .withCrossSourceCollisions(crossSourceCollisions), mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)))) diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index ff6a4498dc..4f79525257 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1705,9 +1705,10 @@ void QMapboxGL::connectionEstablished() \a copyrightsHtml is a string with a HTML snippet. */ -mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings, const QSize &size) { +mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings, const QSize &size, qreal pixelRatio) { return std::move(mbgl::MapOptions() .withSize(sanitizedSize(size)) + .withPixelRatio(pixelRatio) .withMapMode(static_cast<mbgl::MapMode>(settings.mapMode())) .withConstrainMode(static_cast<mbgl::ConstrainMode>(settings.constrainMode())) .withViewportMode(static_cast<mbgl::ViewportMode>(settings.viewportMode()))); @@ -1741,8 +1742,9 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin auto resourceOptions = resourceOptionsFromQMapboxGLSettings(settings); // Setup the Map object. - mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, m_pixelRatio, *m_threadPool, - mapOptionsFromQMapboxGLSettings(settings, size), resourceOptions); + mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, *m_threadPool, + mapOptionsFromQMapboxGLSettings(settings, size, m_pixelRatio), + resourceOptions); if (settings.resourceTransform()) { m_resourceTransform = std::make_unique<mbgl::Actor<mbgl::ResourceTransform>>(*mbgl::Scheduler::GetCurrent(), |