diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-01 17:38:50 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-12-01 18:05:54 -0800 |
commit | e5181e2668beac377ac4bd93ab2bcb849f33b18a (patch) | |
tree | 5f0dd2d01d374457956438f7e4e13ce7f639e970 /src/mbgl/sprite/sprite_atlas.hpp | |
parent | e326d4972f6320c53be6ac0c696688f4918d4614 (diff) | |
download | qtlocation-mapboxgl-e5181e2668beac377ac4bd93ab2bcb849f33b18a.tar.gz |
[core] Use optional where SpriteAtlas return values might not exist
Fixes #3162
Diffstat (limited to 'src/mbgl/sprite/sprite_atlas.hpp')
-rw-r--r-- | src/mbgl/sprite/sprite_atlas.hpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mbgl/sprite/sprite_atlas.hpp b/src/mbgl/sprite/sprite_atlas.hpp index 0e3e8cf225..0d1e52cf81 100644 --- a/src/mbgl/sprite/sprite_atlas.hpp +++ b/src/mbgl/sprite/sprite_atlas.hpp @@ -6,6 +6,8 @@ #include <mbgl/util/noncopyable.hpp> #include <mbgl/util/ptr.hpp> +#include <mapbox/optional.hpp> + #include <string> #include <map> #include <mutex> @@ -41,15 +43,12 @@ public: SpriteAtlas(dimension width, dimension height, float pixelRatio, SpriteStore& store); ~SpriteAtlas(); - // Returns the coordinates of an image that is sourced from the sprite image. - // This getter attempts to read the image from the sprite if it is already loaded. - // In that case, it copies it into the sprite atlas and returns the dimensions. - // Otherwise, it returns a 0/0/0/0 rect. - // This function is used during bucket creation. - SpriteAtlasElement getImage(const std::string& name, const bool wrap); + // If the sprite is loaded, copies the requsted image from it into the atlas and returns + // the resulting icon measurements. If not, returns an empty optional. + mapbox::util::optional<SpriteAtlasElement> getImage(const std::string& name, const bool wrap); // This function is used for getting the position during render time. - SpriteAtlasPosition getPosition(const std::string& name, bool repeating = false); + mapbox::util::optional<SpriteAtlasPosition> getPosition(const std::string& name, bool repeating = false); // Binds the atlas texture to the GPU, and uploads data if it is out of date. void bind(bool linear = false); |