summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mbgl/algorithm/update_renderables.cpp10
-rw-r--r--src/mbgl/algorithm/update_renderables.hpp83
-rw-r--r--src/mbgl/algorithm/update_renderables_impl.hpp90
-rw-r--r--src/mbgl/source/source.cpp2
-rw-r--r--test/algorithm/update_renderables.cpp2
5 files changed, 82 insertions, 105 deletions
diff --git a/src/mbgl/algorithm/update_renderables.cpp b/src/mbgl/algorithm/update_renderables.cpp
deleted file mode 100644
index 7b571308c7..0000000000
--- a/src/mbgl/algorithm/update_renderables.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <mbgl/algorithm/update_renderables_impl.hpp>
-#include <mbgl/style/style_layer.hpp>
-
-namespace mbgl {
-namespace algorithm {
-
-//template void updateRenderables(StyleLayer& layer, const uint8_t z);
-
-} // namespace algorithm
-} // namespace mbgl
diff --git a/src/mbgl/algorithm/update_renderables.hpp b/src/mbgl/algorithm/update_renderables.hpp
index 898f9e68d3..8948b8eafe 100644
--- a/src/mbgl/algorithm/update_renderables.hpp
+++ b/src/mbgl/algorithm/update_renderables.hpp
@@ -1,12 +1,89 @@
#pragma once
-#include <cstdint>
+#include <mbgl/tile/tile_id.hpp>
+
+#include <map>
namespace mbgl {
namespace algorithm {
-template <typename Layer>
-void updateRenderables(Layer& layer, const uint8_t z);
+namespace {
+
+template <typename DataTiles, typename Renderables>
+bool tryTile(const UnwrappedTileID& renderTileID,
+ const OverscaledTileID& dataTileID,
+ const DataTiles& dataTiles,
+ Renderables& renderables) {
+ if (renderables.find(renderTileID) == renderables.end()) {
+ const auto it = dataTiles.find(dataTileID);
+ if (it == dataTiles.end() || !it->second->isRenderable()) {
+ return false;
+ }
+
+ using Renderable = typename Renderables::mapped_type;
+ renderables.emplace(renderTileID, Renderable{ renderTileID, *it->second });
+ }
+
+ return true;
+}
+
+} // namespace
+
+template <typename Renderable, typename DataTiles, typename IdealTileIDs, typename SourceInfo>
+std::map<UnwrappedTileID, Renderable> updateRenderables(const DataTiles& dataTiles,
+ const IdealTileIDs& idealTileIDs,
+ const SourceInfo& info,
+ const uint8_t z) {
+ std::map<UnwrappedTileID, Renderable> renderables;
+
+ // for (all in the set of ideal tiles of the source) {
+ for (const auto& renderTileID : idealTileIDs) {
+ assert(renderTileID.canonical.z >= info.minZoom);
+ assert(renderTileID.canonical.z <= info.maxZoom);
+ assert(z >= renderTileID.canonical.z);
+ const auto wrap = renderTileID.wrap;
+ const OverscaledTileID dataTileID(z, renderTileID.canonical);
+
+ // if (source has the tile and bucket is loaded) {
+ if (!tryTile(renderTileID, dataTileID, dataTiles, renderables)) {
+ // The source doesn't have the tile, or the bucket isn't loaded.
+ bool covered = true;
+ int32_t overscaledZ = z + 1;
+ if (overscaledZ > info.maxZoom) {
+ // We're looking for an overzoomed child tile.
+ const auto childDataTileID = dataTileID.scaledTo(overscaledZ);
+ if (!tryTile(renderTileID, childDataTileID, dataTiles, renderables)) {
+ covered = false;
+ }
+ } else {
+ // Check all four actual child tiles.
+ for (const auto& childTileID : dataTileID.canonical.children()) {
+ const OverscaledTileID childDataTileID(overscaledZ, childTileID);
+ const UnwrappedTileID childRenderTileID(wrap, childTileID);
+ if (!tryTile(childRenderTileID, childDataTileID, dataTiles, renderables)) {
+ // At least one child tile doesn't exist, so we are going to look for
+ // parents as well.
+ covered = false;
+ }
+ }
+ }
+
+ if (!covered) {
+ // We couldn't find child tiles that entirely cover the ideal tile.
+ for (overscaledZ = z - 1; overscaledZ >= info.minZoom; --overscaledZ) {
+ const auto parentDataTileID = dataTileID.scaledTo(overscaledZ);
+ const auto parentRenderTileID = parentDataTileID.unwrapTo(renderTileID.wrap);
+ if (tryTile(parentRenderTileID, parentDataTileID, dataTiles, renderables)) {
+ // Break parent tile ascent, since we found one.
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return renderables;
+}
} // namespace algorithm
} // namespace mbgl
diff --git a/src/mbgl/algorithm/update_renderables_impl.hpp b/src/mbgl/algorithm/update_renderables_impl.hpp
deleted file mode 100644
index 0f97801021..0000000000
--- a/src/mbgl/algorithm/update_renderables_impl.hpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#pragma once
-
-#include <mbgl/algorithm/update_renderables.hpp>
-#include <mbgl/tile/tile_id.hpp>
-
-#include <map>
-
-namespace mbgl {
-namespace algorithm {
-
-namespace {
-
-template <typename DataTiles, typename Renderables>
-bool tryTile(const UnwrappedTileID& renderTileID,
- const OverscaledTileID& dataTileID,
- const DataTiles& dataTiles,
- Renderables& renderables) {
- if (renderables.find(renderTileID) == renderables.end()) {
- const auto it = dataTiles.find(dataTileID);
- if (it == dataTiles.end() || !it->second->isRenderable()) {
- return false;
- }
-
- using Renderable = typename Renderables::mapped_type;
- renderables.emplace(renderTileID, Renderable{ renderTileID, *it->second });
- }
-
- return true;
-}
-
-} // namespace
-
-template <typename Renderable, typename DataTiles, typename IdealTileIDs, typename SourceInfo>
-std::map<UnwrappedTileID, Renderable> updateRenderables(const DataTiles& dataTiles,
- const IdealTileIDs& idealTileIDs,
- const SourceInfo& info,
- const uint8_t z) {
- std::map<UnwrappedTileID, Renderable> renderables;
-
- // for (all in the set of ideal tiles of the source) {
- for (const auto& renderTileID : idealTileIDs) {
- assert(renderTileID.canonical.z >= info.minZoom);
- assert(renderTileID.canonical.z <= info.maxZoom);
- assert(z >= renderTileID.canonical.z);
- const auto wrap = renderTileID.wrap;
- const OverscaledTileID dataTileID(z, renderTileID.canonical);
-
- // if (source has the tile and bucket is loaded) {
- if (!tryTile(renderTileID, dataTileID, dataTiles, renderables)) {
- // The source doesn't have the tile, or the bucket isn't loaded.
- bool covered = true;
- int32_t overscaledZ = z + 1;
- if (overscaledZ > info.maxZoom) {
- // We're looking for an overzoomed child tile.
- const auto childDataTileID = dataTileID.scaledTo(overscaledZ);
- if (!tryTile(renderTileID, childDataTileID, dataTiles, renderables)) {
- covered = false;
- }
- } else {
- // Check all four actual child tiles.
- for (const auto& childTileID : dataTileID.canonical.children()) {
- const OverscaledTileID childDataTileID(overscaledZ, childTileID);
- const UnwrappedTileID childRenderTileID(wrap, childTileID);
- if (!tryTile(childRenderTileID, childDataTileID, dataTiles, renderables)) {
- // At least one child tile doesn't exist, so we are going to look for
- // parents as well.
- covered = false;
- }
- }
- }
-
- if (!covered) {
- // We couldn't find child tiles that entirely cover the ideal tile.
- for (overscaledZ = z - 1; overscaledZ >= info.minZoom; --overscaledZ) {
- const auto parentDataTileID = dataTileID.scaledTo(overscaledZ);
- const auto parentRenderTileID = parentDataTileID.unwrapTo(renderTileID.wrap);
- if (tryTile(parentRenderTileID, parentDataTileID, dataTiles, renderables)) {
- // Break parent tile ascent, since we found one.
- break;
- }
- }
- }
- }
- }
-
- return renderables;
-}
-
-} // namespace algorithm
-} // namespace mbgl
diff --git a/src/mbgl/source/source.cpp b/src/mbgl/source/source.cpp
index 365ed9e6ee..5f2b54485b 100644
--- a/src/mbgl/source/source.cpp
+++ b/src/mbgl/source/source.cpp
@@ -27,7 +27,7 @@
#include <mbgl/style/style_parser.hpp>
#include <mbgl/gl/debugging.hpp>
-#include <mbgl/algorithm/update_renderables_impl.hpp>
+#include <mbgl/algorithm/update_renderables.hpp>
#include <mapbox/geojsonvt.hpp>
#include <mapbox/geojsonvt/convert.hpp>
diff --git a/test/algorithm/update_renderables.cpp b/test/algorithm/update_renderables.cpp
index 860381bdfa..704cd770db 100644
--- a/test/algorithm/update_renderables.cpp
+++ b/test/algorithm/update_renderables.cpp
@@ -1,7 +1,7 @@
#include <mbgl/test/util.hpp>
#include "mock.hpp"
-#include <mbgl/algorithm/update_renderables_impl.hpp>
+#include <mbgl/algorithm/update_renderables.hpp>
using namespace mbgl;