From 0b687312071305c050d97e04fef1c80193f443c5 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 7 Jun 2017 12:45:35 -0700 Subject: [core] Per-bucket icon atlases --- src/mbgl/layout/symbol_layout.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/mbgl/layout/symbol_layout.cpp') diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 6d769e43c4..b64fc4f66e 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -5,8 +5,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -41,7 +41,7 @@ static bool has(const style::SymbolLayoutProperties::PossiblyEvaluated& layout) SymbolLayout::SymbolLayout(const BucketParameters& parameters, const std::vector& layers, const GeometryTileLayer& sourceLayer, - IconDependencies& iconDependencies, + ImageDependencies& imageDependencies, GlyphDependencies& glyphDependencies) : sourceLayerName(sourceLayer.getName()), bucketName(layers.at(0)->getID()), @@ -158,7 +158,7 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, icon = util::replaceTokens(icon, getValue); } ft.icon = icon; - iconDependencies.insert(*ft.icon); + imageDependencies.insert(*ft.icon); } if (ft.text || ft.icon) { @@ -175,7 +175,7 @@ bool SymbolLayout::hasSymbolInstances() const { return !symbolInstances.empty(); } -void SymbolLayout::prepare(const GlyphMap& glyphs, const IconMap& icons) { +void SymbolLayout::prepare(const GlyphMap& glyphs, const ImageMap& images) { float horizontalAlign = 0.5; float verticalAlign = 0.5; @@ -225,6 +225,8 @@ void SymbolLayout::prepare(const GlyphMap& glyphs, const IconMap& icons) { glyphAtlas = makeGlyphAtlas(glyphPositionsIt->second); } + imageAtlas = makeImageAtlas(images); + for (auto it = features.begin(); it != features.end(); ++it) { auto& feature = *it; if (feature.geometry.empty()) continue; @@ -266,15 +268,16 @@ void SymbolLayout::prepare(const GlyphMap& glyphs, const IconMap& icons) { // if feature has icon, get sprite atlas position if (feature.icon) { - auto image = icons.find(*feature.icon); - if (image != icons.end()) { - shapedIcon = PositionedIcon::shapeIcon(image->second, + auto image = images.find(*feature.icon); + if (image != images.end()) { + shapedIcon = PositionedIcon::shapeIcon( + imageAtlas.positions.at(*feature.icon), layout.evaluate(zoom, feature), layout.evaluate(zoom, feature) * util::DEG2RAD); - if (image->second.sdf) { + if (image->second->sdf) { sdfIcons = true; } - if (image->second.pixelRatio != pixelRatio) { + if (image->second->pixelRatio != pixelRatio) { iconsNeedLinear = true; } else if (layout.get().constantOr(1) != 0) { iconsNeedLinear = true; @@ -428,6 +431,7 @@ std::unique_ptr SymbolLayout::place(CollisionTile& collisionTile) auto bucket = std::make_unique(layout, layerPaintProperties, textSize, iconSize, zoom, sdfIcons, iconsNeedLinear); bucket->text.atlasImage = glyphAtlas.image.clone(); + bucket->icon.atlasImage = imageAtlas.image.clone(); // Calculate which labels can be shown and when they can be shown and // create the bufers used for rendering. -- cgit v1.2.1