summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-13 17:37:30 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-09-19 14:51:32 +0300
commitf997ae00ae960f38d6920a625fcb7237e5909f9c (patch)
tree4478f9e94c4181f68a1d76128e9514800f586d31 /src
parent80e8d7a2fcb9f75e585bb7dd26c2f2a893b6f560 (diff)
downloadqtlocation-mapboxgl-f997ae00ae960f38d6920a625fcb7237e5909f9c.tar.gz
[core] Fix Placement constness
Update buckets methods do not mutate placement, placement methods do not mutate buckets.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/feature_index.cpp2
-rw-r--r--src/mbgl/geometry/feature_index.hpp4
-rw-r--r--src/mbgl/renderer/bucket.hpp2
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.cpp10
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.hpp4
-rw-r--r--src/mbgl/text/placement.cpp6
-rw-r--r--src/mbgl/text/placement.hpp8
7 files changed, 20 insertions, 16 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index 20026dd117..982c492469 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -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;
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp
index 5a006a51bc..69897b1f4b 100644
--- a/src/mbgl/geometry/feature_index.hpp
+++ b/src/mbgl/geometry/feature_index.hpp
@@ -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&,
diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp
index 6c74b8309f..3dae53408b 100644
--- a/src/mbgl/renderer/bucket.hpp
+++ b/src/mbgl/renderer/bucket.hpp
@@ -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;
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp
index ff201e9c2c..c3e4adfab6 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.cpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp
@@ -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;
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp
index 020190b81f..c2bbcd40a0 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.hpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp
@@ -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
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 06777dea44..9e3600aa97 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -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 ?
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index b5405cbcd7..1cefaf978c 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -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;