summaryrefslogtreecommitdiff
path: root/src/mbgl/map
diff options
context:
space:
mode:
authorSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2019-03-27 19:17:04 +0200
committerSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2019-03-28 16:41:15 +0200
commit7af00a404f22742fed4a83e9a36d023d7515025f (patch)
treeac050d12346d81030969f88607dbfd59ca33be11 /src/mbgl/map
parentf5064e710884d5b822e59d05e51c127c8b3e852b (diff)
downloadqtlocation-mapboxgl-7af00a404f22742fed4a83e9a36d023d7515025f.tar.gz
[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
Diffstat (limited to 'src/mbgl/map')
-rw-r--r--src/mbgl/map/map.cpp9
-rw-r--r--src/mbgl/map/map_impl.cpp3
-rw-r--r--src/mbgl/map/map_impl.hpp2
-rw-r--r--src/mbgl/map/map_options.cpp12
4 files changed, 18 insertions, 8 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index cfec9952b5..b22a9ee2f2 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -29,12 +29,12 @@ using namespace style;
Map::Map(RendererFrontend& frontend,
MapObserver& observer,
- const float pixelRatio,
Scheduler& scheduler,
const MapOptions& mapOptions,
const ResourceOptions& resourceOptions)
- : impl(std::make_unique<Impl>(frontend, observer, scheduler, pixelRatio,
- FileSource::getSharedFileSource(resourceOptions), mapOptions)) {}
+ : impl(std::make_unique<Impl>(frontend, observer, scheduler,
+ FileSource::getSharedFileSource(resourceOptions),
+ mapOptions)) {}
Map::Map(std::unique_ptr<Impl> impl_) : impl(std::move(impl_)) {}
@@ -336,7 +336,8 @@ MapOptions Map::getMapOptions() const {
.withViewportMode(impl->transform.getViewportMode())
.withCrossSourceCollisions(impl->crossSourceCollisions)
.withNorthOrientation(impl->transform.getNorthOrientation())
- .withSize(impl->transform.getState().getSize()));
+ .withSize(impl->transform.getState().getSize())
+ .withPixelRatio(impl->pixelRatio));
}
#pragma mark - Projection mode
diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp
index afaa05229c..42561cf8bf 100644
--- a/src/mbgl/map/map_impl.cpp
+++ b/src/mbgl/map/map_impl.cpp
@@ -10,7 +10,6 @@ namespace mbgl {
Map::Impl::Impl(RendererFrontend& frontend_,
MapObserver& observer_,
Scheduler& scheduler_,
- float pixelRatio_,
std::shared_ptr<FileSource> fileSource_,
const MapOptions& mapOptions)
: observer(observer_),
@@ -18,7 +17,7 @@ Map::Impl::Impl(RendererFrontend& frontend_,
scheduler(scheduler_),
transform(observer, mapOptions.constrainMode(), mapOptions.viewportMode()),
mode(mapOptions.mapMode()),
- pixelRatio(pixelRatio_),
+ pixelRatio(mapOptions.pixelRatio()),
crossSourceCollisions(mapOptions.crossSourceCollisions()),
fileSource(std::move(fileSource_)),
style(std::make_unique<style::Style>(scheduler, *fileSource, pixelRatio)),
diff --git a/src/mbgl/map/map_impl.hpp b/src/mbgl/map/map_impl.hpp
index 90b0a721ca..7086148276 100644
--- a/src/mbgl/map/map_impl.hpp
+++ b/src/mbgl/map/map_impl.hpp
@@ -30,7 +30,7 @@ struct StillImageRequest {
class Map::Impl : public style::Observer, public RendererObserver {
public:
- Impl(RendererFrontend&, MapObserver&, Scheduler&, float pixelRatio, std::shared_ptr<FileSource>, const MapOptions&);
+ Impl(RendererFrontend&, MapObserver&, Scheduler&, std::shared_ptr<FileSource>, const MapOptions&);
~Impl() final;
// StyleObserver
diff --git a/src/mbgl/map/map_options.cpp b/src/mbgl/map/map_options.cpp
index 98cabb2550..4cebb6adab 100644
--- a/src/mbgl/map/map_options.cpp
+++ b/src/mbgl/map/map_options.cpp
@@ -9,7 +9,8 @@ public:
ViewportMode viewportMode = ViewportMode::Default;
NorthOrientation orientation = NorthOrientation::Upwards;
bool crossSourceCollisions = true;
- Size size;
+ Size size = { 64, 64 };
+ float pixelRatio = 1.0;
};
// These requires the complete type of Impl.
@@ -71,4 +72,13 @@ Size MapOptions::size() const {
return impl_->size;
}
+MapOptions& MapOptions::withPixelRatio(float ratio) {
+ impl_->pixelRatio = ratio;
+ return *this;
+}
+
+float MapOptions::pixelRatio() const {
+ return impl_->pixelRatio;
+}
+
} // namespace mbgl