summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-19 16:52:14 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-20 21:30:08 +0200
commitd1762d7111b39d45430bd7bb75ea60b7a5d85bd2 (patch)
treef91be956d8e038261f12db4d692491d63a50e3f7
parent8ac73254c19b36fff35c50991bf79f5c98fc4421 (diff)
downloadqtlocation-mapboxgl-d1762d7111b39d45430bd7bb75ea60b7a5d85bd2.tar.gz
[core] Cleanup Map::Impl ctor
-rw-r--r--src/mbgl/map/map.cpp22
-rw-r--r--src/mbgl/map/map_impl.cpp42
-rw-r--r--src/mbgl/map/map_impl.hpp20
3 files changed, 30 insertions, 54 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index f545fc8095..e8237cca74 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -27,24 +27,14 @@ namespace mbgl {
using namespace style;
-Map::Map(RendererFrontend& rendererFrontend,
- MapObserver& mapObserver,
+Map::Map(RendererFrontend& frontend,
+ MapObserver& observer,
const Size size,
const float pixelRatio,
FileSource& fileSource,
Scheduler& scheduler,
- const MapOptions& options)
- : impl(std::make_unique<Impl>(*this,
- rendererFrontend,
- mapObserver,
- fileSource,
- scheduler,
- size,
- pixelRatio,
- options.mapMode(),
- options.constrainMode(),
- options.viewportMode(),
- options.crossSourceCollisions())) {}
+ const MapOptions& mapOptions)
+ : impl(std::make_unique<Impl>(frontend, observer, fileSource, scheduler, size, pixelRatio, mapOptions)) {}
Map::~Map() = default;
@@ -139,9 +129,7 @@ CameraOptions Map::getCameraOptions(const EdgeInsets& padding) const {
}
void Map::jumpTo(const CameraOptions& camera) {
- impl->cameraMutated = true;
- impl->transform.jumpTo(camera);
- impl->onUpdate();
+ impl->jumpTo(camera);
}
void Map::easeTo(const CameraOptions& camera, const AnimationOptions& animation) {
diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp
index 84cf324722..fbceff559f 100644
--- a/src/mbgl/map/map_impl.cpp
+++ b/src/mbgl/map/map_impl.cpp
@@ -6,31 +6,23 @@
namespace mbgl {
-Map::Impl::Impl(Map& map_,
- RendererFrontend& frontend,
- MapObserver& mapObserver,
+Map::Impl::Impl(RendererFrontend& frontend_,
+ MapObserver& observer_,
FileSource& fileSource_,
Scheduler& scheduler_,
Size size_,
float pixelRatio_,
- MapMode mode_,
- ConstrainMode constrainMode_,
- ViewportMode viewportMode_,
- bool crossSourceCollisions_)
- : map(map_),
- observer(mapObserver),
- rendererFrontend(frontend),
- fileSource(fileSource_),
- scheduler(scheduler_),
- transform(observer,
- constrainMode_,
- viewportMode_),
- mode(mode_),
- pixelRatio(pixelRatio_),
- crossSourceCollisions(crossSourceCollisions_),
- style(std::make_unique<style::Style>(scheduler, fileSource, pixelRatio)),
- annotationManager(*style) {
-
+ const MapOptions& mapOptions)
+ : observer(observer_),
+ rendererFrontend(frontend_),
+ fileSource(fileSource_),
+ scheduler(scheduler_),
+ transform(observer, mapOptions.constrainMode(), mapOptions.viewportMode()),
+ mode(mapOptions.mapMode()),
+ pixelRatio(pixelRatio_),
+ crossSourceCollisions(mapOptions.crossSourceCollisions()),
+ style(std::make_unique<style::Style>(scheduler, fileSource, pixelRatio)),
+ annotationManager(*style) {
style->impl->setObserver(this);
rendererFrontend.setObserver(*this);
transform.resize(size_);
@@ -90,7 +82,7 @@ void Map::Impl::onStyleLoading() {
void Map::Impl::onStyleLoaded() {
if (!cameraMutated) {
- map.jumpTo(style->getDefaultCamera());
+ jumpTo(style->getDefaultCamera());
}
if (LayerManager::annotationsEnabled) {
annotationManager.onStyleLoaded();
@@ -173,4 +165,10 @@ void Map::Impl::onDidFinishRenderingMap() {
}
};
+void Map::Impl::jumpTo(const CameraOptions& camera) {
+ cameraMutated = true;
+ transform.jumpTo(camera);
+ onUpdate();
+}
+
} // namespace mbgl
diff --git a/src/mbgl/map/map_impl.hpp b/src/mbgl/map/map_impl.hpp
index 32dc728b70..d65fe5aafc 100644
--- a/src/mbgl/map/map_impl.hpp
+++ b/src/mbgl/map/map_impl.hpp
@@ -4,6 +4,7 @@
#include <mbgl/annotation/annotation_manager.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_observer.hpp>
+#include <mbgl/map/map_options.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/renderer/renderer_frontend.hpp>
@@ -26,20 +27,7 @@ struct StillImageRequest {
class Map::Impl : public style::Observer, public RendererObserver {
public:
- Impl(Map&,
- RendererFrontend&,
- MapObserver&,
- FileSource&,
- Scheduler&,
-
- Size size,
- float pixelRatio,
-
- MapMode,
- ConstrainMode,
- ViewportMode,
- bool crossSourceCollisions);
-
+ Impl(RendererFrontend&, MapObserver&, FileSource&, Scheduler&, Size size, float pixelRatio, const MapOptions&);
~Impl() final;
// StyleObserver
@@ -57,7 +45,9 @@ public:
void onWillStartRenderingMap() final;
void onDidFinishRenderingMap() final;
- Map& map;
+ // Map
+ void jumpTo(const CameraOptions&);
+
MapObserver& observer;
RendererFrontend& rendererFrontend;
FileSource& fileSource;