[core] Move SymbolInstance and SymbolFeature into their own files

This commit is contained in:
John Firebaugh
2016-09-13 13:50:27 -07:00
parent 1f375581c3
commit a8dd1bbbb8
8 changed files with 97 additions and 59 deletions

View File

@@ -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

View File

@@ -1,4 +1,5 @@
#include <mbgl/layout/merge_lines.hpp>
#include <mbgl/layout/symbol_feature.hpp>
#include <boost/functional/hash.hpp>

View File

@@ -1,11 +1,15 @@
#pragma once
#include <mbgl/tile/geometry_tile_data.hpp>
#include <unordered_map>
#include <string>
#include <vector>
#include <mbgl/layout/symbol_layout.hpp>
namespace mbgl {
class SymbolFeature;
namespace util {
unsigned int mergeFromRight(std::vector<SymbolFeature> &features,

View File

@@ -0,0 +1,17 @@
#pragma once
#include <mbgl/tile/geometry_tile_data.hpp>
#include <string>
namespace mbgl {
class SymbolFeature {
public:
GeometryCollection geometry;
std::u32string label;
std::string sprite;
std::size_t index;
};
} // namespace mbgl

View File

@@ -0,0 +1,34 @@
#include <mbgl/layout/symbol_instance.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp>
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

View File

@@ -0,0 +1,34 @@
#pragma once
#include <mbgl/text/quads.hpp>
#include <mbgl/text/collision_feature.hpp>
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<float> point;
uint32_t index;
bool hasText;
bool hasIcon;
SymbolQuads glyphQuads;
SymbolQuads iconQuads;
CollisionFeature textCollisionFeature;
CollisionFeature iconCollisionFeature;
};
} // namespace mbgl

View File

@@ -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_,

View File

@@ -1,10 +1,9 @@
#pragma once
#include <mbgl/tile/geometry_tile_data.hpp>
#include <mbgl/map/mode.hpp>
#include <mbgl/text/collision_feature.hpp>
#include <mbgl/text/quads.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp>
#include <mbgl/layout/symbol_feature.hpp>
#include <mbgl/layout/symbol_instance.hpp>
#include <memory>
#include <map>
@@ -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<float> point;
uint32_t index;
bool hasText;
bool hasIcon;
SymbolQuads glyphQuads;
SymbolQuads iconQuads;
CollisionFeature textCollisionFeature;
CollisionFeature iconCollisionFeature;
};
class SymbolLayout {
public:
SymbolLayout(std::string bucketName_,