summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2014-12-03 22:02:55 +1100
committerLeith Bade <leith@mapbox.com>2014-12-03 22:02:55 +1100
commit94d34ce7ac7182a1ff7cc0dea675abcdd7592b56 (patch)
treee5f23d9ec5ff189873928ee6ef9e2d5ea3f7dee0 /platform
parentf090d6b2642a4b28f9690c4724a2f702d82f4072 (diff)
parent82f3574d09064a442e30eb2dc7639f473749c5bd (diff)
downloadqtlocation-mapboxgl-94d34ce7ac7182a1ff7cc0dea675abcdd7592b56.tar.gz
Merge branch 'master' of github.com:mapbox/mapbox-gl-native into android-mason
Conflicts: src/map/map.cpp
Diffstat (limited to 'platform')
-rw-r--r--platform/darwin/http_request_baton_cocoa.mm6
-rw-r--r--platform/darwin/image.mm3
-rw-r--r--platform/default/headless_view.cpp6
-rw-r--r--platform/default/http_request_baton_curl.cpp5
-rw-r--r--platform/default/image.cpp3
-rw-r--r--platform/default/image_reader.cpp4
6 files changed, 16 insertions, 11 deletions
diff --git a/platform/darwin/http_request_baton_cocoa.mm b/platform/darwin/http_request_baton_cocoa.mm
index 1c54dbdc1f..4eea1d8f8b 100644
--- a/platform/darwin/http_request_baton_cocoa.mm
+++ b/platform/darwin/http_request_baton_cocoa.mm
@@ -51,7 +51,7 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
} else {
// TODO: Use different codes for host not found, timeout, invalid URL etc.
// These can be categorized in temporary and permanent errors.
- baton->response = std::make_unique<Response>();
+ baton->response = util::make_unique<Response>();
baton->response->code = [(NSHTTPURLResponse *)res statusCode];
baton->response->message = [[error localizedDescription] UTF8String];
@@ -86,7 +86,7 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
// Assume a Response object already exists.
assert(baton->response);
} else {
- baton->response = std::make_unique<Response>();
+ baton->response = util::make_unique<Response>();
baton->response->code = code;
baton->response->data = {(const char *)[data bytes], [data length]};
}
@@ -117,7 +117,7 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &ptr) {
} else {
// This should never happen.
baton->type = HTTPResponseType::PermanentError;
- baton->response = std::make_unique<Response>();
+ baton->response = util::make_unique<Response>();
baton->response->code = -1;
baton->response->message = "response class is not NSHTTPURLResponse";
}
diff --git a/platform/darwin/image.mm b/platform/darwin/image.mm
index b8df3c403e..4819d2cd3c 100644
--- a/platform/darwin/image.mm
+++ b/platform/darwin/image.mm
@@ -1,4 +1,5 @@
#include <mbgl/util/image.hpp>
+#include <mbgl/util/std.hpp>
#import <ImageIO/ImageIO.h>
@@ -97,7 +98,7 @@ Image::Image(const std::string &source_data) {
height = uint32_t(CGImageGetHeight(image));
CGRect rect = {{ 0, 0 }, { static_cast<CGFloat>(width), static_cast<CGFloat>(height) }};
- img = ::std::unique_ptr<char[]>(new char[width * height * 4]());
+ img = util::make_unique<char[]>(width * height * 4);
CGContextRef context = CGBitmapContextCreate(img.get(), width, height, 8, width * 4,
color_space, kCGImageAlphaPremultipliedLast);
if (!context) {
diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp
index c23ddadd6b..2f74b9c763 100644
--- a/platform/default/headless_view.cpp
+++ b/platform/default/headless_view.cpp
@@ -1,6 +1,8 @@
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/headless_display.hpp>
+#include <mbgl/util/std.hpp>
+
#include <stdexcept>
#include <sstream>
#include <string>
@@ -253,14 +255,14 @@ std::unique_ptr<uint32_t[]> HeadlessView::readPixels() {
const unsigned int w = width_ * pixelRatio_;
const unsigned int h = height_ * pixelRatio_;
- auto pixels = std::unique_ptr<uint32_t[]>(new uint32_t[w * h]);
+ auto pixels = util::make_unique<uint32_t[]>(w * h);
make_active();
glReadPixels(0, 0, width_, height_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get());
make_inactive();
const int stride = w * 4;
- auto tmp = std::unique_ptr<char[]>(new char[stride]());
+ auto tmp = util::make_unique<char[]>(stride);
char *rgba = reinterpret_cast<char *>(pixels.get());
for (int i = 0, j = height_ - 1; i < j; i++, j--) {
std::memcpy(tmp.get(), rgba + i * stride, stride);
diff --git a/platform/default/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp
index 931f8955ec..9ddd5c501b 100644
--- a/platform/default/http_request_baton_curl.cpp
+++ b/platform/default/http_request_baton_curl.cpp
@@ -3,6 +3,7 @@
#include <mbgl/util/uv-messenger.h>
#include <mbgl/util/time.hpp>
#include <mbgl/util/string.hpp>
+#include <mbgl/util/std.hpp>
#ifdef __ANDROID__
#include <mbgl/android/jni.hpp>
@@ -122,7 +123,7 @@ struct Context {
CURLMcode error = curl_multi_remove_handle(multi, handle);
if (error != CURLM_OK) {
- baton->response = std::unique_ptr<Response>(new Response());
+ baton->response = util::make_unique<Response>();
baton->response->code = -1;
baton->response->message = curl_multi_strerror(error);
}
@@ -534,7 +535,7 @@ void start_request(void *const ptr) {
}
if (!context->baton->response) {
- context->baton->response = std::unique_ptr<Response>(new Response());
+ context->baton->response = util::make_unique<Response>();
}
// Carry on the shared pointer in the private information of the CURL handle.
diff --git a/platform/default/image.cpp b/platform/default/image.cpp
index 8c794fc31f..311aa2ed72 100644
--- a/platform/default/image.cpp
+++ b/platform/default/image.cpp
@@ -1,6 +1,7 @@
#include <mbgl/util/image.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/string.hpp>
+#include <mbgl/util/std.hpp>
#include <png.h>
@@ -81,7 +82,7 @@ Image::Image(std::string const& data)
auto reader = getImageReader(data.c_str(), data.size());
width = reader->width();
height = reader->height();
- img = ::std::unique_ptr<char[]>(new char[width * height * 4]());
+ img = util::make_unique<char[]>(width * height * 4);
reader->read(0, 0, width, height, img.get());
}
catch (ImageReaderException const& ex)
diff --git a/platform/default/image_reader.cpp b/platform/default/image_reader.cpp
index e80ccb6819..fc6daec6a5 100644
--- a/platform/default/image_reader.cpp
+++ b/platform/default/image_reader.cpp
@@ -49,11 +49,11 @@ std::unique_ptr<ImageReader> getImageReader(char const* data, size_t size)
{
if (*type == "png")
{
- return std::make_unique<PngReader<boost::iostreams::array_source>>(data, size);
+ return util::make_unique<PngReader<boost::iostreams::array_source>>(data, size);
}
else if (*type == "jpeg")
{
- return std::make_unique<JpegReader<boost::iostreams::array_source>>(data, size);
+ return util::make_unique<JpegReader<boost::iostreams::array_source>>(data, size);
}
}
throw ImageReaderException("ImageReader: can't determine type from input data");