[core] Clang format fix
This commit is contained in:
@@ -74,12 +74,12 @@ void FeatureIndex::query(std::unordered_map<std::string, std::vector<Feature>>&
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::vector<Feature>>
|
||||
FeatureIndex::lookupSymbolFeatures(const std::vector<IndexedSubfeature>& symbolFeatures,
|
||||
const RenderedQueryOptions& queryOptions,
|
||||
const std::unordered_map<std::string, const RenderLayer*>& layers,
|
||||
const OverscaledTileID& tileID,
|
||||
const FeatureSortOrder& featureSortOrder) const {
|
||||
std::unordered_map<std::string, std::vector<Feature>> FeatureIndex::lookupSymbolFeatures(
|
||||
const std::vector<IndexedSubfeature>& symbolFeatures,
|
||||
const RenderedQueryOptions& queryOptions,
|
||||
const std::unordered_map<std::string, const RenderLayer*>& layers,
|
||||
const OverscaledTileID& tileID,
|
||||
const FeatureSortOrder& featureSortOrder) const {
|
||||
std::unordered_map<std::string, std::vector<Feature>> result;
|
||||
if (!tileData) {
|
||||
return result;
|
||||
|
||||
@@ -75,13 +75,13 @@ public:
|
||||
const float pixelsToTileUnits);
|
||||
|
||||
void setBucketLayerIDs(const std::string& bucketLeaderID, const std::vector<std::string>& layerIDs);
|
||||
|
||||
|
||||
std::unordered_map<std::string, std::vector<Feature>> lookupSymbolFeatures(
|
||||
const std::vector<IndexedSubfeature>& symbolFeatures,
|
||||
const RenderedQueryOptions& options,
|
||||
const std::unordered_map<std::string, const RenderLayer*>& layers,
|
||||
const OverscaledTileID& tileID,
|
||||
const FeatureSortOrder& featureSortOrder) const;
|
||||
const std::vector<IndexedSubfeature>& symbolFeatures,
|
||||
const RenderedQueryOptions& options,
|
||||
const std::unordered_map<std::string, const RenderLayer*>& layers,
|
||||
const OverscaledTileID& tileID,
|
||||
const FeatureSortOrder& featureSortOrder) const;
|
||||
|
||||
private:
|
||||
void addFeature(std::unordered_map<std::string, std::vector<Feature>>& result, const IndexedSubfeature&,
|
||||
|
||||
@@ -61,7 +61,8 @@ public:
|
||||
}
|
||||
// Places this bucket to the given placement.
|
||||
virtual void place(Placement&, const BucketPlacementParameters&, std::set<uint32_t>&) {}
|
||||
virtual void updateVertices(const Placement&, bool /*updateOpacities*/, const TransformState&, const RenderTile&, std::set<uint32_t>&) {}
|
||||
virtual void updateVertices(
|
||||
const Placement&, bool /*updateOpacities*/, const TransformState&, const RenderTile&, std::set<uint32_t>&) {}
|
||||
|
||||
protected:
|
||||
Bucket() = default;
|
||||
|
||||
@@ -303,7 +303,11 @@ void SymbolBucket::place(Placement& placement, const BucketPlacementParameters&
|
||||
placement.placeBucket(*this, params, seenIds);
|
||||
}
|
||||
|
||||
void SymbolBucket::updateVertices(const Placement& placement, bool updateOpacities, const TransformState& state, const RenderTile& tile, std::set<uint32_t>& seenIds) {
|
||||
void SymbolBucket::updateVertices(const Placement& placement,
|
||||
bool updateOpacities,
|
||||
const TransformState& state,
|
||||
const RenderTile& tile,
|
||||
std::set<uint32_t>& seenIds) {
|
||||
if (updateOpacities) {
|
||||
placement.updateBucketOpacities(*this, state, seenIds);
|
||||
placementChangesUploaded = false;
|
||||
|
||||
@@ -68,7 +68,8 @@ public:
|
||||
bool hasData() const override;
|
||||
std::pair<uint32_t, bool> registerAtCrossTileIndex(CrossTileSymbolLayerIndex&, const OverscaledTileID&, uint32_t& maxCrossTileID) override;
|
||||
void place(Placement&, const BucketPlacementParameters&, std::set<uint32_t>&) override;
|
||||
void updateVertices(const Placement&, bool updateOpacities, const TransformState&, const RenderTile&, std::set<uint32_t>&) override;
|
||||
void updateVertices(
|
||||
const Placement&, bool updateOpacities, const TransformState&, const RenderTile&, std::set<uint32_t>&) override;
|
||||
bool hasTextData() const;
|
||||
bool hasIconData() const;
|
||||
bool hasSdfIconData() const;
|
||||
|
||||
@@ -72,8 +72,7 @@ public:
|
||||
patternAtlas(patternAtlas_),
|
||||
layersNeedPlacement(std::move(layersNeedPlacement_)),
|
||||
placement(std::move(placement_)),
|
||||
updateSymbolOpacities(updateSymbolOpacities_) {
|
||||
}
|
||||
updateSymbolOpacities(updateSymbolOpacities_) {}
|
||||
|
||||
void prepare() override {
|
||||
for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
|
||||
@@ -375,7 +374,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
|
||||
crossTileSymbolIndex.reset();
|
||||
}
|
||||
|
||||
bool symbolBucketsAdded = false;
|
||||
bool symbolBucketsAdded = false;
|
||||
for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
|
||||
auto result = crossTileSymbolIndex.addLayer(*it, updateParameters.transformState.getLatLng().longitude());
|
||||
symbolBucketsAdded = symbolBucketsAdded || (result & CrossTileSymbolIndex::AddLayerResult::BucketsAdded);
|
||||
@@ -386,15 +385,17 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
|
||||
// a short period of time. Instead, we squeeze placement update period to coalesce buckets updates from several tiles.
|
||||
optional<Duration> maximumPlacementUpdatePeriod;
|
||||
if (symbolBucketsAdded) maximumPlacementUpdatePeriod = optional<Duration>(Milliseconds(30));
|
||||
renderTreeParameters->placementChanged = !placementController.placementIsRecent(updateParameters.timePoint, updateParameters.transformState.getZoom(), maximumPlacementUpdatePeriod);
|
||||
renderTreeParameters->placementChanged = !placementController.placementIsRecent(
|
||||
updateParameters.timePoint, updateParameters.transformState.getZoom(), maximumPlacementUpdatePeriod);
|
||||
symbolBucketsChanged |= renderTreeParameters->placementChanged;
|
||||
|
||||
std::set<std::string> usedSymbolLayers;
|
||||
if (renderTreeParameters->placementChanged) {
|
||||
Mutable<Placement> placement = makeMutable<Placement>(
|
||||
updateParameters.transformState, updateParameters.mode,
|
||||
updateParameters.transitionOptions, updateParameters.crossSourceCollisions,
|
||||
placementController.getPlacement());
|
||||
Mutable<Placement> placement = makeMutable<Placement>(updateParameters.transformState,
|
||||
updateParameters.mode,
|
||||
updateParameters.transitionOptions,
|
||||
updateParameters.crossSourceCollisions,
|
||||
placementController.getPlacement());
|
||||
|
||||
for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) {
|
||||
const RenderLayer& layer = *it;
|
||||
@@ -410,8 +411,9 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
|
||||
placementController.setPlacement(std::move(placement));
|
||||
} else {
|
||||
placementController.setPlacementStale();
|
||||
}
|
||||
renderTreeParameters->symbolFadeChange = placementController.getPlacement()->symbolFadeChange(updateParameters.timePoint);
|
||||
}
|
||||
renderTreeParameters->symbolFadeChange =
|
||||
placementController.getPlacement()->symbolFadeChange(updateParameters.timePoint);
|
||||
}
|
||||
|
||||
renderTreeParameters->needsRepaint = isMapModeContinuous && hasTransitions(updateParameters.timePoint);
|
||||
@@ -428,15 +430,14 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_unique<RenderTreeImpl>(
|
||||
std::move(renderTreeParameters),
|
||||
std::move(layerRenderItems),
|
||||
std::move(sourceRenderItems),
|
||||
*lineAtlas,
|
||||
*patternAtlas,
|
||||
std::move(layersNeedPlacement),
|
||||
placementController.getPlacement(),
|
||||
symbolBucketsChanged);
|
||||
return std::make_unique<RenderTreeImpl>(std::move(renderTreeParameters),
|
||||
std::move(layerRenderItems),
|
||||
std::move(sourceRenderItems),
|
||||
*lineAtlas,
|
||||
*patternAtlas,
|
||||
std::move(layersNeedPlacement),
|
||||
placementController.getPlacement(),
|
||||
symbolBucketsChanged);
|
||||
}
|
||||
|
||||
std::vector<Feature> RenderOrchestrator::queryRenderedFeatures(const ScreenLineString& geometry, const RenderedQueryOptions& options) const {
|
||||
|
||||
@@ -61,8 +61,7 @@ const CollisionGroups::CollisionGroup& CollisionGroups::get(const std::string& s
|
||||
// PlacementController implemenation
|
||||
|
||||
PlacementController::PlacementController()
|
||||
: placement(makeMutable<Placement>(TransformState{}, MapMode::Static, style::TransitionOptions{}, true, nullopt)) {
|
||||
}
|
||||
: placement(makeMutable<Placement>(TransformState{}, MapMode::Static, style::TransitionOptions{}, true, nullopt)) {}
|
||||
|
||||
void PlacementController::setPlacement(Immutable<Placement> placement_) {
|
||||
placement = std::move(placement_);
|
||||
@@ -81,7 +80,6 @@ bool PlacementController::placementIsRecent(TimePoint now, const float zoom, opt
|
||||
return placement->getCommitTime() + updatePeriod > now;
|
||||
}
|
||||
|
||||
|
||||
bool PlacementController::hasTransitions(TimePoint now) const {
|
||||
if (!placement->transitionsEnabled()) return false;
|
||||
|
||||
@@ -92,13 +90,17 @@ bool PlacementController::hasTransitions(TimePoint now) const {
|
||||
|
||||
// Placement implementation
|
||||
|
||||
Placement::Placement(const TransformState& state_, MapMode mapMode_, style::TransitionOptions transitionOptions_, const bool crossSourceCollisions, optional<Immutable<Placement>> prevPlacement_)
|
||||
: collisionIndex(state_)
|
||||
, mapMode(mapMode_)
|
||||
, transitionOptions(std::move(transitionOptions_))
|
||||
, placementZoom(state_.getZoom())
|
||||
, collisionGroups(crossSourceCollisions)
|
||||
, prevPlacement(std::move(prevPlacement_)) {
|
||||
Placement::Placement(const TransformState& state_,
|
||||
MapMode mapMode_,
|
||||
style::TransitionOptions transitionOptions_,
|
||||
const bool crossSourceCollisions,
|
||||
optional<Immutable<Placement>> prevPlacement_)
|
||||
: collisionIndex(state_),
|
||||
mapMode(mapMode_),
|
||||
transitionOptions(std::move(transitionOptions_)),
|
||||
placementZoom(state_.getZoom()),
|
||||
collisionGroups(crossSourceCollisions),
|
||||
prevPlacement(std::move(prevPlacement_)) {
|
||||
if (prevPlacement) {
|
||||
prevPlacement->get()->prevPlacement = nullopt; // Only hold on to one placement back
|
||||
}
|
||||
@@ -221,12 +223,12 @@ void Placement::placeBucket(
|
||||
const CollisionFeature& textCollisionFeature = symbolInstance.textCollisionFeature;
|
||||
|
||||
const auto updatePreviousOrientationIfNotPlaced = [&](bool isPlaced) {
|
||||
if (bucket.allowVerticalPlacement && !isPlaced && getPrevPlacement()) {
|
||||
auto prevOrientation = getPrevPlacement()->placedOrientations.find(symbolInstance.crossTileID);
|
||||
if (prevOrientation != getPrevPlacement()->placedOrientations.end()) {
|
||||
placedOrientations[symbolInstance.crossTileID] = prevOrientation->second;
|
||||
}
|
||||
if (bucket.allowVerticalPlacement && !isPlaced && getPrevPlacement()) {
|
||||
auto prevOrientation = getPrevPlacement()->placedOrientations.find(symbolInstance.crossTileID);
|
||||
if (prevOrientation != getPrevPlacement()->placedOrientations.end()) {
|
||||
placedOrientations[symbolInstance.crossTileID] = prevOrientation->second;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const auto placeTextForPlacementModes = [&] (auto& placeHorizontalFn, auto& placeVerticalFn) {
|
||||
@@ -722,7 +724,9 @@ bool Placement::updateBucketDynamicVertices(SymbolBucket& bucket, const Transfor
|
||||
return result;
|
||||
}
|
||||
|
||||
void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState& state, std::set<uint32_t>& seenCrossTileIDs) const {
|
||||
void Placement::updateBucketOpacities(SymbolBucket& bucket,
|
||||
const TransformState& state,
|
||||
std::set<uint32_t>& seenCrossTileIDs) const {
|
||||
if (bucket.hasTextData()) bucket.text.opacityVertices.clear();
|
||||
if (bucket.hasIconData()) bucket.icon.opacityVertices.clear();
|
||||
if (bucket.hasSdfIconData()) bucket.sdfIcon.opacityVertices.clear();
|
||||
@@ -923,11 +927,15 @@ optional<size_t> justificationToIndex(style::TextJustifyType justify, const Symb
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
const style::TextJustifyType justifyTypes[] = {style::TextJustifyType::Right, style::TextJustifyType::Center, style::TextJustifyType::Left};
|
||||
const style::TextJustifyType justifyTypes[] = {
|
||||
style::TextJustifyType::Right, style::TextJustifyType::Center, style::TextJustifyType::Left};
|
||||
|
||||
} // namespace
|
||||
|
||||
void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableAnchorType placedAnchor, const SymbolInstance& symbolInstance, style::TextWritingModeType orientation) const {
|
||||
void Placement::markUsedJustification(SymbolBucket& bucket,
|
||||
style::TextVariableAnchorType placedAnchor,
|
||||
const SymbolInstance& symbolInstance,
|
||||
style::TextWritingModeType orientation) const {
|
||||
style::TextJustifyType anchorJustify = getAnchorJustification(placedAnchor);
|
||||
assert(anchorJustify != style::TextJustifyType::Auto);
|
||||
const optional<size_t>& autoIndex = justificationToIndex(anchorJustify, symbolInstance, orientation);
|
||||
@@ -947,7 +955,9 @@ void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableA
|
||||
}
|
||||
}
|
||||
|
||||
void Placement::markUsedOrientation(SymbolBucket& bucket, style::TextWritingModeType orientation, const SymbolInstance& symbolInstance) const {
|
||||
void Placement::markUsedOrientation(SymbolBucket& bucket,
|
||||
style::TextWritingModeType orientation,
|
||||
const SymbolInstance& symbolInstance) const {
|
||||
auto horizontal = orientation == style::TextWritingModeType::Horizontal ?
|
||||
optional<style::TextWritingModeType>(orientation) : nullopt;
|
||||
auto vertical = orientation == style::TextWritingModeType::Vertical ?
|
||||
@@ -998,7 +1008,8 @@ float Placement::zoomAdjustment(const float zoom) const {
|
||||
Duration Placement::getUpdatePeriod(const float zoom) const {
|
||||
// Even if transitionOptions.duration is set to a value < 300ms, we still wait for this default transition duration
|
||||
// before attempting another placement operation.
|
||||
const auto fadeDuration = std::max(util::DEFAULT_TRANSITION_DURATION, transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION));
|
||||
const auto fadeDuration = std::max(util::DEFAULT_TRANSITION_DURATION,
|
||||
transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION));
|
||||
return std::chrono::duration_cast<Duration>(fadeDuration * (1.0 - zoomAdjustment(zoom)));
|
||||
}
|
||||
|
||||
@@ -1008,7 +1019,8 @@ bool Placement::transitionsEnabled() const {
|
||||
|
||||
bool Placement::hasTransitions(TimePoint now) const {
|
||||
assert(transitionsEnabled());
|
||||
return std::chrono::duration<float>(now - fadeStartTime) < transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION);
|
||||
return std::chrono::duration<float>(now - fadeStartTime) <
|
||||
transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION);
|
||||
}
|
||||
|
||||
const CollisionIndex& Placement::getCollisionIndex() const {
|
||||
|
||||
@@ -62,7 +62,7 @@ struct RetainedQueryData {
|
||||
std::shared_ptr<FeatureIndex> featureIndex;
|
||||
OverscaledTileID tileID;
|
||||
mutable FeatureSortOrder featureSortOrder;
|
||||
|
||||
|
||||
RetainedQueryData(uint32_t bucketInstanceId_,
|
||||
std::shared_ptr<FeatureIndex> featureIndex_,
|
||||
OverscaledTileID tileID_)
|
||||
@@ -108,18 +108,22 @@ public:
|
||||
void setPlacementStale() { stale = true; }
|
||||
bool placementIsRecent(TimePoint now, const float zoom, optional<Duration> maximumDuration = nullopt) const;
|
||||
bool hasTransitions(TimePoint now) const;
|
||||
|
||||
|
||||
private:
|
||||
Immutable<Placement> placement;
|
||||
bool stale = false;
|
||||
};
|
||||
|
||||
|
||||
class Placement {
|
||||
public:
|
||||
Placement(const TransformState&, MapMode, style::TransitionOptions, const bool crossSourceCollisions, optional<Immutable<Placement>> prevPlacement);
|
||||
Placement(const TransformState&,
|
||||
MapMode,
|
||||
style::TransitionOptions,
|
||||
const bool crossSourceCollisions,
|
||||
optional<Immutable<Placement>> prevPlacement);
|
||||
void placeLayer(const RenderLayer&, const mat4&, bool showCollisionBoxes);
|
||||
void commit(TimePoint, const double zoom);
|
||||
void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const;
|
||||
void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const;
|
||||
float symbolFadeChange(TimePoint now) const;
|
||||
bool hasTransitions(TimePoint now) const;
|
||||
bool transitionsEnabled() const;
|
||||
@@ -133,18 +137,16 @@ public:
|
||||
const RetainedQueryData& getQueryData(uint32_t bucketInstanceId) const;
|
||||
private:
|
||||
friend SymbolBucket;
|
||||
void placeBucket(
|
||||
const SymbolBucket&,
|
||||
const BucketPlacementParameters&,
|
||||
std::set<uint32_t>& seenCrossTileIDs);
|
||||
void placeBucket(const SymbolBucket&, const BucketPlacementParameters&, std::set<uint32_t>& seenCrossTileIDs);
|
||||
// Returns `true` if bucket vertices were updated; returns `false` otherwise.
|
||||
bool updateBucketDynamicVertices(SymbolBucket&, const TransformState&, const RenderTile& tile) const;
|
||||
void updateBucketOpacities(SymbolBucket&, const TransformState&, std::set<uint32_t>&) const;
|
||||
void markUsedJustification(SymbolBucket&, style::TextVariableAnchorType, const SymbolInstance&, style::TextWritingModeType orientation) const;
|
||||
void markUsedJustification(SymbolBucket&,
|
||||
style::TextVariableAnchorType,
|
||||
const SymbolInstance&,
|
||||
style::TextWritingModeType orientation) const;
|
||||
void markUsedOrientation(SymbolBucket&, style::TextWritingModeType, const SymbolInstance&) const;
|
||||
const Placement* getPrevPlacement() const {
|
||||
return prevPlacement ? prevPlacement->get() : nullptr;
|
||||
}
|
||||
const Placement* getPrevPlacement() const { return prevPlacement ? prevPlacement->get() : nullptr; }
|
||||
|
||||
CollisionIndex collisionIndex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user