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.cpp65
1 files changed, 63 insertions, 2 deletions
diff --git a/render-test/runner.cpp b/render-test/runner.cpp
index de43e5ddd8..aed748e39d 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;
@@ -754,6 +757,15 @@ 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;
+ std::string cutOffError;
+ std::string duplicationError;
+ std::size_t duplicationsCount = 0u;
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,13 +788,61 @@ 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);
+ duplicationError += 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);
+ cutOffError += ss.str();
+ }
+ }
+ }
+ }
+
PremultipliedImage::copy(
resultForTile.image, result.image, {0, 0}, {xOffset, yOffset}, resultForTile.image.size);
result.stats += resultForTile.stats;
}
+ if (metadata.labelCutOffFound) {
+ metadata.errorMessage += "\n Label cut-offs:";
+ metadata.errorMessage += cutOffError;
+ if (duplicationsCount) {
+ metadata.errorMessage += "\n\n Label duplications:";
+ metadata.errorMessage += duplicationError;
+ }
+ }
} else {
map.jumpTo(camera);
result = runTest(metadata, ctx);
@@ -795,7 +856,7 @@ void TestRunner::run(TestMetadata& metadata) {
}
if (metadata.renderTest) {
- checkProbingResults(metadata);
+ // checkProbingResults(metadata);
checkRenderTestResults(std::move(result.image), metadata);
} else {
std::vector<mbgl::Feature> features;