From 5dd98df50ba1210b1eef0d8d6655713a725f2995 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 21 Apr 2017 14:52:19 -0700 Subject: [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 --- platform/glfw/glfw_view.cpp | 12 ++++++------ platform/glfw/glfw_view.hpp | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'platform/glfw') 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 -#include +#include #include #include #include @@ -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 GLFWView::makeRandomPoint() const { return { latLng.longitude(), latLng.latitude() }; } -std::shared_ptr -GLFWView::makeSpriteImage(int width, int height, float pixelRatio) { +std::unique_ptr +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(std::move(image), pixelRatio); + return std::make_unique(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 makeRandomPoint() const; - static std::shared_ptr - makeSpriteImage(int width, int height, float pixelRatio); + static std::unique_ptr makeImage(int width, int height, float pixelRatio); void nextOrientation(); -- cgit v1.2.1