diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-21 14:52:19 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-24 15:52:28 -0700 |
commit | 5dd98df50ba1210b1eef0d8d6655713a725f2995 (patch) | |
tree | b289bb3cbad5d1c3076816f4891a057d6089fc93 /platform/glfw | |
parent | 6f708ac5458fe332e25ca398431928b7ff5ba404 (diff) | |
download | qtlocation-mapboxgl-5dd98df50ba1210b1eef0d8d6655713a725f2995.tar.gz |
[all] Rationalize style::Image
A style has a collection of images, just as it has collections of sources and layers.
* Name things appropriately
* Use std::unique_ptr
Diffstat (limited to 'platform/glfw')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 12 | ||||
-rw-r--r-- | platform/glfw/glfw_view.hpp | 3 |
2 files changed, 7 insertions, 8 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 5e9083f503..f4ade26885 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -1,7 +1,7 @@ #include "glfw_view.hpp" #include <mbgl/annotation/annotation.hpp> -#include <mbgl/sprite/sprite_image.hpp> +#include <mbgl/style/image.hpp> #include <mbgl/style/transition_options.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/util/platform.hpp> @@ -124,7 +124,7 @@ GLFWView::~GLFWView() { void GLFWView::setMap(mbgl::Map *map_) { map = map_; - map->addAnnotationIcon("default_marker", makeSpriteImage(22, 22, 1)); + map->addAnnotationImage("default_marker", makeImage(22, 22, 1)); } void GLFWView::updateAssumedState() { @@ -258,8 +258,8 @@ mbgl::Point<double> GLFWView::makeRandomPoint() const { return { latLng.longitude(), latLng.latitude() }; } -std::shared_ptr<const mbgl::SpriteImage> -GLFWView::makeSpriteImage(int width, int height, float pixelRatio) { +std::unique_ptr<mbgl::style::Image> +GLFWView::makeImage(int width, int height, float pixelRatio) { const int r = 255 * (double(std::rand()) / RAND_MAX); const int g = 255 * (double(std::rand()) / RAND_MAX); const int b = 255 * (double(std::rand()) / RAND_MAX); @@ -284,7 +284,7 @@ GLFWView::makeSpriteImage(int width, int height, float pixelRatio) { } } - return std::make_shared<mbgl::SpriteImage>(std::move(image), pixelRatio); + return std::make_unique<mbgl::style::Image>(std::move(image), pixelRatio); } void GLFWView::nextOrientation() { @@ -301,7 +301,7 @@ void GLFWView::addRandomCustomPointAnnotations(int count) { for (int i = 0; i < count; i++) { static int spriteID = 1; const auto name = std::string{ "marker-" } + mbgl::util::toString(spriteID++); - map->addAnnotationIcon(name, makeSpriteImage(22, 22, 1)); + map->addAnnotationImage(name, makeImage(22, 22, 1)); spriteIDs.push_back(name); annotationIDs.push_back(map->addAnnotation(mbgl::SymbolAnnotation { makeRandomPoint(), name })); } diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index bc50eba819..09b8847ff2 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -65,8 +65,7 @@ private: mbgl::Color makeRandomColor() const; mbgl::Point<double> makeRandomPoint() const; - static std::shared_ptr<const mbgl::SpriteImage> - makeSpriteImage(int width, int height, float pixelRatio); + static std::unique_ptr<mbgl::style::Image> makeImage(int width, int height, float pixelRatio); void nextOrientation(); |