summaryrefslogtreecommitdiff
path: root/src/mbgl/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r--src/mbgl/layout/symbol_instance.hpp2
-rw-r--r--src/mbgl/layout/symbol_layout.cpp19
-rw-r--r--src/mbgl/layout/symbol_layout.hpp7
3 files changed, 16 insertions, 12 deletions
diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp
index eadbf67475..6a5d0c7cf3 100644
--- a/src/mbgl/layout/symbol_instance.hpp
+++ b/src/mbgl/layout/symbol_instance.hpp
@@ -1,7 +1,7 @@
#pragma once
#include <mbgl/text/quads.hpp>
-#include <mbgl/text/glyph.hpp>
+#include <mbgl/text/glyph_atlas.hpp>
#include <mbgl/text/collision_feature.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp>
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index b1cfc113fb..6d769e43c4 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -175,7 +175,7 @@ bool SymbolLayout::hasSymbolInstances() const {
return !symbolInstances.empty();
}
-void SymbolLayout::prepare(const GlyphPositionMap& glyphs, const IconMap& icons) {
+void SymbolLayout::prepare(const GlyphMap& glyphs, const IconMap& icons) {
float horizontalAlign = 0.5;
float verticalAlign = 0.5;
@@ -217,17 +217,20 @@ void SymbolLayout::prepare(const GlyphPositionMap& glyphs, const IconMap& icons)
layout.get<TextJustify>() == TextJustifyType::Left ? 0 :
0.5;
-
const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map &&
layout.get<SymbolPlacement>() == SymbolPlacementType::Line;
+ auto glyphPositionsIt = glyphs.find(layout.get<TextFont>());
+ if (glyphPositionsIt != glyphs.end()) {
+ glyphAtlas = makeGlyphAtlas(glyphPositionsIt->second);
+ }
+
for (auto it = features.begin(); it != features.end(); ++it) {
auto& feature = *it;
if (feature.geometry.empty()) continue;
std::pair<Shaping, Shaping> shapedTextOrientations;
optional<PositionedIcon> shapedIcon;
- GlyphPositions face;
// if feature has text, shape the text
if (feature.text) {
@@ -281,8 +284,7 @@ void SymbolLayout::prepare(const GlyphPositionMap& glyphs, const IconMap& icons)
// if either shapedText or icon position is present, add the feature
if (shapedTextOrientations.first || shapedIcon) {
- auto glyphPositionsIt = glyphs.find(layout.get<TextFont>());
- addFeature(std::distance(features.begin(), it), feature, shapedTextOrientations, shapedIcon, glyphPositionsIt == glyphs.end() ? GlyphPositions() : glyphPositionsIt->second);
+ addFeature(std::distance(features.begin(), it), feature, shapedTextOrientations, shapedIcon);
}
feature.geometry.clear();
@@ -294,8 +296,7 @@ void SymbolLayout::prepare(const GlyphPositionMap& glyphs, const IconMap& icons)
void SymbolLayout::addFeature(const std::size_t index,
const SymbolFeature& feature,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
- optional<PositionedIcon> shapedIcon,
- const GlyphPositions& glyphs) {
+ optional<PositionedIcon> shapedIcon) {
const float minScale = 0.5f;
const float glyphSize = 24.0f;
@@ -352,7 +353,7 @@ void SymbolLayout::addFeature(const std::size_t index,
addToBuffers, symbolInstances.size(),
textBoxScale, textPadding, textPlacement,
iconBoxScale, iconPadding, iconPlacement,
- glyphs, indexedFeature, index);
+ glyphAtlas.positions, indexedFeature, index);
};
const auto& type = feature.getType();
@@ -426,6 +427,8 @@ bool SymbolLayout::anchorIsTooClose(const std::u16string& text, const float repe
std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile) {
auto bucket = std::make_unique<SymbolBucket>(layout, layerPaintProperties, textSize, iconSize, zoom, sdfIcons, iconsNeedLinear);
+ bucket->text.atlasImage = glyphAtlas.image.clone();
+
// Calculate which labels can be shown and when they can be shown and
// create the bufers used for rendering.
diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp
index 770820542d..e947ee354b 100644
--- a/src/mbgl/layout/symbol_layout.hpp
+++ b/src/mbgl/layout/symbol_layout.hpp
@@ -33,7 +33,7 @@ public:
IconDependencies&,
GlyphDependencies&);
- void prepare(const GlyphPositionMap& glyphs, const IconMap& icons);
+ void prepare(const GlyphMap& glyphs, const IconMap& icons);
std::unique_ptr<SymbolBucket> place(CollisionTile&);
@@ -53,8 +53,7 @@ private:
void addFeature(const size_t,
const SymbolFeature&,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
- optional<PositionedIcon> shapedIcon,
- const GlyphPositions& face);
+ optional<PositionedIcon> shapedIcon);
bool anchorIsTooClose(const std::u16string& text, const float repeatDistance, const Anchor&);
std::map<std::u16string, std::vector<Anchor>> compareText;
@@ -94,6 +93,8 @@ private:
std::vector<SymbolInstance> symbolInstances;
std::vector<SymbolFeature> features;
+ GlyphAtlas glyphAtlas;
+
BiDi bidi; // Consider moving this up to geometry tile worker to reduce reinstantiation costs; use of BiDi/ubiditransform object must be constrained to one thread
};