Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Populate paint buffers for symbol DDS properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Thakker committed Feb 20, 2017
1 parent 0f30cd3 commit 1400ed8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/mbgl/layout/symbol_feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace mbgl {

class SymbolFeature : GeometryTileFeature {
class SymbolFeature : public GeometryTileFeature {
public:
SymbolFeature(const std::unique_ptr<GeometryTileFeature>& feature) :
id(feature->getID()),
Expand Down
5 changes: 3 additions & 2 deletions src/mbgl/layout/symbol_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line,
const SymbolLayoutProperties::Evaluated& layout, const bool addToBuffers, const uint32_t index_,
const float textBoxScale, const float textPadding, const SymbolPlacementType textPlacement,
const float iconBoxScale, const float iconPadding, const SymbolPlacementType iconPlacement,
const GlyphPositions& face, const IndexedSubfeature& indexedFeature) :
const GlyphPositions& face, const IndexedSubfeature& indexedFeature, const std::size_t featureIndex_) :
point(anchor.point),
index(index_),
hasText(shapedTextOrientations.first || shapedTextOrientations.second),
Expand All @@ -23,7 +23,8 @@ SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line,

// Create the collision features that will be used to check whether this symbol instance can be placed
textCollisionFeature(line, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature),
iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) {
iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature),
featureIndex(featureIndex_) {

// Create the quads used for rendering the glyphs.
if (addToBuffers) {
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/layout/symbol_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SymbolInstance {
const style::SymbolLayoutProperties::Evaluated&, const bool inside, const uint32_t index,
const float textBoxScale, const float textPadding, style::SymbolPlacementType textPlacement,
const float iconBoxScale, const float iconPadding, style::SymbolPlacementType iconPlacement,
const GlyphPositions& face, const IndexedSubfeature& indexedfeature);
const GlyphPositions& face, const IndexedSubfeature& indexedfeature, const std::size_t featureIndex);

Point<float> point;
uint32_t index;
Expand All @@ -28,6 +28,7 @@ class SymbolInstance {
CollisionFeature textCollisionFeature;
CollisionFeature iconCollisionFeature;
WritingModeType writingModes;
std::size_t featureIndex;
};

} // namespace mbgl
18 changes: 12 additions & 6 deletions src/mbgl/layout/symbol_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ void SymbolLayout::prepare(uintptr_t tileUID,
const bool textAlongLine = layout.get<TextRotationAlignment>() == AlignmentType::Map &&
layout.get<SymbolPlacement>() == SymbolPlacementType::Line;

for (const auto& feature : features) {
for (auto it = features.begin(); it != features.end(); ++it) {
const auto feature = *it;
if (feature.geometry.empty()) continue;

std::pair<Shaping, Shaping> shapedTextOrientations;
Expand Down Expand Up @@ -291,14 +292,13 @@ void SymbolLayout::prepare(uintptr_t tileUID,

// if either shapedText or icon position is present, add the feature
if (shapedTextOrientations.first || shapedIcon) {
addFeature(feature, shapedTextOrientations, shapedIcon, face);
addFeature(std::distance(features.begin(), it), feature, shapedTextOrientations, shapedIcon, face);
}
}

features.clear();
}

void SymbolLayout::addFeature(const SymbolFeature& feature,
void SymbolLayout::addFeature(const std::size_t index,
const SymbolFeature& feature,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
const PositionedIcon& shapedIcon,
const GlyphPositions& face) {
Expand Down Expand Up @@ -347,7 +347,7 @@ void SymbolLayout::addFeature(const SymbolFeature& feature,
symbolInstances.emplace_back(anchor, line, shapedTextOrientations, shapedIcon, layout, addToBuffers, symbolInstances.size(),
textBoxScale, textPadding, textPlacement,
iconBoxScale, iconPadding, iconPlacement,
face, indexedFeature);
face, indexedFeature, index);
};

if (layout.get<SymbolPlacement>() == SymbolPlacementType::Line) {
Expand Down Expand Up @@ -499,6 +499,12 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
layout.get<IconKeepUpright>(), iconPlacement, collisionTile.config.angle, symbolInstance.writingModes);
}
}

const auto feature = features.at(symbolInstance.featureIndex);
for (auto& pair : bucket->paintPropertyBinders) {
pair.second.first.populateVertexVectors(feature, bucket->icon.vertices.vertexSize());
pair.second.second.populateVertexVectors(feature, bucket->text.vertices.vertexSize());
}
}

if (collisionTile.config.debug) {
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/layout/symbol_layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class SymbolLayout {
std::pair<style::IconPaintProperties::Evaluated, style::TextPaintProperties::Evaluated>> layerPaintProperties;

private:
void addFeature(const SymbolFeature&,
void addFeature(const size_t,
const SymbolFeature&,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
const PositionedIcon& shapedIcon,
const GlyphPositions& face);
Expand Down

0 comments on commit 1400ed8

Please sign in to comment.