[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user