summaryrefslogtreecommitdiff
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
parentf5064e710884d5b822e59d05e51c127c8b3e852b (diff)
downloadqtlocation-mapboxgl-7af00a404f22742fed4a83e9a36d023d7515025f.tar.gz
[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
-rw-r--r--benchmark/api/query.benchmark.cpp2
-rw-r--r--benchmark/api/render.benchmark.cpp19
-rw-r--r--bin/render.cpp4
-rw-r--r--include/mbgl/map/map.hpp1
-rw-r--r--include/mbgl/map/map_options.hpp15
-rwxr-xr-xplatform/android/src/native_map_view.cpp3
-rw-r--r--platform/default/src/mbgl/map/map_snapshotter.cpp4
-rw-r--r--platform/glfw/main.cpp6
-rw-r--r--platform/ios/src/MGLMapView.mm3
-rw-r--r--platform/macos/src/MGLMapView.mm3
-rw-r--r--platform/node/src/node_map.cpp6
-rw-r--r--platform/qt/src/qmapboxgl.cpp8
-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
-rw-r--r--test/api/annotations.test.cpp7
-rw-r--r--test/api/api_misuse.test.cpp5
-rw-r--r--test/api/custom_geometry_source.test.cpp5
-rw-r--r--test/api/custom_layer.test.cpp5
-rw-r--r--test/api/query.test.cpp7
-rw-r--r--test/api/recycle_map.cpp5
-rw-r--r--test/gl/context.test.cpp5
-rw-r--r--test/map/map.test.cpp18
-rw-r--r--test/map/prefetch.test.cpp2
-rw-r--r--test/src/mbgl/test/map_adapter.hpp3
-rw-r--r--test/text/local_glyph_rasterizer.test.cpp7
-rw-r--r--test/util/memory.test.cpp12
28 files changed, 107 insertions, 74 deletions
diff --git a/benchmark/api/query.benchmark.cpp b/benchmark/api/query.benchmark.cpp
index 1db958c1be..9b7c2d7273 100644
--- a/benchmark/api/query.benchmark.cpp
+++ b/benchmark/api/query.benchmark.cpp
@@ -32,7 +32,7 @@ public:
util::RunLoop loop;
ThreadPool threadPool{ 4 };
HeadlessFrontend frontend { { 1000, 1000 }, 1, threadPool };
- Map map { frontend, MapObserver::nullObserver(), 1, threadPool,
+ Map map { frontend, MapObserver::nullObserver(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath("benchmark/fixtures/api/cache.db").withAssetPath(".").withAccessToken("foobar") };
ScreenBox box{{ 0, 0 }, { 1000, 1000 }};
diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp
index 378ea705f1..3cff0d9056 100644
--- a/benchmark/api/render.benchmark.cpp
+++ b/benchmark/api/render.benchmark.cpp
@@ -45,8 +45,8 @@ static void prepare(Map& map, optional<std::string> json = {}) {
static void API_renderStill_reuse_map(::benchmark::State& state) {
RenderBenchmark bench;
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
- Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
- MapOptions().withMapMode(MapMode::Static).withSize(size),
+ Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
prepare(map);
@@ -58,8 +58,9 @@ static void API_renderStill_reuse_map(::benchmark::State& state) {
static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state) {
RenderBenchmark bench;
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
- Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
- MapOptions().withMapMode(MapMode::Static).withSize(size), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
+ Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
+ ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
prepare(map, util::read_file("benchmark/fixtures/api/style_formatted_labels.json"));
while (state.KeepRunning()) {
@@ -70,8 +71,9 @@ static void API_renderStill_reuse_map_formatted_labels(::benchmark::State& state
static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) {
RenderBenchmark bench;
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
- Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
- MapOptions().withMapMode(MapMode::Static).withSize(size), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
+ Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
+ ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
while (state.KeepRunning()) {
prepare(map, { "{}" });
@@ -86,8 +88,9 @@ static void API_renderStill_recreate_map(::benchmark::State& state) {
while (state.KeepRunning()) {
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
- Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
- MapOptions().withMapMode(MapMode::Static).withSize(size), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
+ Map map { frontend, MapObserver::nullObserver(), bench.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
+ ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
prepare(map);
frontend.render(map);
}
diff --git a/bin/render.cpp b/bin/render.cpp
index 03d1e86144..a805953693 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -78,8 +78,8 @@ int main(int argc, char *argv[]) {
ThreadPool threadPool(4);
HeadlessFrontend frontend({ width, height }, pixelRatio, threadPool);
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, threadPool,
- MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
+ Map map(frontend, MapObserver::nullObserver(), threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(pixelRatio),
ResourceOptions().withCachePath(cache_file).withAssetPath(asset_root).withAccessToken(std::string(token)));
if (style.find("://") == std::string::npos) {
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 822c400ddf..2fdd72dcb8 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -34,7 +34,6 @@ class Map : private util::noncopyable {
public:
explicit Map(RendererFrontend&,
MapObserver&,
- float pixelRatio,
Scheduler&,
const MapOptions&,
const ResourceOptions&);
diff --git a/include/mbgl/map/map_options.hpp b/include/mbgl/map/map_options.hpp
index 508d569ea5..fcb8c8f32f 100644
--- a/include/mbgl/map/map_options.hpp
+++ b/include/mbgl/map/map_options.hpp
@@ -119,6 +119,21 @@ public:
*/
Size size() const;
+ /**
+ * @brief Sets the custom pixel ratio. By default, it is set to 1.
+ *
+ * @param ratio Pixel ratio value.
+ * @return reference to MapOptions for chaining options together.
+ */
+ MapOptions& withPixelRatio(float ratio);
+
+ /**
+ * @brief Gets the previously set (or default) pixel ratio value.
+ *
+ * @return pixel ratio value.
+ */
+ float pixelRatio() const;
+
private:
class Impl;
std::unique_ptr<Impl> impl_;
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index d30a216353..e74e4c3bbc 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -82,13 +82,14 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
MapOptions options;
options.withMapMode(MapMode::Continuous)
.withSize(mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) })
+ .withPixelRatio(pixelRatio)
.withConstrainMode(ConstrainMode::HeightOnly)
.withViewportMode(ViewportMode::Default)
.withCrossSourceCollisions(_crossSourceCollisions);
// Create the core map
map = std::make_unique<mbgl::Map>(
- *rendererFrontend, *this, pixelRatio, *threadPool, options,
+ *rendererFrontend, *this, *threadPool, options,
mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource));
}
diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp
index d5a71a5508..227a61d272 100644
--- a/platform/default/src/mbgl/map/map_snapshotter.cpp
+++ b/platform/default/src/mbgl/map/map_snapshotter.cpp
@@ -58,7 +58,9 @@ MapSnapshotter::Impl::Impl(std::shared_ptr<Scheduler> scheduler_,
const ResourceOptions& resourceOptions)
: scheduler(std::move(scheduler_))
, frontend(size, pixelRatio, *scheduler, programCacheDir, GLContextMode::Unique, localFontFamily)
- , map(frontend, MapObserver::nullObserver(), pixelRatio, *scheduler, MapOptions().withMapMode(MapMode::Static).withSize(size), resourceOptions) {
+ , map(frontend, MapObserver::nullObserver(), *scheduler,
+ MapOptions().withMapMode(MapMode::Static).withSize(size).withPixelRatio(pixelRatio),
+ resourceOptions) {
if (style.first) {
map.getStyle().loadJSON(style.second);
} else{
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index 9f87e579a7..cb3f9b8578 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -110,7 +110,11 @@ int main(int argc, char *argv[]) {
mbgl::ThreadPool threadPool(4);
GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), threadPool), backend };
- mbgl::Map map(rendererFrontend, backend, view->getPixelRatio(), threadPool, mbgl::MapOptions().withSize(view->getSize()), resourceOptions);
+
+ mbgl::Map map1(rendererFrontend, backend, threadPool,mbgl::MapOptions(), resourceOptions);
+
+ mbgl::Map map(rendererFrontend, backend, threadPool,
+ mbgl::MapOptions().withSize(view->getSize()).withPixelRatio(view->getPixelRatio()), resourceOptions);
backend.setMap(&map);
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 036cfd5756..c94cf477ef 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -480,6 +480,7 @@ public:
mbgl::MapOptions mapOptions;
mapOptions.withMapMode(mbgl::MapMode::Continuous)
.withSize(self.size)
+ .withPixelRatio(config.scaleFactor)
.withConstrainMode(mbgl::ConstrainMode::None)
.withViewportMode(mbgl::ViewportMode::Default)
.withCrossSourceCollisions(enableCrossSourceCollisions);
@@ -489,7 +490,7 @@ public:
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
NSAssert(!_mbglMap, @"_mbglMap should be NULL");
- _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions);
+ _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, *_mbglThreadPool, mapOptions, resourceOptions);
// start paused if in IB
if (_isTargetingInterfaceBuilder || background) {
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index fdcc2090b1..091ba462cc 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -293,6 +293,7 @@ public:
mbgl::MapOptions mapOptions;
mapOptions.withMapMode(mbgl::MapMode::Continuous)
.withSize(self.size)
+ .withPixelRatio(config.scaleFactor)
.withConstrainMode(mbgl::ConstrainMode::None)
.withViewportMode(mbgl::ViewportMode::Default)
.withCrossSourceCollisions(enableCrossSourceCollisions);
@@ -301,7 +302,7 @@ public:
resourceOptions.withCachePath([[MGLOfflineStorage sharedOfflineStorage] mbglCachePath])
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
- _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions);
+ _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, *_mbglThreadPool, mapOptions, resourceOptions);
// Install the OpenGL layer. Interface Builder’s synchronous drawing means
// we can’t display a map, so don’t even bother to have a map layer.
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp
index bcd5fb1c16..291dea6bb7 100644
--- a/platform/node/src/node_map.cpp
+++ b/platform/node/src/node_map.cpp
@@ -631,8 +631,9 @@ void NodeMap::cancel() {
});
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, threadpool);
- map = std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool,
+ map = std::make_unique<mbgl::Map>(*frontend, mapObserver, threadpool,
mbgl::MapOptions().withSize(frontend->getSize())
+ .withPixelRatio(pixelRatio)
.withMapMode(mode)
.withCrossSourceCollisions(crossSourceCollisions),
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)));
@@ -1214,8 +1215,9 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
}())
, mapObserver(NodeMapObserver())
, frontend(std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size { 256, 256 }, pixelRatio, threadpool))
- , map(std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool,
+ , map(std::make_unique<mbgl::Map>(*frontend, mapObserver, threadpool,
mbgl::MapOptions().withSize(frontend->getSize())
+ .withPixelRatio(pixelRatio)
.withMapMode(mode)
.withCrossSourceCollisions(crossSourceCollisions),
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this))))
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index ff6a4498dc..4f79525257 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -1705,9 +1705,10 @@ void QMapboxGL::connectionEstablished()
\a copyrightsHtml is a string with a HTML snippet.
*/
-mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings, const QSize &size) {
+mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings, const QSize &size, qreal pixelRatio) {
return std::move(mbgl::MapOptions()
.withSize(sanitizedSize(size))
+ .withPixelRatio(pixelRatio)
.withMapMode(static_cast<mbgl::MapMode>(settings.mapMode()))
.withConstrainMode(static_cast<mbgl::ConstrainMode>(settings.constrainMode()))
.withViewportMode(static_cast<mbgl::ViewportMode>(settings.viewportMode())));
@@ -1741,8 +1742,9 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
auto resourceOptions = resourceOptionsFromQMapboxGLSettings(settings);
// Setup the Map object.
- mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, m_pixelRatio, *m_threadPool,
- mapOptionsFromQMapboxGLSettings(settings, size), resourceOptions);
+ mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, *m_threadPool,
+ mapOptionsFromQMapboxGLSettings(settings, size, m_pixelRatio),
+ resourceOptions);
if (settings.resourceTransform()) {
m_resourceTransform = std::make_unique<mbgl::Actor<mbgl::ResourceTransform>>(*mbgl::Scheduler::GetCurrent(),
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
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index 612c4f0ab8..11920d1624 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -29,11 +29,10 @@ class AnnotationTest {
public:
util::RunLoop loop;
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
+ HeadlessFrontend frontend { 1, threadPool };
- MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, std::make_shared<StubFileSource>(),
- threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
+ MapAdapter map { frontend, MapObserver::nullObserver(), std::make_shared<StubFileSource>(), threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/annotations/") + name,
diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp
index 17eb2de14b..cca47de69c 100644
--- a/test/api/api_misuse.test.cpp
+++ b/test/api/api_misuse.test.cpp
@@ -22,11 +22,10 @@ TEST(API, RenderWithoutCallback) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
+ HeadlessFrontend frontend { 1, threadPool };
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
- pixelRatio, std::make_shared<StubFileSource>(), threadPool,
+ std::make_shared<StubFileSource>(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
map->renderStill(nullptr);
diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp
index 679291372d..f796e3086b 100644
--- a/test/api/custom_geometry_source.test.cpp
+++ b/test/api/custom_geometry_source.test.cpp
@@ -21,9 +21,8 @@ TEST(CustomGeometrySource, Grid) {
util::RunLoop loop;
auto threadPool = sharedThreadPool();
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, *threadPool };
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, *threadPool,
+ HeadlessFrontend frontend { 1, *threadPool };
+ Map map(frontend, MapObserver::nullObserver(), *threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp
index 4f1429d637..c836ab81ac 100644
--- a/test/api/custom_layer.test.cpp
+++ b/test/api/custom_layer.test.cpp
@@ -91,9 +91,8 @@ TEST(CustomLayer, Basic) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, threadPool,
+ HeadlessFrontend frontend { 1, threadPool };
+ Map map(frontend, MapObserver::nullObserver(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp
index 0dd9882be2..ddf5df6aab 100644
--- a/test/api/query.test.cpp
+++ b/test/api/query.test.cpp
@@ -36,10 +36,9 @@ public:
util::RunLoop loop;
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
- MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
+ HeadlessFrontend frontend { 1, threadPool };
+ MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
};
std::vector<Feature> getTopClusterFeature(QueryTest& test) {
diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp
index 6f1560d463..ac9de9b230 100644
--- a/test/api/recycle_map.cpp
+++ b/test/api/recycle_map.cpp
@@ -24,11 +24,10 @@ TEST(API, RecycleMapUpdateImages) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool };
+ HeadlessFrontend frontend { 1, threadPool };
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
- pixelRatio, std::make_shared<StubFileSource>(), threadPool,
+ std::make_shared<StubFileSource>(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
EXPECT_TRUE(map);
diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp
index d9b2750a95..291813bd9a 100644
--- a/test/gl/context.test.cpp
+++ b/test/gl/context.test.cpp
@@ -87,11 +87,10 @@ TEST(GLContextMode, Shared) {
util::RunLoop loop;
ThreadPool threadPool(4);
- float pixelRatio { 1 };
- HeadlessFrontend frontend { pixelRatio, threadPool, {}, GLContextMode::Shared };
+ HeadlessFrontend frontend { 1, threadPool, {}, GLContextMode::Shared };
- Map map(frontend, MapObserver::nullObserver(), pixelRatio, threadPool,
+ Map map(frontend, MapObserver::nullObserver(), threadPool,
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index d443b5eacc..be92890b07 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -41,8 +41,8 @@ public:
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
: fileSource(std::make_shared<FileSource>())
, frontend(pixelRatio, threadPool)
- , map(frontend, observer, pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(mode).withSize(frontend.getSize())) {}
+ , map(frontend, observer, fileSource, threadPool,
+ MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
template <typename T = FileSource>
MapTest(const std::string& cachePath, const std::string& assetPath,
@@ -50,8 +50,8 @@ public:
typename std::enable_if<std::is_same<T, DefaultFileSource>::value>::type* = 0)
: fileSource(std::make_shared<T>(cachePath, assetPath))
, frontend(pixelRatio, threadPool)
- , map(frontend, observer, pixelRatio,
- fileSource, threadPool, MapOptions().withMapMode(mode).withSize(frontend.getSize())) {}
+ , map(frontend, observer, fileSource, threadPool,
+ MapOptions().withMapMode(mode).withSize(frontend.getSize()).withPixelRatio(pixelRatio)) {}
};
TEST(Map, RendererState) {
@@ -322,7 +322,8 @@ TEST(Map, DefaultBoundOptions) {
}
TEST(Map, MapOptions) {
- MapTest<> test { 1, MapMode::Continuous };
+ float pixelRatio { 2 };
+ MapTest<> test { pixelRatio, MapMode::Continuous };
test.map.setNorthOrientation(NorthOrientation::Rightwards);
test.map.setConstrainMode(ConstrainMode::None);
@@ -336,6 +337,7 @@ TEST(Map, MapOptions) {
EXPECT_EQ(options.constrainMode(), ConstrainMode::None);
EXPECT_EQ(options.northOrientation(), NorthOrientation::Rightwards);
EXPECT_EQ(options.size(), size);
+ EXPECT_EQ(options.pixelRatio(), pixelRatio);
}
TEST(Map, DefaultMapOptions) {
@@ -349,6 +351,7 @@ TEST(Map, DefaultMapOptions) {
EXPECT_TRUE(options.crossSourceCollisions());
EXPECT_EQ(options.size().width, 256);
EXPECT_EQ(options.size().height, 256);
+ EXPECT_EQ(options.pixelRatio(), 1);
}
TEST(Map, SetStyleInvalidJSON) {
@@ -741,7 +744,6 @@ TEST(Map, DontLoadUnneededTiles) {
TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
util::RunLoop runLoop;
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
using namespace std::chrono_literals;
@@ -753,7 +755,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
util::Timer timer;
- HeadlessFrontend frontend(pixelRatio, threadPool);
+ HeadlessFrontend frontend(1, threadPool);
StubMapObserver observer;
observer.didFinishRenderingFrameCallback = [&] (MapObserver::RenderMode) {
@@ -765,7 +767,7 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
});
};
- Map map(frontend, observer, pixelRatio, threadPool,
+ Map map(frontend, observer, threadPool,
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()),
ResourceOptions().withCachePath(":memory:").withAssetPath("test/fixtures/api/assets"));
map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json"));
diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp
index 520228e010..3232c99a22 100644
--- a/test/map/prefetch.test.cpp
+++ b/test/map/prefetch.test.cpp
@@ -37,7 +37,7 @@ TEST(Map, PrefetchTiles) {
};
HeadlessFrontend frontend { { 512, 512 }, 1, threadPool };
- MapAdapter map(frontend, observer, 1, fileSource, threadPool,
+ MapAdapter map(frontend, observer, fileSource, threadPool,
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()));
std::vector<int> tiles;
diff --git a/test/src/mbgl/test/map_adapter.hpp b/test/src/mbgl/test/map_adapter.hpp
index 67abea953d..5bdab1d164 100644
--- a/test/src/mbgl/test/map_adapter.hpp
+++ b/test/src/mbgl/test/map_adapter.hpp
@@ -12,11 +12,10 @@ class MapAdapter : public Map {
public:
explicit MapAdapter(RendererFrontend& frontend,
MapObserver& observer,
- float ratio,
std::shared_ptr<FileSource> fileSource,
Scheduler& scheduler,
const MapOptions& options)
- : Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, ratio, std::move(fileSource), options)) {}
+ : Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, std::move(fileSource), options)) {}
};
} // namespace mbgl
diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp
index ac272e2f9f..26e4a2eb1d 100644
--- a/test/text/local_glyph_rasterizer.test.cpp
+++ b/test/text/local_glyph_rasterizer.test.cpp
@@ -34,17 +34,16 @@ namespace {
class LocalGlyphRasterizerTest {
public:
LocalGlyphRasterizerTest(const optional<std::string> fontFamily)
- : frontend(pixelRatio, threadPool, optional<std::string>(), GLContextMode::Unique, fontFamily)
+ : frontend(1, threadPool, optional<std::string>(), GLContextMode::Unique, fontFamily)
{
}
util::RunLoop loop;
std::shared_ptr<StubFileSource> fileSource = std::make_shared<StubFileSource>();
ThreadPool threadPool { 4 };
- float pixelRatio { 1 };
HeadlessFrontend frontend;
- MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, fileSource,
- threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
+ MapAdapter map { frontend, MapObserver::nullObserver(), fileSource, threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
void checkRendering(const char * name) {
test::checkImage(std::string("test/fixtures/local_glyphs/") + name,
diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp
index 03545c648b..e3ad976432 100644
--- a/test/util/memory.test.cpp
+++ b/test/util/memory.test.cpp
@@ -73,8 +73,8 @@ TEST(Memory, Vector) {
float ratio { 2 };
HeadlessFrontend frontend { { 256, 256 }, ratio, test.threadPool };
- MapAdapter map(frontend, MapObserver::nullObserver(), ratio, test.fileSource,
- test.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
+ MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource, test.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
map.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL("mapbox://streets");
@@ -86,8 +86,8 @@ TEST(Memory, Raster) {
float ratio { 2 };
HeadlessFrontend frontend { { 256, 256 }, ratio, test.threadPool };
- MapAdapter map(frontend, MapObserver::nullObserver(), ratio, test.fileSource,
- test.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
+ MapAdapter map(frontend, MapObserver::nullObserver(), test.fileSource, test.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(ratio));
map.getStyle().loadURL("mapbox://satellite");
frontend.render(map);
@@ -124,8 +124,8 @@ TEST(Memory, Footprint) {
public:
FrontendAndMap(MemoryTest& test_, const char* style)
: frontend(Size{ 256, 256 }, 2, test_.threadPool)
- , map(frontend, MapObserver::nullObserver(), 2, test_.fileSource
- , test_.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())) {
+ , map(frontend, MapObserver::nullObserver(), test_.fileSource, test_.threadPool,
+ MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()).withPixelRatio(2)) {
map.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL(style);
frontend.render(map);