[core] Add setFeatureState API to Tile classes

This commit is contained in:
Juha Alanen
2019-08-21 15:27:01 +03:00
committed by Juha Alanen
parent 413278ca20
commit 1ac8e3c161
5 changed files with 35 additions and 1 deletions

View File

@@ -227,4 +227,8 @@ void RenderTile::finishRender(PaintParameters& parameters) const {
}
}
void RenderTile::setFeatureState(const LayerFeatureStates& states) {
tile.setFeatureState(states);
}
} // namespace mbgl

View File

@@ -68,6 +68,9 @@ public:
style::TranslateAnchorType anchor,
const TransformState& state,
const bool inViewportPixelUnits) const;
void setFeatureState(const LayerFeatureStates&);
private:
Tile& tile;
// The following members are reset at placement stage.

View File

@@ -387,4 +387,27 @@ void GeometryTile::performedFadePlacement() {
}
}
void GeometryTile::setFeatureState(const LayerFeatureStates& states) {
auto layers = getData();
if (!layers || states.empty() || !layoutResult) return;
auto& layerIdToLayerRenderData = layoutResult->layerRenderData;
for (auto& layer : layerIdToLayerRenderData) {
const auto& layerID = layer.first;
const auto sourceLayer = layers->getLayer(layerID);
if (sourceLayer) {
const auto& sourceLayerID = sourceLayer->getName();
auto entry = states.find(sourceLayerID);
if (entry == states.end()) continue;
const auto& featureStates = entry->second;
if (featureStates.empty()) continue;
auto bucket = layer.second.bucket;
if (bucket && bucket->hasData()) {
bucket->update(featureStates, *sourceLayer, layerID, layoutResult->iconAtlas.patternPositions);
}
}
}
}
} // namespace mbgl

View File

@@ -94,6 +94,8 @@ public:
const std::string sourceID;
void setFeatureState(const LayerFeatureStates&) override;
protected:
const GeometryTileData* getData() const;
LayerRenderData* getLayerRenderData(const style::Layer::Impl&);

View File

@@ -125,7 +125,9 @@ public:
// We hold onto a tile for two placements: fading starts with the first placement
// and will have time to finish by the second placement.
virtual void performedFadePlacement() {}
virtual void setFeatureState(const LayerFeatureStates&) {}
void dumpDebugLogs() const;
const Kind kind;