diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-17 17:00:56 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-23 12:59:27 -0700 |
commit | 72b13cef6a83594b15f47bfeaee782504def619e (patch) | |
tree | b78d9d585ec99823efc62ffb26e8299b099ee8c2 /src/mbgl/text | |
parent | 3d26574cb4077a8b48071e08f07574964587f747 (diff) | |
download | qtlocation-mapboxgl-72b13cef6a83594b15f47bfeaee782504def619e.tar.gz |
[core] Remove unnecessary optionals in PositionedIcon
Lack of icon is already checked at the call site of shapeIcon; no need to check hasArea() here.
Diffstat (limited to 'src/mbgl/text')
-rw-r--r-- | src/mbgl/text/quads.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/text/shaping.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/text/shaping.hpp | 7 |
3 files changed, 6 insertions, 11 deletions
diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 6f13331d4c..dc48634fb0 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -22,7 +22,7 @@ SymbolQuad getIconQuad(const Anchor& anchor, const float layoutTextSize, const style::SymbolPlacementType placement, const Shaping& shapedText) { - auto image = *shapedIcon.image(); + const SpriteAtlasElement& image = shapedIcon.image(); const float border = 1.0; auto left = shapedIcon.left() - border; diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 5c99a49133..6ee646be96 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -10,11 +10,7 @@ namespace mbgl { -optional<PositionedIcon> PositionedIcon::shapeIcon(const SpriteAtlasElement& image, const std::array<float, 2>& iconOffset, const float iconRotation) { - if (!image.pos.hasArea()) { - return {}; - } - +PositionedIcon PositionedIcon::shapeIcon(const SpriteAtlasElement& image, const std::array<float, 2>& iconOffset, const float iconRotation) { float dx = iconOffset[0]; float dy = iconOffset[1]; float x1 = dx - image.size[0] / 2.0f; @@ -22,7 +18,7 @@ optional<PositionedIcon> PositionedIcon::shapeIcon(const SpriteAtlasElement& ima float y1 = dy - image.size[1] / 2.0f; float y2 = y1 + image.size[1]; - return { PositionedIcon { image, y1, y2, x1, x2, iconRotation } }; + return PositionedIcon { image, y1, y2, x1, x2, iconRotation }; } void align(Shaping& shaping, diff --git a/src/mbgl/text/shaping.hpp b/src/mbgl/text/shaping.hpp index b7eee5a5db..bf81b9213c 100644 --- a/src/mbgl/text/shaping.hpp +++ b/src/mbgl/text/shaping.hpp @@ -3,7 +3,6 @@ #include <mbgl/text/glyph.hpp> #include <mbgl/sprite/sprite_atlas.hpp> #include <mbgl/style/image.hpp> -#include <mbgl/util/optional.hpp> namespace mbgl { @@ -26,7 +25,7 @@ private: _right(right_), _angle(angle_) {} - optional<SpriteAtlasElement> _image; + SpriteAtlasElement _image; float _top; float _bottom; float _left; @@ -34,9 +33,9 @@ private: float _angle; public: - static optional<PositionedIcon> shapeIcon(const class SpriteAtlasElement&, const std::array<float, 2>& iconOffset, const float iconRotation); + static PositionedIcon shapeIcon(const SpriteAtlasElement&, const std::array<float, 2>& iconOffset, const float iconRotation); - optional<class SpriteAtlasElement> image() const { return _image; } + const SpriteAtlasElement& image() const { return _image; } float top() const { return _top; } float bottom() const { return _bottom; } float left() const { return _left; } |