diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-10-27 11:41:16 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-10-27 11:41:16 -0400 |
commit | af9f317c251a0a1adfeaad8dd983ab602cf93070 (patch) | |
tree | 6c02316ffdc6bb450ec554c7136c720ed3bed669 /src | |
parent | 6cd9de4f978835d42c89a78ce2058a5d2be4c0ff (diff) | |
parent | 0883d98e96865c2ddaad70d6d3a6a72debc917e1 (diff) | |
download | qtlocation-mapboxgl-af9f317c251a0a1adfeaad8dd983ab602cf93070.tar.gz |
Merge pull request #504 from mapbox/headless-display
Headless display
Diffstat (limited to 'src')
41 files changed, 273 insertions, 224 deletions
diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 56ad58416d..ea468d69e4 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -48,6 +48,8 @@ #include <ostream> #include <functional> +#pragma GCC diagnostic ignored "-Wshadow" + namespace ClipperLib { #ifdef use_int32 @@ -3242,7 +3244,7 @@ void Clipper::BuildResult(Paths &polys) int cnt = PointCount(p); if (cnt < 2) continue; pg.reserve(cnt); - for (int i = 0; i < cnt; ++i) + for (int j = 0; j < cnt; ++j) { pg.push_back(p->Pt); p = p->Prev; diff --git a/src/geometry/debug_font.cpp b/src/geometry/debug_font.cpp index 2da0c67841..8ee9f6811f 100644 --- a/src/geometry/debug_font.cpp +++ b/src/geometry/debug_font.cpp @@ -98,10 +98,10 @@ const int8_t simplex_94[] = { 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16 struct glyph { glyph() : width(0), length(0), data(nullptr) { } - glyph(uint8_t width, uint8_t length, const int8_t *data) - : width(width), - length(length), - data(data) {} + glyph(uint8_t width_, uint8_t length_, const int8_t *data_) + : width(width_), + length(length_), + data(data_) {} uint8_t width; uint8_t length; const int8_t *data; diff --git a/src/geometry/debug_font_buffer.cpp b/src/geometry/debug_font_buffer.cpp index 387a646299..2a0924a1c4 100644 --- a/src/geometry/debug_font_buffer.cpp +++ b/src/geometry/debug_font_buffer.cpp @@ -10,9 +10,9 @@ using namespace mbgl; void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { uint16_t *coords = nullptr; - size_t length = strlen(text); - for (size_t i = 0; i < length; ++i) { - if (text[i] < 32 || text[i] > 127) { + const size_t len = strlen(text); + for (size_t i = 0; i < len; ++i) { + if (text[i] < 32 || (unsigned char)(text[i]) > 127) { continue; } diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index 76df941d90..6bee475da3 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -9,11 +9,11 @@ using namespace mbgl; -GlyphAtlas::GlyphAtlas(uint16_t width, uint16_t height) - : width(width), - height(height), - bin(width, height), - data(new char[width *height]), +GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) + : width(width_), + height(height_), + bin(width_, height_), + data(new char[width_ *height_]), dirty(true) { } diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 7ea9d4ce7d..10922790c0 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -14,10 +14,10 @@ using namespace mbgl; -SpriteAtlas::SpriteAtlas(dimension width, dimension height) - : width(width), - height(height), - bin(width, height), +SpriteAtlas::SpriteAtlas(dimension width_, dimension height_) + : width(width_), + height(height_), + bin(width_, height_), dirty(true) { } @@ -88,10 +88,10 @@ void copy_bitmap(const uint32_t *src, const int src_stride, const int src_x, con } } -Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(size_t width, size_t height) { +Rect<SpriteAtlas::dimension> SpriteAtlas::allocateImage(size_t pixel_width, size_t pixel_height) { // We have to allocate a new area in the bin, and store an empty image in it. // Add a 1px border around every image. - Rect<dimension> rect = bin.allocate(width + 2 * buffer, height + 2 * buffer); + Rect<dimension> rect = bin.allocate(pixel_width + 2 * buffer, pixel_height + 2 * buffer); if (rect.w == 0) { return rect; } diff --git a/src/map/map.cpp b/src/map/map.cpp index f255c3ff65..a7520b2517 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -30,17 +30,17 @@ using namespace mbgl; -Map::Map(View& view) +Map::Map(View& view_) : loop(std::make_shared<uv::loop>()), thread(std::make_unique<uv::thread>()), async_terminate(new uv_async_t()), async_render(new uv_async_t()), async_cleanup(new uv_async_t()), - view(view), + view(view_), #ifndef NDEBUG main_thread(uv_thread_self()), #endif - transform(view), + transform(view_), glyphAtlas(std::make_shared<GlyphAtlas>(1024, 1024)), spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)), texturepool(std::make_shared<Texturepool>()), @@ -163,7 +163,6 @@ void Map::run() { // If the map rendering wasn't started asynchronously, we perform one render // *after* all events have been processed. if (!async) { - prepare(); render(); #ifndef NDEBUG map_thread = -1; @@ -206,10 +205,13 @@ void Map::cleanup(uv_async_t *async) { #endif Map *map = static_cast<Map *>(async->data); - map->view.make_active(); map->painter.cleanup(); } +void Map::terminate() { + painter.terminate(); +} + void Map::setReachability(bool reachable) { // Note: This function may be called from *any* thread. if (reachable) { @@ -271,8 +273,8 @@ void Map::terminate(uv_async_t *async) { void Map::setup() { assert(uv_thread_self() == map_thread); view.make_active(); - painter.setup(); + view.make_inactive(); } void Map::setStyleURL(const std::string &url) { @@ -605,8 +607,6 @@ void Map::updateRenderState() { } void Map::prepare() { - view.make_active(); - if (!fileSource) { fileSource = std::make_shared<FileSource>(**loop, platform::defaultCacheDatabase()); glyphStore = std::make_shared<GlyphStore>(fileSource); @@ -651,9 +651,8 @@ void Map::prepare() { } void Map::render() { -#if defined(DEBUG) - std::vector<std::string> debug; -#endif + view.make_active(); + painter.clear(); painter.resize(); @@ -685,6 +684,8 @@ void Map::render() { } glFlush(); + + view.make_inactive(); } void Map::renderLayers(util::ptr<StyleLayerGroup> group) { diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index e7725b7abd..99ca327fe7 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -RasterTileData::RasterTileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source) - : TileData(id, map, source), +RasterTileData::RasterTileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &source_) + : TileData(id_, map_, source_), bucket(map.getTexturepool(), properties) { } diff --git a/src/map/source.cpp b/src/map/source.cpp index 36f1a71c84..9c0f7caf28 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -18,10 +18,12 @@ #include <mbgl/map/vector_tile_data.hpp> #include <mbgl/map/raster_tile_data.hpp> +#include <algorithm> + namespace mbgl { -Source::Source(const util::ptr<SourceInfo>& info) - : info(info) +Source::Source(const util::ptr<SourceInfo>& info_) + : info(info_) { } @@ -219,15 +221,15 @@ std::forward_list<Tile::ID> Source::coveringTiles(const TransformState& state) c box points = state.cornersToBox(z); const vec2<double>& center = points.center; - std::forward_list<Tile::ID> tiles = Tile::cover(z, points); + std::forward_list<Tile::ID> covering_tiles = Tile::cover(z, points); - tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { + covering_tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { // Sorts by distance from the box center return std::fabs(a.x - center.x) + std::fabs(a.y - center.y) < std::fabs(b.x - center.x) + std::fabs(b.y - center.y); }); - return tiles; + return covering_tiles; } /** diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index c069ece45a..876586e4b0 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -13,13 +13,13 @@ using namespace mbgl; -SpritePosition::SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio, bool sdf) - : x(x), - y(y), - width(width), - height(height), - pixelRatio(pixelRatio), - sdf(sdf) { +SpritePosition::SpritePosition(uint16_t x_, uint16_t y_, uint16_t width_, uint16_t height_, float pixelRatio_, bool sdf_) + : x(x_), + y(y_), + width(width_), + height(height_), + pixelRatio(pixelRatio_), + sdf(sdf_) { } util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr<FileSource> &fileSource) { @@ -28,11 +28,11 @@ util::ptr<Sprite> Sprite::Create(const std::string& base_url, float pixelRatio, return sprite; } -Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio) +Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio_) : valid(base_url.length() > 0), - pixelRatio(pixelRatio), - spriteURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".png"), - jsonURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".json"), + pixelRatio(pixelRatio_), + spriteURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".png"), + jsonURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".json"), raster(), loadedImage(false), loadedJSON(false), @@ -123,16 +123,16 @@ void Sprite::parseJSON() { uint16_t y = 0; uint16_t width = 0; uint16_t height = 0; - float pixelRatio = 1.0f; + float spritePixelRatio = 1.0f; bool sdf = false; if (value.HasMember("x")) x = value["x"].GetInt(); if (value.HasMember("y")) y = value["y"].GetInt(); if (value.HasMember("width")) width = value["width"].GetInt(); if (value.HasMember("height")) height = value["height"].GetInt(); - if (value.HasMember("pixelRatio")) pixelRatio = value["pixelRatio"].GetInt(); + if (value.HasMember("pixelRatio")) spritePixelRatio = value["pixelRatio"].GetInt(); if (value.HasMember("sdf")) sdf = value["sdf"].GetBool(); - pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio, sdf }); + pos.emplace(name, SpritePosition { x, y, width, height, spritePixelRatio, sdf }); } } } else { diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 863fbfbece..3070d3fd96 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -7,8 +7,8 @@ using namespace mbgl; #include <iostream> -Tile::Tile(const ID& id) - : id(id) { +Tile::Tile(const ID& id_) + : id(id_) { } Tile::ID Tile::ID::parent(int8_t parent_z) const { @@ -25,13 +25,13 @@ std::forward_list<Tile::ID> Tile::ID::children(int32_t child_z) const { assert(child_z > z); int32_t factor = std::pow(2, child_z - z); - std::forward_list<ID> children; + std::forward_list<ID> child_ids; for (int32_t ty = y * factor, y_max = (y + 1) * factor; ty < y_max; ++ty) { for (int32_t tx = x * factor, x_max = (x + 1) * factor; tx < x_max; ++tx) { - children.emplace_front(child_z, tx, ty); + child_ids.emplace_front(child_z, tx, ty); } } - return children; + return child_ids; } Tile::ID Tile::ID::normalized() const { @@ -42,13 +42,13 @@ Tile::ID Tile::ID::normalized() const { return ID { z, nx, ny }; } -bool Tile::ID::isChildOf(const Tile::ID &parent) const { - if (parent.z >= z || parent.w != w) { +bool Tile::ID::isChildOf(const Tile::ID &parent_id) const { + if (parent_id.z >= z || parent_id.w != w) { return false; } - int32_t scale = std::pow(2, z - parent.z); - return parent.x == ((x < 0 ? x - scale + 1 : x) / scale) && - parent.y == y / scale; + int32_t scale = std::pow(2, z - parent_id.z); + return parent_id.x == ((x < 0 ? x - scale + 1 : x) / scale) && + parent_id.y == y / scale; } diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 44e3826bf5..7e4d1a1de1 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -9,14 +9,14 @@ using namespace mbgl; -TileData::TileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source) - : id(id), +TileData::TileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &source_) + : id(id_), state(State::initial), - map(map), - source(source), + map(map_), + source(source_), debugBucket(debugFontBuffer) { // Initialize tile debug coordinates - const std::string str = util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y); + const std::string str = util::sprintf<32>("%d/%d/%d", id_.z, id_.x, id_.y); debugFontBuffer.addText(str.c_str(), 50, 200, 5); } diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 3dc5cb9cef..235151cd47 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -37,14 +37,14 @@ namespace mbgl { // its header file. TileParser::~TileParser() = default; -TileParser::TileParser(const std::string &data, VectorTileData &tile, +TileParser::TileParser(const std::string &data, VectorTileData &tile_, const util::ptr<const Style> &style_, const util::ptr<GlyphAtlas> &glyphAtlas_, const util::ptr<GlyphStore> &glyphStore_, const util::ptr<SpriteAtlas> &spriteAtlas_, const util::ptr<Sprite> &sprite_) : vector_data(pbf((const uint8_t *)data.data(), data.size())), - tile(tile), + tile(tile_), style(style_), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), diff --git a/src/map/transform.cpp b/src/map/transform.cpp index baa615b94a..b42f24a83d 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -17,7 +17,7 @@ const double R2D = 180.0 / M_PI; const double M2PI = 2 * M_PI; const double MIN_ROTATE_SCALE = 8; -Transform::Transform(View &view) : view(view), mtx(std::make_unique<uv::rwlock>()) { +Transform::Transform(View &view_) : view(view_), mtx(std::make_unique<uv::rwlock>()) { setScale(current.scale); setAngle(current.angle); } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index 4b1bc4161e..0a858bce6a 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -96,8 +96,8 @@ float TransformState::lngX(float lon) const { } float TransformState::latY(float lat) const { - float y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); - return (180 - y) * worldSize() / 360; + float lat_y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - lat_y) * worldSize() / 360; } std::array<float, 2> TransformState::locationCoordinate(float lon, float lat) const { diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index 4ec25d6cf6..8f097c8292 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -103,9 +103,9 @@ VectorTileLayer::VectorTileLayer(pbf layer) : data(layer) { } } -FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer, const FilterExpression &filterExpression) - : layer(layer), - filterExpression(filterExpression) { +FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer_, const FilterExpression &filterExpression_) + : layer(layer_), + filterExpression(filterExpression_) { } FilteredVectorTileLayer::iterator FilteredVectorTileLayer::begin() const { @@ -116,10 +116,10 @@ FilteredVectorTileLayer::iterator FilteredVectorTileLayer::end() const { return iterator(*this, pbf(layer.data.end, 0)); } -FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent, const pbf& data) - : parent(parent), +FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent_, const pbf& data_) + : parent(parent_), feature(pbf()), - data(data) { + data(data_) { operator++(); } diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index 48b46059a5..b94bc66dea 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -VectorTileData::VectorTileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source) - : TileData(id, map, source), +VectorTileData::VectorTileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &source_) + : TileData(id_, map_, source_), depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) { } diff --git a/src/renderer/debug_bucket.cpp b/src/renderer/debug_bucket.cpp index 699c1c1db9..58fbf8a35b 100644 --- a/src/renderer/debug_bucket.cpp +++ b/src/renderer/debug_bucket.cpp @@ -10,8 +10,8 @@ struct geometry_too_long_exception : std::exception {}; using namespace mbgl; -DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer) - : fontBuffer(fontBuffer) { +DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer_) + : fontBuffer(fontBuffer_) { } void DebugBucket::render(Painter& painter, util::ptr<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) { diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index 5358cae0b2..0a7d77935d 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -30,11 +30,11 @@ void FillBucket::free(void *, void *ptr) { ::free(ptr); } -FillBucket::FillBucket(FillVertexBuffer &vertexBuffer, - TriangleElementsBuffer &triangleElementsBuffer, - LineElementsBuffer &lineElementsBuffer, - const StyleBucketFill &properties) - : properties(properties), +FillBucket::FillBucket(FillVertexBuffer &vertexBuffer_, + TriangleElementsBuffer &triangleElementsBuffer_, + LineElementsBuffer &lineElementsBuffer_, + const StyleBucketFill &properties_) + : properties(properties_), allocator(new TESSalloc{&alloc, &realloc, &free, nullptr, // userData 64, // meshEdgeBucketSize 64, // meshVertexBucketSize @@ -44,11 +44,11 @@ FillBucket::FillBucket(FillVertexBuffer &vertexBuffer, 128, // extraVertices allocated for the priority queue. }), tesselator(tessNewTess(allocator)), - vertexBuffer(vertexBuffer), - triangleElementsBuffer(triangleElementsBuffer), - lineElementsBuffer(lineElementsBuffer), - vertex_start(vertexBuffer.index()), - triangle_elements_start(triangleElementsBuffer.index()), + vertexBuffer(vertexBuffer_), + triangleElementsBuffer(triangleElementsBuffer_), + lineElementsBuffer(lineElementsBuffer_), + vertex_start(vertexBuffer_.index()), + triangle_elements_start(triangleElementsBuffer_.index()), line_elements_start(lineElementsBuffer.index()) { assert(tesselator); } @@ -123,10 +123,10 @@ void FillBucket::tessellate() { const size_t group_count = polygon.size(); assert(group_count >= 3); - std::vector<TESSreal> line; + std::vector<TESSreal> clipped_line; for (const ClipperLib::IntPoint& pt : polygon) { - line.push_back(pt.X); - line.push_back(pt.Y); + clipped_line.push_back(pt.X); + clipped_line.push_back(pt.Y); vertexBuffer.add(pt.X, pt.Y); } @@ -137,7 +137,7 @@ void FillBucket::tessellate() { lineIndex += group_count; - tessAddContour(tesselator, vertexSize, line.data(), stride, (int)line.size() / vertexSize); + tessAddContour(tesselator, vertexSize, clipped_line.data(), stride, (int)clipped_line.size() / vertexSize); } lineGroup.elements_length += total_vertex_count; diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index 3ef7411be6..8267cbaba2 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -17,17 +17,17 @@ struct geometry_too_long_exception : std::exception {}; using namespace mbgl; -LineBucket::LineBucket(LineVertexBuffer& vertexBuffer, - TriangleElementsBuffer& triangleElementsBuffer, - PointElementsBuffer& pointElementsBuffer, - const StyleBucketLine& properties) - : properties(properties), - vertexBuffer(vertexBuffer), - triangleElementsBuffer(triangleElementsBuffer), - pointElementsBuffer(pointElementsBuffer), - vertex_start(vertexBuffer.index()), - triangle_elements_start(triangleElementsBuffer.index()), - point_elements_start(pointElementsBuffer.index()) +LineBucket::LineBucket(LineVertexBuffer& vertexBuffer_, + TriangleElementsBuffer& triangleElementsBuffer_, + PointElementsBuffer& pointElementsBuffer_, + const StyleBucketLine& properties_) + : properties(properties_), + vertexBuffer(vertexBuffer_), + triangleElementsBuffer(triangleElementsBuffer_), + pointElementsBuffer(pointElementsBuffer_), + vertex_start(vertexBuffer_.index()), + triangle_elements_start(triangleElementsBuffer_.index()), + point_elements_start(pointElementsBuffer_.index()) { } @@ -53,7 +53,7 @@ void LineBucket::addGeometry(pbf& geom) { } struct TriangleElement { - TriangleElement(uint16_t a, uint16_t b, uint16_t c) : a(a), b(b), c(c) {} + TriangleElement(uint16_t a_, uint16_t b_, uint16_t c_) : a(a_), b(b_), c(c_) {} uint16_t a, b, c; }; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 474b7b954f..38c2176aed 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -21,8 +21,8 @@ using namespace mbgl; #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) -Painter::Painter(Map &map) - : map(map) { +Painter::Painter(Map &map_) + : map(map_) { } Painter::~Painter() { @@ -85,9 +85,29 @@ void Painter::setupShaders() { if (!gaussianShader) gaussianShader = std::make_unique<GaussianShader>(); } +void Painter::deleteShaders() { + plainShader = nullptr; + outlineShader = nullptr; + lineShader = nullptr; + linejoinShader = nullptr; + linepatternShader = nullptr; + patternShader = nullptr; + iconShader = nullptr; + rasterShader = nullptr; + sdfGlyphShader = nullptr; + sdfIconShader = nullptr; + dotShader = nullptr; + gaussianShader = nullptr; +} + void Painter::cleanup() { } +void Painter::terminate() { + cleanup(); + deleteShaders(); +} + void Painter::resize() { const TransformState &state = map.getState(); if (gl_viewport != state.getFramebufferDimensions()) { @@ -108,10 +128,10 @@ void Painter::useProgram(uint32_t program) { } } -void Painter::lineWidth(float lineWidth) { - if (gl_lineWidth != lineWidth) { - glLineWidth(lineWidth); - gl_lineWidth = lineWidth; +void Painter::lineWidth(float line_width) { + if (gl_lineWidth != line_width) { + glLineWidth(line_width); + gl_lineWidth = line_width; } } diff --git a/src/renderer/prerendered_texture.cpp b/src/renderer/prerendered_texture.cpp index 0a47816323..adb7a59105 100644 --- a/src/renderer/prerendered_texture.cpp +++ b/src/renderer/prerendered_texture.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties) - : properties(properties) { +PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties_) + : properties(properties_) { } PrerenderedTexture::~PrerenderedTexture() { diff --git a/src/renderer/raster_bucket.cpp b/src/renderer/raster_bucket.cpp index fc5e3dd3c8..7adb3f845e 100644 --- a/src/renderer/raster_bucket.cpp +++ b/src/renderer/raster_bucket.cpp @@ -3,9 +3,9 @@ using namespace mbgl; -RasterBucket::RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties) -: properties(properties), - texture(properties), +RasterBucket::RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties_) +: properties(properties_), + texture(properties_), raster(texturepool) { } @@ -24,8 +24,8 @@ void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index()); } -void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture) { - raster.bind(texture); +void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture_) { + raster.bind(texture_); shader.u_image = 0; array.bind(shader, vertices, BUFFER_OFFSET(0)); glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index()); diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 3a4b017ef3..47cc4db44c 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -19,8 +19,8 @@ namespace mbgl { -SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties, Collision &collision) - : properties(properties), collision(collision) {} +SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties_, Collision &collision_) + : properties(properties_), collision(collision_) {} void SymbolBucket::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const Tile::ID &id, const mat4 &matrix) { @@ -52,12 +52,12 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer & const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite) { - const bool text = properties.text.field.size(); - const bool icon = properties.icon.image.size(); + const bool has_text = properties.text.field.size(); + const bool has_icon = properties.icon.image.size(); std::vector<SymbolFeature> features; - if (!text && !icon) { + if (!has_text && !has_icon) { return features; } @@ -72,7 +72,7 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer & SymbolFeature ft; - if (text) { + if (has_text) { std::string u8string = util::replaceTokens(properties.text.field, feature.properties); if (properties.text.transform == TextTransformType::Uppercase) { @@ -91,7 +91,7 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer & } } - if (icon) { + if (has_icon) { ft.sprite = util::replaceTokens(properties.icon.image, feature.properties); } diff --git a/src/shader/shader.cpp b/src/shader/shader.cpp index 91c9b58c89..d9f63cae12 100644 --- a/src/shader/shader.cpp +++ b/src/shader/shader.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -Shader::Shader(const char *name, const GLchar *vertSource, const GLchar *fragSource) - : name(name), +Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSource) + : name(name_), valid(false), program(0) { util::timer timer("shader compilation", Event::Shader); diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index 64c6c13b12..1b41a53706 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -2,6 +2,8 @@ #include <mbgl/storage/file_request.hpp> #include <mbgl/storage/response.hpp> +#include <limits> + namespace mbgl { FileRequestBaton::FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop) @@ -97,8 +99,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_req_cleanup(req); uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { - const unsigned int size = - (unsigned int)(stat->st_size); + const unsigned int size = (unsigned int)(stat->st_size); ptr->body.resize(size); ptr->buffer = uv_buf_init(const_cast<char *>(ptr->body.data()), size); uv_fs_req_cleanup(req); diff --git a/src/storage/file_source.cpp b/src/storage/file_source.cpp index 12d924416c..70b4abe4c7 100644 --- a/src/storage/file_source.cpp +++ b/src/storage/file_source.cpp @@ -27,12 +27,12 @@ FileSource::~FileSource() { // NOTE: We don't need to delete the messenger since it will be deleted by the // uv_messenger_stop() function. - util::ptr<BaseRequest> request; + util::ptr<BaseRequest> req; // Send a cancel() message to all requests that we are still holding. for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) { - if ((request = pair.second.lock())) { - request->cancel(); + if ((req = pair.second.lock())) { + req->cancel(); } } } @@ -61,25 +61,25 @@ std::unique_ptr<Request> FileSource::request(ResourceType type, const std::strin } }(); - util::ptr<BaseRequest> request; + util::ptr<BaseRequest> req; // First, try to find an existing Request object. auto it = pending.find(absoluteURL); if (it != pending.end()) { - request = it->second.lock(); + req = it->second.lock(); } - if (!request) { + if (!req) { if (absoluteURL.substr(0, 7) == "file://") { - request = std::make_shared<FileRequest>(absoluteURL.substr(7), loop); + req = std::make_shared<FileRequest>(absoluteURL.substr(7), loop); } else { - request = std::make_shared<HTTPRequest>(type, absoluteURL, loop, store); + req = std::make_shared<HTTPRequest>(type, absoluteURL, loop, store); } - pending.emplace(absoluteURL, request); + pending.emplace(absoluteURL, req); } - return std::unique_ptr<Request>(new Request(request)); + return std::unique_ptr<Request>(new Request(req)); } void FileSource::prepare(std::function<void()> fn) { @@ -93,10 +93,10 @@ void FileSource::prepare(std::function<void()> fn) { void FileSource::retryAllPending() { assert(thread_id == uv_thread_self()); - util::ptr<BaseRequest> request; + util::ptr<BaseRequest> req; for (const std::pair<std::string, std::weak_ptr<BaseRequest>> &pair : pending) { - if ((request = pair.second.lock())) { - request->retryImmediately(); + if ((req = pair.second.lock())) { + req->retryImmediately(); } } diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index ca1412fd9e..46b1d5e194 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -20,8 +20,8 @@ struct CacheRequestBaton { util::ptr<SQLiteStore> store; }; -HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path, uv_loop_t *loop_, util::ptr<SQLiteStore> store_) - : BaseRequest(path), thread_id(uv_thread_self()), loop(loop_), store(store_), type(type_) { +HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path_, uv_loop_t *loop_, util::ptr<SQLiteStore> store_) + : BaseRequest(path_), thread_id(uv_thread_self()), loop(loop_), store(store_), type(type_) { if (store) { startCacheRequest(); } else { @@ -82,19 +82,19 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) { #else uv_async_init(loop, http_baton->async, [](uv_async_t *async) { #endif - util::ptr<HTTPRequestBaton> &http_baton = *(util::ptr<HTTPRequestBaton> *)async->data; + util::ptr<HTTPRequestBaton> &baton = *(util::ptr<HTTPRequestBaton> *)async->data; - if (http_baton->request) { - HTTPRequest *request = http_baton->request; + if (baton->request) { + HTTPRequest *request = baton->request; request->http_baton.reset(); - http_baton->request = nullptr; - request->handleHTTPResponse(http_baton->type, std::move(http_baton->response)); + baton->request = nullptr; + request->handleHTTPResponse(baton->type, std::move(baton->response)); } delete (util::ptr<HTTPRequestBaton> *)async->data; uv_close((uv_handle_t *)async, [](uv_handle_t *handle) { - uv_async_t *async = (uv_async_t *)handle; - delete async; + uv_async_t *async_handle = (uv_async_t *)handle; + delete async_handle; }); }); attempts++; diff --git a/src/storage/response.cpp b/src/storage/response.cpp index cdaf33e4e4..f1e1c35874 100644 --- a/src/storage/response.cpp +++ b/src/storage/response.cpp @@ -9,7 +9,7 @@ int64_t Response::parseCacheControl(const char *value) { uint64_t seconds = 0; // TODO: cache-control may contain other information as well: // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 - if (std::sscanf(value, "max-age=%llu", &seconds) == 1) { + if (std::sscanf(value, "max-age=%lu", &seconds) == 1) { return std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now().time_since_epoch()).count() + seconds; diff --git a/src/storage/sqlite_store.cpp b/src/storage/sqlite_store.cpp index 763100f411..e0757ecc36 100644 --- a/src/storage/sqlite_store.cpp +++ b/src/storage/sqlite_store.cpp @@ -68,8 +68,8 @@ SQLiteStore::~SQLiteStore() { // Nothing to do. This function needs to be here because we're forward-declaring // Database, so we need the actual definition here to be able to properly destruct it. if (worker) { - uv_worker_close(worker, [](uv_worker_t *worker) { - delete worker; + uv_worker_close(worker, [](uv_worker_t *worker_handle) { + delete worker_handle; }); } } diff --git a/src/style/applied_class_properties.cpp b/src/style/applied_class_properties.cpp index ca9c09436c..9037c6ad5d 100644 --- a/src/style/applied_class_properties.cpp +++ b/src/style/applied_class_properties.cpp @@ -2,11 +2,11 @@ namespace mbgl { -AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value) +AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin_, timestamp end_, const PropertyValue &value_) : name(class_id), - begin(begin), - end(end), - value(value) {} + begin(begin_), + end(end_), + value(value_) {} // Returns thie ID of the most recent ClassID AppliedClassProperties::mostRecent() const { diff --git a/src/style/class_dictionary.cpp b/src/style/class_dictionary.cpp index 6e1eb5a879..ba7c0d55be 100644 --- a/src/style/class_dictionary.cpp +++ b/src/style/class_dictionary.cpp @@ -1,8 +1,34 @@ #include <mbgl/style/class_dictionary.hpp> +#include <uv.h> + namespace mbgl { -ClassID ClassDictionary::Lookup(const std::string &class_name) { +ClassDictionary::ClassDictionary() {} + +ClassDictionary &ClassDictionary::Get() { + // Note: We should eventually switch to uv_key_* functions, but libuv 0.10 doesn't have these + // yet. Instead, we're using the pthread functions directly for now. + static pthread_once_t store_once = PTHREAD_ONCE_INIT; + static pthread_key_t store_key; + + // Create the key. + pthread_once(&store_once, []() { + pthread_key_create(&store_key, [](void *ptr) { + delete reinterpret_cast<ClassDictionary *>(ptr); + }); + }); + + ClassDictionary *ptr = reinterpret_cast<ClassDictionary *>(pthread_getspecific(store_key)); + if (ptr == nullptr) { + ptr = new ClassDictionary(); + pthread_setspecific(store_key, ptr); + } + + return *ptr; +} + +ClassID ClassDictionary::lookup(const std::string &class_name) { auto it = store.find(class_name); if (it == store.end()) { // Insert the class name into the store. @@ -14,7 +40,7 @@ ClassID ClassDictionary::Lookup(const std::string &class_name) { } } -ClassID ClassDictionary::Normalize(ClassID id) { +ClassID ClassDictionary::normalize(ClassID id) { if (id >= ClassID::Named) { return ClassID::Named; } else { @@ -22,8 +48,4 @@ ClassID ClassDictionary::Normalize(ClassID id) { } } - -std::unordered_map<std::string, ClassID> ClassDictionary::store = { { "", ClassID::Default } }; -uint32_t ClassDictionary::offset = 0; - } diff --git a/src/style/style.cpp b/src/style/style.cpp index 6f0a0e3b28..aa5b150882 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -12,6 +12,7 @@ #include <rapidjson/document.h> +#include <algorithm> namespace mbgl { diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index d78750195b..4d64386be8 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -7,8 +7,8 @@ namespace mbgl { -StyleLayer::StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles) - : id(id), styles(std::move(styles)) {} +StyleLayer::StyleLayer(const std::string &id_, std::map<ClassID, ClassProperties> &&styles_) + : id(id_), styles(std::move(styles_)) {} bool StyleLayer::isBackground() const { return type == StyleLayerType::Background; @@ -23,7 +23,7 @@ void StyleLayer::setClasses(const std::vector<std::string> &class_names, const t for (auto it = class_names.rbegin(); it != class_names.rend(); it++) { const std::string &class_name = *it; // From here on, we're only dealing with IDs to avoid comparing strings all the time. - const ClassID class_id = ClassDictionary::Lookup(class_name); + const ClassID class_id = ClassDictionary::Get().lookup(class_name); applyClassProperties(class_id, already_applied, now, defaultTransition); } @@ -70,8 +70,8 @@ void StyleLayer::applyClassProperties(const ClassID class_id, // Loop through all the properties in this style, and add transitions to them, if they're // not already the most recent transition. - const ClassProperties &properties = style_it->second; - for (const std::pair<PropertyKey, PropertyValue> &property_pair : properties) { + const ClassProperties &class_properties = style_it->second; + for (const std::pair<PropertyKey, PropertyValue> &property_pair : class_properties) { PropertyKey key = property_pair.first; if (already_applied.find(key) != already_applied.end()) { // This property has already been set by a previous class. @@ -87,7 +87,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id, AppliedClassProperties &appliedProperties = appliedStyle[key]; if (appliedProperties.mostRecent() != class_id) { const PropertyTransition &transition = - properties.getTransition(key, defaultTransition); + class_properties.getTransition(key, defaultTransition); const timestamp begin = now + transition.delay * 1_millisecond; const timestamp end = begin + transition.duration * 1_millisecond; const PropertyValue &value = property_pair.second; @@ -99,7 +99,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id, template <typename T> struct PropertyEvaluator { typedef T result_type; - PropertyEvaluator(float z) : z(z) {} + PropertyEvaluator(float z_) : z(z_) {} template <typename P, typename std::enable_if<std::is_convertible<P, T>::value, int>::type = 0> T operator()(const P &value) const { @@ -269,11 +269,11 @@ void StyleLayer::cleanupAppliedStyleProperties(timestamp now) { auto it = appliedStyle.begin(); const auto end = appliedStyle.end(); while (it != end) { - AppliedClassProperties &properties = it->second; - properties.cleanup(now); + AppliedClassProperties &applied_properties = it->second; + applied_properties.cleanup(now); // If the current properties object is empty, remove it from the map entirely. - if (properties.empty()) { + if (applied_properties.empty()) { appliedStyle.erase(it++); } else { ++it; diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 3aa12a6670..47ff0c30ab 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -6,6 +6,8 @@ #include <mbgl/platform/log.hpp> #include <csscolorparser/csscolorparser.hpp> +#include <algorithm> + namespace mbgl { using JSVal = const rapidjson::Value&; @@ -108,13 +110,13 @@ template<> bool StyleParser::parseRenderProperty(JSVal value, uint16_t &target, if (value.HasMember(name)) { JSVal property = replaceConstant(value[name]); if (property.IsUint()) { - unsigned int value = property.GetUint(); - if (value > std::numeric_limits<uint16_t>::max()) { + unsigned int int_value = property.GetUint(); + if (int_value > std::numeric_limits<uint16_t>::max()) { Log::Warning(Event::ParseStyle, "values for %s that are larger than %d are not supported", name, std::numeric_limits<uint16_t>::max()); return false; } - target = value; + target = int_value; return true; } else { Log::Warning(Event::ParseStyle, "%s must be an unsigned integer", name); @@ -554,7 +556,7 @@ void StyleParser::parseStyles(JSVal value, std::map<ClassID, ClassProperties> &s if (name == "style") { parseStyle(replaceConstant(itr->value), styles[ClassID::Default]); } else if (name.compare(0, 6, "style.") == 0 && name.length() > 6) { - const ClassID class_id = ClassDictionary::Lookup(name.substr(6)); + const ClassID class_id = ClassDictionary::Get().lookup(name.substr(6)); parseStyle(replaceConstant(itr->value), styles[class_id]); } } @@ -763,11 +765,11 @@ FilterExpression StyleParser::parseFilter(JSVal value, FilterExpression::Operato FilterComparison comparison(name); JSVal filterValue = replaceConstant(itr->value); if (filterValue.IsObject()) { - rapidjson::Value::ConstMemberIterator itr = filterValue.MemberBegin(); - for (; itr != filterValue.MemberEnd(); ++itr) { + rapidjson::Value::ConstMemberIterator filter_itr = filterValue.MemberBegin(); + for (; filter_itr != filterValue.MemberEnd(); ++filter_itr) { comparison.add( - parseFilterComparisonOperator({ itr->name.GetString(), itr->name.GetStringLength() }), - parseValues(replaceConstant(itr->value)) + parseFilterComparisonOperator({ filter_itr->name.GetString(), filter_itr->name.GetStringLength() }), + parseValues(replaceConstant(filter_itr->value)) ); } } else if (filterValue.IsArray()) { diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 6326bea825..2e0ec6dce2 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -19,11 +19,11 @@ Box getBox(const CollisionAnchor &anchor, const CollisionRect &bbox, float minSc }; }; -Collision::Collision(float zoom, float tileExtent, float tileSize, float placementDepth) +Collision::Collision(float zoom_, float tileExtent, float tileSize, float placementDepth) // tile pixels per screen pixels at the tile's zoom level : tilePixelRatio(tileExtent / tileSize), - zoom(zoom), + zoom(zoom_), // Calculate the maximum scale we can go down in our fake-3d rtree so that // placement still makes sense. This is calculated so that the minimum @@ -33,7 +33,7 @@ Collision::Collision(float zoom, float tileExtent, float tileSize, float placeme // We don't want to place labels all the way to 25.5. This lets too many // glyphs be placed, slowing down collision checking. Only place labels if // they will show up within the intended zoom range of the tile. - maxPlacementScale(std::exp(std::log(2) * util::min(3.0f, placementDepth, 25.5f - zoom))) { + maxPlacementScale(std::exp(std::log(2) * util::min(3.0f, placementDepth, 25.5f - zoom_))) { const float m = 4096; const float edge = m * tilePixelRatio * 2; diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 1723bd3d94..5619c4f93f 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -228,7 +228,7 @@ void GlyphPBF::parse(FontStack &stack) { data.clear(); } -GlyphStore::GlyphStore(const util::ptr<FileSource> &fileSource) : fileSource(fileSource) {} +GlyphStore::GlyphStore(const util::ptr<FileSource> &fileSource_) : fileSource(fileSource_) {} void GlyphStore::setURL(const std::string &url) { glyphURL = url; diff --git a/src/text/placement.cpp b/src/text/placement.cpp index 0c95e3a80d..84d4e20b2f 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -12,10 +12,10 @@ namespace mbgl { const float Placement::globalMinScale = 0.5; // underscale by 1 zoom level struct GlyphInstance { - explicit GlyphInstance(const vec2<float> &anchor) : anchor(anchor) {} - explicit GlyphInstance(const vec2<float> &anchor, float offset, float minScale, float maxScale, - float angle) - : anchor(anchor), offset(offset), minScale(minScale), maxScale(maxScale), angle(angle) {} + explicit GlyphInstance(const vec2<float> &anchor_) : anchor(anchor_) {} + explicit GlyphInstance(const vec2<float> &anchor_, float offset_, float minScale_, float maxScale_, + float angle_) + : anchor(anchor_), offset(offset_), minScale(minScale_), maxScale(maxScale_), angle(angle_) {} const vec2<float> anchor; const float offset = 0.0f; diff --git a/src/util/image.cpp b/src/util/image.cpp index 28906c4e91..fd0d34de2d 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -1,4 +1,5 @@ #include <mbgl/util/image.hpp> + #include <png.h> #include <cassert> @@ -30,8 +31,8 @@ std::string mbgl::util::compress_png(int width, int height, void *rgba, bool fli } std::string result; - png_set_write_fn(png_ptr, &result, [](png_structp png_ptr, png_bytep data, png_size_t length) { - std::string *out = static_cast<std::string *>(png_get_io_ptr(png_ptr)); + png_set_write_fn(png_ptr, &result, [](png_structp png_ptr_, png_bytep data, png_size_t length) { + std::string *out = static_cast<std::string *>(png_get_io_ptr(png_ptr_)); out->append(reinterpret_cast<char *>(data), length); }, NULL); @@ -57,8 +58,8 @@ using namespace mbgl::util; struct Buffer { - Buffer(const std::string& data) - : data(data.data()), length(data.size()) {} + Buffer(const std::string& data_) + : data(data_.data()), length(data_.size()) {} const char *const data = 0; const size_t length = 0; size_t pos = 0; diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 7b52c51037..76cd411223 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -6,15 +6,13 @@ #include <mbgl/util/uv_detail.hpp> #include <mbgl/util/std.hpp> -#include <png.h> - #include <cassert> #include <cstring> using namespace mbgl; -Raster::Raster(const util::ptr<Texturepool> &texturepool) - : texturepool(texturepool) +Raster::Raster(const util::ptr<Texturepool> &texturepool_) + : texturepool(texturepool_) {} Raster::~Raster() { @@ -59,32 +57,32 @@ void Raster::bind(bool linear) { glBindTexture(GL_TEXTURE_2D, texture); } - GLuint filter = linear ? GL_LINEAR : GL_NEAREST; - if (filter != this->filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - this->filter = filter; + GLuint new_filter = linear ? GL_LINEAR : GL_NEAREST; + if (new_filter != this->filter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter); + filter = new_filter; } } // overload ::bind for prerendered raster textures -void Raster::bind(const GLuint texture) { +void Raster::bind(const GLuint custom_texture) { if (img && !textured) { - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, custom_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->getData()); img.reset(); textured = true; } else if (textured) { - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, custom_texture); } - GLuint filter = GL_LINEAR; - if (filter != this->filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - this->filter = filter; + GLuint new_filter = GL_LINEAR; + if (new_filter != this->filter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter); + filter = new_filter; } } diff --git a/src/util/timer.cpp b/src/util/timer.cpp index d56860d193..5c4af51da4 100644 --- a/src/util/timer.cpp +++ b/src/util/timer.cpp @@ -8,22 +8,22 @@ using namespace mbgl::util; -timer::timer(Event event) - : event(event), start(now()) {} +timer::timer(Event event_) + : event(event_), start(now()) {} -timer::timer(EventSeverity severity, Event event) - : severity(severity), event(event), start(now()) {} +timer::timer(EventSeverity severity_, Event event_) + : severity(severity_), event(event_), start(now()) {} -timer::timer(const std::string &name, Event event) - : name(name), event(event), start(now()) {} +timer::timer(const std::string &name_, Event event_) + : name(name_), event(event_), start(now()) {} -timer::timer(const std::string &name, EventSeverity severity, Event event) - : name(name), severity(severity), event(event), start(now()) {} +timer::timer(const std::string &name_, EventSeverity severity_, Event event_) + : name(name_), severity(severity_), event(event_), start(now()) {} -void timer::report(const std::string &name) { +void timer::report(const std::string &name_) { timestamp duration = now() - start; - Log::Record(severity, event, name + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); + Log::Record(severity, event, name_ + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); start += duration; } diff --git a/src/util/uv-messenger.c b/src/util/uv-messenger.c index 82df1cae75..bfa1565768 100644 --- a/src/util/uv-messenger.c +++ b/src/util/uv-messenger.c @@ -8,7 +8,6 @@ typedef struct { void *queue[2]; } uv__messenger_item_t; - #if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" |