summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mbgl/algorithm/generate_clip_ids_impl.hpp7
-rw-r--r--src/mbgl/renderer/render_tile.hpp1
-rw-r--r--src/mbgl/style/source_impl.cpp6
-rw-r--r--src/mbgl/style/source_impl.hpp2
-rw-r--r--src/mbgl/style/style.cpp1
-rw-r--r--test/algorithm/generate_clip_ids.test.cpp1
-rw-r--r--test/api/annotations.test.cpp29
-rw-r--r--test/fixtures/annotations/debug_empty/expected.pngbin0 -> 1238 bytes
-rw-r--r--test/fixtures/annotations/debug_sparse/expected.pngbin0 -> 2933 bytes
9 files changed, 44 insertions, 3 deletions
diff --git a/src/mbgl/algorithm/generate_clip_ids_impl.hpp b/src/mbgl/algorithm/generate_clip_ids_impl.hpp
index 47f7df12f9..9b550fcbba 100644
--- a/src/mbgl/algorithm/generate_clip_ids_impl.hpp
+++ b/src/mbgl/algorithm/generate_clip_ids_impl.hpp
@@ -15,6 +15,10 @@ void ClipIDGenerator::update(Renderables& renderables) {
for (auto it = renderables.begin(); it != end; it++) {
auto& tileID = it->first;
auto& renderable = it->second;
+ if (!renderable.used) {
+ continue;
+ }
+
renderable.clip = {};
Leaf leaf{ renderable.clip };
@@ -58,6 +62,9 @@ void ClipIDGenerator::update(Renderables& renderables) {
uint8_t count = 1;
for (auto& pair : renderables) {
auto& renderable = pair.second;
+ if (!renderable.used) {
+ continue;
+ }
renderable.clip.mask |= mask;
// Assign only to clip IDs that have no value yet.
diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp
index 74669faaf9..e2e0c3d656 100644
--- a/src/mbgl/renderer/render_tile.hpp
+++ b/src/mbgl/renderer/render_tile.hpp
@@ -24,6 +24,7 @@ public:
Tile& tile;
ClipID clip;
mat4 matrix;
+ bool used = false;
mat4 translatedMatrix(const std::array<float, 2>& translate,
style::TranslateAnchorType anchor,
diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp
index 75668fc3b0..d31a6bf5a4 100644
--- a/src/mbgl/style/source_impl.cpp
+++ b/src/mbgl/style/source_impl.cpp
@@ -70,11 +70,13 @@ void Source::Impl::startRender(algorithm::ClipIDGenerator& generator,
void Source::Impl::finishRender(Painter& painter) {
for (auto& pair : renderTiles) {
auto& tile = pair.second;
- painter.renderTileDebug(tile);
+ if (tile.used) {
+ painter.renderTileDebug(tile);
+ }
}
}
-const std::map<UnwrappedTileID, RenderTile>& Source::Impl::getRenderTiles() const {
+std::map<UnwrappedTileID, RenderTile>& Source::Impl::getRenderTiles() {
return renderTiles;
}
diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp
index 1041ebffed..e6340ae1cb 100644
--- a/src/mbgl/style/source_impl.hpp
+++ b/src/mbgl/style/source_impl.hpp
@@ -63,7 +63,7 @@ public:
const TransformState&);
void finishRender(Painter&);
- const std::map<UnwrappedTileID, RenderTile>& getRenderTiles() const;
+ std::map<UnwrappedTileID, RenderTile>& getRenderTiles();
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const QueryParameters&) const;
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index f14be51392..acbc949b4c 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -404,6 +404,7 @@ RenderData Style::getRenderData(MapDebugOptions debugOptions) const {
auto bucket = tile.tile.getBucket(*layer);
if (bucket) {
result.order.emplace_back(*layer, &tile, bucket);
+ tile.used = true;
}
}
}
diff --git a/test/algorithm/generate_clip_ids.test.cpp b/test/algorithm/generate_clip_ids.test.cpp
index 5b7f4afb26..8ca0191b3a 100644
--- a/test/algorithm/generate_clip_ids.test.cpp
+++ b/test/algorithm/generate_clip_ids.test.cpp
@@ -6,6 +6,7 @@ using namespace mbgl;
struct Renderable {
ClipID clip;
+ bool used = true;
bool operator==(const Renderable& rhs) const {
return clip == rhs.clip;
diff --git a/test/api/annotations.test.cpp b/test/api/annotations.test.cpp
index 06a0a61b0a..b143bd961c 100644
--- a/test/api/annotations.test.cpp
+++ b/test/api/annotations.test.cpp
@@ -419,3 +419,32 @@ TEST(Annotations, VisibleFeatures) {
features.erase(std::unique(features.begin(), features.end(), sameID), features.end());
EXPECT_EQ(features.size(), ids.size());
}
+
+
+TEST(Annotations, DebugEmpty) {
+ // This test should render nothing, not even the tile borders. Tile borders are only rendered
+ // when there is an actual tile we're trying to render, but since there is no annotation, we
+ // should not render them.
+ AnnotationTest test;
+
+ test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ test.map.setDebug(MapDebugOptions::TileBorders);
+ test.map.setZoom(1);
+
+ test.checkRendering("debug_empty");
+}
+
+
+TEST(Annotations, DebugSparse) {
+ // This test should only render the top right tile with the associated tile border, but no other
+ // tiles because they're all empty.
+ AnnotationTest test;
+
+ test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
+ test.map.setDebug(MapDebugOptions::TileBorders);
+ test.map.setZoom(1);
+ test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
+ test.map.addAnnotation(SymbolAnnotation { Point<double>(10, 10), "default_marker" });
+
+ test.checkRendering("debug_sparse");
+}
diff --git a/test/fixtures/annotations/debug_empty/expected.png b/test/fixtures/annotations/debug_empty/expected.png
new file mode 100644
index 0000000000..04f8682f88
--- /dev/null
+++ b/test/fixtures/annotations/debug_empty/expected.png
Binary files differ
diff --git a/test/fixtures/annotations/debug_sparse/expected.png b/test/fixtures/annotations/debug_sparse/expected.png
new file mode 100644
index 0000000000..3c1ad1599c
--- /dev/null
+++ b/test/fixtures/annotations/debug_sparse/expected.png
Binary files differ