diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2015-04-02 12:16:42 -0700 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2015-04-02 12:16:42 -0700 |
commit | 7b02800ad908347133494f9f1334d2384d5ead48 (patch) | |
tree | 328705da682cd8a0c0582025a4ec9099478dd22b /src | |
parent | 07b85043c8eb1feca4cea75e0460c35ba1325136 (diff) | |
download | qtlocation-mapboxgl-7b02800ad908347133494f9f1334d2384d5ead48.tar.gz |
remove old symbol collision types
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.cpp | 9 | ||||
-rw-r--r-- | src/mbgl/renderer/symbol_bucket.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/quads.hpp | 32 | ||||
-rw-r--r-- | src/mbgl/text/shaping.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/text/types.hpp | 113 |
6 files changed, 40 insertions, 131 deletions
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index ddf19f2d36..9967932a60 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -9,7 +9,6 @@ #include <mbgl/text/get_anchors.hpp> #include <mbgl/renderer/painter.hpp> #include <mbgl/text/glyph_store.hpp> -#include <mbgl/text/quads.hpp> #include <mbgl/platform/log.hpp> #include <mbgl/text/collision_tile.hpp> #include <mbgl/map/sprite.hpp> @@ -35,12 +34,12 @@ SymbolInstance::SymbolInstance(Anchor &anchor, const std::vector<Coordinate> &li // Create the quads used for rendering the glyphs. glyphQuads(inside && shapedText ? getGlyphQuads(anchor, shapedText, textBoxScale, line, layout, textAlongLine, face) : - PlacedGlyphs()), + SymbolQuads()), // Create the quad used for rendering the icon. iconQuads(inside && shapedIcon ? getIconQuads(anchor, shapedIcon, line, layout, iconAlongLine) : - PlacedGlyphs()), + SymbolQuads()), // Create the collision features that will be used to check whether this symbol instance can be placed textCollisionFeature(line, anchor, shapedText, textBoxScale, textPadding, textAlongLine), @@ -365,12 +364,12 @@ void SymbolBucket::placeFeatures() { } template <typename Buffer, typename GroupType> -void SymbolBucket::addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float scale, const bool keepUpright, const bool alongLine) { +void SymbolBucket::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const bool alongLine) { const float zoom = collision.zoom; const float placementZoom = std::log(scale) / std::log(2) + zoom; - for (const PlacedGlyph &symbol : symbols) { + for (const SymbolQuad &symbol : symbols) { const auto &tl = symbol.tl; const auto &tr = symbol.tr; const auto &bl = symbol.bl; diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index f49afba362..40a68e02e3 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -8,10 +8,10 @@ #include <mbgl/geometry/text_buffer.hpp> #include <mbgl/geometry/icon_buffer.hpp> #include <mbgl/geometry/collision_box_buffer.hpp> -#include <mbgl/text/types.hpp> #include <mbgl/text/glyph.hpp> #include <mbgl/text/collision_feature.hpp> #include <mbgl/text/shaping.hpp> +#include <mbgl/text/quads.hpp> #include <mbgl/style/style_bucket.hpp> #include <mbgl/util/ptr.hpp> @@ -53,8 +53,8 @@ class SymbolInstance { const GlyphPositions &face); const bool hasText; const bool hasIcon; - const PlacedGlyphs glyphQuads; - const PlacedGlyphs iconQuads; + const SymbolQuads glyphQuads; + const SymbolQuads iconQuads; CollisionFeature textCollisionFeature; CollisionFeature iconCollisionFeature; }; @@ -102,7 +102,7 @@ private: // Adds placed items to the buffer. template <typename Buffer, typename GroupType> - void addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float scale, const bool keepUpright, const bool alongLine); + void addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const bool alongLine); public: const std::unique_ptr<const StyleLayoutSymbol> styleLayout; diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 02ffb1fb61..ca76dfe9fe 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -9,7 +9,7 @@ namespace mbgl { const float globalMinScale = 0.5f; // underscale by 1 zoom level -PlacedGlyphs getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, +SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout, const bool alongLine) { @@ -39,7 +39,7 @@ PlacedGlyphs getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, br = br.matMul(matrix); } - PlacedGlyphs quads; + SymbolQuads quads; quads.emplace_back(tl, tr, bl, br, shapedIcon.image, 0, anchor, globalMinScale, std::numeric_limits<float>::infinity()); return quads; } @@ -115,14 +115,14 @@ void getSegmentGlyphs(std::back_insert_iterator<GlyphInstances> glyphs, Anchor & } } -PlacedGlyphs getGlyphQuads(Anchor &anchor, const Shaping &shapedText, +SymbolQuads getGlyphQuads(Anchor &anchor, const Shaping &shapedText, const float boxScale, const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout, const bool alongLine, const GlyphPositions &face) { const float textRotate = layout.text.rotate * M_PI / 180; const bool keepUpright = layout.text.keep_upright; - PlacedGlyphs quads; + SymbolQuads quads; for (const PositionedGlyph &positionedGlyph: shapedText.positionedGlyphs) { auto face_it = face.find(positionedGlyph.glyph); diff --git a/src/mbgl/text/quads.hpp b/src/mbgl/text/quads.hpp index 19acd72f46..b47cc718b6 100644 --- a/src/mbgl/text/quads.hpp +++ b/src/mbgl/text/quads.hpp @@ -1,22 +1,46 @@ #ifndef MBGL_TEXT_QUADS #define MBGL_TEXT_QUADS -#include <mbgl/text/types.hpp> #include <mbgl/text/glyph.hpp> - #include <mbgl/util/vec.hpp> +#include <vector> + namespace mbgl { + struct SymbolQuad { + explicit SymbolQuad(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<SymbolQuad> SymbolQuads; + struct Anchor; class StyleLayoutSymbol; class PositionedIcon; - PlacedGlyphs getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, + SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon, const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout, const bool alongLine); - PlacedGlyphs getGlyphQuads(Anchor &anchor, const Shaping &shapedText, + SymbolQuads getGlyphQuads(Anchor &anchor, const Shaping &shapedText, const float boxScale, const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout, const bool alongLine, const GlyphPositions &face); } diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index 6e55fabae6..41e889333e 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -1,7 +1,6 @@ #ifndef MBGL_TEXT_SHAPING #define MBGL_TEXT_SHAPING -#include <mbgl/text/types.hpp> #include <mbgl/text/glyph.hpp> #include <mbgl/util/vec.hpp> diff --git a/src/mbgl/text/types.hpp b/src/mbgl/text/types.hpp deleted file mode 100644 index 23f49aa748..0000000000 --- a/src/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 |