From 5bdee52e5c441e6daaae7cf9f320257d0ea3d031 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Fri, 10 Nov 2017 09:20:25 -0800 Subject: [core] Cleanup in response to review comments --- src/mbgl/geometry/feature_index.cpp | 2 +- src/mbgl/text/cross_tile_symbol_index.hpp | 63 +++++++++++++++---------------- src/mbgl/text/placement.cpp | 4 +- src/mbgl/text/placement.hpp | 6 +-- src/mbgl/tile/geometry_tile.cpp | 4 +- src/mbgl/util/grid_index.cpp | 9 ++--- 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 anchorPoint; - -}; - class IndexedSymbolInstance { - public: - IndexedSymbolInstance(uint32_t crossTileID_, Point coord_) - : crossTileID(crossTileID_), coord(coord_) {}; - uint32_t crossTileID; - Point coord; +public: + IndexedSymbolInstance(uint32_t crossTileID_, Point coord_) + : crossTileID(crossTileID_), coord(coord_) + {} + + uint32_t crossTileID; + Point coord; }; class TileLayerIndex { - public: - TileLayerIndex(OverscaledTileID coord, std::vector&, uint32_t bucketInstanceId); +public: + TileLayerIndex(OverscaledTileID coord, std::vector&, uint32_t bucketInstanceId); - Point getScaledCoordinates(SymbolInstance&, const OverscaledTileID&); - void findMatches(std::vector&, const OverscaledTileID&); - - OverscaledTileID coord; - uint32_t bucketInstanceId; - std::map> indexedSymbolInstances; + Point getScaledCoordinates(SymbolInstance&, const OverscaledTileID&); + void findMatches(std::vector&, const OverscaledTileID&); + + OverscaledTileID coord; + uint32_t bucketInstanceId; + std::map> indexedSymbolInstances; }; class CrossTileSymbolLayerIndex { - public: - CrossTileSymbolLayerIndex(); - void addBucket(const OverscaledTileID&, SymbolBucket&); - bool removeStaleBuckets(const std::unordered_set& currentIDs); - private: - std::map> indexes; - uint32_t maxBucketInstanceId = 0; - static uint32_t maxCrossTileID; +public: + CrossTileSymbolLayerIndex(); + void addBucket(const OverscaledTileID&, SymbolBucket&); + bool removeStaleBuckets(const std::unordered_set& currentIDs); +private: + std::map> indexes; + uint32_t maxBucketInstanceId = 0; + static uint32_t maxCrossTileID; }; class CrossTileSymbolIndex { - public: - CrossTileSymbolIndex(); +public: + CrossTileSymbolIndex(); - bool addLayer(RenderSymbolLayer&); - - void reset(); - private: - std::map layerIndexes; + bool addLayer(RenderSymbolLayer&); + + void reset(); +private: + std::map 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 seenCrossTileIDs; + std::set 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& seenCrossTileIDs) { +void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set& 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& seenCrossTileIDs); - void updateBucketOpacities(SymbolBucket&, std::unordered_set&); + void updateBucketOpacities(SymbolBucket&, std::set&); CollisionIndex collisionIndex; @@ -72,8 +72,8 @@ namespace mbgl { MapMode mapMode; TimePoint commitTime; - std::unordered_map placements; - std::unordered_map opacities; + std::unordered_map placements; + std::unordered_map 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>& 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::query(const BBox& queryBBox, std::function::query(const BCircle& queryBCircle, std::function