summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2017-11-10 09:20:25 -0800
committerChris Loer <chris.loer@mapbox.com>2017-11-17 10:05:15 -0800
commit5bdee52e5c441e6daaae7cf9f320257d0ea3d031 (patch)
treefc107897c960eeb76263d74145ffb14ccfc3e50d
parent3e074390b5afb0bf6d50b83c5327786bc011cd95 (diff)
downloadqtlocation-mapboxgl-5bdee52e5c441e6daaae7cf9f320257d0ea3d031.tar.gz
[core] Cleanup in response to review comments
-rw-r--r--src/mbgl/geometry/feature_index.cpp2
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.hpp63
-rw-r--r--src/mbgl/text/placement.cpp4
-rw-r--r--src/mbgl/text/placement.hpp6
-rw-r--r--src/mbgl/tile/geometry_tile.cpp4
-rw-r--r--src/mbgl/util/grid_index.cpp9
6 files changed, 42 insertions, 46 deletions
diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp
index e610e5ba5f..3b5e12b54a 100644
--- a/src/mbgl/geometry/feature_index.cpp
+++ b/src/mbgl/geometry/feature_index.cpp
@@ -18,7 +18,7 @@
namespace mbgl {
FeatureIndex::FeatureIndex()
- : grid(util::EXTENT, util::EXTENT, util::EXTENT >> 5) {
+ : grid(util::EXTENT, util::EXTENT, util::EXTENT / 16) { // 16x16 grid -> 32px cell
}
void FeatureIndex::insert(const GeometryCollection& geometries,
diff --git a/src/mbgl/text/cross_tile_symbol_index.hpp b/src/mbgl/text/cross_tile_symbol_index.hpp
index 0b8c5c4780..a32430d872 100644
--- a/src/mbgl/text/cross_tile_symbol_index.hpp
+++ b/src/mbgl/text/cross_tile_symbol_index.hpp
@@ -17,51 +17,48 @@ class SymbolInstance;
class RenderSymbolLayer;
class SymbolBucket;
-class IndexEntry {
- Point<float> anchorPoint;
-
-};
-
class IndexedSymbolInstance {
- public:
- IndexedSymbolInstance(uint32_t crossTileID_, Point<int64_t> coord_)
- : crossTileID(crossTileID_), coord(coord_) {};
- uint32_t crossTileID;
- Point<int64_t> coord;
+public:
+ IndexedSymbolInstance(uint32_t crossTileID_, Point<int64_t> coord_)
+ : crossTileID(crossTileID_), coord(coord_)
+ {}
+
+ uint32_t crossTileID;
+ Point<int64_t> coord;
};
class TileLayerIndex {
- public:
- TileLayerIndex(OverscaledTileID coord, std::vector<SymbolInstance>&, uint32_t bucketInstanceId);
+public:
+ TileLayerIndex(OverscaledTileID coord, std::vector<SymbolInstance>&, uint32_t bucketInstanceId);
- Point<int64_t> getScaledCoordinates(SymbolInstance&, const OverscaledTileID&);
- void findMatches(std::vector<SymbolInstance>&, const OverscaledTileID&);
-
- OverscaledTileID coord;
- uint32_t bucketInstanceId;
- std::map<std::u16string,std::vector<IndexedSymbolInstance>> indexedSymbolInstances;
+ Point<int64_t> getScaledCoordinates(SymbolInstance&, const OverscaledTileID&);
+ void findMatches(std::vector<SymbolInstance>&, const OverscaledTileID&);
+
+ OverscaledTileID coord;
+ uint32_t bucketInstanceId;
+ std::map<std::u16string,std::vector<IndexedSymbolInstance>> indexedSymbolInstances;
};
class CrossTileSymbolLayerIndex {
- public:
- CrossTileSymbolLayerIndex();
- void addBucket(const OverscaledTileID&, SymbolBucket&);
- bool removeStaleBuckets(const std::unordered_set<uint32_t>& currentIDs);
- private:
- std::map<uint8_t,std::map<OverscaledTileID,TileLayerIndex>> indexes;
- uint32_t maxBucketInstanceId = 0;
- static uint32_t maxCrossTileID;
+public:
+ CrossTileSymbolLayerIndex();
+ void addBucket(const OverscaledTileID&, SymbolBucket&);
+ bool removeStaleBuckets(const std::unordered_set<uint32_t>& currentIDs);
+private:
+ std::map<uint8_t,std::map<OverscaledTileID,TileLayerIndex>> indexes;
+ uint32_t maxBucketInstanceId = 0;
+ static uint32_t maxCrossTileID;
};
class CrossTileSymbolIndex {
- public:
- CrossTileSymbolIndex();
+public:
+ CrossTileSymbolIndex();
- bool addLayer(RenderSymbolLayer&);
-
- void reset();
- private:
- std::map<std::string,CrossTileSymbolLayerIndex> layerIndexes;
+ bool addLayer(RenderSymbolLayer&);
+
+ void reset();
+private:
+ std::map<std::string, CrossTileSymbolLayerIndex> layerIndexes;
};
} // namespace mbgl
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index b9f270d52e..1503db1d83 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -185,7 +185,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
}
void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
- std::unordered_set<uint32_t> seenCrossTileIDs;
+ std::set<uint32_t> seenCrossTileIDs;
for (RenderTile& renderTile : symbolLayer.renderTiles) {
if (!renderTile.tile.isRenderable()) {
continue;
@@ -198,7 +198,7 @@ void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
}
}
-void Placement::updateBucketOpacities(SymbolBucket& bucket, std::unordered_set<uint32_t>& seenCrossTileIDs) {
+void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>& seenCrossTileIDs) {
if (bucket.hasTextData()) bucket.text.opacityVertices.clear();
if (bucket.hasIconData()) bucket.icon.opacityVertices.clear();
if (bucket.hasCollisionBoxData()) bucket.collisionBox.dynamicVertices.clear();
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index a50fc47125..78bfc0a4d8 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -64,7 +64,7 @@ namespace mbgl {
const bool showCollisionBoxes,
std::unordered_set<uint32_t>& seenCrossTileIDs);
- void updateBucketOpacities(SymbolBucket&, std::unordered_set<uint32_t>&);
+ void updateBucketOpacities(SymbolBucket&, std::set<uint32_t>&);
CollisionIndex collisionIndex;
@@ -72,8 +72,8 @@ namespace mbgl {
MapMode mapMode;
TimePoint commitTime;
- std::unordered_map<uint32_t,PlacementPair> placements;
- std::unordered_map<uint32_t,JointOpacityState> opacities;
+ std::unordered_map<uint32_t, PlacementPair> placements;
+ std::unordered_map<uint32_t, JointOpacityState> opacities;
TimePoint recentUntil;
bool stale = false;
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 576c23b682..66778fa2b7 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -118,8 +118,8 @@ void GeometryTile::setLayers(const std::vector<Immutable<Layer::Impl>>& layers)
void GeometryTile::setShowCollisionBoxes(const bool showCollisionBoxes_) {
if (showCollisionBoxes != showCollisionBoxes_) {
- showCollisionBoxes = showCollisionBoxes_;
- ++correlationID;
+ showCollisionBoxes = showCollisionBoxes_;
+ ++correlationID;
worker.invoke(&GeometryTileWorker::setShowCollisionBoxes, showCollisionBoxes, correlationID);
}
}
diff --git a/src/mbgl/util/grid_index.cpp b/src/mbgl/util/grid_index.cpp
index 88ec1f2b86..1e1dcf0ed5 100644
--- a/src/mbgl/util/grid_index.cpp
+++ b/src/mbgl/util/grid_index.cpp
@@ -128,12 +128,12 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool (const T&, co
for (auto& element : boxElements) {
if (resultFn(element.first, element.second)) {
return;
- };
+ }
}
for (auto& element : circleElements) {
if (resultFn(element.first, convertToBox(element.second))) {
return;
- };
+ }
}
return;
}
@@ -189,16 +189,15 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool (const
if (noIntersection(queryBBox)) {
return;
} else if (completeIntersection(queryBBox)) {
- // TODO: std::for_each?
for (auto& element : boxElements) {
if (resultFn(element.first, element.second)) {
return;
- };
+ }
}
for (auto& element : circleElements) {
if (resultFn(element.first, convertToBox(element.second))) {
return;
- };
+ }
}
}