diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-12-03 11:27:24 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-12-03 11:27:24 +0100 |
commit | 82f3574d09064a442e30eb2dc7639f473749c5bd (patch) | |
tree | dfb0aa6182a0d7d04b6131199d67ff90a87cb9c1 /src | |
parent | 50669307c5648e62941a63e0c75dba8602448d9d (diff) | |
download | qtlocation-mapboxgl-82f3574d09064a442e30eb2dc7639f473749c5bd.tar.gz |
add array overloads to make_unique and move it to mbgl::util from std
Diffstat (limited to 'src')
-rw-r--r-- | src/map/map.cpp | 12 | ||||
-rw-r--r-- | src/map/source.cpp | 2 | ||||
-rw-r--r-- | src/map/sprite.cpp | 2 | ||||
-rw-r--r-- | src/map/tile_parser.cpp | 10 | ||||
-rw-r--r-- | src/renderer/painter.cpp | 24 | ||||
-rw-r--r-- | src/storage/base_request.cpp | 3 | ||||
-rw-r--r-- | src/storage/file_request_baton.cpp | 7 | ||||
-rw-r--r-- | src/storage/file_source.cpp | 3 | ||||
-rw-r--r-- | src/storage/sqlite_store.cpp | 3 | ||||
-rw-r--r-- | src/style/style.cpp | 2 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 2 | ||||
-rw-r--r-- | src/text/glyph_store.cpp | 4 | ||||
-rw-r--r-- | src/util/raster.cpp | 2 |
13 files changed, 40 insertions, 36 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp index b3c83d1be6..cc22e048f7 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -86,7 +86,7 @@ const static bool sqlite_version_check = []() { using namespace mbgl; Map::Map(View& view_) - : loop(std::make_unique<uv::loop>()), + : loop(util::make_unique<uv::loop>()), view(view_), #ifndef NDEBUG mainThread(uv_thread_self()), @@ -123,7 +123,7 @@ Map::~Map() { uv::worker &Map::getWorker() { if (!workers) { - workers = std::make_unique<uv::worker>(**loop, 4, "Tile Worker"); + workers = util::make_unique<uv::worker>(**loop, 4, "Tile Worker"); } return *workers; } @@ -140,7 +140,7 @@ void Map::start() { isStopped = false; // Setup async notifications - asyncTerminate = std::make_unique<uv::async>(**loop, [this]() { + asyncTerminate = util::make_unique<uv::async>(**loop, [this]() { assert(uv_thread_self() == mapThread); // Remove all of these to make sure they are destructed in the correct thread. @@ -156,7 +156,7 @@ void Map::start() { asyncTerminate.reset(); }); - asyncRender = std::make_unique<uv::async>(**loop, [this]() { + asyncRender = util::make_unique<uv::async>(**loop, [this]() { assert(uv_thread_self() == mapThread); if (state.hasSize()) { @@ -175,11 +175,11 @@ void Map::start() { } }); - asyncCleanup = std::make_unique<uv::async>(**loop, [this]() { + asyncCleanup = util::make_unique<uv::async>(**loop, [this]() { painter.cleanup(); }); - thread = std::make_unique<uv::thread>([this]() { + thread = util::make_unique<uv::thread>([this]() { #ifndef NDEBUG mapThread = uv_thread_self(); #endif diff --git a/src/map/source.cpp b/src/map/source.cpp index 8737e38757..35f5072860 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -164,7 +164,7 @@ TileData::State Source::addTile(Map& map, uv::worker& worker, return state; } - auto pos = tiles.emplace(id, std::make_unique<Tile>(id)); + auto pos = tiles.emplace(id, util::make_unique<Tile>(id)); Tile& new_tile = *pos.first->second; // We couldn't find the tile in the list. Create a new one. diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index 82073619d4..c1f71e59d9 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -101,7 +101,7 @@ bool Sprite::isLoaded() const { } void Sprite::parseImage() { - raster = std::make_unique<util::Image>(image); + raster = util::make_unique<util::Image>(image); if (!*raster) { raster.reset(); } diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 8f55326787..cbfd6fa7b3 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -44,7 +44,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_, spriteAtlas(spriteAtlas_), sprite(sprite_), texturePool(texturePool_), - collision(std::make_unique<Collision>(tile.id.z, 4096, tile.source.tile_size, tile.depth)) { + collision(util::make_unique<Collision>(tile.id.z, 4096, tile.source.tile_size, tile.depth)) { assert(&tile != nullptr); assert(style); assert(sprite); @@ -150,24 +150,24 @@ void TileParser::addBucketGeometries(Bucket& bucket, const VectorTileLayer& laye } std::unique_ptr<Bucket> TileParser::createFillBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketFill &fill) { - std::unique_ptr<FillBucket> bucket = std::make_unique<FillBucket>(tile.fillVertexBuffer, tile.triangleElementsBuffer, tile.lineElementsBuffer, fill); + std::unique_ptr<FillBucket> bucket = util::make_unique<FillBucket>(tile.fillVertexBuffer, tile.triangleElementsBuffer, tile.lineElementsBuffer, fill); addBucketGeometries(bucket, layer, filter); return obsolete() ? nullptr : std::move(bucket); } std::unique_ptr<Bucket> TileParser::createRasterBucket(const StyleBucketRaster &raster) { - std::unique_ptr<RasterBucket> bucket = std::make_unique<RasterBucket>(texturePool, raster); + std::unique_ptr<RasterBucket> bucket = util::make_unique<RasterBucket>(texturePool, raster); return obsolete() ? nullptr : std::move(bucket); } std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketLine &line) { - std::unique_ptr<LineBucket> bucket = std::make_unique<LineBucket>(tile.lineVertexBuffer, tile.triangleElementsBuffer, tile.pointElementsBuffer, line); + std::unique_ptr<LineBucket> bucket = util::make_unique<LineBucket>(tile.lineVertexBuffer, tile.triangleElementsBuffer, tile.pointElementsBuffer, line); addBucketGeometries(bucket, layer, filter); return obsolete() ? nullptr : std::move(bucket); } std::unique_ptr<Bucket> TileParser::createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol) { - std::unique_ptr<SymbolBucket> bucket = std::make_unique<SymbolBucket>(symbol, *collision); + std::unique_ptr<SymbolBucket> bucket = util::make_unique<SymbolBucket>(symbol, *collision); bucket->addFeatures(layer, filter, tile.id, spriteAtlas, *sprite, glyphAtlas, glyphStore); return obsolete() ? nullptr : std::move(bucket); } diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 3b4e817d33..15bf9e3a0d 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -89,18 +89,18 @@ void Painter::setup() { } void Painter::setupShaders() { - if (!plainShader) plainShader = std::make_unique<PlainShader>(); - if (!outlineShader) outlineShader = std::make_unique<OutlineShader>(); - if (!lineShader) lineShader = std::make_unique<LineShader>(); - if (!linejoinShader) linejoinShader = std::make_unique<LinejoinShader>(); - 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>(); + if (!plainShader) plainShader = util::make_unique<PlainShader>(); + if (!outlineShader) outlineShader = util::make_unique<OutlineShader>(); + if (!lineShader) lineShader = util::make_unique<LineShader>(); + if (!linejoinShader) linejoinShader = util::make_unique<LinejoinShader>(); + 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>(); } void Painter::deleteShaders() { diff --git a/src/storage/base_request.cpp b/src/storage/base_request.cpp index e87679ae1b..9819dc89f1 100644 --- a/src/storage/base_request.cpp +++ b/src/storage/base_request.cpp @@ -1,6 +1,7 @@ #include <mbgl/storage/base_request.hpp> #include <mbgl/storage/response.hpp> #include <mbgl/storage/request.hpp> +#include <mbgl/util/std.hpp> #include <uv.h> @@ -68,7 +69,7 @@ Callback *BaseRequest::add(Callback &&callback, const util::ptr<BaseRequest> &re return nullptr; } else { self = request; - callbacks.push_front(std::unique_ptr<Callback>(new Callback(std::move(callback)))); + callbacks.push_front(util::make_unique<Callback>(std::move(callback))); return callbacks.front().get(); } } diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index 1b41a53706..75ea95df41 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -1,6 +1,7 @@ #include <mbgl/storage/file_request_baton.hpp> #include <mbgl/storage/file_request.hpp> #include <mbgl/storage/response.hpp> +#include <mbgl/util/std.hpp> #include <limits> @@ -29,7 +30,7 @@ void FileRequestBaton::notify_error(uv_fs_t *req) { assert(ptr->thread_id == uv_thread_self()); if (ptr->request && req->result < 0 && !ptr->canceled && req->result != UV_ECANCELED) { - ptr->request->response = std::unique_ptr<Response>(new Response); + ptr->request->response = util::make_unique<Response>(); ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500; #if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 ptr->request->response->message = uv_strerror(uv_last_error(req->loop)); @@ -86,7 +87,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { // File is too large for us to open this way because uv_buf's only support unsigned // ints as maximum size. if (ptr->request) { - ptr->request->response = std::unique_ptr<Response>(new Response); + ptr->request->response = util::make_unique<Response>(); ptr->request->response->code = UV_EFBIG; #if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 ptr->request->response->message = uv_strerror(uv_err_t {UV_EFBIG, 0}); @@ -123,7 +124,7 @@ void FileRequestBaton::file_read(uv_fs_t *req) { } else { // File was successfully read. if (ptr->request) { - ptr->request->response = std::unique_ptr<Response>(new Response); + ptr->request->response = util::make_unique<Response>(); ptr->request->response->code = 200; ptr->request->response->data = std::move(ptr->body); ptr->request->notify(); diff --git a/src/storage/file_source.cpp b/src/storage/file_source.cpp index a67f57dac4..d1e4c8f38d 100644 --- a/src/storage/file_source.cpp +++ b/src/storage/file_source.cpp @@ -3,6 +3,7 @@ #include <mbgl/storage/http_request.hpp> #include <mbgl/storage/sqlite_store.hpp> #include <mbgl/util/uv-messenger.h> +#include <mbgl/util/std.hpp> #include <uv.h> @@ -79,7 +80,7 @@ std::unique_ptr<Request> FileSource::request(ResourceType type, const std::strin pending.emplace(absoluteURL, req); } - return std::unique_ptr<Request>(new Request(req)); + return util::make_unique<Request>(req); } void FileSource::prepare(std::function<void()> fn) { diff --git a/src/storage/sqlite_store.cpp b/src/storage/sqlite_store.cpp index e0757ecc36..bc262e386a 100644 --- a/src/storage/sqlite_store.cpp +++ b/src/storage/sqlite_store.cpp @@ -1,6 +1,7 @@ #include <mbgl/storage/sqlite_store.hpp> #include <mbgl/util/compression.hpp> #include <mbgl/util/sqlite3.hpp> +#include <mbgl/util/std.hpp> #include <mbgl/util/uv-worker.h> @@ -127,7 +128,7 @@ void SQLiteStore::get(const std::string &path, GetCallback callback, void *ptr) stmt.bind(1, url.c_str()); if (stmt.run()) { // There is data. - baton->response = std::unique_ptr<Response>(new Response); + baton->response = util::make_unique<Response>(); baton->response->code = stmt.get<int>(0); baton->type = ResourceType(stmt.get<int>(1)); diff --git a/src/style/style.cpp b/src/style/style.cpp index 030c502089..15ca4e14fb 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -17,7 +17,7 @@ namespace mbgl { Style::Style() - : mtx(std::make_unique<uv::rwlock>()) { + : mtx(util::make_unique<uv::rwlock>()) { } // Note: This constructor is seemingly empty, but we need to declare it anyway diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 22d43df443..2dec648aff 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -449,7 +449,7 @@ bool StyleParser::parseOptionalProperty(const char *property_name, const std::ve std::unique_ptr<StyleLayerGroup> StyleParser::createLayers(JSVal value) { if (value.IsArray()) { - std::unique_ptr<StyleLayerGroup> group = std::make_unique<StyleLayerGroup>(); + std::unique_ptr<StyleLayerGroup> group = util::make_unique<StyleLayerGroup>(); for (rapidjson::SizeType i = 0; i < value.Size(); ++i) { util::ptr<StyleLayer> layer = createLayer(value[i]); if (layer) { diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 737bad35d8..8537ab5156 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -271,7 +271,7 @@ std::shared_future<GlyphPBF &> GlyphStore::loadGlyphRange(const std::string &fon auto range_it = rangeSets.find(range); if (range_it == rangeSets.end()) { // We don't have this glyph set yet for this font stack. - range_it = rangeSets.emplace(range, std::make_unique<GlyphPBF>(glyphURL, fontStack, range, fileSource)).first; + range_it = rangeSets.emplace(range, util::make_unique<GlyphPBF>(glyphURL, fontStack, range, fileSource)).first; } return range_it->second->getFuture(); @@ -280,7 +280,7 @@ std::shared_future<GlyphPBF &> GlyphStore::loadGlyphRange(const std::string &fon FontStack &GlyphStore::createFontStack(const std::string &fontStack) { auto stack_it = stacks.find(fontStack); if (stack_it == stacks.end()) { - stack_it = stacks.emplace(fontStack, std::make_unique<FontStack>()).first; + stack_it = stacks.emplace(fontStack, util::make_unique<FontStack>()).first; } return *stack_it->second.get(); } diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 66c5c13fea..56461aec5f 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -27,7 +27,7 @@ bool Raster::isLoaded() const { } bool Raster::load(const std::string &data) { - img = std::make_unique<util::Image>(data); + img = util::make_unique<util::Image>(data); width = img->getWidth(); height = img->getHeight(); |