[core] Fix Placement constness
Update buckets methods do not mutate placement, placement methods do not mutate buckets.
This commit is contained in:
@@ -79,7 +79,7 @@ FeatureIndex::lookupSymbolFeatures(const std::vector<IndexedSubfeature>& symbolF
|
||||
const RenderedQueryOptions& queryOptions,
|
||||
const std::unordered_map<std::string, const RenderLayer*>& layers,
|
||||
const OverscaledTileID& tileID,
|
||||
const std::shared_ptr<std::vector<size_t>>& featureSortOrder) const {
|
||||
const FeatureSortOrder& featureSortOrder) const {
|
||||
std::unordered_map<std::string, std::vector<Feature>> result;
|
||||
if (!tileData) {
|
||||
return result;
|
||||
|
||||
@@ -51,6 +51,8 @@ public:
|
||||
uint16_t collisionGroupId;
|
||||
};
|
||||
|
||||
using FeatureSortOrder = std::shared_ptr<const std::vector<size_t>>;
|
||||
|
||||
class FeatureIndex {
|
||||
public:
|
||||
FeatureIndex(std::unique_ptr<const GeometryTileData> tileData_);
|
||||
@@ -79,7 +81,7 @@ public:
|
||||
const RenderedQueryOptions& options,
|
||||
const std::unordered_map<std::string, const RenderLayer*>& layers,
|
||||
const OverscaledTileID& tileID,
|
||||
const std::shared_ptr<std::vector<size_t>>& featureSortOrder) const;
|
||||
const FeatureSortOrder& featureSortOrder) const;
|
||||
|
||||
private:
|
||||
void addFeature(std::unordered_map<std::string, std::vector<Feature>>& result, const IndexedSubfeature&,
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
// Places this bucket to the given placement.
|
||||
virtual void place(Placement&, const BucketPlacementParameters&, std::set<uint32_t>&) {}
|
||||
virtual void updateVertices(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;
|
||||
|
||||
@@ -232,14 +232,14 @@ void SymbolBucket::sortFeatures(const float angle) {
|
||||
icon.triangles.clear();
|
||||
sdfIcon.triangles.clear();
|
||||
|
||||
featureSortOrder = std::make_unique<std::vector<size_t>>();
|
||||
featureSortOrder->reserve(symbolInstances.size());
|
||||
auto symbolsSortOrder = std::make_unique<std::vector<size_t>>();
|
||||
symbolsSortOrder->reserve(symbolInstances.size());
|
||||
|
||||
// If the symbols are allowed to overlap sort them by their vertical screen position.
|
||||
// The index array buffer is rewritten to reference the (unchanged) vertices in the
|
||||
// sorted order.
|
||||
for (const SymbolInstance& symbolInstance : getSortedSymbols(angle)) {
|
||||
featureSortOrder->push_back(symbolInstance.dataFeatureIndex);
|
||||
symbolsSortOrder->push_back(symbolInstance.dataFeatureIndex);
|
||||
|
||||
if (symbolInstance.placedRightTextIndex) {
|
||||
addPlacedSymbol(text.triangles, text.placedSymbols[*symbolInstance.placedRightTextIndex]);
|
||||
@@ -266,6 +266,8 @@ void SymbolBucket::sortFeatures(const float angle) {
|
||||
addPlacedSymbol(iconBuffer.triangles, iconBuffer.placedSymbols[*symbolInstance.placedVerticalIconIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
featureSortOrder = std::move(symbolsSortOrder);
|
||||
}
|
||||
|
||||
std::vector<std::reference_wrapper<const SymbolInstance>> SymbolBucket::getSortedSymbols(const float angle) const {
|
||||
@@ -301,7 +303,7 @@ void SymbolBucket::place(Placement& placement, const BucketPlacementParameters&
|
||||
placement.placeBucket(*this, params, seenIds);
|
||||
}
|
||||
|
||||
void SymbolBucket::updateVertices(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,7 @@ 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(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;
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
const std::vector<style::TextWritingModeType> placementModes;
|
||||
mutable optional<bool> hasFormatSectionOverrides_;
|
||||
|
||||
std::shared_ptr<std::vector<size_t>> featureSortOrder;
|
||||
FeatureSortOrder featureSortOrder;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -690,7 +690,7 @@ bool Placement::updateBucketDynamicVertices(SymbolBucket& bucket, const Transfor
|
||||
return result;
|
||||
}
|
||||
|
||||
void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState& state, std::set<uint32_t>& seenCrossTileIDs) {
|
||||
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();
|
||||
@@ -895,7 +895,7 @@ const style::TextJustifyType justifyTypes[] = {style::TextJustifyType::Right, st
|
||||
|
||||
} // namespace
|
||||
|
||||
void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableAnchorType placedAnchor, const SymbolInstance& symbolInstance, style::TextWritingModeType orientation) {
|
||||
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);
|
||||
@@ -915,7 +915,7 @@ void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableA
|
||||
}
|
||||
}
|
||||
|
||||
void Placement::markUsedOrientation(SymbolBucket& bucket, style::TextWritingModeType orientation, const SymbolInstance& symbolInstance) {
|
||||
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 ?
|
||||
|
||||
@@ -61,7 +61,7 @@ struct RetainedQueryData {
|
||||
uint32_t bucketInstanceId;
|
||||
std::shared_ptr<FeatureIndex> featureIndex;
|
||||
OverscaledTileID tileID;
|
||||
std::shared_ptr<std::vector<size_t>> featureSortOrder;
|
||||
mutable FeatureSortOrder featureSortOrder;
|
||||
|
||||
RetainedQueryData(uint32_t bucketInstanceId_,
|
||||
std::shared_ptr<FeatureIndex> featureIndex_,
|
||||
@@ -122,9 +122,9 @@ private:
|
||||
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>&);
|
||||
void markUsedJustification(SymbolBucket&, style::TextVariableAnchorType, const SymbolInstance&, style::TextWritingModeType orientation);
|
||||
void markUsedOrientation(SymbolBucket&, style::TextWritingModeType, const SymbolInstance&);
|
||||
void updateBucketOpacities(SymbolBucket&, const TransformState&, std::set<uint32_t>&) const;
|
||||
void markUsedJustification(SymbolBucket&, style::TextVariableAnchorType, const SymbolInstance&, style::TextWritingModeType orientation) const;
|
||||
void markUsedOrientation(SymbolBucket&, style::TextWritingModeType, const SymbolInstance&) const;
|
||||
float zoomAdjustment(const float zoom) const;
|
||||
Duration getUpdatePeriod(const float zoom) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user