From d1762d7111b39d45430bd7bb75ea60b7a5d85bd2 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 19 Mar 2019 16:52:14 +0200 Subject: [core] Cleanup Map::Impl ctor --- src/mbgl/map/map.cpp | 22 +++++----------------- src/mbgl/map/map_impl.cpp | 42 ++++++++++++++++++++---------------------- src/mbgl/map/map_impl.hpp | 20 +++++--------------- 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(*this, - rendererFrontend, - mapObserver, - fileSource, - scheduler, - size, - pixelRatio, - options.mapMode(), - options.constrainMode(), - options.viewportMode(), - options.crossSourceCollisions())) {} + const MapOptions& mapOptions) + : impl(std::make_unique(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(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(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 #include #include +#include #include #include #include @@ -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; -- cgit v1.2.1