summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer
diff options
context:
space:
mode:
authorJuha Alanen <juha.alanen@mapbox.com>2019-08-21 14:39:36 +0300
committerJuha Alanen <19551460+jmalanen@users.noreply.github.com>2019-09-18 14:29:15 +0300
commit8e19be9d9c7f66bff16f97066570e990fe09fd4e (patch)
tree5e63da429ae71040e160748e868b06716ff1b6b3 /src/mbgl/renderer
parent46eab5f1488570262b218dfaec99c476829ab21f (diff)
downloadqtlocation-mapboxgl-8e19be9d9c7f66bff16f97066570e990fe09fd4e.tar.gz
[core] Add support for set/getFeatureState APIs
Diffstat (limited to 'src/mbgl/renderer')
-rw-r--r--src/mbgl/renderer/render_orchestrator.cpp18
-rw-r--r--src/mbgl/renderer/render_orchestrator.hpp10
-rw-r--r--src/mbgl/renderer/render_source.hpp8
-rw-r--r--src/mbgl/renderer/renderer.cpp14
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.cpp13
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.hpp10
6 files changed, 73 insertions, 0 deletions
diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp
index a62ccb0a0a..fbf98500b4 100644
--- a/src/mbgl/renderer/render_orchestrator.cpp
+++ b/src/mbgl/renderer/render_orchestrator.cpp
@@ -562,6 +562,24 @@ FeatureExtensionValue RenderOrchestrator::queryFeatureExtensions(const std::stri
return {};
}
+void RenderOrchestrator::setFeatureState(const std::string& sourceID,
+ const optional<std::string>& sourceLayerID,
+ const std::string& featureID,
+ const FeatureState& state) {
+ if (RenderSource* renderSource = getRenderSource(sourceID)) {
+ renderSource->setFeatureState(sourceLayerID, featureID, state);
+ }
+}
+
+void RenderOrchestrator::getFeatureState(FeatureState& state,
+ const std::string& sourceID,
+ const optional<std::string>& sourceLayerID,
+ const std::string& featureID) const {
+ if (RenderSource* renderSource = getRenderSource(sourceID)) {
+ renderSource->getFeatureState(state, sourceLayerID, featureID);
+ }
+}
+
void RenderOrchestrator::reduceMemoryUse() {
filteredLayersForSource.shrink_to_fit();
for (const auto& entry : renderSources) {
diff --git a/src/mbgl/renderer/render_orchestrator.hpp b/src/mbgl/renderer/render_orchestrator.hpp
index 884bd21b7b..7467e0c7dd 100644
--- a/src/mbgl/renderer/render_orchestrator.hpp
+++ b/src/mbgl/renderer/render_orchestrator.hpp
@@ -64,6 +64,16 @@ public:
const std::string& extensionField,
const optional<std::map<std::string, Value>>& args) const;
+ void setFeatureState(const std::string& sourceID,
+ const optional<std::string>& layerID,
+ const std::string& featureID,
+ const FeatureState& state);
+
+ void getFeatureState(FeatureState& state,
+ const std::string& sourceID,
+ const optional<std::string>& layerID,
+ const std::string& featureID) const;
+
void reduceMemoryUse();
void dumpDebugLogs();
diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp
index cd471223a8..c803c82c95 100644
--- a/src/mbgl/renderer/render_source.hpp
+++ b/src/mbgl/renderer/render_source.hpp
@@ -93,6 +93,14 @@ public:
return {};
}
+ virtual void setFeatureState(const optional<std::string>&,
+ const std::string&,
+ const FeatureState&) {}
+
+ virtual void getFeatureState(FeatureState&,
+ const optional<std::string>&,
+ const std::string&) const {}
+
virtual void reduceMemoryUse() = 0;
virtual void dumpDebugLogs() const = 0;
diff --git a/src/mbgl/renderer/renderer.cpp b/src/mbgl/renderer/renderer.cpp
index 52cd7a4351..40b342b1d4 100644
--- a/src/mbgl/renderer/renderer.cpp
+++ b/src/mbgl/renderer/renderer.cpp
@@ -109,6 +109,20 @@ FeatureExtensionValue Renderer::queryFeatureExtensions(const std::string& source
return impl->orchestrator.queryFeatureExtensions(sourceID, feature, extension, extensionField, args);
}
+void Renderer::setFeatureState(const std::string& sourceID,
+ const optional<std::string>& sourceLayerID,
+ const std::string& featureID,
+ const FeatureState& state) {
+ impl->orchestrator.setFeatureState(sourceID, sourceLayerID, featureID, state);
+}
+
+void Renderer::getFeatureState(FeatureState& state,
+ const std::string& sourceID,
+ const optional<std::string>& sourceLayerID,
+ const std::string& featureID) const {
+ impl->orchestrator.getFeatureState(state, sourceID, sourceLayerID, featureID);
+}
+
void Renderer::dumpDebugLogs() {
impl->orchestrator.dumpDebugLogs();
}
diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp
index c5afb38435..6859c454f3 100644
--- a/src/mbgl/renderer/sources/render_tile_source.cpp
+++ b/src/mbgl/renderer/sources/render_tile_source.cpp
@@ -68,6 +68,7 @@ void RenderTileSource::prepare(const SourcePrepareParameters& parameters) {
tiles->emplace_back(entry.first, entry.second);
tiles->back().prepare(parameters);
}
+ featureState.coalesceChanges(*tiles);
renderTiles = std::move(tiles);
}
@@ -133,6 +134,18 @@ std::vector<Feature> RenderTileSource::querySourceFeatures(const SourceQueryOpti
return tilePyramid.querySourceFeatures(options);
}
+void RenderTileSource::setFeatureState(const optional<std::string>& sourceLayerID,
+ const std::string& featureID,
+ const FeatureState& state) {
+ featureState.updateState(sourceLayerID, featureID, state);
+}
+
+void RenderTileSource::getFeatureState(FeatureState& state,
+ const optional<std::string>& sourceLayerID,
+ const std::string& featureID) const {
+ featureState.getState(state, sourceLayerID, featureID);
+}
+
void RenderTileSource::reduceMemoryUse() {
tilePyramid.reduceMemoryUse();
}
diff --git a/src/mbgl/renderer/sources/render_tile_source.hpp b/src/mbgl/renderer/sources/render_tile_source.hpp
index 7edff726d5..822b2cac16 100644
--- a/src/mbgl/renderer/sources/render_tile_source.hpp
+++ b/src/mbgl/renderer/sources/render_tile_source.hpp
@@ -3,6 +3,7 @@
#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/tile_pyramid.hpp>
#include <mbgl/style/sources/vector_source_impl.hpp>
+#include <mbgl/renderer/source_state.hpp>
namespace mbgl {
@@ -34,6 +35,14 @@ public:
std::vector<Feature>
querySourceFeatures(const SourceQueryOptions&) const override;
+ virtual void setFeatureState(const optional<std::string>&,
+ const std::string&,
+ const FeatureState&) override;
+
+ virtual void getFeatureState(FeatureState& state,
+ const optional<std::string>&,
+ const std::string&) const override;
+
void reduceMemoryUse() override;
void dumpDebugLogs() const override;
@@ -44,6 +53,7 @@ protected:
mutable RenderTiles filteredRenderTiles;
mutable RenderTiles renderTilesSortedByY;
float bearing = 0.0f;
+ SourceFeatureState featureState;
};
/**