diff options
Diffstat (limited to 'src/mbgl/tile')
-rw-r--r-- | src/mbgl/tile/geometry_tile.cpp | 22 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile_worker.cpp | 3 |
3 files changed, 13 insertions, 20 deletions
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 5089f95022..a99cb91d26 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -133,7 +133,7 @@ void GeometryTile::onLayout(LayoutResult result, const uint64_t resultCorrelatio buckets = std::move(result.buckets); - dataPendingCommit = {{ std::move(result.tileData), std::move(result.featureIndex) }}; + featureIndexPendingCommit = { std::move(result.featureIndex) }; if (result.glyphAtlasImage) { glyphAtlasImage = std::move(*result.glyphAtlasImage); @@ -202,12 +202,11 @@ Bucket* GeometryTile::getBucket(const Layer::Impl& layer) const { } void GeometryTile::commitFeatureIndex() { - // We commit our pending FeatureIndex and GeometryTileData when a global placement has run, - // synchronizing the global CollisionIndex with the latest buckets/FeatureIndex/GeometryTileData - if (dataPendingCommit) { - data = std::move(dataPendingCommit->first); - featureIndex = std::move(dataPendingCommit->second); - dataPendingCommit = nullopt; + // We commit our pending FeatureIndex when a global placement has run, + // synchronizing the global CollisionIndex with the latest buckets/FeatureIndex + if (featureIndexPendingCommit) { + featureIndex = std::move(*featureIndexPendingCommit); + featureIndexPendingCommit = nullopt; } } @@ -219,7 +218,7 @@ void GeometryTile::queryRenderedFeatures( const RenderedQueryOptions& options, const CollisionIndex& collisionIndex) { - if (!featureIndex || !data) return; + if (!getData()) return; // Determine the additional radius needed factoring in property functions float additionalRadius = 0; @@ -236,7 +235,6 @@ void GeometryTile::queryRenderedFeatures( util::tileSize * id.overscaleFactor(), std::pow(2, transformState.getZoom() - id.overscaledZ), options, - *data, id.toUnwrapped(), sourceID, layers, @@ -248,8 +246,8 @@ void GeometryTile::querySourceFeatures( std::vector<Feature>& result, const SourceQueryOptions& options) { - // Data not yet available - if (!data) { + // Data not yet available, or tile is empty + if (!getData()) { return; } @@ -262,7 +260,7 @@ void GeometryTile::querySourceFeatures( for (auto sourceLayer : *options.sourceLayers) { // Go throught all sourceLayers, if any // to gather all the features - auto layer = data->getLayer(sourceLayer); + auto layer = getData()->getLayer(sourceLayer); if (layer) { auto featureCount = layer->featureCount(); diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index 0161e00efd..418db4a0b2 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -67,18 +67,15 @@ public: public: std::unordered_map<std::string, std::shared_ptr<Bucket>> buckets; std::unique_ptr<FeatureIndex> featureIndex; - std::unique_ptr<GeometryTileData> tileData; optional<AlphaImage> glyphAtlasImage; optional<PremultipliedImage> iconAtlasImage; LayoutResult(std::unordered_map<std::string, std::shared_ptr<Bucket>> buckets_, std::unique_ptr<FeatureIndex> featureIndex_, - std::unique_ptr<GeometryTileData> tileData_, optional<AlphaImage> glyphAtlasImage_, optional<PremultipliedImage> iconAtlasImage_) : buckets(std::move(buckets_)), featureIndex(std::move(featureIndex_)), - tileData(std::move(tileData_)), glyphAtlasImage(std::move(glyphAtlasImage_)), iconAtlasImage(std::move(iconAtlasImage_)) {} }; @@ -95,7 +92,7 @@ public: protected: const GeometryTileData* getData() { - return data.get(); + return featureIndex ? featureIndex->getData() : nullptr; } private: @@ -116,9 +113,8 @@ private: std::unordered_map<std::string, std::shared_ptr<Bucket>> buckets; - optional<std::pair<std::unique_ptr<const GeometryTileData>, std::unique_ptr<FeatureIndex>>> dataPendingCommit; + optional<std::unique_ptr<FeatureIndex>> featureIndexPendingCommit; std::unique_ptr<FeatureIndex> featureIndex; - std::unique_ptr<const GeometryTileData> data; optional<AlphaImage> glyphAtlasImage; optional<PremultipliedImage> iconAtlasImage; diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index f57732117b..1378ad5d3a 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -329,7 +329,7 @@ void GeometryTileWorker::parse() { std::unordered_map<std::string, std::unique_ptr<SymbolLayout>> symbolLayoutMap; buckets.clear(); - featureIndex = std::make_unique<FeatureIndex>(); + featureIndex = std::make_unique<FeatureIndex>(*data ? (*data)->clone() : nullptr); BucketParameters parameters { id, mode, pixelRatio }; GlyphDependencies glyphDependencies; @@ -471,7 +471,6 @@ void GeometryTileWorker::performSymbolLayout() { parent.invoke(&GeometryTile::onLayout, GeometryTile::LayoutResult { std::move(buckets), std::move(featureIndex), - *data ? (*data)->clone() : nullptr, std::move(glyphAtlasImage), std::move(iconAtlasImage) }, correlationID); |