Replace mbgl::util::make_unique<> with std::make_unique<>
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include <mbgl/platform/event.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
@@ -214,7 +213,7 @@ void NativeMapView::initializeDisplay() {
|
||||
throw new std::runtime_error("eglChooseConfig() failed");
|
||||
}
|
||||
|
||||
const std::unique_ptr<EGLConfig[]> configs = mbgl::util::make_unique<EGLConfig[]>(numConfigs);
|
||||
const auto configs = std::make_unique<EGLConfig[]>(numConfigs);
|
||||
if (!eglChooseConfig(display, configAttribs, configs.get(), numConfigs, &numConfigs)) {
|
||||
mbgl::Log::Error(mbgl::Event::OpenGL, "eglChooseConfig() returned error %d", eglGetError());
|
||||
throw new std::runtime_error("eglChooseConfig() failed");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/still_image.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
|
||||
#include <mbgl/platform/default/headless_view.hpp>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef MBGL_UTIL_IMAGE_READER_HPP
|
||||
#define MBGL_UTIL_IMAGE_READER_HPP
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
// stl
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl { namespace util {
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <mbgl/platform/event.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "resource.hpp"
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -8,29 +8,6 @@
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
// C++14 backfill based on http://llvm.org/svn/llvm-project/libcxx/trunk/include/memory
|
||||
|
||||
namespace detail {
|
||||
template<class T> struct unique_type { typedef ::std::unique_ptr<T> single; };
|
||||
template<class T> struct unique_type<T[]> { typedef ::std::unique_ptr<T[]> unknown_bound; };
|
||||
template<class T, size_t size> struct unique_type<T[size]> { typedef void known_bound; };
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
typename detail::unique_type<T>::single make_unique(Args&&... args) {
|
||||
return ::std::unique_ptr<T>(new T(::std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
typename detail::unique_type<T>::unknown_bound make_unique(size_t size) {
|
||||
return ::std::unique_ptr<T>(new typename ::std::remove_extent<T>::type[size]());
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
typename detail::unique_type<T>::known_bound make_unique(Args&&...) = delete;
|
||||
|
||||
|
||||
|
||||
template <typename Container, typename ForwardIterator, typename Predicate>
|
||||
void erase_if(Container &container, ForwardIterator it, const ForwardIterator end, Predicate pred) {
|
||||
while (it != end) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <mbgl/mbgl.hpp>
|
||||
#include "../platform/default/default_styles.hpp"
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
@@ -66,7 +65,7 @@ int main(int argc, char *argv[]) {
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
view = mbgl::util::make_unique<GLFWView>();
|
||||
view = std::make_unique<GLFWView>();
|
||||
|
||||
mbgl::SQLiteCache cache("/tmp/mbgl-cache.db");
|
||||
mbgl::DefaultFileSource fileSource(&cache);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/response.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/util/parsedate.h>
|
||||
|
||||
@@ -250,7 +249,7 @@ void HTTPRequest::handleResult(NSData *data, NSURLResponse *res, NSError *error)
|
||||
} else {
|
||||
// TODO: Use different codes for host not found, timeout, invalid URL etc.
|
||||
// These can be categorized in temporary and permanent errors.
|
||||
response = util::make_unique<Response>();
|
||||
response = std::make_unique<Response>();
|
||||
response->status = Response::Error;
|
||||
response->message = [[error localizedDescription] UTF8String];
|
||||
|
||||
@@ -282,7 +281,7 @@ void HTTPRequest::handleResult(NSData *data, NSURLResponse *res, NSError *error)
|
||||
} else if ([res isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||
const long responseCode = [(NSHTTPURLResponse *)res statusCode];
|
||||
|
||||
response = util::make_unique<Response>();
|
||||
response = std::make_unique<Response>();
|
||||
response->data = {(const char *)[data bytes], [data length]};
|
||||
|
||||
NSDictionary *headers = [(NSHTTPURLResponse *)res allHeaderFields];
|
||||
@@ -338,7 +337,7 @@ void HTTPRequest::handleResult(NSData *data, NSURLResponse *res, NSError *error)
|
||||
} else {
|
||||
// This should never happen.
|
||||
status = ResponseStatus::PermanentError;
|
||||
response = util::make_unique<Response>();
|
||||
response = std::make_unique<Response>();
|
||||
response->status = Response::Error;
|
||||
response->message = "response class is not NSHTTPURLResponse";
|
||||
}
|
||||
@@ -364,7 +363,7 @@ void HTTPRequest::retry() {
|
||||
}
|
||||
|
||||
std::unique_ptr<HTTPContext> HTTPContext::createContext(uv_loop_t* loop) {
|
||||
return util::make_unique<HTTPNSURLContext>(loop);
|
||||
return std::make_unique<HTTPNSURLContext>(loop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#import <ImageIO/ImageIO.h>
|
||||
|
||||
@@ -98,7 +97,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 = util::make_unique<char[]>(width * height * 4);
|
||||
img = std::make_unique<char[]>(width * height * 4);
|
||||
CGContextRef context = CGBitmapContextCreate(img.get(), width, height, 8, width * 4,
|
||||
color_space, kCGImageAlphaPremultipliedLast);
|
||||
if (!context) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/storage/asset_context.hpp>
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/response.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
#include <mbgl/util/url.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
@@ -114,7 +113,7 @@ void AssetRequest::fileStated(uv_fs_t *req) {
|
||||
if (stat->st_size > std::numeric_limits<int>::max()) {
|
||||
// File is too large for us to open this way because uv_buf's only support unsigned
|
||||
// ints as maximum size.
|
||||
auto response = util::make_unique<Response>();
|
||||
auto response = std::make_unique<Response>();
|
||||
response->status = Response::Error;
|
||||
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
|
||||
response->message = uv_strerror(uv_err_t {UV_EFBIG, 0});
|
||||
@@ -126,7 +125,7 @@ void AssetRequest::fileStated(uv_fs_t *req) {
|
||||
uv_fs_req_cleanup(req);
|
||||
uv_fs_close(req->loop, req, self->fd, fileClosed);
|
||||
} else {
|
||||
self->response = util::make_unique<Response>();
|
||||
self->response = std::make_unique<Response>();
|
||||
#ifdef __APPLE__
|
||||
self->response->modified = stat->st_mtimespec.tv_sec;
|
||||
#else
|
||||
@@ -184,7 +183,7 @@ void AssetRequest::notifyError(uv_fs_t *req) {
|
||||
MBGL_VERIFY_THREAD(self->tid);
|
||||
|
||||
if (req->result < 0 && !self->canceled && req->result != UV_ECANCELED) {
|
||||
auto response = util::make_unique<Response>();
|
||||
auto response = std::make_unique<Response>();
|
||||
response->status = Response::Error;
|
||||
response->message = uv::getFileRequestError(req);
|
||||
self->notify(std::move(response), FileCache::Hint::No);
|
||||
@@ -208,7 +207,7 @@ void AssetRequest::cancel() {
|
||||
}
|
||||
|
||||
std::unique_ptr<AssetContext> AssetContext::createContext(uv_loop_t*) {
|
||||
return util::make_unique<AssetFSContext>();
|
||||
return std::make_unique<AssetFSContext>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/storage/resource.hpp>
|
||||
#include <mbgl/storage/response.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/util.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
@@ -178,7 +177,7 @@ void AssetRequest::fileStated(uv_zip_t *zip) {
|
||||
notifyError("Could not determine file size in zip file");
|
||||
cleanup(zip);
|
||||
} else {
|
||||
response = util::make_unique<Response>();
|
||||
response = std::make_unique<Response>();
|
||||
|
||||
// Allocate the space for reading the data.
|
||||
response->data.resize(zip->stat->size);
|
||||
@@ -247,7 +246,7 @@ void AssetRequest::notifyError(const char *message) {
|
||||
MBGL_VERIFY_THREAD(tid);
|
||||
|
||||
if (!cancelled) {
|
||||
response = util::make_unique<Response>();
|
||||
response = std::make_unique<Response>();
|
||||
response->status = Response::Error;
|
||||
response->message = message;
|
||||
notify(std::move(response), FileCache::Hint::No);
|
||||
@@ -261,7 +260,7 @@ void AssetRequest::cancel() {
|
||||
}
|
||||
|
||||
std::unique_ptr<AssetContext> AssetContext::createContext(uv_loop_t* loop) {
|
||||
return util::make_unique<AssetZipContext>(loop);
|
||||
return std::make_unique<AssetZipContext>(loop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <mbgl/map/still_image.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
@@ -172,15 +171,15 @@ std::unique_ptr<StillImage> HeadlessView::readStillImage() {
|
||||
const unsigned int w = dimensions.pixelWidth();
|
||||
const unsigned int h = dimensions.pixelHeight();
|
||||
|
||||
auto image = util::make_unique<StillImage>();
|
||||
auto image = std::make_unique<StillImage>();
|
||||
image->width = w;
|
||||
image->height = h;
|
||||
image->pixels = util::make_unique<uint32_t[]>(w * h);
|
||||
image->pixels = std::make_unique<uint32_t[]>(w * h);
|
||||
|
||||
MBGL_CHECK_ERROR(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels.get()));
|
||||
|
||||
const int stride = w * 4;
|
||||
auto tmp = util::make_unique<char[]>(stride);
|
||||
auto tmp = std::make_unique<char[]>(stride);
|
||||
char *rgba = reinterpret_cast<char *>(image->pixels.get());
|
||||
for (int i = 0, j = h - 1; i < j; i++, j--) {
|
||||
std::memcpy(tmp.get(), rgba + i * stride, stride);
|
||||
|
||||
@@ -385,7 +385,7 @@ static CURLcode sslctx_function(CURL * /* curl */, void *sslctx, void * /* parm
|
||||
return CURLE_SSL_CACERT_BADFILE;
|
||||
}
|
||||
|
||||
const auto pem = util::make_unique<char[]>(stat.size);
|
||||
const auto pem = std::make_unique<char[]>(stat.size);
|
||||
|
||||
if (static_cast<zip_uint64_t>(zip_fread(apkFile, reinterpret_cast<void *>(pem.get()), stat.size)) != stat.size) {
|
||||
zip_fclose(apkFile);
|
||||
@@ -537,7 +537,7 @@ size_t HTTPRequest::writeCallback(void *const contents, const size_t size, const
|
||||
MBGL_VERIFY_THREAD(impl->tid);
|
||||
|
||||
if (!impl->response) {
|
||||
impl->response = util::make_unique<Response>();
|
||||
impl->response = std::make_unique<Response>();
|
||||
}
|
||||
|
||||
impl->response->data.append((char *)contents, size * nmemb);
|
||||
@@ -581,7 +581,7 @@ size_t HTTPRequest::headerCallback(char *const buffer, const size_t size, const
|
||||
MBGL_VERIFY_THREAD(baton->tid);
|
||||
|
||||
if (!baton->response) {
|
||||
baton->response = util::make_unique<Response>();
|
||||
baton->response = std::make_unique<Response>();
|
||||
}
|
||||
|
||||
const size_t length = size * nmemb;
|
||||
@@ -675,7 +675,7 @@ void HTTPRequest::handleResult(CURLcode code) {
|
||||
// Make sure a response object exists in case we haven't got any headers
|
||||
// or content.
|
||||
if (!response) {
|
||||
response = util::make_unique<Response>();
|
||||
response = std::make_unique<Response>();
|
||||
}
|
||||
|
||||
// Add human-readable error code
|
||||
@@ -734,7 +734,7 @@ void HTTPRequest::handleResult(CURLcode code) {
|
||||
}
|
||||
|
||||
std::unique_ptr<HTTPContext> HTTPContext::createContext(uv_loop_t* loop) {
|
||||
return util::make_unique<HTTPCURLContext>(loop);
|
||||
return std::make_unique<HTTPCURLContext>(loop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <png.h>
|
||||
|
||||
@@ -82,7 +81,7 @@ Image::Image(std::string const& data)
|
||||
auto reader = getImageReader(data.c_str(), data.size());
|
||||
width = reader->width();
|
||||
height = reader->height();
|
||||
img = util::make_unique<char[]>(width * height * 4);
|
||||
img = std::make_unique<char[]>(width * height * 4);
|
||||
reader->read(0, 0, width, height, img.get());
|
||||
}
|
||||
catch (ImageReaderException const& ex)
|
||||
|
||||
@@ -49,11 +49,11 @@ std::unique_ptr<ImageReader> getImageReader(char const* data, size_t size)
|
||||
{
|
||||
if (*type == "png")
|
||||
{
|
||||
return util::make_unique<PngReader<boost::iostreams::array_source>>(data, size);
|
||||
return std::make_unique<PngReader<boost::iostreams::array_source>>(data, size);
|
||||
}
|
||||
else if (*type == "jpeg")
|
||||
{
|
||||
return util::make_unique<JpegReader<boost::iostreams::array_source>>(data, size);
|
||||
return std::make_unique<JpegReader<boost::iostreams::array_source>>(data, size);
|
||||
}
|
||||
}
|
||||
throw ImageReaderException("ImageReader: can't determine type from input data");
|
||||
|
||||
@@ -62,7 +62,7 @@ std::string unifyMapboxURLs(const std::string &url) {
|
||||
using namespace mapbox::sqlite;
|
||||
|
||||
SQLiteCache::SQLiteCache(const std::string& path_)
|
||||
: thread(util::make_unique<util::Thread<Impl>>("SQLite Cache", util::ThreadPriority::Low, path_)) {
|
||||
: thread(std::make_unique<util::Thread<Impl>>("SQLite Cache", util::ThreadPriority::Low, path_)) {
|
||||
}
|
||||
|
||||
SQLiteCache::~SQLiteCache() = default;
|
||||
@@ -85,7 +85,7 @@ SQLiteCache::Impl::~Impl() {
|
||||
}
|
||||
|
||||
void SQLiteCache::Impl::createDatabase() {
|
||||
db = util::make_unique<Database>(path.c_str(), ReadWrite | Create);
|
||||
db = std::make_unique<Database>(path.c_str(), ReadWrite | Create);
|
||||
}
|
||||
|
||||
void SQLiteCache::Impl::createSchema() {
|
||||
@@ -114,7 +114,7 @@ void SQLiteCache::Impl::createSchema() {
|
||||
} catch (util::IOException& ioEx) {
|
||||
Log::Error(Event::Database, ex.code, ex.what());
|
||||
}
|
||||
db = util::make_unique<Database>(path.c_str(), ReadWrite | Create);
|
||||
db = std::make_unique<Database>(path.c_str(), ReadWrite | Create);
|
||||
} else {
|
||||
Log::Error(Event::Database, ex.code, ex.what());
|
||||
}
|
||||
@@ -146,8 +146,8 @@ std::unique_ptr<Response> SQLiteCache::Impl::get(const Resource &resource) {
|
||||
}
|
||||
|
||||
if (!getStmt) {
|
||||
// Initialize the statement 0 1
|
||||
getStmt = util::make_unique<Statement>(db->prepare("SELECT `status`, `modified`, "
|
||||
// Initialize the statement 0 1
|
||||
getStmt = std::make_unique<Statement>(db->prepare("SELECT `status`, `modified`, "
|
||||
// 2 3 4 5 1
|
||||
"`etag`, `expires`, `data`, `compressed` FROM `http_cache` WHERE `url` = ?"));
|
||||
} else {
|
||||
@@ -158,7 +158,7 @@ std::unique_ptr<Response> SQLiteCache::Impl::get(const Resource &resource) {
|
||||
getStmt->bind(1, unifiedURL.c_str());
|
||||
if (getStmt->run()) {
|
||||
// There is data.
|
||||
auto response = util::make_unique<Response>();
|
||||
auto response = std::make_unique<Response>();
|
||||
response->status = Response::Status(getStmt->get<int>(0));
|
||||
response->modified = getStmt->get<int64_t>(1);
|
||||
response->etag = getStmt->get<std::string>(2);
|
||||
@@ -200,7 +200,7 @@ void SQLiteCache::Impl::put(const Resource& resource, std::shared_ptr<const Resp
|
||||
}
|
||||
|
||||
if (!putStmt) {
|
||||
putStmt = util::make_unique<Statement>(db->prepare("REPLACE INTO `http_cache` ("
|
||||
putStmt = std::make_unique<Statement>(db->prepare("REPLACE INTO `http_cache` ("
|
||||
// 1 2 3 4 5 6 7 8
|
||||
"`url`, `status`, `kind`, `modified`, `etag`, `expires`, `data`, `compressed`"
|
||||
") VALUES(?, ?, ?, ?, ?, ?, ?, ?)"));
|
||||
@@ -249,7 +249,7 @@ void SQLiteCache::Impl::refresh(const Resource& resource, int64_t expires) {
|
||||
}
|
||||
|
||||
if (!refreshStmt) {
|
||||
refreshStmt = util::make_unique<Statement>( // 1 2
|
||||
refreshStmt = std::make_unique<Statement>( // 1 2
|
||||
db->prepare("UPDATE `http_cache` SET `expires` = ? WHERE `url` = ?"));
|
||||
} else {
|
||||
refreshStmt->reset();
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -18,7 +16,7 @@ GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_)
|
||||
: width(width_),
|
||||
height(height_),
|
||||
bin(width_, height_),
|
||||
data(util::make_unique<uint8_t[]>(width_ * height_)),
|
||||
data(std::make_unique<uint8_t[]>(width_ * height_)),
|
||||
dirty(true) {
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
@@ -15,7 +14,7 @@ using namespace mbgl;
|
||||
LineAtlas::LineAtlas(uint16_t w, uint16_t h)
|
||||
: width(w),
|
||||
height(h),
|
||||
data(util::make_unique<uint8_t[]>(w * h)),
|
||||
data(std::make_unique<uint8_t[]>(w * h)),
|
||||
dirty(true) {
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ void SpriteAtlas::allocate() {
|
||||
if (!data) {
|
||||
dimension w = static_cast<dimension>(width * pixelRatio);
|
||||
dimension h = static_cast<dimension>(height * pixelRatio);
|
||||
data = util::make_unique<uint32_t[]>(w * h);
|
||||
data = std::make_unique<uint32_t[]>(w * h);
|
||||
std::fill(data.get(), data.get() + w * h, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/map/map_data.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
@@ -110,7 +109,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
|
||||
// track the annotation global ID and its geometry
|
||||
auto anno_it = annotations.emplace(
|
||||
annotationID,
|
||||
util::make_unique<Annotation>(AnnotationType::Point,
|
||||
std::make_unique<Annotation>(AnnotationType::Point,
|
||||
AnnotationSegments({ { points[i] } })));
|
||||
|
||||
const uint8_t maxZoom = data.transform.getMaxZoom();
|
||||
@@ -162,7 +161,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
|
||||
// create tile & record annotation association
|
||||
auto tile_pos = tiles.emplace(
|
||||
tileID, std::make_pair(std::unordered_set<uint32_t>({ annotationID }),
|
||||
util::make_unique<LiveTile>()));
|
||||
std::make_unique<LiveTile>()));
|
||||
// add point layer to tile
|
||||
tile_pos.first->second.second->addLayer(layerID, layer);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/map/tile_id.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
#include <mbgl/map/view.hpp>
|
||||
#include <mbgl/map/map_data.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/projection.hpp>
|
||||
#include <mbgl/util/thread.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
Map::Map(View& view, FileSource& fileSource, MapMode mode)
|
||||
: data(util::make_unique<MapData>(view, mode)),
|
||||
context(util::make_unique<util::Thread<MapContext>>("Map", util::ThreadPriority::Regular, view, fileSource, *data))
|
||||
: data(std::make_unique<MapData>(view, mode)),
|
||||
context(std::make_unique<util::Thread<MapContext>>("Map", util::ThreadPriority::Regular, view, fileSource, *data))
|
||||
{
|
||||
view.initialize(this);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include <mbgl/style/style.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/worker.hpp>
|
||||
#include <mbgl/util/texture_pool.hpp>
|
||||
@@ -34,12 +33,12 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map
|
||||
env(fileSource),
|
||||
envScope(env, ThreadType::Map, "Map"),
|
||||
updated(static_cast<UpdateType>(Update::Nothing)),
|
||||
asyncUpdate(util::make_unique<uv::async>(loop, [this] { update(); })),
|
||||
glyphStore(util::make_unique<GlyphStore>(loop, env)),
|
||||
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
|
||||
spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)),
|
||||
lineAtlas(util::make_unique<LineAtlas>(512, 512)),
|
||||
texturePool(util::make_unique<TexturePool>()) {
|
||||
asyncUpdate(std::make_unique<uv::async>(loop, [this] { update(); })),
|
||||
glyphStore(std::make_unique<GlyphStore>(loop, env)),
|
||||
glyphAtlas(std::make_unique<GlyphAtlas>(1024, 1024)),
|
||||
spriteAtlas(std::make_unique<SpriteAtlas>(512, 512)),
|
||||
lineAtlas(std::make_unique<LineAtlas>(512, 512)),
|
||||
texturePool(std::make_unique<TexturePool>()) {
|
||||
assert(Environment::currentlyOn(ThreadType::Map));
|
||||
|
||||
asyncUpdate->unref();
|
||||
@@ -120,7 +119,7 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base)
|
||||
resourceLoader.reset();
|
||||
style.reset();
|
||||
|
||||
style = util::make_unique<Style>();
|
||||
style = std::make_unique<Style>();
|
||||
style->base = base;
|
||||
style->loadJSON((const uint8_t *)json.c_str());
|
||||
style->cascade(data.getClasses());
|
||||
@@ -128,7 +127,7 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base)
|
||||
|
||||
glyphStore->setURL(style->glyph_url);
|
||||
|
||||
resourceLoader = util::make_unique<ResourceLoader>();
|
||||
resourceLoader = std::make_unique<ResourceLoader>();
|
||||
resourceLoader->setObserver(this);
|
||||
resourceLoader->setStyle(style.get());
|
||||
resourceLoader->setGlyphStore(glyphStore.get());
|
||||
@@ -221,7 +220,7 @@ void MapContext::render() {
|
||||
assert(style);
|
||||
|
||||
if (!painter) {
|
||||
painter = util::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas);
|
||||
painter = std::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas);
|
||||
painter->setup();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ void ResourceLoader::update(MapData& data,
|
||||
|
||||
const float pixelRatio = transform.getPixelRatio();
|
||||
if (!sprite_ || !sprite_->hasPixelRatio(pixelRatio)) {
|
||||
sprite_ = util::make_unique<Sprite>(style_->getSpriteURL(), pixelRatio);
|
||||
sprite_ = std::make_unique<Sprite>(style_->getSpriteURL(), pixelRatio);
|
||||
sprite_->setObserver(this);
|
||||
|
||||
spriteAtlas.resize(pixelRatio);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/token.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/tile_cover.hpp>
|
||||
@@ -264,7 +265,7 @@ TileData::State Source::addTile(MapData& data,
|
||||
return state;
|
||||
}
|
||||
|
||||
auto pos = tiles.emplace(id, util::make_unique<Tile>(id));
|
||||
auto pos = tiles.emplace(id, std::make_unique<Tile>(id));
|
||||
Tile& new_tile = *pos.first->second;
|
||||
|
||||
// We couldn't find the tile in the list. Create a new one.
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <mbgl/storage/response.hpp>
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include <mbgl/util/raster.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
@@ -107,7 +106,7 @@ bool Sprite::hasPixelRatio(float ratio) const {
|
||||
}
|
||||
|
||||
void Sprite::parseImage() {
|
||||
raster = util::make_unique<util::Image>(image);
|
||||
raster = std::make_unique<util::Image>(image);
|
||||
if (!*raster) {
|
||||
raster.reset();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <mbgl/renderer/line_bucket.hpp>
|
||||
#include <mbgl/renderer/symbol_bucket.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
|
||||
#include <locale>
|
||||
@@ -154,7 +153,7 @@ void TileParser::addBucketGeometries(Bucket& bucket, const GeometryTileLayer& la
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createFillBucket(const GeometryTileLayer& layer,
|
||||
const StyleBucket& bucket_desc) {
|
||||
auto bucket = util::make_unique<FillBucket>(tile.fillVertexBuffer,
|
||||
auto bucket = std::make_unique<FillBucket>(tile.fillVertexBuffer,
|
||||
tile.triangleElementsBuffer,
|
||||
tile.lineElementsBuffer);
|
||||
addBucketGeometries(bucket, layer, bucket_desc.filter);
|
||||
@@ -163,7 +162,7 @@ std::unique_ptr<Bucket> TileParser::createFillBucket(const GeometryTileLayer& la
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createLineBucket(const GeometryTileLayer& layer,
|
||||
const StyleBucket& bucket_desc) {
|
||||
auto bucket = util::make_unique<LineBucket>(tile.lineVertexBuffer,
|
||||
auto bucket = std::make_unique<LineBucket>(tile.lineVertexBuffer,
|
||||
tile.triangleElementsBuffer);
|
||||
|
||||
const float z = tile.id.z;
|
||||
@@ -180,7 +179,7 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const GeometryTileLayer& la
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createSymbolBucket(const GeometryTileLayer& layer,
|
||||
const StyleBucket& bucket_desc) {
|
||||
auto bucket = util::make_unique<SymbolBucket>(*tile.getCollision());
|
||||
auto bucket = std::make_unique<SymbolBucket>(*tile.getCollision());
|
||||
|
||||
const float z = tile.id.z;
|
||||
auto& layout = bucket->layout;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <mbgl/map/view.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/unitbezier.hpp>
|
||||
#include <mbgl/util/interpolate.hpp>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <mbgl/map/vector_tile_data.hpp>
|
||||
#include <mbgl/map/tile_parser.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
#include <mbgl/style/style_bucket.hpp>
|
||||
#include <mbgl/map/source.hpp>
|
||||
@@ -26,7 +25,7 @@ VectorTileData::VectorTileData(const TileID& id_,
|
||||
spriteAtlas(spriteAtlas_),
|
||||
sprite(sprite_),
|
||||
style(style_),
|
||||
collision(util::make_unique<Collision>(id_.z, 4096, source_.tile_size, depth)) {
|
||||
collision(std::make_unique<Collision>(id_.z, 4096, source_.tile_size, depth)) {
|
||||
}
|
||||
|
||||
VectorTileData::~VectorTileData() {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <mbgl/shader/plain_shader.hpp>
|
||||
#include <mbgl/shader/pattern_shader.hpp>
|
||||
#include <mbgl/shader/outline_shader.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
|
||||
@@ -107,7 +106,7 @@ void FillBucket::tessellate() {
|
||||
|
||||
if (!lineGroups.size() || (lineGroups.back()->vertex_length + total_vertex_count > 65535)) {
|
||||
// Move to a new group because the old one can't hold the geometry.
|
||||
lineGroups.emplace_back(util::make_unique<LineGroup>());
|
||||
lineGroups.emplace_back(std::make_unique<LineGroup>());
|
||||
}
|
||||
|
||||
assert(lineGroups.back());
|
||||
@@ -154,7 +153,7 @@ void FillBucket::tessellate() {
|
||||
|
||||
if (!triangleGroups.size() || (triangleGroups.back()->vertex_length + total_vertex_count > 65535)) {
|
||||
// Move to a new group because the old one can't hold the geometry.
|
||||
triangleGroups.emplace_back(util::make_unique<TriangleGroup>());
|
||||
triangleGroups.emplace_back(std::make_unique<TriangleGroup>());
|
||||
}
|
||||
|
||||
// We're generating triangle fans, so we always start with the first
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <mbgl/shader/linesdf_shader.hpp>
|
||||
#include <mbgl/shader/linepattern_shader.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
|
||||
#ifndef BUFFER_OFFSET
|
||||
@@ -290,7 +289,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
|
||||
if (!triangleGroups.size() ||
|
||||
(triangleGroups.back()->vertex_length + vertexCount > 65535)) {
|
||||
// Move to a new group because the old one can't hold the geometry.
|
||||
triangleGroups.emplace_back(util::make_unique<TriangleGroup>());
|
||||
triangleGroups.emplace_back(std::make_unique<TriangleGroup>());
|
||||
}
|
||||
|
||||
assert(triangleGroups.back());
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <mbgl/shader/dot_shader.hpp>
|
||||
#include <mbgl/shader/gaussian_shader.hpp>
|
||||
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/mat3.hpp>
|
||||
|
||||
@@ -94,18 +93,18 @@ void Painter::setup() {
|
||||
}
|
||||
|
||||
void Painter::setupShaders() {
|
||||
if (!plainShader) plainShader = util::make_unique<PlainShader>();
|
||||
if (!outlineShader) outlineShader = util::make_unique<OutlineShader>();
|
||||
if (!lineShader) lineShader = util::make_unique<LineShader>();
|
||||
if (!linesdfShader) linesdfShader = util::make_unique<LineSDFShader>();
|
||||
if (!linepatternShader) linepatternShader = util::make_unique<LinepatternShader>();
|
||||
if (!patternShader) patternShader = util::make_unique<PatternShader>();
|
||||
if (!iconShader) iconShader = util::make_unique<IconShader>();
|
||||
if (!rasterShader) rasterShader = util::make_unique<RasterShader>();
|
||||
if (!sdfGlyphShader) sdfGlyphShader = util::make_unique<SDFGlyphShader>();
|
||||
if (!sdfIconShader) sdfIconShader = util::make_unique<SDFIconShader>();
|
||||
if (!dotShader) dotShader = util::make_unique<DotShader>();
|
||||
if (!gaussianShader) gaussianShader = util::make_unique<GaussianShader>();
|
||||
if (!plainShader) plainShader = std::make_unique<PlainShader>();
|
||||
if (!outlineShader) outlineShader = std::make_unique<OutlineShader>();
|
||||
if (!lineShader) lineShader = std::make_unique<LineShader>();
|
||||
if (!linesdfShader) linesdfShader = std::make_unique<LineSDFShader>();
|
||||
if (!linepatternShader) linepatternShader = std::make_unique<LinepatternShader>();
|
||||
if (!patternShader) patternShader = std::make_unique<PatternShader>();
|
||||
if (!iconShader) iconShader = std::make_unique<IconShader>();
|
||||
if (!rasterShader) rasterShader = std::make_unique<RasterShader>();
|
||||
if (!sdfGlyphShader) sdfGlyphShader = std::make_unique<SDFGlyphShader>();
|
||||
if (!sdfIconShader) sdfIconShader = std::make_unique<SDFIconShader>();
|
||||
if (!dotShader) dotShader = std::make_unique<DotShader>();
|
||||
if (!gaussianShader) gaussianShader = std::make_unique<GaussianShader>();
|
||||
}
|
||||
|
||||
void Painter::resize() {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <mbgl/shader/outline_shader.hpp>
|
||||
#include <mbgl/shader/pattern_shader.hpp>
|
||||
#include <mbgl/shader/plain_shader.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/mat3.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/renderer/raster_bucket.hpp>
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
#include <mbgl/shader/raster_shader.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <mbgl/util/token.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/merge_lines.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#ifndef BUFFER_OFFSET
|
||||
#define BUFFER_OFFSET(i) ((char *)nullptr + (i))
|
||||
@@ -409,7 +408,7 @@ void SymbolBucket::addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float
|
||||
if (!buffer.groups.size() ||
|
||||
(buffer.groups.back()->vertex_length + glyph_vertex_length > 65535)) {
|
||||
// Move to a new group because the old one can't hold the geometry.
|
||||
buffer.groups.emplace_back(util::make_unique<GroupType>());
|
||||
buffer.groups.emplace_back(std::make_unique<GroupType>());
|
||||
}
|
||||
|
||||
// We're generating triangle fans, so we always start with the first
|
||||
|
||||
@@ -51,7 +51,7 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo
|
||||
if (status == 0) {
|
||||
GLint logLength;
|
||||
MBGL_CHECK_ERROR(glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength));
|
||||
std::unique_ptr<GLchar[]> log = mbgl::util::make_unique<GLchar[]>(logLength);
|
||||
const auto log = std::make_unique<GLchar[]>(logLength);
|
||||
if (logLength > 0) {
|
||||
MBGL_CHECK_ERROR(glGetProgramInfoLog(program, logLength, &logLength, log.get()));
|
||||
Log::Error(Event::Shader, "Program failed to link: %s", log.get());
|
||||
@@ -76,7 +76,7 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo
|
||||
if (status == 0) {
|
||||
GLint logLength;
|
||||
MBGL_CHECK_ERROR(glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength));
|
||||
std::unique_ptr<GLchar[]> log = mbgl::util::make_unique<GLchar[]>(logLength);
|
||||
const auto log = std::make_unique<GLchar[]>(logLength);
|
||||
if (logLength > 0) {
|
||||
MBGL_CHECK_ERROR(glGetProgramInfoLog(program, logLength, &logLength, log.get()));
|
||||
Log::Error(Event::Shader, "Program failed to validate: %s", log.get());
|
||||
@@ -115,7 +115,7 @@ bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) {
|
||||
GLint logLength;
|
||||
MBGL_CHECK_ERROR(glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength));
|
||||
if (logLength > 0) {
|
||||
std::unique_ptr<GLchar[]> log = mbgl::util::make_unique<GLchar[]>(logLength);
|
||||
const auto log = std::make_unique<GLchar[]>(logLength);
|
||||
MBGL_CHECK_ERROR(glGetShaderInfoLog(*shader, logLength, &logLength, log.get()));
|
||||
Log::Error(Event::Shader, "Shader failed to compile: %s", log.get());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace algo = boost::algorithm;
|
||||
namespace mbgl {
|
||||
|
||||
DefaultFileSource::DefaultFileSource(FileCache* cache, const std::string& root)
|
||||
: thread(util::make_unique<util::Thread<Impl>>("FileSource", util::ThreadPriority::Low, cache, root)) {
|
||||
: thread(std::make_unique<util::Thread<Impl>>("FileSource", util::ThreadPriority::Low, cache, root)) {
|
||||
}
|
||||
|
||||
DefaultFileSource::~DefaultFileSource() {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/storage/response.hpp>
|
||||
|
||||
#include <mbgl/util/util.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
#include <cassert>
|
||||
@@ -16,7 +15,7 @@ struct Request::Canceled { std::mutex mutex; bool confirmed = false; };
|
||||
|
||||
// Note: This requires that loop is running in the current thread (or not yet running).
|
||||
Request::Request(const Resource &resource_, uv_loop_t *loop, Callback callback_)
|
||||
: async(util::make_unique<uv::async>(loop, [this] { notifyCallback(); })),
|
||||
: async(std::make_unique<uv::async>(loop, [this] { notifyCallback(); })),
|
||||
callback(callback_),
|
||||
resource(resource_) {
|
||||
}
|
||||
@@ -62,7 +61,7 @@ void Request::notify(const std::shared_ptr<const Response> &response_) {
|
||||
void Request::cancel() {
|
||||
assert(async);
|
||||
assert(!canceled);
|
||||
canceled = util::make_unique<Canceled>();
|
||||
canceled = std::make_unique<Canceled>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/style/style_parser.hpp>
|
||||
#include <mbgl/style/style_bucket.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
#include <csscolorparser/csscolorparser.hpp>
|
||||
@@ -17,7 +16,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
Style::Style()
|
||||
: mtx(util::make_unique<uv::rwlock>()),
|
||||
: mtx(std::make_unique<uv::rwlock>()),
|
||||
workers(4) {
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
#include <mbgl/map/annotation.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
#include <mbgl/text/font_stack.hpp>
|
||||
|
||||
#include <mbgl/util/exception.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
GlyphStore::GlyphStore(uv_loop_t* loop, Environment& env_)
|
||||
: env(env_),
|
||||
asyncEmitGlyphRangeLoaded(util::make_unique<uv::async>(loop, [this] { emitGlyphRangeLoaded(); })),
|
||||
asyncEmitGlyphRangeLoadedingFailed(util::make_unique<uv::async>(loop, [this] { emitGlyphRangeLoadingFailed(); })),
|
||||
asyncEmitGlyphRangeLoaded(std::make_unique<uv::async>(loop, [this] { emitGlyphRangeLoaded(); })),
|
||||
asyncEmitGlyphRangeLoadedingFailed(std::make_unique<uv::async>(loop, [this] { emitGlyphRangeLoadingFailed(); })),
|
||||
observer(nullptr) {
|
||||
asyncEmitGlyphRangeLoaded->unref();
|
||||
asyncEmitGlyphRangeLoadedingFailed->unref();
|
||||
@@ -51,7 +50,7 @@ bool GlyphStore::requestGlyphRangesIfNeeded(const std::string& fontStackName,
|
||||
for (const auto& range : glyphRanges) {
|
||||
const auto& rangeSets_it = rangeSets.find(range);
|
||||
if (rangeSets_it == rangeSets.end()) {
|
||||
auto glyph = util::make_unique<GlyphPBF>(glyphURL, fontStackName, range, env,
|
||||
auto glyph = std::make_unique<GlyphPBF>(glyphURL, fontStackName, range, env,
|
||||
successCallback, failureCallback);
|
||||
rangeSets.emplace(range, std::move(glyph));
|
||||
requestIsNeeded = true;
|
||||
@@ -67,18 +66,18 @@ bool GlyphStore::requestGlyphRangesIfNeeded(const std::string& fontStackName,
|
||||
}
|
||||
|
||||
util::exclusive<FontStack> GlyphStore::createFontStack(const std::string &fontStack) {
|
||||
auto lock = util::make_unique<std::lock_guard<std::mutex>>(stacksMutex);
|
||||
auto lock = std::make_unique<std::lock_guard<std::mutex>>(stacksMutex);
|
||||
|
||||
auto stack_it = stacks.find(fontStack);
|
||||
if (stack_it == stacks.end()) {
|
||||
stack_it = stacks.emplace(fontStack, util::make_unique<FontStack>()).first;
|
||||
stack_it = stacks.emplace(fontStack, std::make_unique<FontStack>()).first;
|
||||
}
|
||||
|
||||
return { stack_it->second.get(), std::move(lock) };
|
||||
}
|
||||
|
||||
util::exclusive<FontStack> GlyphStore::getFontStack(const std::string &fontStack) {
|
||||
auto lock = util::make_unique<std::lock_guard<std::mutex>>(stacksMutex);
|
||||
auto lock = std::make_unique<std::lock_guard<std::mutex>>(stacksMutex);
|
||||
|
||||
const auto& stack_it = stacks.find(fontStack);
|
||||
if (stack_it == stacks.end()) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <mbgl/util/raster.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
@@ -27,7 +26,7 @@ bool Raster::isLoaded() const {
|
||||
}
|
||||
|
||||
bool Raster::load(const std::string &data) {
|
||||
img = util::make_unique<util::Image>(data);
|
||||
img = std::make_unique<util::Image>(data);
|
||||
width = img->getWidth();
|
||||
height = img->getHeight();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define MBGL_UTIL_RUN_LOOP
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
#include <functional>
|
||||
@@ -24,7 +23,7 @@ public:
|
||||
template <class Fn, class... Args>
|
||||
void invoke(Fn&& fn, Args&&... args) {
|
||||
auto tuple = std::make_tuple(std::move(args)...);
|
||||
auto invokable = util::make_unique<Invoker<Fn, decltype(tuple), Args...>>(std::move(fn), std::move(tuple));
|
||||
auto invokable = std::make_unique<Invoker<Fn, decltype(tuple), Args...>>(std::move(fn), std::move(tuple));
|
||||
withMutex([&] { queue.push(std::move(invokable)); });
|
||||
async.send();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
Worker::Worker(std::size_t count) {
|
||||
for (std::size_t i = 0; i < count; i++) {
|
||||
threads.emplace_back(util::make_unique<util::Thread<Impl>>("Worker", util::ThreadPriority::Low));
|
||||
threads.emplace_back(std::make_unique<util::Thread<Impl>>("Worker", util::ThreadPriority::Low));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ Worker::~Worker() = default;
|
||||
|
||||
std::unique_ptr<WorkRequest> Worker::send(Fn work, Fn after) {
|
||||
auto task = std::make_shared<WorkTask>(work, after);
|
||||
auto request = util::make_unique<WorkRequest>(task);
|
||||
auto request = std::make_unique<WorkRequest>(task);
|
||||
|
||||
threads[current]->invokeWithResult(&Worker::Impl::doWork, [task] {
|
||||
task->runAfter();
|
||||
|
||||
@@ -20,7 +20,7 @@ TEST(API, RepeatedRender) {
|
||||
HeadlessView view(display);
|
||||
DefaultFileSource fileSource(nullptr);
|
||||
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ TEST(API, SetStyle) {
|
||||
HeadlessView view(display);
|
||||
DefaultFileSource fileSource(nullptr);
|
||||
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
{
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/still_image.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <mbgl/util/scaling.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@@ -24,7 +23,7 @@ TEST(Bilinear, Scaling) {
|
||||
const uint32_t *srcData = reinterpret_cast<const uint32_t *>(src + 8);
|
||||
const vec2<uint32_t> srcSize { width, height };
|
||||
const vec2<uint32_t> dstSize { 128, 128 };
|
||||
auto dst = util::make_unique<uint32_t[]>(dstSize.x * dstSize.y);
|
||||
auto dst = std::make_unique<uint32_t[]>(dstSize.x * dstSize.y);
|
||||
uint32_t *dstData = dst.get();
|
||||
std::fill(dstData, dstData + dstSize.x * dstSize.y, 0xFFFF00FF);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <mbgl/util/clip_id.hpp>
|
||||
#include <mbgl/map/tile.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void MockFileSource::Impl::handleRequest(Request* req) const {
|
||||
}
|
||||
|
||||
MockFileSource::MockFileSource(const std::string& matchFail)
|
||||
: thread_(util::make_unique<util::Thread<Impl>>("FileSource", util::ThreadPriority::Low, matchFail)) {
|
||||
: thread_(std::make_unique<util::Thread<Impl>>("FileSource", util::ThreadPriority::Low, matchFail)) {
|
||||
}
|
||||
|
||||
Request* MockFileSource::request(const Resource& resource, uv_loop_t* loop, Callback callback) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -30,13 +30,13 @@ public:
|
||||
: env_(fileSource),
|
||||
envScope_(env_, ThreadType::Map, "Map"),
|
||||
data_(view, MapMode::Still),
|
||||
glyphStore_(util::make_unique<GlyphStore>(loop, env_)),
|
||||
glyphAtlas_(util::make_unique<GlyphAtlas>(1024, 1024)),
|
||||
spriteAtlas_(util::make_unique<SpriteAtlas>(512, 512)),
|
||||
texturePool_(util::make_unique<TexturePool>()),
|
||||
style_(util::make_unique<Style>()),
|
||||
resourceLoader_(util::make_unique<ResourceLoader>()),
|
||||
asyncUpdate(util::make_unique<uv::async>(loop, [this] { update(); })),
|
||||
glyphStore_(std::make_unique<GlyphStore>(loop, env_)),
|
||||
glyphAtlas_(std::make_unique<GlyphAtlas>(1024, 1024)),
|
||||
spriteAtlas_(std::make_unique<SpriteAtlas>(512, 512)),
|
||||
texturePool_(std::make_unique<TexturePool>()),
|
||||
style_(std::make_unique<Style>()),
|
||||
resourceLoader_(std::make_unique<ResourceLoader>()),
|
||||
asyncUpdate(std::make_unique<uv::async>(loop, [this] { update(); })),
|
||||
callback_(callback) {
|
||||
asyncUpdate->unref();
|
||||
|
||||
@@ -147,7 +147,7 @@ TEST_P(ResourceLoaderTest, RequestFailure) {
|
||||
};
|
||||
|
||||
std::unique_ptr<util::Thread<MockMapContext>> context(
|
||||
util::make_unique<util::Thread<MockMapContext>>(
|
||||
std::make_unique<util::Thread<MockMapContext>>(
|
||||
"Map", util::ThreadPriority::Regular, view, fileSource, callback));
|
||||
|
||||
uv_run(loop.get(), UV_RUN_DEFAULT);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
TEST_F(Storage, DatabaseDoesNotExist) {
|
||||
using namespace mbgl;
|
||||
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
SQLiteCache::Impl cache(nullptr, "test/fixtures/404/cache.db");
|
||||
|
||||
@@ -52,7 +52,7 @@ TEST_F(Storage, DatabaseCreate) {
|
||||
createDir("test/fixtures/database");
|
||||
deleteFile("test/fixtures/database/cache.db");
|
||||
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
SQLiteCache::Impl cache(nullptr, "test/fixtures/database/cache.db");
|
||||
|
||||
@@ -113,7 +113,7 @@ TEST_F(Storage, DatabaseLockedRead) {
|
||||
|
||||
{
|
||||
// First request should fail.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
std::unique_ptr<Response> res = cache.get({ Resource::Unknown, "mapbox://test" });
|
||||
EXPECT_EQ(nullptr, res.get());
|
||||
@@ -129,7 +129,7 @@ TEST_F(Storage, DatabaseLockedRead) {
|
||||
|
||||
{
|
||||
// First, try getting a file (the cache value should not exist).
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
std::unique_ptr<Response> res = cache.get({ Resource::Unknown, "mapbox://test" });
|
||||
EXPECT_EQ(nullptr, res.get());
|
||||
@@ -153,7 +153,7 @@ TEST_F(Storage, DatabaseLockedWrite) {
|
||||
|
||||
{
|
||||
// Adds a file (which should fail).
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
cache.put({ Resource::Unknown, "mapbox://test" }, response);
|
||||
@@ -170,7 +170,7 @@ TEST_F(Storage, DatabaseLockedWrite) {
|
||||
|
||||
{
|
||||
// Then, set a file and obtain it again.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
response->data = "Demo";
|
||||
@@ -201,7 +201,7 @@ TEST_F(Storage, DatabaseLockedRefresh) {
|
||||
|
||||
{
|
||||
// Adds a file.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
response->data = "Demo";
|
||||
@@ -216,7 +216,7 @@ TEST_F(Storage, DatabaseLockedRefresh) {
|
||||
|
||||
{
|
||||
// Then, try to refresh it.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
response->data = "Demo";
|
||||
@@ -244,7 +244,7 @@ TEST_F(Storage, DatabaseDeleted) {
|
||||
|
||||
{
|
||||
// Adds a file.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
response->data = "Demo";
|
||||
@@ -260,7 +260,7 @@ TEST_F(Storage, DatabaseDeleted) {
|
||||
|
||||
{
|
||||
// Adds a file.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
response->data = "Demo";
|
||||
@@ -289,7 +289,7 @@ TEST_F(Storage, DatabaseInvalid) {
|
||||
|
||||
{
|
||||
// Adds a file.
|
||||
Log::setObserver(util::make_unique<FixtureLogObserver>());
|
||||
Log::setObserver(std::make_unique<FixtureLogObserver>());
|
||||
|
||||
auto response = std::make_shared<Response>();
|
||||
response->data = "Demo";
|
||||
|
||||
Reference in New Issue
Block a user