diff options
author | Molly Lloyd <molly@mapbox.com> | 2018-08-29 17:27:40 -0700 |
---|---|---|
committer | Molly Lloyd <mollymerp@users.noreply.github.com> | 2018-08-31 13:08:47 -0700 |
commit | d197fc7d8daf06cc2efc35a34fb45d86ea64d65b (patch) | |
tree | 365b09122531ef51b253417191368c14de171eb4 /src/mbgl/layout/symbol_layout.cpp | |
parent | f7dcd5d7416f076c3553ccec9844fa77fe0e0ea5 (diff) | |
download | qtlocation-mapboxgl-d197fc7d8daf06cc2efc35a34fb45d86ea64d65b.tar.gz |
[core] simplify dependency layout process and refactor data structures
Diffstat (limited to 'src/mbgl/layout/symbol_layout.cpp')
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index fd4dd2bedd..344a76bbe9 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -1,3 +1,4 @@ +#include <mbgl/layout/layout.hpp> #include <mbgl/layout/symbol_layout.hpp> #include <mbgl/layout/merge_lines.hpp> #include <mbgl/layout/clip_lines.hpp> @@ -40,7 +41,8 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, std::unique_ptr<GeometryTileLayer> sourceLayer_, ImageDependencies& imageDependencies, GlyphDependencies& glyphDependencies) - : bucketLeaderID(layers.at(0)->getID()), + : Layout(), + bucketLeaderID(layers.at(0)->getID()), sourceLayer(std::move(sourceLayer_)), overscaling(parameters.tileID.overscaleFactor()), zoom(parameters.tileID.overscaledZ), @@ -149,11 +151,15 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, } } +bool SymbolLayout::hasDependencies() const { + return features.size() != 0; +} + bool SymbolLayout::hasSymbolInstances() const { return !symbolInstances.empty(); } -void SymbolLayout::prepare(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions, +void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions, const ImageMap& imageMap, const ImagePositions& imagePositions) { const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map && layout.get<SymbolPlacement>() != SymbolPlacementType::Point; @@ -394,11 +400,11 @@ std::vector<float> CalculateTileDistances(const GeometryCoordinates& line, const return tileDistances; } -std::unique_ptr<SymbolBucket> SymbolLayout::place(const bool showCollisionBoxes) { +void SymbolLayout::createBucket(const ImagePositions&, std::unique_ptr<FeatureIndex>&, std::unordered_map<std::string, std::shared_ptr<Bucket>>& buckets, const bool firstLoad, const bool showCollisionBoxes) { const bool mayOverlap = layout.get<TextAllowOverlap>() || layout.get<IconAllowOverlap>() || layout.get<TextIgnorePlacement>() || layout.get<IconIgnorePlacement>(); - auto bucket = std::make_unique<SymbolBucket>(layout, layerPaintProperties, textSize, iconSize, zoom, sdfIcons, iconsNeedLinear, mayOverlap, bucketLeaderID, std::move(symbolInstances)); + auto bucket = std::make_shared<SymbolBucket>(layout, layerPaintProperties, textSize, iconSize, zoom, sdfIcons, iconsNeedLinear, mayOverlap, bucketLeaderID, std::move(symbolInstances)); for (SymbolInstance &symbolInstance : bucket->symbolInstances) { @@ -469,8 +475,15 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(const bool showCollisionBoxes) if (showCollisionBoxes) { addToDebugBuffers(*bucket); } + if (bucket->hasData()){ + for (const auto& pair : layerPaintProperties) { + if (!firstLoad) { + bucket->justReloaded = true; + } + buckets.emplace(pair.first, bucket); + } + } - return bucket; } template <typename Buffer> |