diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index 851fe4bd5..1a7353e97 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -84,6 +84,9 @@ set(MBGL_CORE_FILES src/mbgl/layout/clip_lines.hpp src/mbgl/layout/merge_lines.cpp src/mbgl/layout/merge_lines.hpp + src/mbgl/layout/symbol_feature.hpp + src/mbgl/layout/symbol_instance.cpp + src/mbgl/layout/symbol_instance.hpp src/mbgl/layout/symbol_layout.cpp src/mbgl/layout/symbol_layout.hpp diff --git a/src/mbgl/layout/merge_lines.cpp b/src/mbgl/layout/merge_lines.cpp index 1e33a655e..ddae9c2c8 100644 --- a/src/mbgl/layout/merge_lines.cpp +++ b/src/mbgl/layout/merge_lines.cpp @@ -1,4 +1,5 @@ #include +#include #include diff --git a/src/mbgl/layout/merge_lines.hpp b/src/mbgl/layout/merge_lines.hpp index bb4c01f6a..4cce39a65 100644 --- a/src/mbgl/layout/merge_lines.hpp +++ b/src/mbgl/layout/merge_lines.hpp @@ -1,11 +1,15 @@ #pragma once +#include + #include #include #include -#include namespace mbgl { + +class SymbolFeature; + namespace util { unsigned int mergeFromRight(std::vector &features, diff --git a/src/mbgl/layout/symbol_feature.hpp b/src/mbgl/layout/symbol_feature.hpp new file mode 100644 index 000000000..3b4eb78d8 --- /dev/null +++ b/src/mbgl/layout/symbol_feature.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include + +namespace mbgl { + +class SymbolFeature { +public: + GeometryCollection geometry; + std::u32string label; + std::string sprite; + std::size_t index; +}; + +} // namespace mbgl diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp new file mode 100644 index 000000000..64b913200 --- /dev/null +++ b/src/mbgl/layout/symbol_instance.cpp @@ -0,0 +1,34 @@ +#include +#include + +namespace mbgl { + +using namespace style; + +SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, + const Shaping& shapedText, const PositionedIcon& shapedIcon, + const SymbolLayoutProperties& 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) : + point(anchor.point), + index(index_), + hasText(shapedText), + hasIcon(shapedIcon), + + // Create the quads used for rendering the glyphs. + glyphQuads(addToBuffers && shapedText ? + getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textPlacement, face) : + SymbolQuads()), + + // Create the quad used for rendering the icon. + iconQuads(addToBuffers && shapedIcon ? + getIconQuads(anchor, shapedIcon, line, layout, iconPlacement, shapedText) : + SymbolQuads()), + + // Create the collision features that will be used to check whether this symbol instance can be placed + textCollisionFeature(line, anchor, shapedText, textBoxScale, textPadding, textPlacement, indexedFeature), + iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) + {} + +} // namespace mbgl diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp new file mode 100644 index 000000000..3087bf09f --- /dev/null +++ b/src/mbgl/layout/symbol_instance.hpp @@ -0,0 +1,34 @@ +#pragma once + +#include +#include + +namespace mbgl { + +struct Anchor; +class IndexedSubfeature; + +namespace style { +class SymbolLayoutProperties; +} // namespace style + +class SymbolInstance { +public: + explicit SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, + const Shaping& shapedText, const PositionedIcon& shapedIcon, + const style::SymbolLayoutProperties&, 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); + + Point point; + uint32_t index; + bool hasText; + bool hasIcon; + SymbolQuads glyphQuads; + SymbolQuads iconQuads; + CollisionFeature textCollisionFeature; + CollisionFeature iconCollisionFeature; +}; + +} // namespace mbgl diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 2a85ead32..5161d3c34 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -23,33 +23,6 @@ namespace mbgl { using namespace style; -SymbolInstance::SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, - const Shaping& shapedText, const PositionedIcon& shapedIcon, - const SymbolLayoutProperties& 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) : - point(anchor.point), - index(index_), - hasText(shapedText), - hasIcon(shapedIcon), - - // Create the quads used for rendering the glyphs. - glyphQuads(addToBuffers && shapedText ? - getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textPlacement, face) : - SymbolQuads()), - - // Create the quad used for rendering the icon. - iconQuads(addToBuffers && shapedIcon ? - getIconQuads(anchor, shapedIcon, line, layout, iconPlacement, shapedText) : - SymbolQuads()), - - // Create the collision features that will be used to check whether this symbol instance can be placed - textCollisionFeature(line, anchor, shapedText, textBoxScale, textPadding, textPlacement, indexedFeature), - iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature) - {} - - SymbolLayout::SymbolLayout(std::string bucketName_, std::string sourceLayerName_, uint32_t overscaling_, diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 83a373506..e365e7b44 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -1,10 +1,9 @@ #pragma once -#include #include -#include -#include #include +#include +#include #include #include @@ -13,47 +12,20 @@ namespace mbgl { +class GeometryTileLayer; class CollisionTile; class SpriteAtlas; class SpriteStore; class GlyphAtlas; class GlyphStore; -class IndexedSubfeature; class SymbolBucket; namespace style { class Filter; } // namespace style -class SymbolFeature { -public: - GeometryCollection geometry; - std::u32string label; - std::string sprite; - std::size_t index; -}; - struct Anchor; -class SymbolInstance { -public: - explicit SymbolInstance(Anchor& anchor, const GeometryCoordinates& line, - const Shaping& shapedText, const PositionedIcon& shapedIcon, - const style::SymbolLayoutProperties&, 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); - - Point point; - uint32_t index; - bool hasText; - bool hasIcon; - SymbolQuads glyphQuads; - SymbolQuads iconQuads; - CollisionFeature textCollisionFeature; - CollisionFeature iconCollisionFeature; -}; - class SymbolLayout { public: SymbolLayout(std::string bucketName_,