[core] Include pixelRatio property in MapOptions
Move pixelRatio property from Map constructor to MapOptions.
This commit is contained in:
@@ -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