[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
This commit is contained in:
@@ -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 }};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -34,7 +34,6 @@ class Map : private util::noncopyable {
|
||||
public:
|
||||
explicit Map(RendererFrontend&,
|
||||
MapObserver&,
|
||||
float pixelRatio,
|
||||
Scheduler&,
|
||||
const MapOptions&,
|
||||
const ResourceOptions&);
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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))))
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user