[core] Add support for set/getFeatureState APIs
This commit is contained in:
@@ -49,6 +49,18 @@ public:
|
||||
const std::string& extensionField,
|
||||
const optional<std::map<std::string, Value>>& args = {}) const;
|
||||
|
||||
void setFeatureState(const std::string& sourceID,
|
||||
const optional<std::string>& sourceLayerID,
|
||||
const std::string& featureID,
|
||||
const FeatureState& state);
|
||||
|
||||
void getFeatureState(FeatureState& state,
|
||||
const std::string& sourceID,
|
||||
const optional<std::string>& sourceLayerID,
|
||||
const std::string& featureID) const;
|
||||
|
||||
|
||||
|
||||
// Debug
|
||||
void dumpDebugLogs();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user