summaryrefslogtreecommitdiff
path: root/include/mbgl/text
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/text')
-rw-r--r--include/mbgl/text/collision.hpp58
-rw-r--r--include/mbgl/text/glyph.hpp60
-rw-r--r--include/mbgl/text/glyph_store.hpp99
-rw-r--r--include/mbgl/text/placement.hpp31
-rw-r--r--include/mbgl/text/rotation_range.hpp54
-rw-r--r--include/mbgl/text/types.hpp113
6 files changed, 0 insertions, 415 deletions
diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp
deleted file mode 100644
index 3bf37a6a12..0000000000
--- a/include/mbgl/text/collision.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef MBGL_TEXT_COLLISION
-#define MBGL_TEXT_COLLISION
-
-#include <mbgl/text/types.hpp>
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wshadow"
-#ifdef __clang__
-#pragma GCC diagnostic ignored "-Wdeprecated-register"
-#else
-#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif
-#include <boost/geometry.hpp>
-#include <boost/geometry/geometries/point.hpp>
-#include <boost/geometry/geometries/box.hpp>
-#include <boost/geometry/index/rtree.hpp>
-#pragma GCC diagnostic pop
-
-namespace mbgl {
-
-namespace bg = boost::geometry;
-namespace bgm = bg::model;
-namespace bgi = bg::index;
-typedef bgm::point<float, 2, bg::cs::cartesian> Point;
-typedef bgm::box<Point> Box;
-typedef std::pair<Box, PlacementBox> PlacementValue;
-typedef bgi::rtree<PlacementValue, bgi::linear<16,4>> Tree;
-
-class Collision {
-
-public:
- Collision(float zoom, float tileExtent, float tileSize, float placementDepth = 1);
-
- float getPlacementScale(const GlyphBoxes &glyphs, float minPlacementScale, bool avoidEdges);
- PlacementRange getPlacementRange(const GlyphBoxes &glyphs, float placementScale,
- bool horizontal);
- void insert(const GlyphBoxes &glyphs, const CollisionAnchor &anchor, float placementScale,
- const PlacementRange &placementRange, bool horizontal);
-
-private:
- Tree hTree;
- Tree cTree;
- PlacementValue leftEdge;
- PlacementValue topEdge;
- PlacementValue rightEdge;
- PlacementValue bottomEdge;
-
-public:
- const float tilePixelRatio;
- const float zoom;
- const float maxPlacementScale;
-};
-}
-
-#endif
diff --git a/include/mbgl/text/glyph.hpp b/include/mbgl/text/glyph.hpp
deleted file mode 100644
index 4fbb75fc1e..0000000000
--- a/include/mbgl/text/glyph.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef MBGL_TEXT_GLYPH
-#define MBGL_TEXT_GLYPH
-
-#include <mbgl/util/rect.hpp>
-
-#include <cstdint>
-#include <vector>
-#include <map>
-
-namespace mbgl {
-
-typedef std::pair<uint16_t, uint16_t> GlyphRange;
-
-// Note: this only works for the BMP
-GlyphRange getGlyphRange(char32_t glyph);
-
-struct GlyphMetrics {
- operator bool() const {
- return !(width == 0 && height == 0 && advance == 0);
- }
-
- // Glyph metrics.
- uint32_t width = 0;
- uint32_t height = 0;
- int32_t left = 0;
- int32_t top = 0;
- uint32_t advance = 0;
-
-};
-
-struct Glyph {
- inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {}
- inline explicit Glyph(const Rect<uint16_t> &rect_,
- const GlyphMetrics &metrics_)
- : rect(rect_), metrics(metrics_) {}
-
- operator bool() const {
- return metrics || rect;
- }
-
- const Rect<uint16_t> rect;
- const GlyphMetrics metrics;
-};
-
-typedef std::map<uint32_t, Glyph> GlyphPositions;
-
-class PositionedGlyph {
-public:
- inline explicit PositionedGlyph(uint32_t glyph_, float x_, float y_)
- : glyph(glyph_), x(x_), y(y_) {}
-
- uint32_t glyph = 0;
- float x = 0;
- float y = 0;
-};
-
-typedef std::vector<PositionedGlyph> Shaping;
-}
-
-#endif
diff --git a/include/mbgl/text/glyph_store.hpp b/include/mbgl/text/glyph_store.hpp
deleted file mode 100644
index 95ab92f307..0000000000
--- a/include/mbgl/text/glyph_store.hpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#ifndef MBGL_TEXT_GLYPH_STORE
-#define MBGL_TEXT_GLYPH_STORE
-
-#include <mbgl/text/glyph.hpp>
-#include <mbgl/util/pbf.hpp>
-#include <mbgl/util/vec.hpp>
-#include <mbgl/util/ptr.hpp>
-
-#include <cstdint>
-#include <vector>
-#include <future>
-#include <map>
-#include <set>
-#include <unordered_map>
-
-namespace mbgl {
-
-class FileSource;
-
-class SDFGlyph {
-public:
- uint32_t id = 0;
-
- // A signed distance field of the glyph with a border of 3 pixels.
- std::string bitmap;
-
- // Glyph metrics
- GlyphMetrics metrics;
-};
-
-class FontStack {
-public:
- void insert(uint32_t id, const SDFGlyph &glyph);
- const std::map<uint32_t, GlyphMetrics> &getMetrics() const;
- const std::map<uint32_t, SDFGlyph> &getSDFs() const;
- const Shaping getShaping(const std::u32string &string, float maxWidth, float lineHeight,
- float horizontalAlign, float verticalAlign, float justify,
- float spacing, const vec2<float> &translate) const;
- void lineWrap(Shaping &shaping, float lineHeight, float maxWidth, float horizontalAlign,
- float verticalAlign, float justify) const;
-
-private:
- std::map<uint32_t, std::string> bitmaps;
- std::map<uint32_t, GlyphMetrics> metrics;
- std::map<uint32_t, SDFGlyph> sdfs;
- mutable std::mutex mtx;
-};
-
-class GlyphPBF {
-public:
- GlyphPBF(const std::string &glyphURL, const std::string &fontStack, GlyphRange glyphRange, FileSource& fileSource);
-
-private:
- GlyphPBF(const GlyphPBF &) = delete;
- GlyphPBF(GlyphPBF &&) = delete;
- GlyphPBF &operator=(const GlyphPBF &) = delete;
- GlyphPBF &operator=(GlyphPBF &&) = delete;
-
-public:
- void parse(FontStack &stack);
-
- std::shared_future<GlyphPBF &> getFuture();
-
-private:
- std::string data;
- std::promise<GlyphPBF &> promise;
- std::shared_future<GlyphPBF &> future;
- std::mutex mtx;
-};
-
-// Manages Glyphrange PBF loading.
-class GlyphStore {
-public:
- GlyphStore(FileSource& fileSource);
-
- // Block until all specified GlyphRanges of the specified font stack are loaded.
- void waitForGlyphRanges(const std::string &fontStack, const std::set<GlyphRange> &glyphRanges);
-
- FontStack &getFontStack(const std::string &fontStack);
-
- void setURL(const std::string &url);
-
-private:
- // Loads an individual glyph range from the font stack and adds it to rangeSets
- std::shared_future<GlyphPBF &> loadGlyphRange(const std::string &fontStack, std::map<GlyphRange, std::unique_ptr<GlyphPBF>> &rangeSets, GlyphRange range);
-
- FontStack &createFontStack(const std::string &fontStack);
-
- std::string glyphURL;
- FileSource& fileSource;
- std::unordered_map<std::string, std::map<GlyphRange, std::unique_ptr<GlyphPBF>>> ranges;
- std::unordered_map<std::string, std::unique_ptr<FontStack>> stacks;
- std::mutex mtx;
-};
-
-
-}
-
-#endif
diff --git a/include/mbgl/text/placement.hpp b/include/mbgl/text/placement.hpp
deleted file mode 100644
index 28eb8d5317..0000000000
--- a/include/mbgl/text/placement.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef MBGL_TEXT_PLACEMENT
-#define MBGL_TEXT_PLACEMENT
-
-#include <mbgl/text/types.hpp>
-#include <mbgl/text/glyph.hpp>
-
-#include <mbgl/util/vec.hpp>
-
-namespace mbgl {
-
-struct Anchor;
-class StyleBucketSymbol;
-
-class Placement {
-public:
- static Placement getIcon(Anchor &anchor, const Rect<uint16_t> &image, float iconBoxScale,
- const std::vector<Coordinate> &line, const StyleBucketSymbol &props);
-
- static Placement getGlyphs(Anchor &anchor, const vec2<float> &origin, const Shaping &shaping,
- const GlyphPositions &face, float boxScale, bool horizontal,
- const std::vector<Coordinate> &line, const StyleBucketSymbol &props);
-
- static const float globalMinScale;
-
- GlyphBoxes boxes;
- PlacedGlyphs shapes;
- float minScale;
-};
-}
-
-#endif
diff --git a/include/mbgl/text/rotation_range.hpp b/include/mbgl/text/rotation_range.hpp
deleted file mode 100644
index 4968fda164..0000000000
--- a/include/mbgl/text/rotation_range.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef MBGL_TEXT_ROTATION_RANGE
-#define MBGL_TEXT_ROTATION_RANGE
-
-#include <mbgl/util/math.hpp>
-#include <mbgl/text/types.hpp>
-
-#include <vector>
-#include <cassert>
-
-namespace mbgl {
-
-/*
- * Combine an array of collision ranges to form a continuous
- * range that includes 0. Collisions within the ignoreRange are ignored
- */
-CollisionRange mergeCollisions(const CollisionList &collisions,
- PlacementRange ignoreRange);
-
-/*
- * Calculate collision ranges for two rotating boxes.e
- */
-CollisionList rotatingRotatingCollisions(const CollisionRect &a,
- const CollisionRect &b,
- const CollisionAnchor &anchorToAnchor);
-
-/*
- * Return the intersection points of a circle and a line segment;
- */
-void circleEdgeCollisions(std::back_insert_iterator<CollisionAngles> angles,
- const CollisionPoint &corner, float radius,
- const CollisionPoint &p1, const CollisionPoint &p2);
-
-/*
- * Calculate the ranges for which the corner,
- * rotatated around the anchor, is within the box;
- */
-void cornerBoxCollisions(std::back_insert_iterator<CollisionList> collisions,
- const CollisionPoint &corner,
- const CollisionCorners &boxCorners, bool flip = false);
-
-/*
- * Calculate collision ranges for a rotating box and a fixed box;
- */
-CollisionList rotatingFixedCollisions(const CollisionRect &rotating,
- const CollisionRect &fixed);
-
-/*
- * Calculate the range a box conflicts with a second box
- */
-CollisionRange rotationRange(const GlyphBox &inserting,
- const PlacementBox &blocker, float scale);
-}
-
-#endif
diff --git a/include/mbgl/text/types.hpp b/include/mbgl/text/types.hpp
deleted file mode 100644
index 23f49aa748..0000000000
--- a/include/mbgl/text/types.hpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#ifndef MBGL_TEXT_TYPES
-#define MBGL_TEXT_TYPES
-
-#include <mbgl/util/vec.hpp>
-#include <mbgl/util/rect.hpp>
-#include <mbgl/util/optional.hpp>
-#include <array>
-#include <vector>
-
-namespace mbgl {
-
-typedef vec2<float> CollisionPoint;
-typedef vec2<float> CollisionAnchor;
-
-typedef std::array<float, 2> PlacementRange;
-typedef float CollisionAngle;
-typedef std::vector<CollisionAngle> CollisionAngles;
-typedef std::array<CollisionAngle, 2> CollisionRange;
-typedef std::vector<CollisionRange> CollisionList;
-typedef std::array<CollisionPoint, 4> CollisionCorners;
-
-struct CollisionRect {
- CollisionPoint tl;
- CollisionPoint br;
- inline explicit CollisionRect() {}
- inline explicit CollisionRect(CollisionPoint::Type ax,
- CollisionPoint::Type ay,
- CollisionPoint::Type bx,
- CollisionPoint::Type by)
- : tl(ax, ay), br(bx, by) {}
- inline explicit CollisionRect(const CollisionPoint &tl_,
- const CollisionPoint &br_)
- : tl(tl_), br(br_) {}
-};
-
-// These are the glyph boxes that we want to have placed.
-struct GlyphBox {
- explicit GlyphBox() {}
- explicit GlyphBox(const CollisionRect &box_,
- const CollisionAnchor &anchor_,
- float minScale_,
- float maxScale_,
- float padding_)
- : box(box_), anchor(anchor_), minScale(minScale_), maxScale(maxScale_), padding(padding_) {}
- explicit GlyphBox(const CollisionRect &box_,
- float minScale_,
- float padding_)
- : box(box_), minScale(minScale_), padding(padding_) {}
-
- CollisionRect box;
- CollisionAnchor anchor;
- float minScale = 0.0f;
- float maxScale = std::numeric_limits<float>::infinity();
- float padding = 0.0f;
- mapbox::util::optional<CollisionRect> hBox;
-};
-
-typedef std::vector<GlyphBox> GlyphBoxes;
-
-
-// TODO: Transform the vec2<float>s to vec2<int16_t> to save bytes
-struct PlacedGlyph {
- explicit PlacedGlyph(const vec2<float> &tl_, const vec2<float> &tr_,
- const vec2<float> &bl_, const vec2<float> &br_,
- const Rect<uint16_t> &tex_, float angle_, const vec2<float> &anchor_,
- float minScale_, float maxScale_)
- : tl(tl_),
- tr(tr_),
- bl(bl_),
- br(br_),
- tex(tex_),
- angle(angle_),
- anchor(anchor_),
- minScale(minScale_),
- maxScale(maxScale_) {}
-
- vec2<float> tl, tr, bl, br;
- Rect<uint16_t> tex;
- float angle;
- vec2<float> anchor;
- float minScale, maxScale;
-};
-
-typedef std::vector<PlacedGlyph> PlacedGlyphs;
-
-// These are the placed boxes contained in the rtree.
-struct PlacementBox {
- CollisionAnchor anchor;
- CollisionRect box;
- mapbox::util::optional<CollisionRect> hBox;
- PlacementRange placementRange = {{0.0f, 0.0f}};
- float placementScale = 0.0f;
- float maxScale = std::numeric_limits<float>::infinity();
- float padding = 0.0f;
-};
-
-struct PlacementProperty {
- explicit PlacementProperty() {}
- explicit PlacementProperty(float zoom_, const PlacementRange &rotationRange_)
- : zoom(zoom_), rotationRange(rotationRange_) {}
-
- inline operator bool() const {
- return !std::isnan(zoom) && zoom != std::numeric_limits<float>::infinity() &&
- rotationRange[0] != rotationRange[1];
- }
-
- float zoom = std::numeric_limits<float>::infinity();
- PlacementRange rotationRange = {{0.0f, 0.0f}};
-};
-
-}
-
-#endif