From 9676028be8393aaf616f3abd6f2a3e6bf493b54c Mon Sep 17 00:00:00 2001 From: Sudarsana Babu Nagineni Date: Mon, 4 Mar 2019 11:25:13 +0200 Subject: [WIP][core] Add Map options --- benchmark/api/query.benchmark.cpp | 4 +- benchmark/api/render.benchmark.cpp | 10 +- bin/render.cpp | 4 +- include/mbgl/map/map.hpp | 6 +- include/mbgl/map/map_options.hpp | 147 ++++++++++++++++++++++ platform/android/src/native_map_view.cpp | 11 +- platform/default/src/mbgl/map/map_snapshotter.cpp | 3 +- platform/glfw/main.cpp | 3 +- platform/ios/src/MGLMapView.mm | 11 +- platform/macos/src/MGLMapView.mm | 9 +- platform/node/src/node_map.cpp | 18 +-- platform/qt/src/qmapboxgl.cpp | 9 +- src/core-files.json | 2 + src/mbgl/map/map.cpp | 13 +- src/mbgl/map/map_options.cpp | 94 ++++++++++++++ test/api/annotations.test.cpp | 4 +- test/api/api_misuse.test.cpp | 4 +- test/api/custom_geometry_source.test.cpp | 3 +- test/api/custom_layer.test.cpp | 3 +- test/api/query.test.cpp | 3 +- test/api/recycle_map.cpp | 4 +- test/gl/context.test.cpp | 4 +- test/map/map.test.cpp | 10 +- test/map/prefetch.test.cpp | 4 +- test/text/local_glyph_rasterizer.test.cpp | 3 +- test/util/memory.test.cpp | 8 +- 26 files changed, 344 insertions(+), 50 deletions(-) create mode 100644 include/mbgl/map/map_options.hpp create mode 100644 src/mbgl/map/map_options.cpp diff --git a/benchmark/api/query.benchmark.cpp b/benchmark/api/query.benchmark.cpp index 7694585526..2748f372a1 100644 --- a/benchmark/api/query.benchmark.cpp +++ b/benchmark/api/query.benchmark.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -34,7 +35,8 @@ public: DefaultFileSource fileSource{ "benchmark/fixtures/api/cache.db", "." }; ThreadPool threadPool{ 4 }; HeadlessFrontend frontend { { 1000, 1000 }, 1, fileSource, threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, fileSource, threadPool, MapMode::Static}; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, + fileSource, threadPool, MapOptions().withMapMode(MapMode::Static) }; ScreenBox box{{ 0, 0 }, { 1000, 1000 }}; }; diff --git a/benchmark/api/render.benchmark.cpp b/benchmark/api/render.benchmark.cpp index a1b557777f..de60ccb3db 100644 --- a/benchmark/api/render.benchmark.cpp +++ b/benchmark/api/render.benchmark.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,8 @@ static void prepare(Map& map, optional json = {}) { static void API_renderStill_reuse_map(::benchmark::State& state) { RenderBenchmark bench; HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Static}; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, + bench.fileSource, bench.threadPool, MapOptions().withMapMode(MapMode::Static) }; prepare(map); while (state.KeepRunning()) { @@ -52,7 +54,8 @@ static void API_renderStill_reuse_map(::benchmark::State& state) { static void API_renderStill_reuse_map_switch_styles(::benchmark::State& state) { RenderBenchmark bench; HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Static}; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, + bench.fileSource, bench.threadPool, MapOptions().withMapMode(MapMode::Static) }; while (state.KeepRunning()) { prepare(map, { "{}" }); @@ -67,7 +70,8 @@ static void API_renderStill_recreate_map(::benchmark::State& state) { while (state.KeepRunning()) { HeadlessFrontend frontend { { 1000, 1000 }, 1, bench.fileSource, bench.threadPool }; - Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, bench.fileSource, bench.threadPool, MapMode::Static}; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, + bench.fileSource, bench.threadPool, MapOptions().withMapMode(MapMode::Static) }; prepare(map); frontend.render(map); } diff --git a/bin/render.cpp b/bin/render.cpp index 1e7b210a4c..6d323f942a 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -84,7 +85,8 @@ int main(int argc, char *argv[]) { ThreadPool threadPool(4); HeadlessFrontend frontend({ width, height }, pixelRatio, fileSource, threadPool); - Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, threadPool, MapMode::Static); + Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + fileSource, threadPool, MapOptions().withMapMode(MapMode::Static)); if (style.find("://") == std::string::npos) { style = std::string("file://") + style; diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index fec67eb281..71b8dbc560 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -35,10 +36,7 @@ public: float pixelRatio, FileSource&, Scheduler&, - MapMode mapMode = MapMode::Continuous, - ConstrainMode constrainMode = ConstrainMode::HeightOnly, - ViewportMode viewportMode = ViewportMode::Default, - bool crossSourceCollisions = true); + MapOptions); ~Map(); // Register a callback that will get called (on the render thread) when all resources have diff --git a/include/mbgl/map/map_options.hpp b/include/mbgl/map/map_options.hpp new file mode 100644 index 0000000000..c9b1661dc8 --- /dev/null +++ b/include/mbgl/map/map_options.hpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2019 - Mapbox, Inc. + * + * You may use this code with your Mapbox account and under the + * Mapbox Terms of Service (https://www.mapbox.com/tos/). + * + * All other rights reserved. + */ + +#pragma once + +#include + +#include +#include + +namespace mbgl { + +/** + * @brief Holds values for Map options. + */ +class MapOptions { +public: + /** + * @brief Constructs a MapOptions object with default values. + */ + MapOptions(); + ~MapOptions(); + + /** + * @brief Sets the map rendering mode. By default, it is set to Continuous + * so the map will render as data arrives from the network and react + * immediately to state changes. + * + * @param mode Map rendering mode. + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withMapMode(MapMode mode); + + /** + * @brief Gets the previously set (or default) map mode. + * + * @return map mode. + */ + MapMode mapMode() const; + + /** + * @brief Sets the map constrain mode. This is used to limit the map to wrap + * around the globe horizontally. By default, it is set to HeightOnly. + * + * @param mode Map constrain mode. + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withConstrainMode(ConstrainMode mode); + + /** + * @brief Gets the previously set (or default) constrain mode. + * + * @return constrain mode. + */ + ConstrainMode constrainMode() const; + + /** + * @brief Sets the viewport mode. This is used to flip the vertical + * orientation of the map as some devices may use inverted orientation. + * + * @param mode Viewport mode. + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withViewportMode(ViewportMode mode); + + /** + * @brief Gets the previously set (or default) viewport mode. + * + * @return viewport mode. + */ + ViewportMode viewportMode() const; + + /** + * @brief Sets the cache path. + * + * @param path Cache path. + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withCachePath(std::string path); + + /** + * @brief Gets the previously set (or default) cache path. + * + * @return cache path + */ + const std::string& cachePath() const; + + /** + * @brief Sets the asset path, which is the root directory from where + * the asset:// scheme gets resolved in a style. + * + * @param path Asset path. + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withAssetRoot(std::string path); + + /** + * @brief Gets the previously set (or default) assert path. + * + * @return asset path + */ + const std::string& assetRoot() const; + + /** + * @brief Sets the maximum cache size. + * + * @param size Cache maximum size in bytes. + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withMaximumCacheSize(uint64_t size); + + /** + * @brief Gets the previously set (or default) maximum allowed cache size. + * + * @return maximum allowed cache database size in bytes. + */ + uint64_t maximumCacheSize() const; + + /** + * @brief Specify whether to enable cross-source symbol collision detection + * or not. By default, it is set to true. + * + * @param enableCollisions true to enable, false to disable + * @return reference to MapOptions for chaining options together. + */ + MapOptions& withCrossSourceCollisions(bool enableCollisions); + + /** + * @brief Gets the previously set (or default) crossSourceCollisions + * + * @return true if ecross-source symbol collision detection enabled, + * false otherwise. + */ + bool crossSourceCollisions() const; + +private: + class Impl; + std::shared_ptr impl_; +}; + +} // namespace mbgl diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index e8bc14c8c2..eed12fa9cf 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -79,12 +80,18 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, // Create a renderer frontend rendererFrontend = std::make_unique(mapRenderer); + // Create Map options + MapOptions options; + options.withMapMode(MapMode::Continuous) + .withConstrainMode(ConstrainMode::HeightOnly) + .withViewportMode(ViewportMode::Default) + .withCrossSourceCollisions(_crossSourceCollisions); + // Create the core map map = std::make_unique(*rendererFrontend, *this, mbgl::Size{ static_cast(width), static_cast(height) }, pixelRatio, - fileSource, *threadPool, MapMode::Continuous, - ConstrainMode::HeightOnly, ViewportMode::Default, _crossSourceCollisions); + fileSource, *threadPool, options); } /** diff --git a/platform/default/src/mbgl/map/map_snapshotter.cpp b/platform/default/src/mbgl/map/map_snapshotter.cpp index ae14b20721..8d5c096f9b 100644 --- a/platform/default/src/mbgl/map/map_snapshotter.cpp +++ b/platform/default/src/mbgl/map/map_snapshotter.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,7 @@ MapSnapshotter::Impl::Impl(FileSource* fileSource, const optional localFontFamily) : scheduler(std::move(scheduler_)) , frontend(size, pixelRatio, *fileSource, *scheduler, programCacheDir, GLContextMode::Unique, localFontFamily) - , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, *scheduler, MapMode::Static) { + , map(frontend, MapObserver::nullObserver(), size, pixelRatio, *fileSource, *scheduler, MapOptions().withMapMode(MapMode::Static)) { if (style.first) { map.getStyle().loadJSON(style.second); diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 1bb2e13614..779998d897 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -109,7 +109,8 @@ int main(int argc, char *argv[]) { mbgl::ThreadPool threadPool(4); GLFWRendererFrontend rendererFrontend { std::make_unique(backend, view->getPixelRatio(), fileSource, threadPool), backend }; - mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool); + mbgl::MapOptions options; + mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool, options); backend.setMap(&map); diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f9ccab1422..8f82f45117 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -4,6 +4,7 @@ #import #include +#include #include #include #include @@ -472,9 +473,15 @@ public: auto renderer = std::make_unique(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName); BOOL enableCrossSourceCollisions = !config.perSourceCollisions; _rendererFrontend = std::make_unique(std::move(renderer), self, *_mbglView); - + + mbgl::MapOptions mapOptions; + mapOptions.withMapMode(mbgl::MapMode::Continuous) + .withConstrainMode(mbgl::ConstrainMode::None) + .withViewportMode(mbgl::ViewportMode::Default) + .withCrossSourceCollisions(enableCrossSourceCollisions); + NSAssert(!_mbglMap, @"_mbglMap should be NULL"); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, enableCrossSourceCollisions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mapOptions); // start paused if in IB if (_isTargetingInterfaceBuilder || background) { diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 5a24524b4a..ae3f845744 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -26,6 +26,7 @@ #import "MGLImageSource.h" #import +#import #import #import #import @@ -288,7 +289,13 @@ public: auto renderer = std::make_unique(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName); BOOL enableCrossSourceCollisions = !config.perSourceCollisions; _rendererFrontend = std::make_unique(std::move(renderer), self, *_mbglView, true); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, enableCrossSourceCollisions); + + mbgl::MapOptions mapOptions; + mapOptions.withMapMode(mbgl::MapMode::Continuous) + .withConstrainMode(mbgl::ConstrainMode::None) + .withViewportMode(mbgl::ViewportMode::Default) + .withCrossSourceCollisions(enableCrossSourceCollisions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mapOptions); // 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 6dccdf5292..0d1cd953a3 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -620,11 +620,13 @@ void NodeMap::cancel() { }); frontend = std::make_unique(mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool); + mbgl::MapOptions options; + options.withMapMode(mode) + .withConstrainMode(mbgl::ConstrainMode::HeightOnly) + .withViewportMode(mbgl::ViewportMode::Default) + .withCrossSourceCollisions(crossSourceCollisions); map = std::make_unique(*frontend, mapObserver, frontend->getSize(), pixelRatio, - *this, threadpool, mode, - mbgl::ConstrainMode::HeightOnly, - mbgl::ViewportMode::Default, - crossSourceCollisions); + *this, threadpool, options); // FIXME: Reload the style after recreating the map. We need to find // a better way of canceling an ongoing rendering on the core level @@ -1206,10 +1208,10 @@ NodeMap::NodeMap(v8::Local options) pixelRatio, *this, threadpool, - mode, - mbgl::ConstrainMode::HeightOnly, - mbgl::ViewportMode::Default, - crossSourceCollisions)), + mbgl::MapOptions().withMapMode(mode) + .withConstrainMode(mbgl::ConstrainMode::HeightOnly) + .withViewportMode(mbgl::ViewportMode::Default) + .withCrossSourceCollisions(crossSourceCollisions))), async(new uv_async_t) { async->data = this; diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 203a1a5341..fb670e034a 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1766,15 +1766,18 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin connect(m_mapObserver.get(), SIGNAL(mapLoadingFailed(QMapboxGL::MapLoadingFailure,QString)), q, SIGNAL(mapLoadingFailed(QMapboxGL::MapLoadingFailure,QString))); connect(m_mapObserver.get(), SIGNAL(copyrightsChanged(QString)), q, SIGNAL(copyrightsChanged(QString))); + mbgl::MapOptions options; + options.withMapMode(static_cast(settings.mapMode())) + .withConstrainMode(static_cast(settings.constrainMode())) + .withViewportMode(static_cast(settings.viewportMode())); + // Setup the Map object mapObj = std::make_unique( *this, // RendererFrontend *m_mapObserver, sanitizedSize(size), m_pixelRatio, *m_fileSourceObj, *m_threadPool, - static_cast(settings.mapMode()), - static_cast(settings.constrainMode()), - static_cast(settings.viewportMode())); + options); // Needs to be Queued to give time to discard redundant draw calls via the `renderQueued` flag. connect(this, SIGNAL(needsRendering()), q, SIGNAL(needsRendering()), Qt::QueuedConnection); diff --git a/src/core-files.json b/src/core-files.json index 42a30a3ea8..817c7bbf22 100644 --- a/src/core-files.json +++ b/src/core-files.json @@ -44,6 +44,7 @@ "src/mbgl/layout/symbol_projection.cpp", "src/mbgl/map/map.cpp", "src/mbgl/map/map_impl.cpp", + "src/mbgl/map/map_options.cpp", "src/mbgl/map/transform.cpp", "src/mbgl/map/transform_state.cpp", "src/mbgl/math/log2.cpp", @@ -329,6 +330,7 @@ "mbgl/map/change.hpp": "include/mbgl/map/change.hpp", "mbgl/map/map.hpp": "include/mbgl/map/map.hpp", "mbgl/map/map_observer.hpp": "include/mbgl/map/map_observer.hpp", + "mbgl/map/map_options.hpp": "include/mbgl/map/map_options.hpp", "mbgl/map/mode.hpp": "include/mbgl/map/mode.hpp", "mbgl/math/clamp.hpp": "include/mbgl/math/clamp.hpp", "mbgl/math/log2.hpp": "include/mbgl/math/log2.hpp", diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 7c19375542..e94eab353d 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -33,10 +33,7 @@ Map::Map(RendererFrontend& rendererFrontend, const float pixelRatio, FileSource& fileSource, Scheduler& scheduler, - MapMode mapMode, - ConstrainMode constrainMode, - ViewportMode viewportMode, - bool crossSourceCollisions) + MapOptions options) : impl(std::make_unique(*this, rendererFrontend, mapObserver, @@ -44,10 +41,10 @@ Map::Map(RendererFrontend& rendererFrontend, scheduler, size, pixelRatio, - mapMode, - constrainMode, - viewportMode, - crossSourceCollisions)) {} + options.mapMode(), + options.constrainMode(), + options.viewportMode(), + options.crossSourceCollisions())) {} Map::~Map() = default; diff --git a/src/mbgl/map/map_options.cpp b/src/mbgl/map/map_options.cpp new file mode 100644 index 0000000000..daf65c3077 --- /dev/null +++ b/src/mbgl/map/map_options.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2019 - Mapbox, Inc. + * + * You may use this code with your Mapbox account and under the + * Mapbox Terms of Service (https://www.mapbox.com/tos/). + * + * All other rights reserved. + */ + +#include +#include + +#include + +namespace mbgl { + +class MapOptions::Impl { +public: + MapMode mapMode = MapMode::Continuous; + ConstrainMode constrainMode = ConstrainMode::HeightOnly; + ViewportMode viewportMode = ViewportMode::Default; + std::string cachePath; + std::string assertRoot; + uint64_t maximumSize{mbgl::util::DEFAULT_MAX_CACHE_SIZE}; + bool crossSourceCollisions = true; +}; + +MapOptions::MapOptions() : impl_(std::make_shared()) {} +MapOptions::~MapOptions() = default; + +MapOptions& MapOptions::withMapMode(MapMode mode) { + impl_->mapMode = mode; + return *this; +} + +MapMode MapOptions::mapMode() const { + return impl_->mapMode; +} + +MapOptions& MapOptions::withConstrainMode(ConstrainMode mode) { + impl_->constrainMode = mode; + return *this; +} + +ConstrainMode MapOptions::constrainMode() const { + return impl_->constrainMode; +} + +MapOptions& MapOptions::withViewportMode(ViewportMode mode) { + impl_->viewportMode = mode; + return *this; +} + +ViewportMode MapOptions::viewportMode() const { + return impl_->viewportMode; +} + +MapOptions& MapOptions::withCachePath(std::string path) { + impl_->cachePath = std::move(path); + return *this; +} + +const std::string& MapOptions::cachePath() const { + return impl_->cachePath; +} + +MapOptions& MapOptions::withAssetRoot(std::string path) { + impl_->assertRoot = std::move(path); + return *this; +} + +const std::string& MapOptions::assetRoot() const { + return impl_->assertRoot; +} + +MapOptions& MapOptions::withMaximumCacheSize(uint64_t size) { + impl_->maximumSize = size; + return *this; +} + +uint64_t MapOptions::maximumCacheSize() const { + return impl_->maximumSize; +} + +MapOptions& MapOptions::withCrossSourceCollisions(bool enableCollisions) { + impl_->crossSourceCollisions = enableCollisions; + return *this; +} + +bool MapOptions::crossSourceCollisions() const { + return impl_->crossSourceCollisions; +} + +} // namespace mbgl diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index d13bc15ea7..9208e671cb 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -31,8 +32,9 @@ public: ThreadPool threadPool { 4 }; float pixelRatio { 1 }; HeadlessFrontend frontend { pixelRatio, fileSource, threadPool }; + Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - threadPool, MapMode::Static}; + threadPool, MapOptions().withMapMode(MapMode::Static)}; 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 363958451b..8899173071 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -27,7 +28,8 @@ TEST(API, RenderWithoutCallback) { HeadlessFrontend frontend { pixelRatio, fileSource, threadPool }; auto map = std::make_unique(frontend, MapObserver::nullObserver(), frontend.getSize(), - pixelRatio, fileSource, threadPool, MapMode::Static); + pixelRatio, fileSource, threadPool, + MapOptions().withMapMode(MapMode::Static)); map->renderStill(nullptr); // Force Map thread to join. diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp index 51d026e30d..9b8f166e03 100644 --- a/test/api/custom_geometry_source.test.cpp +++ b/test/api/custom_geometry_source.test.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -24,7 +25,7 @@ TEST(CustomGeometrySource, Grid) { float pixelRatio { 1 }; HeadlessFrontend frontend { pixelRatio, fileSource, *threadPool }; Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - *threadPool, MapMode::Static); + *threadPool, MapOptions().withMapMode(MapMode::Static)); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index c2a0797483..ef0ff579b0 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -94,7 +95,7 @@ TEST(CustomLayer, Basic) { float pixelRatio { 1 }; HeadlessFrontend frontend { pixelRatio, fileSource, threadPool }; Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - threadPool, MapMode::Static); + threadPool, MapOptions().withMapMode(MapMode::Static)); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); map.getStyle().addLayer(std::make_unique( diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index f5eb32788d..6aee0d6b7c 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -37,7 +38,7 @@ public: float pixelRatio { 1 }; HeadlessFrontend frontend { pixelRatio, fileSource, threadPool }; Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - threadPool, MapMode::Static}; + threadPool, MapOptions().withMapMode(MapMode::Static)}; }; std::vector getTopClusterFeature(QueryTest& test) { diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp index fc7e5223ec..0883241274 100644 --- a/test/api/recycle_map.cpp +++ b/test/api/recycle_map.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,8 @@ TEST(API, RecycleMapUpdateImages) { HeadlessFrontend frontend { pixelRatio, fileSource, threadPool }; auto map = std::make_unique(frontend, MapObserver::nullObserver(), frontend.getSize(), - pixelRatio, fileSource, threadPool, MapMode::Static); + pixelRatio, fileSource, threadPool, + MapOptions().withMapMode(MapMode::Static)); EXPECT_TRUE(map); diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp index 176257916f..28f4a15d52 100644 --- a/test/gl/context.test.cpp +++ b/test/gl/context.test.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -91,7 +92,8 @@ TEST(GLContextMode, Shared) { HeadlessFrontend frontend { pixelRatio, fileSource, threadPool, {}, GLContextMode::Shared }; - Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, threadPool, MapMode::Static); + Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, + fileSource, threadPool, MapOptions().withMapMode(MapMode::Static)); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); map.setLatLngZoom({ 37.8, -122.5 }, 10); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index 690df6b3e9..cf83eeeb81 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,8 @@ public: MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static) : frontend(pixelRatio, fileSource, threadPool) - , map(frontend, observer, frontend.getSize(), pixelRatio, fileSource, threadPool, mode) { + , map(frontend, observer, frontend.getSize(), pixelRatio, + fileSource, threadPool, MapOptions().withMapMode(mode)) { } template @@ -47,7 +49,8 @@ public: typename std::enable_if::value>::type* = 0) : fileSource { cachePath, assetRoot } , frontend(pixelRatio, fileSource, threadPool) - , map(frontend, observer, frontend.getSize(), pixelRatio, fileSource, threadPool, mode) { + , map(frontend, observer, frontend.getSize(), pixelRatio, + fileSource, threadPool, MapOptions().withMapMode(mode)) { } }; @@ -682,7 +685,8 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) { }); }; - Map map(frontend, observer, frontend.getSize(), pixelRatio, fileSource, threadPool, MapMode::Continuous); + Map map(frontend, observer, frontend.getSize(), pixelRatio, fileSource, + threadPool, MapOptions().withMapMode(MapMode::Continuous)); map.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); runLoop.run(); diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp index 9b61224027..7f252fcb2e 100644 --- a/test/map/prefetch.test.cpp +++ b/test/map/prefetch.test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -37,7 +38,8 @@ TEST(Map, PrefetchTiles) { }; HeadlessFrontend frontend { { 512, 512 }, 1, fileSource, threadPool }; - Map map(frontend, observer, frontend.getSize(), 1, fileSource, threadPool, MapMode::Continuous); + Map map(frontend, observer, frontend.getSize(), 1, fileSource, threadPool, + MapOptions().withMapMode(MapMode::Continuous)); std::vector tiles; diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp index 0dfec1689a..20f825c935 100644 --- a/test/text/local_glyph_rasterizer.test.cpp +++ b/test/text/local_glyph_rasterizer.test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,7 @@ public: float pixelRatio { 1 }; HeadlessFrontend frontend; Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource, - threadPool, MapMode::Static}; + threadPool, MapOptions().withMapMode(MapMode::Static)}; 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 6befb521f0..76f385d3d6 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -72,7 +73,7 @@ TEST(Memory, Vector) { HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource, test.threadPool }; Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), ratio, test.fileSource, - test.threadPool, MapMode::Static); + test.threadPool, MapOptions().withMapMode(MapMode::Static)); map.setZoom(16); // more map features map.getStyle().loadURL("mapbox://streets"); @@ -85,7 +86,7 @@ TEST(Memory, Raster) { HeadlessFrontend frontend { { 256, 256 }, ratio, test.fileSource, test.threadPool }; Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), ratio, test.fileSource, - test.threadPool, MapMode::Static); + test.threadPool, MapOptions().withMapMode(MapMode::Static)); map.getStyle().loadURL("mapbox://satellite"); frontend.render(map); @@ -122,7 +123,8 @@ TEST(Memory, Footprint) { public: FrontendAndMap(MemoryTest& test_, const char* style) : frontend(Size{ 256, 256 }, 2, test_.fileSource, test_.threadPool) - , map(frontend, MapObserver::nullObserver(), frontend.getSize(), 2, test_.fileSource, test_.threadPool, MapMode::Static) { + , map(frontend, MapObserver::nullObserver(), frontend.getSize(), 2, test_.fileSource + , test_.threadPool, MapOptions().withMapMode(MapMode::Static)) { map.setZoom(16); map.getStyle().loadURL(style); frontend.render(map); -- cgit v1.2.1