[core] Cleanup Map::Impl ctor

This commit is contained in:
Bruno de Oliveira Abinader
2019-03-19 16:52:14 +02:00
parent 8ac73254c1
commit d1762d7111
3 changed files with 30 additions and 54 deletions

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;