summaryrefslogtreecommitdiff
path: root/render-test
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-05 12:05:03 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-03-05 16:12:43 +0200
commitc5155dcf334a5c5125c065e4447cb8b30989e5e5 (patch)
tree2592e57eab0b73368fe47c2cb83b83ca896d8a00 /render-test
parentdc510e44c085e87233b628a995b6957ad9c0ab9b (diff)
downloadqtlocation-mapboxgl-c5155dcf334a5c5125c065e4447cb8b30989e5e5.tar.gz
[render test runner] Enable pixel ratio in tile mode
Diffstat (limited to 'render-test')
-rw-r--r--render-test/parser.cpp51
-rw-r--r--render-test/runner.cpp15
2 files changed, 39 insertions, 27 deletions
diff --git a/render-test/parser.cpp b/render-test/parser.cpp
index 8147852c4f..e5c5a1edc9 100644
--- a/render-test/parser.cpp
+++ b/render-test/parser.cpp
@@ -466,14 +466,42 @@ TestMetadata parseTestMetadata(const TestPaths& paths) {
const mbgl::JSValue& testValue = metadataValue["test"];
+ if (testValue.HasMember("mapMode")) {
+ metadata.outputsImage = true;
+ assert(testValue["mapMode"].IsString());
+ std::string mapModeStr = testValue["mapMode"].GetString();
+ if (mapModeStr == "tile") {
+ metadata.mapMode = mbgl::MapMode::Tile;
+ // In the tile mode, map is showing exactly one tile.
+ metadata.size = {uint32_t(mbgl::util::tileSize), uint32_t(mbgl::util::tileSize)};
+ } else if (mapModeStr == "continuous") {
+ metadata.mapMode = mbgl::MapMode::Continuous;
+ metadata.outputsImage = false;
+ } else if (mapModeStr == "static")
+ metadata.mapMode = mbgl::MapMode::Static;
+ else {
+ mbgl::Log::Warning(
+ mbgl::Event::ParseStyle, "Unknown map mode: %s. Falling back to static mode", mapModeStr.c_str());
+ metadata.mapMode = mbgl::MapMode::Static;
+ }
+ }
+
if (testValue.HasMember("width")) {
assert(testValue["width"].IsNumber());
- metadata.size.width = testValue["width"].GetInt();
+ if (metadata.mapMode == mbgl::MapMode::Tile) {
+ mbgl::Log::Warning(mbgl::Event::ParseStyle, "The 'width' metadata field is ignored in tile map mode");
+ } else {
+ metadata.size.width = testValue["width"].GetInt();
+ }
}
if (testValue.HasMember("height")) {
assert(testValue["height"].IsNumber());
- metadata.size.height = testValue["height"].GetInt();
+ if (metadata.mapMode == mbgl::MapMode::Tile) {
+ mbgl::Log::Warning(mbgl::Event::ParseStyle, "The 'height' metadata field is ignored in tile map mode");
+ } else {
+ metadata.size.height = testValue["height"].GetInt();
+ }
}
if (testValue.HasMember("pixelRatio")) {
@@ -492,25 +520,6 @@ TestMetadata parseTestMetadata(const TestPaths& paths) {
std::string{testValue["description"].GetString(), testValue["description"].GetStringLength()};
}
- if (testValue.HasMember("mapMode")) {
- metadata.outputsImage = true;
- assert(testValue["mapMode"].IsString());
- std::string mapModeStr = testValue["mapMode"].GetString();
- if (mapModeStr == "tile") {
- metadata.mapMode = mbgl::MapMode::Tile;
- metadata.size = {uint32_t(mbgl::util::tileSize), uint32_t(mbgl::util::tileSize)};
- } else if (mapModeStr == "continuous") {
- metadata.mapMode = mbgl::MapMode::Continuous;
- metadata.outputsImage = false;
- } else if (mapModeStr == "static")
- metadata.mapMode = mbgl::MapMode::Static;
- else {
- mbgl::Log::Warning(
- mbgl::Event::ParseStyle, "Unknown map mode: %s. Falling back to static mode", mapModeStr.c_str());
- metadata.mapMode = mbgl::MapMode::Static;
- }
- }
-
// Test operations handled in runner.cpp.
if (testValue.HasMember("debug")) {
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index 3f59b6df4c..b700b449fa 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -658,15 +658,17 @@ LatLng getTileCenterCoordinates(const UnwrappedTileID& tileId) {
return Projection::unproject(tileCenter, scale);
}
-constexpr auto kTileSizeUint = uint32_t(util::tileSize);
+uint32_t getTileScreenPixelSize(float pixelRatio) {
+ return util::tileSize * pixelRatio;
+}
-uint32_t getImageTileOffset(const std::set<uint32_t>& dims, uint32_t dim) {
+uint32_t getImageTileOffset(const std::set<uint32_t>& dims, uint32_t dim, float pixelRatio) {
auto it = dims.find(dim);
if (it == dims.end()) {
assert(false);
return 0;
}
- return static_cast<uint32_t>(std::distance(dims.begin(), it)) * kTileSizeUint;
+ return static_cast<uint32_t>(std::distance(dims.begin(), it)) * getTileScreenPixelSize(pixelRatio);
}
} // namespace
@@ -757,9 +759,10 @@ void TestRunner::run(TestMetadata& metadata) {
yDims.insert(tileId.canonical.y);
assert(tileId.canonical.z == uint8_t(*camera.zoom));
}
+ auto tileScreenSize = getTileScreenPixelSize(metadata.pixelRatio);
result.image =
- PremultipliedImage({uint32_t(xDims.size()) * kTileSizeUint, uint32_t(yDims.size()) * kTileSizeUint});
+ PremultipliedImage({uint32_t(xDims.size()) * tileScreenSize, uint32_t(yDims.size()) * tileScreenSize});
for (const auto& tileId : tileIds) {
resetContext(metadata, ctx);
auto cameraForTile{camera};
@@ -772,8 +775,8 @@ void TestRunner::run(TestMetadata& metadata) {
return;
}
- auto xOffset = getImageTileOffset(xDims, tileId.canonical.x);
- auto yOffset = getImageTileOffset(yDims, tileId.canonical.y);
+ auto xOffset = getImageTileOffset(xDims, tileId.canonical.x, metadata.pixelRatio);
+ auto yOffset = getImageTileOffset(yDims, tileId.canonical.y, metadata.pixelRatio);
PremultipliedImage::copy(
resultForTile.image, result.image, {0, 0}, {xOffset, yOffset}, resultForTile.image.size);
result.stats += resultForTile.stats;