From 7af00a404f22742fed4a83e9a36d023d7515025f Mon Sep 17 00:00:00 2001 From: Sudarsana Babu Nagineni Date: Wed, 27 Mar 2019 19:17:04 +0200 Subject: [core] Include pixelRatio property in MapOptions Move pixelRatio property from Map constructor to MapOptions. --- test/api/annotations.test.cpp | 7 +++---- test/api/api_misuse.test.cpp | 5 ++--- test/api/custom_geometry_source.test.cpp | 5 ++--- test/api/custom_layer.test.cpp | 5 ++--- test/api/query.test.cpp | 7 +++---- test/api/recycle_map.cpp | 5 ++--- test/gl/context.test.cpp | 5 ++--- test/map/map.test.cpp | 18 ++++++++++-------- test/map/prefetch.test.cpp | 2 +- test/src/mbgl/test/map_adapter.hpp | 3 +-- test/text/local_glyph_rasterizer.test.cpp | 7 +++---- test/util/memory.test.cpp | 12 ++++++------ 12 files changed, 37 insertions(+), 44 deletions(-) (limited to 'test') diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp index 612c4f0ab8..11920d1624 100644 --- a/test/api/annotations.test.cpp +++ b/test/api/annotations.test.cpp @@ -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(), - threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())}; + MapAdapter map { frontend, MapObserver::nullObserver(), std::make_shared(), threadPool, + MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())}; void checkRendering(const char * name) { test::checkImage(std::string("test/fixtures/annotations/") + name, diff --git a/test/api/api_misuse.test.cpp b/test/api/api_misuse.test.cpp index 17eb2de14b..cca47de69c 100644 --- a/test/api/api_misuse.test.cpp +++ b/test/api/api_misuse.test.cpp @@ -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(frontend, MapObserver::nullObserver(), - pixelRatio, std::make_shared(), threadPool, + std::make_shared(), threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())); map->renderStill(nullptr); diff --git a/test/api/custom_geometry_source.test.cpp b/test/api/custom_geometry_source.test.cpp index 679291372d..f796e3086b 100644 --- a/test/api/custom_geometry_source.test.cpp +++ b/test/api/custom_geometry_source.test.cpp @@ -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")); diff --git a/test/api/custom_layer.test.cpp b/test/api/custom_layer.test.cpp index 4f1429d637..c836ab81ac 100644 --- a/test/api/custom_layer.test.cpp +++ b/test/api/custom_layer.test.cpp @@ -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")); diff --git a/test/api/query.test.cpp b/test/api/query.test.cpp index 0dd9882be2..ddf5df6aab 100644 --- a/test/api/query.test.cpp +++ b/test/api/query.test.cpp @@ -36,10 +36,9 @@ public: util::RunLoop loop; std::shared_ptr fileSource = std::make_shared(); 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 getTopClusterFeature(QueryTest& test) { diff --git a/test/api/recycle_map.cpp b/test/api/recycle_map.cpp index 6f1560d463..ac9de9b230 100644 --- a/test/api/recycle_map.cpp +++ b/test/api/recycle_map.cpp @@ -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(frontend, MapObserver::nullObserver(), - pixelRatio, std::make_shared(), threadPool, + std::make_shared(), threadPool, MapOptions().withMapMode(MapMode::Static).withSize(frontend.getSize())); EXPECT_TRUE(map); diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp index d9b2750a95..291813bd9a 100644 --- a/test/gl/context.test.cpp +++ b/test/gl/context.test.cpp @@ -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")); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index d443b5eacc..be92890b07 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -41,8 +41,8 @@ public: MapTest(float pixelRatio = 1, MapMode mode = MapMode::Static) : fileSource(std::make_shared()) , 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 MapTest(const std::string& cachePath, const std::string& assetPath, @@ -50,8 +50,8 @@ public: typename std::enable_if::value>::type* = 0) : fileSource(std::make_shared(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")); diff --git a/test/map/prefetch.test.cpp b/test/map/prefetch.test.cpp index 520228e010..3232c99a22 100644 --- a/test/map/prefetch.test.cpp +++ b/test/map/prefetch.test.cpp @@ -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 tiles; diff --git a/test/src/mbgl/test/map_adapter.hpp b/test/src/mbgl/test/map_adapter.hpp index 67abea953d..5bdab1d164 100644 --- a/test/src/mbgl/test/map_adapter.hpp +++ b/test/src/mbgl/test/map_adapter.hpp @@ -12,11 +12,10 @@ class MapAdapter : public Map { public: explicit MapAdapter(RendererFrontend& frontend, MapObserver& observer, - float ratio, std::shared_ptr fileSource, Scheduler& scheduler, const MapOptions& options) - : Map(std::make_unique(frontend, observer, scheduler, ratio, std::move(fileSource), options)) {} + : Map(std::make_unique(frontend, observer, scheduler, std::move(fileSource), options)) {} }; } // namespace mbgl diff --git a/test/text/local_glyph_rasterizer.test.cpp b/test/text/local_glyph_rasterizer.test.cpp index ac272e2f9f..26e4a2eb1d 100644 --- a/test/text/local_glyph_rasterizer.test.cpp +++ b/test/text/local_glyph_rasterizer.test.cpp @@ -34,17 +34,16 @@ namespace { class LocalGlyphRasterizerTest { public: LocalGlyphRasterizerTest(const optional fontFamily) - : frontend(pixelRatio, threadPool, optional(), GLContextMode::Unique, fontFamily) + : frontend(1, threadPool, optional(), GLContextMode::Unique, fontFamily) { } util::RunLoop loop; std::shared_ptr fileSource = std::make_shared(); 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, diff --git a/test/util/memory.test.cpp b/test/util/memory.test.cpp index 03545c648b..e3ad976432 100644 --- a/test/util/memory.test.cpp +++ b/test/util/memory.test.cpp @@ -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); -- cgit v1.2.1