[core] Add setter/getter for size property in MapOptions
This commit is contained in:
@@ -32,8 +32,8 @@ public:
|
||||
util::RunLoop loop;
|
||||
ThreadPool threadPool{ 4 };
|
||||
HeadlessFrontend frontend { { 1000, 1000 }, 1, threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), frontend.getSize(), 1, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static),
|
||||
Map map { frontend, MapObserver::nullObserver(), 1, 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(), size, pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static),
|
||||
Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size),
|
||||
ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
prepare(map);
|
||||
|
||||
@@ -58,8 +58,8 @@ 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(), size, pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
prepare(map, util::read_file("benchmark/fixtures/api/style_formatted_labels.json"));
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
@@ -70,8 +70,8 @@ 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(), size, pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
prepare(map, { "{}" });
|
||||
@@ -86,8 +86,8 @@ static void API_renderStill_recreate_map(::benchmark::State& state) {
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
HeadlessFrontend frontend { size, pixelRatio, bench.threadPool };
|
||||
Map map { frontend, MapObserver::nullObserver(), size, pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static), ResourceOptions().withCachePath(cachePath).withAccessToken("foobar") };
|
||||
Map map { frontend, MapObserver::nullObserver(), pixelRatio, bench.threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(size), 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(), frontend.getSize(), pixelRatio, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static),
|
||||
Map map(frontend, MapObserver::nullObserver(), pixelRatio, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()),
|
||||
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&,
|
||||
Size size,
|
||||
float pixelRatio,
|
||||
Scheduler&,
|
||||
const MapOptions&,
|
||||
@@ -91,16 +90,13 @@ public:
|
||||
void setNorthOrientation(NorthOrientation);
|
||||
void setConstrainMode(ConstrainMode);
|
||||
void setViewportMode(ViewportMode);
|
||||
void setSize(Size);
|
||||
MapOptions getMapOptions() const;
|
||||
|
||||
//Projection Mode
|
||||
void setProjectionMode(const ProjectionMode&);
|
||||
ProjectionMode getProjectionMode() const;
|
||||
|
||||
// Size
|
||||
void setSize(Size);
|
||||
Size getSize() const;
|
||||
|
||||
// Projection
|
||||
ScreenCoordinate pixelForLatLng(const LatLng&) const;
|
||||
LatLng latLngForPixel(const ScreenCoordinate&) const;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include <mbgl/util/size.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -103,6 +104,21 @@ public:
|
||||
*/
|
||||
NorthOrientation northOrientation() const;
|
||||
|
||||
/**
|
||||
* @brief Sets the size to resize the map object and renderer backend.
|
||||
*
|
||||
* @param size_ A size given in logical pixels.
|
||||
* @return reference to MapOptions for chaining options together.
|
||||
*/
|
||||
MapOptions& withSize(Size size_);
|
||||
|
||||
/**
|
||||
* @brief Gets the previously set size.
|
||||
*
|
||||
* @return Size.
|
||||
*/
|
||||
Size size() const;
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
std::unique_ptr<Impl> impl_;
|
||||
|
||||
@@ -81,14 +81,15 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env,
|
||||
// Create Map options
|
||||
MapOptions options;
|
||||
options.withMapMode(MapMode::Continuous)
|
||||
.withSize(mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) })
|
||||
.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, *threadPool, options, mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource));
|
||||
*rendererFrontend, *this, pixelRatio, *threadPool, options,
|
||||
mbgl::android::FileSource::getSharedResourceOptions(_env, jFileSource));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ 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(), size, pixelRatio, *scheduler, MapOptions().withMapMode(MapMode::Static), resourceOptions) {
|
||||
, map(frontend, MapObserver::nullObserver(), pixelRatio, *scheduler, MapOptions().withMapMode(MapMode::Static).withSize(size), resourceOptions) {
|
||||
if (style.first) {
|
||||
map.getStyle().loadJSON(style.second);
|
||||
} else{
|
||||
@@ -141,7 +141,7 @@ void MapSnapshotter::Impl::setSize(Size size) {
|
||||
}
|
||||
|
||||
Size MapSnapshotter::Impl::getSize() const {
|
||||
return map.getSize();
|
||||
return map.getMapOptions().size();
|
||||
}
|
||||
|
||||
void MapSnapshotter::Impl::setCameraOptions(CameraOptions cameraOptions) {
|
||||
|
||||
@@ -110,7 +110,7 @@ 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->getSize(), view->getPixelRatio(), threadPool, mbgl::MapOptions(), resourceOptions);
|
||||
mbgl::Map map(rendererFrontend, backend, view->getPixelRatio(), threadPool, mbgl::MapOptions().withSize(view->getSize()), resourceOptions);
|
||||
|
||||
backend.setMap(&map);
|
||||
|
||||
|
||||
@@ -479,6 +479,7 @@ public:
|
||||
|
||||
mbgl::MapOptions mapOptions;
|
||||
mapOptions.withMapMode(mbgl::MapMode::Continuous)
|
||||
.withSize(self.size)
|
||||
.withConstrainMode(mbgl::ConstrainMode::None)
|
||||
.withViewportMode(mbgl::ViewportMode::Default)
|
||||
.withCrossSourceCollisions(enableCrossSourceCollisions);
|
||||
@@ -488,7 +489,7 @@ public:
|
||||
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
|
||||
|
||||
NSAssert(!_mbglMap, @"_mbglMap should be NULL");
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions);
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions);
|
||||
|
||||
// start paused if in IB
|
||||
if (_isTargetingInterfaceBuilder || background) {
|
||||
|
||||
@@ -292,6 +292,7 @@ public:
|
||||
|
||||
mbgl::MapOptions mapOptions;
|
||||
mapOptions.withMapMode(mbgl::MapMode::Continuous)
|
||||
.withSize(self.size)
|
||||
.withConstrainMode(mbgl::ConstrainMode::None)
|
||||
.withViewportMode(mbgl::ViewportMode::Default)
|
||||
.withCrossSourceCollisions(enableCrossSourceCollisions);
|
||||
@@ -300,7 +301,7 @@ public:
|
||||
resourceOptions.withCachePath([[MGLOfflineStorage sharedOfflineStorage] mbglCachePath])
|
||||
.withAssetPath([NSBundle mainBundle].resourceURL.path.UTF8String);
|
||||
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *_mbglThreadPool, mapOptions, resourceOptions);
|
||||
_mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, config.scaleFactor, *_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,10 @@ void NodeMap::cancel() {
|
||||
});
|
||||
|
||||
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, threadpool);
|
||||
map = std::make_unique<mbgl::Map>(*frontend, mapObserver, frontend->getSize(), pixelRatio, threadpool,
|
||||
mbgl::MapOptions().withMapMode(mode).withCrossSourceCollisions(crossSourceCollisions),
|
||||
map = std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool,
|
||||
mbgl::MapOptions().withSize(frontend->getSize())
|
||||
.withMapMode(mode)
|
||||
.withCrossSourceCollisions(crossSourceCollisions),
|
||||
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this)));
|
||||
|
||||
// FIXME: Reload the style after recreating the map. We need to find
|
||||
@@ -1212,8 +1214,10 @@ 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, frontend->getSize(), pixelRatio, threadpool,
|
||||
mbgl::MapOptions().withMapMode(mode).withCrossSourceCollisions(crossSourceCollisions),
|
||||
, map(std::make_unique<mbgl::Map>(*frontend, mapObserver, pixelRatio, threadpool,
|
||||
mbgl::MapOptions().withSize(frontend->getSize())
|
||||
.withMapMode(mode)
|
||||
.withCrossSourceCollisions(crossSourceCollisions),
|
||||
mbgl::ResourceOptions().withPlatformContext(reinterpret_cast<void*>(this))))
|
||||
, async(new uv_async_t) {
|
||||
async->data = this;
|
||||
|
||||
@@ -1127,7 +1127,7 @@ void QMapboxGL::resize(const QSize& size_)
|
||||
{
|
||||
auto size = sanitizedSize(size_);
|
||||
|
||||
if (d_ptr->mapObj->getSize() == size)
|
||||
if (d_ptr->mapObj->getMapOptions().size() == size)
|
||||
return;
|
||||
|
||||
d_ptr->mapObj->setSize(size);
|
||||
@@ -1705,8 +1705,9 @@ void QMapboxGL::connectionEstablished()
|
||||
\a copyrightsHtml is a string with a HTML snippet.
|
||||
*/
|
||||
|
||||
mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings) {
|
||||
mbgl::MapOptions mapOptionsFromQMapboxGLSettings(const QMapboxGLSettings &settings, const QSize &size) {
|
||||
return std::move(mbgl::MapOptions()
|
||||
.withSize(sanitizedSize(size))
|
||||
.withMapMode(static_cast<mbgl::MapMode>(settings.mapMode()))
|
||||
.withConstrainMode(static_cast<mbgl::ConstrainMode>(settings.constrainMode()))
|
||||
.withViewportMode(static_cast<mbgl::ViewportMode>(settings.viewportMode())));
|
||||
@@ -1740,8 +1741,8 @@ QMapboxGLPrivate::QMapboxGLPrivate(QMapboxGL *q, const QMapboxGLSettings &settin
|
||||
auto resourceOptions = resourceOptionsFromQMapboxGLSettings(settings);
|
||||
|
||||
// Setup the Map object.
|
||||
mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, sanitizedSize(size), m_pixelRatio, *m_threadPool,
|
||||
mapOptionsFromQMapboxGLSettings(settings), resourceOptions);
|
||||
mapObj = std::make_unique<mbgl::Map>(*this, *m_mapObserver, m_pixelRatio, *m_threadPool,
|
||||
mapOptionsFromQMapboxGLSettings(settings, size), resourceOptions);
|
||||
|
||||
if (settings.resourceTransform()) {
|
||||
m_resourceTransform = std::make_unique<mbgl::Actor<mbgl::ResourceTransform>>(*mbgl::Scheduler::GetCurrent(),
|
||||
|
||||
@@ -29,12 +29,11 @@ using namespace style;
|
||||
|
||||
Map::Map(RendererFrontend& frontend,
|
||||
MapObserver& observer,
|
||||
const Size size,
|
||||
const float pixelRatio,
|
||||
Scheduler& scheduler,
|
||||
const MapOptions& mapOptions,
|
||||
const ResourceOptions& resourceOptions)
|
||||
: impl(std::make_unique<Impl>(frontend, observer, scheduler, size, pixelRatio,
|
||||
: impl(std::make_unique<Impl>(frontend, observer, scheduler, pixelRatio,
|
||||
FileSource::getSharedFileSource(resourceOptions), mapOptions)) {}
|
||||
|
||||
Map::Map(std::unique_ptr<Impl> impl_) : impl(std::move(impl_)) {}
|
||||
@@ -308,47 +307,36 @@ BoundOptions Map::getBounds() const {
|
||||
.withMaxZoom(impl->transform.getState().getMaxZoom());
|
||||
}
|
||||
|
||||
#pragma mark - Size
|
||||
#pragma mark - Map options
|
||||
|
||||
void Map::setSize(const Size size) {
|
||||
impl->transform.resize(size);
|
||||
impl->onUpdate();
|
||||
}
|
||||
|
||||
Size Map::getSize() const {
|
||||
return impl->transform.getState().getSize();
|
||||
}
|
||||
|
||||
#pragma mark - North Orientation
|
||||
|
||||
void Map::setNorthOrientation(NorthOrientation orientation) {
|
||||
impl->transform.setNorthOrientation(orientation);
|
||||
impl->onUpdate();
|
||||
}
|
||||
|
||||
#pragma mark - Constrain mode
|
||||
|
||||
void Map::setConstrainMode(mbgl::ConstrainMode mode) {
|
||||
impl->transform.setConstrainMode(mode);
|
||||
impl->onUpdate();
|
||||
}
|
||||
|
||||
#pragma mark - Viewport mode
|
||||
|
||||
void Map::setViewportMode(mbgl::ViewportMode mode) {
|
||||
impl->transform.setViewportMode(mode);
|
||||
impl->onUpdate();
|
||||
}
|
||||
|
||||
#pragma mark - Map options
|
||||
|
||||
MapOptions Map::getMapOptions() const {
|
||||
return std::move(MapOptions()
|
||||
.withMapMode(impl->mode)
|
||||
.withConstrainMode(impl->transform.getConstrainMode())
|
||||
.withViewportMode(impl->transform.getViewportMode())
|
||||
.withCrossSourceCollisions(impl->crossSourceCollisions)
|
||||
.withNorthOrientation(impl->transform.getNorthOrientation()));
|
||||
.withNorthOrientation(impl->transform.getNorthOrientation())
|
||||
.withSize(impl->transform.getState().getSize()));
|
||||
}
|
||||
|
||||
#pragma mark - Projection mode
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace mbgl {
|
||||
Map::Impl::Impl(RendererFrontend& frontend_,
|
||||
MapObserver& observer_,
|
||||
Scheduler& scheduler_,
|
||||
Size size_,
|
||||
float pixelRatio_,
|
||||
std::shared_ptr<FileSource> fileSource_,
|
||||
const MapOptions& mapOptions)
|
||||
@@ -27,7 +26,7 @@ Map::Impl::Impl(RendererFrontend& frontend_,
|
||||
transform.setNorthOrientation(mapOptions.northOrientation());
|
||||
style->impl->setObserver(this);
|
||||
rendererFrontend.setObserver(*this);
|
||||
transform.resize(size_);
|
||||
transform.resize(mapOptions.size());
|
||||
}
|
||||
|
||||
Map::Impl::~Impl() {
|
||||
|
||||
@@ -30,7 +30,7 @@ struct StillImageRequest {
|
||||
|
||||
class Map::Impl : public style::Observer, public RendererObserver {
|
||||
public:
|
||||
Impl(RendererFrontend&, MapObserver&, Scheduler&, Size size, float pixelRatio, std::shared_ptr<FileSource>, const MapOptions&);
|
||||
Impl(RendererFrontend&, MapObserver&, Scheduler&, float pixelRatio, std::shared_ptr<FileSource>, const MapOptions&);
|
||||
~Impl() final;
|
||||
|
||||
// StyleObserver
|
||||
|
||||
@@ -9,6 +9,7 @@ public:
|
||||
ViewportMode viewportMode = ViewportMode::Default;
|
||||
NorthOrientation orientation = NorthOrientation::Upwards;
|
||||
bool crossSourceCollisions = true;
|
||||
Size size;
|
||||
};
|
||||
|
||||
// These requires the complete type of Impl.
|
||||
@@ -61,4 +62,13 @@ NorthOrientation MapOptions::northOrientation() const {
|
||||
return impl_->orientation;
|
||||
}
|
||||
|
||||
MapOptions& MapOptions::withSize(Size size_) {
|
||||
impl_->size = size_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Size MapOptions::size() const {
|
||||
return impl_->size;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
float pixelRatio { 1 };
|
||||
HeadlessFrontend frontend { pixelRatio, threadPool };
|
||||
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, std::make_shared<StubFileSource>(),
|
||||
threadPool, MapOptions().withMapMode(MapMode::Static)};
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, 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,
|
||||
|
||||
@@ -25,9 +25,9 @@ TEST(API, RenderWithoutCallback) {
|
||||
float pixelRatio { 1 };
|
||||
HeadlessFrontend frontend { pixelRatio, threadPool };
|
||||
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(), frontend.getSize(),
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
|
||||
pixelRatio, std::make_shared<StubFileSource>(), threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static));
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
map->renderStill(nullptr);
|
||||
|
||||
// Force Map thread to join.
|
||||
|
||||
@@ -23,8 +23,8 @@ TEST(CustomGeometrySource, Grid) {
|
||||
auto threadPool = sharedThreadPool();
|
||||
float pixelRatio { 1 };
|
||||
HeadlessFrontend frontend { pixelRatio, *threadPool };
|
||||
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, *threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static),
|
||||
Map map(frontend, MapObserver::nullObserver(), pixelRatio, *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"));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
|
||||
|
||||
@@ -93,8 +93,8 @@ TEST(CustomLayer, Basic) {
|
||||
ThreadPool threadPool(4);
|
||||
float pixelRatio { 1 };
|
||||
HeadlessFrontend frontend { pixelRatio, threadPool };
|
||||
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static),
|
||||
Map map(frontend, MapObserver::nullObserver(), pixelRatio, 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"));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
|
||||
|
||||
@@ -38,8 +38,8 @@ public:
|
||||
ThreadPool threadPool { 4 };
|
||||
float pixelRatio { 1 };
|
||||
HeadlessFrontend frontend { pixelRatio, threadPool };
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
|
||||
threadPool, MapOptions().withMapMode(MapMode::Static)};
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, fileSource,
|
||||
threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())};
|
||||
};
|
||||
|
||||
std::vector<Feature> getTopClusterFeature(QueryTest& test) {
|
||||
|
||||
@@ -27,9 +27,9 @@ TEST(API, RecycleMapUpdateImages) {
|
||||
float pixelRatio { 1 };
|
||||
|
||||
HeadlessFrontend frontend { pixelRatio, threadPool };
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(), frontend.getSize(),
|
||||
auto map = std::make_unique<MapAdapter>(frontend, MapObserver::nullObserver(),
|
||||
pixelRatio, std::make_shared<StubFileSource>(), threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static));
|
||||
MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
|
||||
EXPECT_TRUE(map);
|
||||
|
||||
|
||||
@@ -91,8 +91,8 @@ TEST(GLContextMode, Shared) {
|
||||
|
||||
HeadlessFrontend frontend { pixelRatio, threadPool, {}, GLContextMode::Shared };
|
||||
|
||||
Map map(frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Static),
|
||||
Map map(frontend, MapObserver::nullObserver(), pixelRatio, 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"));
|
||||
map.jumpTo(CameraOptions().withCenter(LatLng { 37.8, -122.5 }).withZoom(10.0));
|
||||
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static)
|
||||
: fileSource(std::make_shared<FileSource>())
|
||||
, frontend(pixelRatio, threadPool)
|
||||
, map(frontend, observer, frontend.getSize(), pixelRatio,
|
||||
fileSource, threadPool, MapOptions().withMapMode(mode)) {}
|
||||
, map(frontend, observer, pixelRatio,
|
||||
fileSource, threadPool, MapOptions().withMapMode(mode).withSize(frontend.getSize())) {}
|
||||
|
||||
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, frontend.getSize(), pixelRatio,
|
||||
fileSource, threadPool, MapOptions().withMapMode(mode)) {}
|
||||
, map(frontend, observer, pixelRatio,
|
||||
fileSource, threadPool, MapOptions().withMapMode(mode).withSize(frontend.getSize())) {}
|
||||
};
|
||||
|
||||
TEST(Map, RendererState) {
|
||||
@@ -85,7 +85,7 @@ TEST(Map, RendererState) {
|
||||
const ScreenCoordinate& point = test.frontend.pixelForLatLng(coordinate);
|
||||
EXPECT_NEAR(coordinate.latitude(), latLng.latitude(), 1e-1);
|
||||
EXPECT_NEAR(coordinate.longitude(), latLng.longitude(), 1e-1);
|
||||
const Size size = test.map.getSize();
|
||||
const Size size = test.map.getMapOptions().size();
|
||||
EXPECT_NEAR(point.x, size.width / 2.0, 1e-7);
|
||||
EXPECT_NEAR(point.y, size.height / 2.0, 1e-7);
|
||||
}
|
||||
@@ -221,9 +221,10 @@ TEST(Map, CameraToLatLngBounds) {
|
||||
|
||||
test.map.jumpTo(CameraOptions().withCenter(LatLng { 45, 90 }).withZoom(16.0));
|
||||
|
||||
const Size size = test.map.getMapOptions().size();
|
||||
LatLngBounds bounds = LatLngBounds::hull(
|
||||
test.map.latLngForPixel({}),
|
||||
test.map.latLngForPixel({ double(test.map.getSize().width), double(test.map.getSize().height) }));
|
||||
test.map.latLngForPixel({ double(size.width), double(size.height) }));
|
||||
|
||||
CameraOptions camera = test.map.getCameraOptions();
|
||||
|
||||
@@ -734,8 +735,8 @@ TEST(Map, TEST_DISABLED_ON_CI(ContinuousRendering)) {
|
||||
});
|
||||
};
|
||||
|
||||
Map map(frontend, observer, frontend.getSize(), pixelRatio, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Continuous),
|
||||
Map map(frontend, observer, pixelRatio, 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,8 +37,8 @@ TEST(Map, PrefetchTiles) {
|
||||
};
|
||||
|
||||
HeadlessFrontend frontend { { 512, 512 }, 1, threadPool };
|
||||
MapAdapter map(frontend, observer, frontend.getSize(), 1, fileSource, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Continuous));
|
||||
MapAdapter map(frontend, observer, 1, fileSource, threadPool,
|
||||
MapOptions().withMapMode(MapMode::Continuous).withSize(frontend.getSize()));
|
||||
|
||||
std::vector<int> tiles;
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@ class MapAdapter : public Map {
|
||||
public:
|
||||
explicit MapAdapter(RendererFrontend& frontend,
|
||||
MapObserver& observer,
|
||||
Size size,
|
||||
float ratio,
|
||||
std::shared_ptr<FileSource> fileSource,
|
||||
Scheduler& scheduler,
|
||||
const MapOptions& options)
|
||||
: Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, size, ratio, std::move(fileSource), options)) {}
|
||||
: Map(std::make_unique<Map::Impl>(frontend, observer, scheduler, ratio, std::move(fileSource), options)) {}
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
ThreadPool threadPool { 4 };
|
||||
float pixelRatio { 1 };
|
||||
HeadlessFrontend frontend;
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), frontend.getSize(), pixelRatio, fileSource,
|
||||
threadPool, MapOptions().withMapMode(MapMode::Static)};
|
||||
MapAdapter map { frontend, MapObserver::nullObserver(), pixelRatio, 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(), frontend.getSize(), ratio, test.fileSource,
|
||||
test.threadPool, MapOptions().withMapMode(MapMode::Static));
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), ratio, test.fileSource,
|
||||
test.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
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(), frontend.getSize(), ratio, test.fileSource,
|
||||
test.threadPool, MapOptions().withMapMode(MapMode::Static));
|
||||
MapAdapter map(frontend, MapObserver::nullObserver(), ratio, test.fileSource,
|
||||
test.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize()));
|
||||
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(), frontend.getSize(), 2, test_.fileSource
|
||||
, test_.threadPool, MapOptions().withMapMode(MapMode::Static)) {
|
||||
, map(frontend, MapObserver::nullObserver(), 2, test_.fileSource
|
||||
, test_.threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())) {
|
||||
map.jumpTo(CameraOptions().withZoom(16));
|
||||
map.getStyle().loadURL(style);
|
||||
frontend.render(map);
|
||||
|
||||
Reference in New Issue
Block a user