[core] Add MapOptions to define properties of Map

To simplify the Map constructor, introduce MapOptions
interface to define the properties that can be set on
a Map.
This commit is contained in:
Sudarsana Babu Nagineni
2019-03-07 14:29:19 +02:00
parent c4115f0539
commit 5e2b6bf636
26 changed files with 326 additions and 50 deletions

View File

@@ -1,6 +1,7 @@
#include <benchmark/benchmark.h>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/renderer/renderer.hpp>
@@ -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 }};
};

View File

@@ -2,6 +2,7 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_observer.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/renderer/renderer.hpp>
@@ -41,7 +42,8 @@ static void prepare(Map& map, optional<std::string> 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);
}

View File

@@ -1,4 +1,5 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/default_styles.hpp>
@@ -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;

View File

@@ -3,6 +3,7 @@
#include <mbgl/util/optional.hpp>
#include <mbgl/util/chrono.hpp>
#include <mbgl/map/map_observer.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/size.hpp>
@@ -36,10 +37,7 @@ public:
float pixelRatio,
FileSource&,
Scheduler&,
MapMode mapMode = MapMode::Continuous,
ConstrainMode constrainMode = ConstrainMode::HeightOnly,
ViewportMode viewportMode = ViewportMode::Default,
bool crossSourceCollisions = true);
const MapOptions&);
~Map();
// Register a callback that will get called (on the render thread) when all resources have

View File

@@ -0,0 +1,139 @@
#pragma once
#include <mbgl/map/mode.hpp>
#include <memory>
#include <string>
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 can be 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 can be 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) asset 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 value.
*
* @return true if ecross-source symbol collision detection enabled,
* false otherwise.
*/
bool crossSourceCollisions() const;
private:
class Impl;
std::shared_ptr<Impl> impl_;
};
} // namespace mbgl

View File

@@ -13,6 +13,7 @@
#include <jni/jni.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/math/minmax.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/event.hpp>
@@ -79,12 +80,18 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
// Create a renderer frontend
rendererFrontend = std::make_unique<AndroidRendererFrontend>(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<mbgl::Map>(*rendererFrontend, *this,
mbgl::Size{ static_cast<uint32_t>(width),
static_cast<uint32_t>(height) }, pixelRatio,
fileSource, *threadPool, MapMode::Continuous,
ConstrainMode::HeightOnly, ViewportMode::Default, _crossSourceCollisions);
fileSource, *threadPool, options);
}
/**

View File

@@ -3,6 +3,7 @@
#include <mbgl/actor/actor_ref.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/style/style.hpp>
@@ -57,7 +58,7 @@ MapSnapshotter::Impl::Impl(FileSource* fileSource,
const optional<std::string> 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);

View File

@@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
mbgl::ThreadPool threadPool(4);
GLFWRendererFrontend rendererFrontend { std::make_unique<mbgl::Renderer>(backend, view->getPixelRatio(), fileSource, threadPool), backend };
mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool);
mbgl::Map map(rendererFrontend, backend, view->getSize(), view->getPixelRatio(), fileSource, threadPool, mbgl::MapOptions());
backend.setMap(&map);

View File

@@ -4,6 +4,7 @@
#import <OpenGLES/EAGL.h>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/map/camera.hpp>
#include <mbgl/map/mode.hpp>
@@ -472,9 +473,15 @@ public:
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(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) {

View File

@@ -26,6 +26,7 @@
#import "MGLImageSource.h"
#import <mbgl/map/map.hpp>
#import <mbgl/map/map_options.hpp>
#import <mbgl/style/style.hpp>
#import <mbgl/annotation/annotation.hpp>
#import <mbgl/map/camera.hpp>
@@ -288,7 +289,13 @@ public:
auto renderer = std::make_unique<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(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.

View File

@@ -616,11 +616,13 @@ void NodeMap::cancel() {
});
frontend = std::make_unique<mbgl::HeadlessFrontend>(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<mbgl::Map>(*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
@@ -1205,10 +1207,10 @@ NodeMap::NodeMap(v8::Local<v8::Object> 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;

View File

@@ -1767,15 +1767,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<mbgl::MapMode>(settings.mapMode()))
.withConstrainMode(static_cast<mbgl::ConstrainMode>(settings.constrainMode()))
.withViewportMode(static_cast<mbgl::ViewportMode>(settings.viewportMode()));
// Setup the Map object
mapObj = std::make_unique<mbgl::Map>(
*this, // RendererFrontend
*m_mapObserver,
sanitizedSize(size),
m_pixelRatio, *m_fileSourceObj, *m_threadPool,
static_cast<mbgl::MapMode>(settings.mapMode()),
static_cast<mbgl::ConstrainMode>(settings.constrainMode()),
static_cast<mbgl::ViewportMode>(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);

View File

@@ -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/map/projection_mode.hpp": "include/mbgl/map/projection_mode.hpp",
"mbgl/math/clamp.hpp": "include/mbgl/math/clamp.hpp",

View File

@@ -33,10 +33,7 @@ Map::Map(RendererFrontend& rendererFrontend,
const float pixelRatio,
FileSource& fileSource,
Scheduler& scheduler,
MapMode mapMode,
ConstrainMode constrainMode,
ViewportMode viewportMode,
bool crossSourceCollisions)
const MapOptions& options)
: impl(std::make_unique<Impl>(*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;

View File

@@ -0,0 +1,85 @@
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/constants.hpp>
#include <cassert>
namespace mbgl {
class MapOptions::Impl {
public:
MapMode mapMode = MapMode::Continuous;
ConstrainMode constrainMode = ConstrainMode::HeightOnly;
ViewportMode viewportMode = ViewportMode::Default;
std::string cachePath;
std::string assetRoot;
uint64_t maximumSize{mbgl::util::DEFAULT_MAX_CACHE_SIZE};
bool crossSourceCollisions = true;
};
MapOptions::MapOptions() : impl_(std::make_shared<MapOptions::Impl>()) {}
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_->assetRoot = std::move(path);
return *this;
}
const std::string& MapOptions::assetRoot() const {
return impl_->assetRoot;
}
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

View File

@@ -6,6 +6,7 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/color.hpp>
@@ -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,

View File

@@ -3,6 +3,7 @@
#include <mbgl/test/fixture_log_observer.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/renderer/backend_scope.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/storage/online_file_source.hpp>
@@ -27,7 +28,8 @@ TEST(API, RenderWithoutCallback) {
HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
auto map = std::make_unique<Map>(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.

View File

@@ -1,6 +1,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/shared_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/headless_frontend.hpp>
@@ -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.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));

View File

@@ -2,6 +2,7 @@
#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/defines.hpp>
@@ -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.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
map.getStyle().addLayer(std::make_unique<CustomLayer>(

View File

@@ -1,4 +1,5 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/test/stub_file_source.hpp>
#include <mbgl/test/util.hpp>
@@ -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<Feature> getTopClusterFeature(QueryTest& test) {

View File

@@ -3,6 +3,7 @@
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/renderer/backend_scope.hpp>
#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
@@ -29,7 +30,8 @@ TEST(API, RecycleMapUpdateImages) {
HeadlessFrontend frontend { pixelRatio, fileSource, threadPool };
auto map = std::make_unique<Map>(frontend, MapObserver::nullObserver(), frontend.getSize(),
pixelRatio, fileSource, threadPool, MapMode::Static);
pixelRatio, fileSource, threadPool,
MapOptions().withMapMode(MapMode::Static));
EXPECT_TRUE(map);

View File

@@ -3,6 +3,7 @@
#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/gl/defines.hpp>
@@ -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.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));

View File

@@ -5,6 +5,7 @@
#include <mbgl/test/fixture_log_observer.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/util/default_thread_pool.hpp>
@@ -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 <typename T = FileSource>
@@ -47,7 +49,8 @@ public:
typename std::enable_if<std::is_same<T, DefaultFileSource>::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)) {
}
};
@@ -694,7 +697,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();

View File

@@ -3,6 +3,7 @@
#include <mbgl/test/stub_map_observer.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/storage/default_file_source.hpp>
#include <mbgl/style/style.hpp>
@@ -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<int> tiles;

View File

@@ -1,6 +1,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/test/stub_file_source.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/color.hpp>
@@ -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,

View File

@@ -3,6 +3,7 @@
#include <mbgl/test/util.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/map_options.hpp>
#include <mbgl/gl/headless_frontend.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/util/io.hpp>
@@ -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.jumpTo(CameraOptions().withZoom(16));
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.jumpTo(CameraOptions().withZoom(16));
map.getStyle().loadURL(style);
frontend.render(map);