summaryrefslogtreecommitdiff
path: root/render-test/runner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'render-test/runner.cpp')
-rw-r--r--render-test/runner.cpp63
1 files changed, 62 insertions, 1 deletions
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index de43e5ddd8..fe006f3a90 100644
--- a/render-test/runner.cpp
+++ b/render-test/runner.cpp
@@ -30,6 +30,9 @@
#include <utility>
#include <sstream>
+#include <codecvt>
+#include <locale>
+
using namespace mbgl;
using namespace TestOperationNames;
@@ -746,6 +749,9 @@ void TestRunner::run(TestMetadata& metadata) {
auto camera = map.getStyle().getDefaultCamera();
HeadlessFrontend::RenderResult result{};
+ std::string cutOffLabelsReport;
+ std::string duplicationsReport;
+ std::size_t duplicationsCount = 0u;
if (metadata.mapMode == MapMode::Tile) {
assert(camera.zoom);
@@ -754,6 +760,12 @@ void TestRunner::run(TestMetadata& metadata) {
assert(!tileIds.empty());
std::set<uint32_t> xDims;
std::set<uint32_t> yDims;
+ struct SymbolLocationAndStatus {
+ UnwrappedTileID tileId;
+ mapbox::geometry::box<float> location;
+ bool placed;
+ };
+ std::map<std::u16string, std::vector<SymbolLocationAndStatus>> symbolIndex;
for (const auto& tileId : tileIds) {
xDims.insert(tileId.canonical.x);
@@ -766,6 +778,7 @@ void TestRunner::run(TestMetadata& metadata) {
PremultipliedImage({uint32_t(xDims.size()) * tileScreenSize, uint32_t(yDims.size()) * tileScreenSize});
for (const auto& tileId : tileIds) {
resetContext(metadata, ctx);
+ ctx.getFrontend().getRenderer()->collectPlacedSymbolData(true);
auto cameraForTile{camera};
cameraForTile.withCenter(getTileCenterCoordinates(tileId));
map.jumpTo(cameraForTile);
@@ -775,9 +788,49 @@ void TestRunner::run(TestMetadata& metadata) {
metadata.errorMessage = "Failed rendering tile: " + util::toString(tileId);
return;
}
-
auto xOffset = getImageTileOffset(xDims, tileId.canonical.x, metadata.pixelRatio);
auto yOffset = getImageTileOffset(yDims, tileId.canonical.y, metadata.pixelRatio);
+
+ const auto& placedSymbols = ctx.getFrontend().getRenderer()->getPlacedSymbolsData();
+ for (const auto& placedSymbol : placedSymbols) {
+ if (placedSymbol.intersectsTileBorder) {
+ if (placedSymbol.textCollisionBox) {
+ mapbox::geometry::box<float> box = *placedSymbol.textCollisionBox;
+ box.min.x += xOffset - placedSymbol.viewportPadding;
+ box.max.x += xOffset - placedSymbol.viewportPadding;
+ box.min.y += yOffset - placedSymbol.viewportPadding;
+ box.max.y += yOffset - placedSymbol.viewportPadding;
+
+ auto& symbols = symbolIndex[placedSymbol.key];
+ auto it = std::find_if(symbols.begin(), symbols.end(), [box](const auto& a) {
+ return a.location.min == box.min && a.location.max == box.max;
+ });
+
+ static std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> cv;
+ if (it == symbols.end()) {
+ symbols.push_back({tileId, box, placedSymbol.textPlaced});
+ } else if (tileId == it->tileId) {
+ std::stringstream ss;
+ ss << std::endl
+ << ++duplicationsCount << ". \"" << cv.to_bytes(placedSymbol.key) << "\" ((" << box.min.x
+ << ", " << box.min.y << "), (" << box.max.x << ", " << box.max.y << ")) "
+ << "at " << util::toString(tileId);
+ duplicationsReport += ss.str();
+ continue;
+ } else if (it->placed != placedSymbol.textPlaced) {
+ std::stringstream ss;
+ ss << std::endl
+ << ++metadata.labelCutOffFound << ". \"" << cv.to_bytes(placedSymbol.key) << "\" (("
+ << box.min.x << ", " << box.min.y << "), (" << box.max.x << ", " << box.max.y << "))"
+ << (placedSymbol.textPlaced ? " is placed at " : " is not placed at ")
+ << util::toString(tileId) << " and" << (it->placed ? " placed at " : " not placed at ")
+ << util::toString(it->tileId);
+ cutOffLabelsReport += ss.str();
+ }
+ }
+ }
+ }
+
PremultipliedImage::copy(
resultForTile.image, result.image, {0, 0}, {xOffset, yOffset}, resultForTile.image.size);
result.stats += resultForTile.stats;
@@ -796,6 +849,14 @@ void TestRunner::run(TestMetadata& metadata) {
if (metadata.renderTest) {
checkProbingResults(metadata);
+ if (metadata.labelCutOffFound) { // Append label cut-off statistics.
+ metadata.errorMessage += "\n Label cut-offs:";
+ metadata.errorMessage += cutOffLabelsReport;
+ if (duplicationsCount) {
+ metadata.errorMessage += "\n\n Label duplications:";
+ metadata.errorMessage += duplicationsReport;
+ }
+ }
checkRenderTestResults(std::move(result.image), metadata);
} else {
std::vector<mbgl::Feature> features;