diff options
-rw-r--r-- | common/headless_view.cpp | 5 | ||||
-rw-r--r-- | common/headless_view.hpp | 2 | ||||
-rw-r--r-- | test/headless.cpp | 15 |
3 files changed, 15 insertions, 7 deletions
diff --git a/common/headless_view.cpp b/common/headless_view.cpp index f790d90cec..ed00f48e82 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -65,9 +65,12 @@ HeadlessView::HeadlessView() { } -void HeadlessView::resize(int width, int height) { +void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { clear_buffers(); + width *= pixelRatio; + height *= pixelRatio; + #if MBGL_USE_CGL make_active(); diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 0b255b4a38..a8ce4aa325 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -19,7 +19,7 @@ public: HeadlessView(); ~HeadlessView(); - void resize(int width, int height); + void resize(uint16_t width, uint16_t height, float pixelRatio); void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); diff --git a/test/headless.cpp b/test/headless.cpp index 4299fd79b9..3cc2607e47 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -65,6 +65,8 @@ TEST_P(HeadlessTest, render) { const double longitude = value.HasMember("center") ? value["center"][rapidjson::SizeType(1)].GetDouble() : 0; const unsigned int width = value.HasMember("width") ? value["width"].GetUint() : 512; const unsigned int height = value.HasMember("height") ? value["height"].GetUint() : 512; + const unsigned int pixelRatio = value.HasMember("pixelRatio") ? value["pixelRatio"].GetUint() : 1; + std::vector<std::string> classes; if (value.HasMember("classes")) { const rapidjson::Value &js_classes = value["classes"]; @@ -82,18 +84,21 @@ TEST_P(HeadlessTest, render) { map.setStyleJSON(style, base_directory); map.setAppliedClasses(classes); - view.resize(width, height); - map.resize(width, height); + view.resize(width, height, pixelRatio); + map.resize(width, height, pixelRatio); map.setLonLatZoom(longitude, latitude, zoom); map.setBearing(bearing); // Run the loop. It will terminate when we don't have any further listeners. map.run(); - const std::unique_ptr<uint32_t[]> pixels(new uint32_t[width * height]); - glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); + const unsigned int w = width * pixelRatio; + const unsigned int h = height * pixelRatio; + + const std::unique_ptr<uint32_t[]> pixels(new uint32_t[w * h]); + glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); - const std::string image = util::compress_png(width, height, pixels.get(), true); + const std::string image = util::compress_png(w, h, pixels.get(), true); util::write_file(actual_image, image); } } |