summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-07-01 11:51:54 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-07-01 12:38:33 +0200
commit77e784675687d13439a8104c97c5bb0a9ccd8b01 (patch)
treeac5fe39c7c1d0db0923fec2b00b56291ef0f548e
parentda863c6e52f656bd35c3d3346093a24d747d0bbd (diff)
downloadqtlocation-mapboxgl-77e784675687d13439a8104c97c5bb0a9ccd8b01.tar.gz
[core] code style cleanups
- puts function definitions in a namespace ... {} rather than using namespace ...; - remove trailing whitespace - add trailing newline - protect SQL statements from being formatted by clang-format
-rw-r--r--include/mbgl/gl/gl.hpp6
-rw-r--r--include/mbgl/map/camera.hpp26
-rw-r--r--include/mbgl/util/geo.hpp8
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp62
-rw-r--r--platform/default/settings_json.cpp4
-rw-r--r--platform/ios/app/MBXAppDelegate.h2
-rw-r--r--platform/ios/benchmark/MBXBenchAppDelegate.h2
-rw-r--r--src/csscolorparser/csscolorparser.cpp6
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp2
-rw-r--r--src/mbgl/geometry/circle_buffer.cpp4
-rw-r--r--src/mbgl/geometry/debug_font_buffer.cpp4
-rw-r--r--src/mbgl/geometry/elements_buffer.cpp4
-rw-r--r--src/mbgl/geometry/fill_buffer.cpp4
-rw-r--r--src/mbgl/geometry/glyph_atlas.cpp4
-rw-r--r--src/mbgl/geometry/line_atlas.cpp4
-rw-r--r--src/mbgl/geometry/line_buffer.cpp4
-rw-r--r--src/mbgl/gl/gl.cpp4
-rw-r--r--src/mbgl/map/map.cpp2
-rw-r--r--src/mbgl/map/transform.cpp72
-rw-r--r--src/mbgl/map/transform.hpp6
-rw-r--r--src/mbgl/map/transform_state.cpp6
-rw-r--r--src/mbgl/map/transform_state.hpp2
-rw-r--r--src/mbgl/renderer/debug_bucket.cpp4
-rw-r--r--src/mbgl/renderer/frame_history.cpp4
-rw-r--r--src/mbgl/renderer/painter_clipping.cpp4
-rw-r--r--src/mbgl/renderer/painter_debug.cpp4
-rw-r--r--src/mbgl/renderer/painter_line.cpp2
-rw-r--r--src/mbgl/renderer/render_tile.cpp4
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp2
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp2
-rw-r--r--src/mbgl/shader/circle_shader.cpp7
-rw-r--r--src/mbgl/shader/collision_box_shader.cpp14
-rw-r--r--src/mbgl/shader/icon_shader.cpp13
-rw-r--r--src/mbgl/shader/line_shader.cpp9
-rw-r--r--src/mbgl/shader/linepattern_shader.cpp12
-rw-r--r--src/mbgl/shader/linesdf_shader.cpp12
-rw-r--r--src/mbgl/shader/outline_shader.cpp7
-rw-r--r--src/mbgl/shader/outlinepattern_shader.cpp10
-rw-r--r--src/mbgl/shader/pattern_shader.cpp7
-rw-r--r--src/mbgl/shader/plain_shader.cpp7
-rw-r--r--src/mbgl/shader/raster_shader.cpp7
-rw-r--r--src/mbgl/shader/sdf_shader.cpp13
-rw-r--r--src/mbgl/sprite/sprite_atlas.cpp4
-rw-r--r--src/mbgl/text/get_anchors.cpp10
-rw-r--r--src/mbgl/tile/raster_tile.cpp4
-rw-r--r--src/mbgl/tile/tile_worker.cpp2
-rw-r--r--src/mbgl/util/mat2.cpp4
-rw-r--r--src/mbgl/util/mat3.cpp4
-rw-r--r--src/mbgl/util/raster.cpp4
-rw-r--r--src/mbgl/util/stopwatch.cpp7
-rw-r--r--src/mbgl/util/version_info.cpp2
51 files changed, 268 insertions, 155 deletions
diff --git a/include/mbgl/gl/gl.hpp b/include/mbgl/gl/gl.hpp
index 0f54b96110..d033fef549 100644
--- a/include/mbgl/gl/gl.hpp
+++ b/include/mbgl/gl/gl.hpp
@@ -45,9 +45,9 @@ namespace gl {
GLsizei length,
const GLchar *message,
const void *userParam);
-
+
template <class... Args> void mbx_trapExtension(const char *name, Args... args);
-
+
void mbx_trapExtension(const char *);
void mbx_trapExtension(const char *, GLint, const char *);
void mbx_trapExtension(const char *, GLsizei, GLuint *);
@@ -58,7 +58,7 @@ namespace gl {
void mbx_trapExtension(const char *, GLuint, GLuint, GLuint, GLuint, GLint, const char *, const void*);
void mbx_trapExtension(const char *name, GLuint array);
#endif
-
+
struct Error : ::std::runtime_error {
Error(GLenum err, const std::string &msg) : ::std::runtime_error(msg), code(err) {};
const GLenum code;
diff --git a/include/mbgl/map/camera.hpp b/include/mbgl/map/camera.hpp
index 3f39ca2dc9..1c389577f0 100644
--- a/include/mbgl/map/camera.hpp
+++ b/include/mbgl/map/camera.hpp
@@ -14,23 +14,23 @@ namespace mbgl {
struct CameraOptions {
/** Coordinate at the center of the map. */
optional<LatLng> center;
-
+
/** Padding around the interior of the view that affects the frame of
reference for `center`. */
optional<EdgeInsets> padding;
-
+
/** Point of reference for `zoom` and `angle`, assuming an origin at the
top-left corner of the view. */
optional<ScreenCoordinate> anchor;
-
+
/** Zero-based zoom level. Constrained to the minimum and maximum zoom
levels. */
optional<double> zoom;
-
+
/** Bearing, measured in radians counterclockwise from true north. Wrapped
to [−π rad, π rad). */
optional<double> angle;
-
+
/** Pitch toward the horizon measured in radians, with 0 rad resulting in a
two-dimensional map. */
optional<double> pitch;
@@ -42,33 +42,33 @@ struct CameraOptions {
struct AnimationOptions {
/** Time to animate to the viewpoint defined herein. */
optional<Duration> duration;
-
+
/** Average velocity of a flyTo() transition, measured in screenfuls per
second, assuming a linear timing curve.
-
+
A <i>screenful</i> is the visible span in pixels. It does not correspond
to a fixed physical distance but rather varies by zoom level. */
optional<double> velocity;
-
+
/** Zero-based zoom level at the peak of the flyTo() transition’s flight
path. */
optional<double> minZoom;
-
+
/** The easing timing curve of the transition. */
optional<mbgl::util::UnitBezier> easing;
-
+
/** A function that is called on each frame of the transition, just before a
screen update, except on the last frame. The first parameter indicates
the elapsed time as a percentage of the duration. */
std::function<void(double)> transitionFrameFn;
-
+
/** A function that is called once on the last frame of the transition, just
before the corresponding screen update. */
std::function<void()> transitionFinishFn;
-
+
/** Creates an animation with no options specified. */
AnimationOptions() {}
-
+
/** Creates an animation with the specified duration. */
AnimationOptions(Duration d)
: duration(d) {}
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index a68058048d..9dca10eb84 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -191,12 +191,12 @@ public:
double left = 0; ///< Number of pixels inset from the left edge.
double bottom = 0; ///< Number of pixels inset from the bottom edge.
double right = 0; ///< Number of pixels inset from the right edge.
-
+
EdgeInsets() {}
-
+
EdgeInsets(const double t, const double l, const double b, const double r)
: top(t), left(l), bottom(b), right(r) {}
-
+
explicit operator bool() const {
return !(std::isnan(top) || std::isnan(left) || std::isnan(bottom) || std::isnan(right))
&& (top || left || bottom || right);
@@ -214,7 +214,7 @@ public:
top + o.top, left + o.left, bottom + o.bottom, right + o.right,
};
}
-
+
ScreenCoordinate getCenter(uint16_t width, uint16_t height) const;
};
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index e46fc42225..46a2c2bc25 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -11,8 +11,6 @@
namespace mbgl {
-using namespace mapbox::sqlite;
-
OfflineDatabase::Statement::~Statement() {
stmt.reset();
stmt.clearBindings();
@@ -36,7 +34,7 @@ OfflineDatabase::~OfflineDatabase() {
}
void OfflineDatabase::connect(int flags) {
- db = std::make_unique<Database>(path.c_str(), flags);
+ db = std::make_unique<mapbox::sqlite::Database>(path.c_str(), flags);
db->setBusyTimeout(Milliseconds::max());
db->exec("PRAGMA foreign_keys = ON");
}
@@ -44,7 +42,7 @@ void OfflineDatabase::connect(int flags) {
void OfflineDatabase::ensureSchema() {
if (path != ":memory:") {
try {
- connect(ReadWrite);
+ connect(mapbox::sqlite::ReadWrite);
switch (userVersion()) {
case 0: break; // cache-only database; ok to delete
@@ -55,7 +53,7 @@ void OfflineDatabase::ensureSchema() {
}
removeExisting();
- connect(ReadWrite | Create);
+ connect(mapbox::sqlite::ReadWrite | mapbox::sqlite::Create);
} catch (mapbox::sqlite::Exception& ex) {
if (ex.code != SQLITE_CANTOPEN && ex.code != SQLITE_NOTADB) {
Log::Error(Event::Database, "Unexpected error connecting to database: %s", ex.what());
@@ -66,7 +64,7 @@ void OfflineDatabase::ensureSchema() {
if (ex.code == SQLITE_NOTADB) {
removeExisting();
}
- connect(ReadWrite | Create);
+ connect(mapbox::sqlite::ReadWrite | mapbox::sqlite::Create);
} catch (...) {
Log::Error(Event::Database, "Unexpected error creating database: %s", util::toString(std::current_exception()).c_str());
throw;
@@ -77,7 +75,7 @@ void OfflineDatabase::ensureSchema() {
try {
#include "offline_schema.cpp.include"
- connect(ReadWrite | Create);
+ connect(mapbox::sqlite::ReadWrite | mapbox::sqlite::Create);
// If you change the schema you must write a migration from the previous version.
db->exec("PRAGMA auto_vacuum = INCREMENTAL");
@@ -178,18 +176,22 @@ std::pair<bool, uint64_t> OfflineDatabase::putInternal(const Resource& resource,
}
optional<std::pair<Response, uint64_t>> OfflineDatabase::getResource(const Resource& resource) {
+ // clang-format off
Statement accessedStmt = getStatement(
"UPDATE resources SET accessed = ?1 WHERE url = ?2");
+ // clang-format on
accessedStmt->bind(1, util::now());
accessedStmt->bind(2, resource.url);
accessedStmt->run();
+ // clang-format off
Statement stmt = getStatement(
// 0 1 2 3 4
"SELECT etag, expires, modified, data, compressed "
"FROM resources "
"WHERE url = ?");
+ // clang-format on
stmt->bind(1, resource.url);
@@ -223,11 +225,13 @@ bool OfflineDatabase::putResource(const Resource& resource,
const std::string& data,
bool compressed) {
if (response.notModified) {
+ // clang-format off
Statement update = getStatement(
"UPDATE resources "
"SET accessed = ?1, "
" expires = ?2 "
"WHERE url = ?3 ");
+ // clang-format on
update->bind(1, util::now());
update->bind(2, response.expires);
@@ -240,8 +244,9 @@ bool OfflineDatabase::putResource(const Resource& resource,
// Begin an immediate-mode transaction to ensure that two writers do not attempt
// to INSERT a resource at the same moment.
- Transaction transaction(*db, Transaction::Immediate);
+ mapbox::sqlite::Transaction transaction(*db, mapbox::sqlite::Transaction::Immediate);
+ // clang-format off
Statement update = getStatement(
"UPDATE resources "
"SET kind = ?1, "
@@ -252,6 +257,7 @@ bool OfflineDatabase::putResource(const Resource& resource,
" data = ?6, "
" compressed = ?7 "
"WHERE url = ?8 ");
+ // clang-format on
update->bind(1, int(resource.kind));
update->bind(2, response.etag);
@@ -274,9 +280,11 @@ bool OfflineDatabase::putResource(const Resource& resource,
return false;
}
+ // clang-format off
Statement insert = getStatement(
"INSERT INTO resources (url, kind, etag, expires, modified, accessed, data, compressed) "
"VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8) ");
+ // clang-format on
insert->bind(1, resource.url);
insert->bind(2, int(resource.kind));
@@ -300,6 +308,7 @@ bool OfflineDatabase::putResource(const Resource& resource,
}
optional<std::pair<Response, uint64_t>> OfflineDatabase::getTile(const Resource::TileData& tile) {
+ // clang-format off
Statement accessedStmt = getStatement(
"UPDATE tiles "
"SET accessed = ?1 "
@@ -308,6 +317,7 @@ optional<std::pair<Response, uint64_t>> OfflineDatabase::getTile(const Resource:
" AND x = ?4 "
" AND y = ?5 "
" AND z = ?6 ");
+ // clang-format on
accessedStmt->bind(1, util::now());
accessedStmt->bind(2, tile.urlTemplate);
@@ -317,6 +327,7 @@ optional<std::pair<Response, uint64_t>> OfflineDatabase::getTile(const Resource:
accessedStmt->bind(6, tile.z);
accessedStmt->run();
+ // clang-format off
Statement stmt = getStatement(
// 0 1 2 3 4
"SELECT etag, expires, modified, data, compressed "
@@ -326,6 +337,7 @@ optional<std::pair<Response, uint64_t>> OfflineDatabase::getTile(const Resource:
" AND x = ?3 "
" AND y = ?4 "
" AND z = ?5 ");
+ // clang-format on
stmt->bind(1, tile.urlTemplate);
stmt->bind(2, tile.pixelRatio);
@@ -363,6 +375,7 @@ bool OfflineDatabase::putTile(const Resource::TileData& tile,
const std::string& data,
bool compressed) {
if (response.notModified) {
+ // clang-format off
Statement update = getStatement(
"UPDATE tiles "
"SET accessed = ?1, "
@@ -372,6 +385,7 @@ bool OfflineDatabase::putTile(const Resource::TileData& tile,
" AND x = ?5 "
" AND y = ?6 "
" AND z = ?7 ");
+ // clang-format on
update->bind(1, util::now());
update->bind(2, response.expires);
@@ -388,8 +402,9 @@ bool OfflineDatabase::putTile(const Resource::TileData& tile,
// Begin an immediate-mode transaction to ensure that two writers do not attempt
// to INSERT a resource at the same moment.
- Transaction transaction(*db, Transaction::Immediate);
+ mapbox::sqlite::Transaction transaction(*db, mapbox::sqlite::Transaction::Immediate);
+ // clang-format off
Statement update = getStatement(
"UPDATE tiles "
"SET modified = ?1, "
@@ -403,6 +418,7 @@ bool OfflineDatabase::putTile(const Resource::TileData& tile,
" AND x = ?9 "
" AND y = ?10 "
" AND z = ?11 ");
+ // clang-format on
update->bind(1, response.modified);
update->bind(2, response.etag);
@@ -428,9 +444,11 @@ bool OfflineDatabase::putTile(const Resource::TileData& tile,
return false;
}
+ // clang-format off
Statement insert = getStatement(
"INSERT INTO tiles (url_template, pixel_ratio, x, y, z, modified, etag, expires, accessed, data, compressed) "
"VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11) ");
+ // clang-format on
insert->bind(1, tile.urlTemplate);
insert->bind(2, tile.pixelRatio);
@@ -457,8 +475,10 @@ bool OfflineDatabase::putTile(const Resource::TileData& tile,
}
std::vector<OfflineRegion> OfflineDatabase::listRegions() {
+ // clang-format off
Statement stmt = getStatement(
"SELECT id, definition, description FROM regions");
+ // clang-format on
std::vector<OfflineRegion> result;
@@ -474,9 +494,11 @@ std::vector<OfflineRegion> OfflineDatabase::listRegions() {
OfflineRegion OfflineDatabase::createRegion(const OfflineRegionDefinition& definition,
const OfflineRegionMetadata& metadata) {
+ // clang-format off
Statement stmt = getStatement(
"INSERT INTO regions (definition, description) "
"VALUES (?1, ?2) ");
+ // clang-format on
stmt->bind(1, encodeOfflineRegionDefinition(definition));
stmt->bindBlob(2, metadata);
@@ -486,8 +508,10 @@ OfflineRegion OfflineDatabase::createRegion(const OfflineRegionDefinition& defin
}
void OfflineDatabase::deleteRegion(OfflineRegion&& region) {
+ // clang-format off
Statement stmt = getStatement(
"DELETE FROM regions WHERE id = ?");
+ // clang-format on
stmt->bind(1, region.getID());
stmt->run();
@@ -525,6 +549,7 @@ uint64_t OfflineDatabase::putRegionResource(int64_t regionID, const Resource& re
bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
if (resource.kind == Resource::Kind::Tile) {
+ // clang-format off
Statement insert = getStatement(
"INSERT OR IGNORE INTO region_tiles (region_id, tile_id) "
"SELECT ?1, tiles.id "
@@ -534,6 +559,7 @@ bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
" AND x = ?4 "
" AND y = ?5 "
" AND z = ?6 ");
+ // clang-format on
const Resource::TileData& tile = *resource.tileData;
insert->bind(1, regionID);
@@ -548,6 +574,7 @@ bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
return false;
}
+ // clang-format off
Statement select = getStatement(
"SELECT region_id "
"FROM region_tiles, tiles "
@@ -558,6 +585,7 @@ bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
" AND y = ?5 "
" AND z = ?6 "
"LIMIT 1 ");
+ // clang-format on
select->bind(1, regionID);
select->bind(2, tile.urlTemplate);
@@ -567,11 +595,13 @@ bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
select->bind(6, tile.z);
return !select->run();
} else {
+ // clang-format off
Statement insert = getStatement(
"INSERT OR IGNORE INTO region_resources (region_id, resource_id) "
"SELECT ?1, resources.id "
"FROM resources "
"WHERE resources.url = ?2 ");
+ // clang-format on
insert->bind(1, regionID);
insert->bind(2, resource.url);
@@ -581,12 +611,14 @@ bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
return false;
}
+ // clang-format off
Statement select = getStatement(
"SELECT region_id "
"FROM region_resources, resources "
"WHERE region_id != ?1 "
" AND resources.url = ?2 "
"LIMIT 1 ");
+ // clang-format on
select->bind(1, regionID);
select->bind(2, resource.url);
@@ -595,8 +627,10 @@ bool OfflineDatabase::markUsed(int64_t regionID, const Resource& resource) {
}
OfflineRegionDefinition OfflineDatabase::getRegionDefinition(int64_t regionID) {
+ // clang-format off
Statement stmt = getStatement(
"SELECT definition FROM regions WHERE id = ?1");
+ // clang-format on
stmt->bind(1, regionID);
stmt->run();
@@ -619,22 +653,26 @@ OfflineRegionStatus OfflineDatabase::getRegionCompletedStatus(int64_t regionID)
}
std::pair<int64_t, int64_t> OfflineDatabase::getCompletedResourceCountAndSize(int64_t regionID) {
+ // clang-format off
Statement stmt = getStatement(
"SELECT COUNT(*), SUM(LENGTH(data)) "
"FROM region_resources, resources "
"WHERE region_id = ?1 "
"AND resource_id = resources.id ");
+ // clang-format on
stmt->bind(1, regionID);
stmt->run();
return { stmt->get<int64_t>(0), stmt->get<int64_t>(1) };
}
std::pair<int64_t, int64_t> OfflineDatabase::getCompletedTileCountAndSize(int64_t regionID) {
+ // clang-format off
Statement stmt = getStatement(
"SELECT COUNT(*), SUM(LENGTH(data)) "
"FROM region_tiles, tiles "
"WHERE region_id = ?1 "
"AND tile_id = tiles.id ");
+ // clang-format on
stmt->bind(1, regionID);
stmt->run();
return { stmt->get<int64_t>(0), stmt->get<int64_t>(1) };
@@ -668,6 +706,7 @@ bool OfflineDatabase::evict(uint64_t neededFreeSize) {
// The addition of pageSize is a fudge factor to account for non `data` column
// size, and because pages can get fragmented on the database.
while (usedSize() + neededFreeSize + pageSize > maximumCacheSize) {
+ // clang-format off
Statement stmt1 = getStatement(
"DELETE FROM resources "
"WHERE id IN ( "
@@ -677,10 +716,12 @@ bool OfflineDatabase::evict(uint64_t neededFreeSize) {
" WHERE resource_id IS NULL "
" ORDER BY accessed ASC LIMIT ?1 "
") ");
+ // clang-format on
stmt1->bind(1, 50);
stmt1->run();
uint64_t changes1 = db->changes();
+ // clang-format off
Statement stmt2 = getStatement(
"DELETE FROM tiles "
"WHERE id IN ( "
@@ -690,6 +731,7 @@ bool OfflineDatabase::evict(uint64_t neededFreeSize) {
" WHERE tile_id IS NULL "
" ORDER BY accessed ASC LIMIT ?1 "
") ");
+ // clang-format on
stmt2->bind(1, 50);
stmt2->run();
uint64_t changes2 = db->changes();
@@ -727,11 +769,13 @@ uint64_t OfflineDatabase::getOfflineMapboxTileCount() {
return *offlineMapboxTileCount;
}
+ // clang-format off
Statement stmt = getStatement(
"SELECT COUNT(DISTINCT id) "
"FROM region_tiles, tiles "
"WHERE tile_id = tiles.id "
"AND url_template LIKE 'mapbox://%' ");
+ // clang-format on
stmt->run();
diff --git a/platform/default/settings_json.cpp b/platform/default/settings_json.cpp
index 2c1bb3d242..ef53aa83e7 100644
--- a/platform/default/settings_json.cpp
+++ b/platform/default/settings_json.cpp
@@ -1,7 +1,7 @@
#include <mbgl/platform/default/settings_json.hpp>
#include <fstream>
-using namespace mbgl;
+namespace mbgl {
Settings_JSON::Settings_JSON() { load(); }
@@ -37,3 +37,5 @@ void Settings_JSON::clear() {
pitch = 0;
debug = 0;
}
+
+} // namespace mbgl
diff --git a/platform/ios/app/MBXAppDelegate.h b/platform/ios/app/MBXAppDelegate.h
index 8145d3b8ca..7ff321b6c7 100644
--- a/platform/ios/app/MBXAppDelegate.h
+++ b/platform/ios/app/MBXAppDelegate.h
@@ -6,4 +6,4 @@ extern NSString * const MBXMapboxAccessTokenDefaultsKey;
@property (strong, nonatomic) UIWindow *window;
-@end \ No newline at end of file
+@end
diff --git a/platform/ios/benchmark/MBXBenchAppDelegate.h b/platform/ios/benchmark/MBXBenchAppDelegate.h
index e89add93fd..6ae9cdf27c 100644
--- a/platform/ios/benchmark/MBXBenchAppDelegate.h
+++ b/platform/ios/benchmark/MBXBenchAppDelegate.h
@@ -6,4 +6,4 @@ extern NSString * const MBXMapboxAccessTokenDefaultsKey;
@property (strong, nonatomic) UIWindow *window;
-@end \ No newline at end of file
+@end
diff --git a/src/csscolorparser/csscolorparser.cpp b/src/csscolorparser/csscolorparser.cpp
index 8281eb4202..592f10f025 100644
--- a/src/csscolorparser/csscolorparser.cpp
+++ b/src/csscolorparser/csscolorparser.cpp
@@ -30,7 +30,7 @@
#include <cmath>
#include <algorithm>
-using namespace CSSColorParser;
+namespace CSSColorParser {
// http://www.w3.org/TR/css3-color/
struct NamedColor { const char *const name; const Color color; };
@@ -180,7 +180,7 @@ std::vector<std::string> split(const std::string& s, char delim) {
return elems;
}
-Color CSSColorParser::parse(const std::string& css_str) {
+Color parse(const std::string& css_str) {
std::string str = css_str;
// Remove all whitespace, not compliant, but should just be more accepting.
@@ -288,3 +288,5 @@ Color CSSColorParser::parse(const std::string& css_str) {
return {};
}
+
+} // namespace CSSColorParser
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp
index 7e1984a3c8..0cd6bdf231 100644
--- a/src/mbgl/annotation/annotation_manager.cpp
+++ b/src/mbgl/annotation/annotation_manager.cpp
@@ -200,7 +200,7 @@ void AnnotationManager::addIcon(const std::string& name, std::shared_ptr<const S
spriteStore.setSprite(name, sprite);
spriteAtlas.updateDirty();
}
-
+
void AnnotationManager::removeIcon(const std::string& name) {
spriteStore.removeSprite(name);
spriteAtlas.updateDirty();
diff --git a/src/mbgl/geometry/circle_buffer.cpp b/src/mbgl/geometry/circle_buffer.cpp
index 74ccfa8267..cc31fb83bf 100644
--- a/src/mbgl/geometry/circle_buffer.cpp
+++ b/src/mbgl/geometry/circle_buffer.cpp
@@ -4,10 +4,12 @@
#include <climits>
-using namespace mbgl;
+namespace mbgl {
void CircleVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey) {
vertex_type *vertices = static_cast<vertex_type *>(addElement());
vertices[0] = (x * 2) + ((ex + 1) / 2);
vertices[1] = (y * 2) + ((ey + 1) / 2);
}
+
+} // namespace mbgl
diff --git a/src/mbgl/geometry/debug_font_buffer.cpp b/src/mbgl/geometry/debug_font_buffer.cpp
index 5df67accd6..f64ce8816b 100644
--- a/src/mbgl/geometry/debug_font_buffer.cpp
+++ b/src/mbgl/geometry/debug_font_buffer.cpp
@@ -5,7 +5,7 @@
#include <cmath>
#include <cstring>
-using namespace mbgl;
+namespace mbgl {
void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) {
uint16_t *coords = nullptr;
@@ -40,3 +40,5 @@ void DebugFontBuffer::addText(const char *text, double left, double baseline, do
left += glyph.width * scale;
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/geometry/elements_buffer.cpp b/src/mbgl/geometry/elements_buffer.cpp
index 3e2e2794dd..b7d8cb2015 100644
--- a/src/mbgl/geometry/elements_buffer.cpp
+++ b/src/mbgl/geometry/elements_buffer.cpp
@@ -1,6 +1,6 @@
#include <mbgl/geometry/elements_buffer.hpp>
-using namespace mbgl;
+namespace mbgl {
void TriangleElementsBuffer::add(element_type a, element_type b, element_type c) {
element_type *elements = static_cast<element_type *>(addElement());
@@ -14,3 +14,5 @@ void LineElementsBuffer::add(element_type a, element_type b) {
elements[0] = a;
elements[1] = b;
}
+
+} // namespace mbgl
diff --git a/src/mbgl/geometry/fill_buffer.cpp b/src/mbgl/geometry/fill_buffer.cpp
index ee70dfc53b..6cb07ea66a 100644
--- a/src/mbgl/geometry/fill_buffer.cpp
+++ b/src/mbgl/geometry/fill_buffer.cpp
@@ -4,10 +4,12 @@
#include <climits>
-using namespace mbgl;
+namespace mbgl {
void FillVertexBuffer::add(vertex_type x, vertex_type y) {
vertex_type *vertices = static_cast<vertex_type *>(addElement());
vertices[0] = x;
vertices[1] = y;
}
+
+} // namespace mbgl
diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp
index 37e55c9952..c45a93d24e 100644
--- a/src/mbgl/geometry/glyph_atlas.cpp
+++ b/src/mbgl/geometry/glyph_atlas.cpp
@@ -9,7 +9,7 @@
#include <algorithm>
-using namespace mbgl;
+namespace mbgl {
GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_)
: width(width_),
@@ -197,3 +197,5 @@ void GlyphAtlas::bind(gl::ObjectStore& store) {
MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, *texture));
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp
index cf79c874ce..d7ae5b4a60 100644
--- a/src/mbgl/geometry/line_atlas.cpp
+++ b/src/mbgl/geometry/line_atlas.cpp
@@ -9,7 +9,7 @@
#include <sstream>
#include <cmath>
-using namespace mbgl;
+namespace mbgl {
LineAtlas::LineAtlas(GLsizei w, GLsizei h)
: width(w),
@@ -171,3 +171,5 @@ void LineAtlas::bind(gl::ObjectStore& store) {
dirty = false;
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/geometry/line_buffer.cpp b/src/mbgl/geometry/line_buffer.cpp
index 3d979a2a45..7d2e2eb9a2 100644
--- a/src/mbgl/geometry/line_buffer.cpp
+++ b/src/mbgl/geometry/line_buffer.cpp
@@ -3,7 +3,7 @@
#include <cmath>
-using namespace mbgl;
+namespace mbgl {
GLsizei LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey, bool tx, bool ty, int8_t dir, int32_t linesofar) {
GLsizei idx = index();
@@ -34,3 +34,5 @@ GLsizei LineVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey,
return idx;
}
+
+} // namespace mbgl
diff --git a/src/mbgl/gl/gl.cpp b/src/mbgl/gl/gl.cpp
index 48f00ec177..7747717c63 100644
--- a/src/mbgl/gl/gl.cpp
+++ b/src/mbgl/gl/gl.cpp
@@ -121,7 +121,7 @@ namespace mbgl {
void mbx_trapExtension(const char *, GLenum, GLuint, GLsizei, const GLchar *) { }
void mbx_trapExtension(const char *, GLDEBUGPROC, const void *) { }
void mbx_trapExtension(const char *, GLuint, GLuint, GLuint, GLuint, GLint, const char *, const void*) { }
-
+
void mbx_trapExtension(const char *name, GLuint array) {
if(strncasecmp(name, "glBindVertexArray", 17) == 0) {
currentVertexArray = array;
@@ -188,7 +188,7 @@ void mbx_glBufferData(GLenum target,
}
std::cout << "GL glBufferData: " << currentBinding << " using " << bufferBindingToSizeMap[currentBinding] << " bytes current total " << currentUsedBufferBytes << " high water mark " << largestAmountUsedSoFar << "\n";
lock.unlock();
-
+
glBufferData(target, size, data, usage);
}
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 5697036a62..5d3a1f3e5d 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -377,7 +377,7 @@ bool Map::isPanning() const {
}
#pragma mark -
-
+
CameraOptions Map::getCameraOptions(optional<EdgeInsets> padding) const {
return impl->transform.getCameraOptions(padding);
}
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 9137f859d3..41fc36ce27 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -14,7 +14,7 @@
#include <cstdio>
#include <cmath>
-using namespace mbgl;
+namespace mbgl {
/** Converts the given angle (in radians) to be numerically close to the anchor angle, allowing it to be interpolated properly without sudden jumps. */
static double _normalizeAngle(double angle, double anchorAngle)
@@ -117,24 +117,24 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
ScreenCoordinate center = getScreenCoordinate(padding);
center.y = state.height - center.y;
-
+
// Constrain camera options.
zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom());
const double scale = state.zoomScale(zoom);
pitch = util::clamp(pitch, 0., util::PITCH_MAX);
-
+
Update update = state.getZoom() == zoom ? Update::Repaint : Update::RecalculateStyle;
-
+
// Minimize rotation by taking the shorter path around the circle.
angle = _normalizeAngle(angle, state.angle);
state.angle = _normalizeAngle(state.angle, angle);
Duration duration = animation.duration ? *animation.duration : Duration::zero();
-
+
const double startWorldSize = state.worldSize();
state.Bc = startWorldSize / util::DEGREES_MAX;
state.Cc = startWorldSize / util::M2PI;
-
+
const double startScale = state.scale;
const double startAngle = state.angle;
const double startPitch = state.pitch;
@@ -147,14 +147,14 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
LatLng frameLatLng = state.unproject(framePoint, startWorldSize);
double frameScale = util::interpolate(startScale, scale, t);
state.setLatLngZoom(frameLatLng, state.scaleZoom(frameScale));
-
+
if (angle != startAngle) {
state.angle = util::wrap(util::interpolate(startAngle, angle, t), -M_PI, M_PI);
}
if (pitch != startPitch) {
state.pitch = util::interpolate(startPitch, pitch, t);
}
-
+
if (padding) {
state.moveLatLng(frameLatLng, center);
}
@@ -163,11 +163,11 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
}
/** This method implements an “optimal path” animation, as detailed in:
-
+
Van Wijk, Jarke J.; Nuij, Wim A. A. “Smooth and efficient zooming and
panning.” INFOVIS ’03. pp. 15–22.
<https://www.win.tue.nl/~vanwijk/zoompan.pdf#page=5>.
-
+
Where applicable, local variable documentation begins with the associated
variable or function in van Wijk (2003). */
void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &animation) {
@@ -179,7 +179,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
if (!latLng || std::isnan(zoom)) {
return;
}
-
+
// Determine endpoints.
EdgeInsets padding;
if (camera.padding) padding = *camera.padding;
@@ -191,19 +191,19 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
ScreenCoordinate center = getScreenCoordinate(padding);
center.y = state.height - center.y;
-
+
// Constrain camera options.
zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom());
pitch = util::clamp(pitch, 0., util::PITCH_MAX);
-
+
// Minimize rotation by taking the shorter path around the circle.
angle = _normalizeAngle(angle, state.angle);
state.angle = _normalizeAngle(state.angle, angle);
-
+
const double startZoom = state.scaleZoom(state.scale);
const double startAngle = state.angle;
const double startPitch = state.pitch;
-
+
/// w₀: Initial visible span, measured in pixels at the initial scale.
/// Known henceforth as a <i>screenful</i>.
double w0 = padding ? std::max(state.width, state.height)
@@ -215,11 +215,11 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
/// Length of the flight path as projected onto the ground plane, measured
/// in pixels from the world image origin at the initial scale.
double u1 = ::hypot((endPoint - startPoint).x, (endPoint - startPoint).y);
-
+
/** ρ: The relative amount of zooming that takes place along the flight
path. A high value maximizes zooming for an exaggerated animation, while
a low value minimizes zooming for something closer to easeTo().
-
+
1.42 is the average value selected by participants in the user study in
van Wijk (2003). A value of 6<sup>¼</sup> would be equivalent to the
root mean squared average velocity, V<sub>RMS</sub>. A value of 1 would
@@ -235,16 +235,16 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
}
/// ρ²
double rho2 = rho * rho;
-
+
/** rᵢ: Returns the zoom-out factor at one end of the animation.
-
+
@param i 0 for the ascent or 1 for the descent. */
auto r = [=](double i) {
/// bᵢ
double b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
return std::log(std::sqrt(b * b + 1) - b);
};
-
+
// When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
bool isClose = std::abs(u1) < 0.000001;
// Perform a more or less instantaneous transition if the path is too short.
@@ -252,12 +252,12 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
easeTo(camera, animation);
return;
}
-
+
/// r₀: Zoom-out factor during ascent.
double r0 = r(0);
/** w(s): Returns the visible span on the ground, measured in pixels with
respect to the initial scale.
-
+
Assumes an angular field of view of 2 arctan ½ ≈ 53°. */
auto w = [=](double s) {
return (isClose ? std::exp((w1 < w0 ? -1 : 1) * rho * s)
@@ -273,7 +273,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
/// S: Total length of the flight path, measured in ρ-screenfuls.
double S = (isClose ? (std::abs(std::log(w1 / w0)) / rho)
: ((r(1) - r0) / rho));
-
+
Duration duration;
if (animation.duration) {
duration = *animation.duration;
@@ -290,36 +290,36 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
jumpTo(camera);
return;
}
-
+
const double startWorldSize = state.worldSize();
state.Bc = startWorldSize / util::DEGREES_MAX;
state.Cc = startWorldSize / util::M2PI;
-
+
state.panning = true;
state.scaling = true;
state.rotating = angle != startAngle;
-
+
startTransition(camera, animation, [=](double k) {
/// s: The distance traveled along the flight path, measured in
/// ρ-screenfuls.
double s = k * S;
double us = u(s);
-
+
// Calculate the current point and zoom level along the flight path.
Point<double> framePoint = util::interpolate(startPoint, endPoint, us);
double frameZoom = startZoom + state.scaleZoom(1 / w(s));
-
+
// Convert to geographic coordinates and set the new viewpoint.
LatLng frameLatLng = state.unproject(framePoint, startWorldSize);
state.setLatLngZoom(frameLatLng, frameZoom);
-
+
if (angle != startAngle) {
state.angle = util::wrap(util::interpolate(startAngle, angle, k), -M_PI, M_PI);
}
if (pitch != startPitch) {
state.pitch = util::interpolate(startPitch, pitch, k);
}
-
+
if (padding) {
state.moveLatLng(frameLatLng, center);
}
@@ -474,7 +474,7 @@ void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate&
center.x = first.x + std::cos(rotateAngle) * heightOffset;
center.y = first.y + std::sin(rotateAngle) * heightOffset;
}
-
+
CameraOptions camera;
camera.angle = state.angle + util::angle_between(first - center, second - center);
easeTo(camera, duration);
@@ -561,7 +561,7 @@ void Transform::startTransition(const CameraOptions& camera,
if (transitionFinishFn) {
transitionFinishFn();
}
-
+
bool isAnimated = duration != Duration::zero();
if (callback) {
callback(isAnimated ? MapChangeRegionWillChangeAnimated : MapChangeRegionWillChange);
@@ -587,9 +587,9 @@ void Transform::startTransition(const CameraOptions& camera,
util::UnitBezier ease = animation.easing ? *animation.easing : util::DEFAULT_TRANSITION_EASE;
result = frame(ease.solve(t, 0.001));
}
-
+
if (anchor) state.moveLatLng(anchorLatLng, *anchor);
-
+
// At t = 1.0, a DidChangeAnimated notification should be sent from finish().
if (t < 1.0) {
if (animation.transitionFrameFn) {
@@ -620,7 +620,7 @@ void Transform::startTransition(const CameraOptions& camera,
callback(isAnimated ? MapChangeRegionDidChangeAnimated : MapChangeRegionDidChange);
}
};
-
+
if (!isAnimated) {
transitionFrameFn(Clock::now());
}
@@ -665,3 +665,5 @@ LatLng Transform::screenCoordinateToLatLng(const ScreenCoordinate& point) const
flippedPoint.y = state.height - flippedPoint.y;
return state.screenCoordinateToLatLng(flippedPoint).wrapped();
}
+
+} // namespace mbgl
diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp
index 904ed11392..abc301b1cb 100644
--- a/src/mbgl/map/transform.hpp
+++ b/src/mbgl/map/transform.hpp
@@ -28,7 +28,7 @@ public:
// Camera
/** Returns the current camera options. */
CameraOptions getCameraOptions(optional<EdgeInsets>) const;
-
+
/** Instantaneously, synchronously applies the given camera options. */
void jumpTo(const CameraOptions&);
/** Asynchronously transitions all specified camera options linearly along
@@ -40,7 +40,7 @@ public:
void flyTo(const CameraOptions&, const AnimationOptions& = {});
// Position
-
+
/** Pans the map by the given amount.
@param offset The distance to pan the map by, measured in pixels from
top to bottom and from left to right. */
@@ -157,7 +157,7 @@ public:
bool isRotating() const { return state.isRotating(); }
bool isScaling() const { return state.isScaling(); }
bool isPanning() const { return state.isPanning(); }
-
+
// Conversion and projection
ScreenCoordinate latLngToScreenCoordinate(const LatLng&) const;
LatLng screenCoordinateToLatLng(const ScreenCoordinate&) const;
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index 3d5a1a6798..86ffc254d8 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -336,10 +336,10 @@ void TransformState::setLatLngZoom(const LatLng &latLng, double zoom) {
const double newWorldSize = newScale * util::tileSize;
Bc = newWorldSize / util::DEGREES_MAX;
Cc = newWorldSize / util::M2PI;
-
+
const double m = 1 - 1e-15;
const double f = util::clamp(std::sin(util::DEG2RAD * latLng.latitude), -m, m);
-
+
ScreenCoordinate point = {
-latLng.longitude * Bc,
0.5 * Cc * std::log((1 + f) / (1 - f)),
@@ -351,7 +351,7 @@ void TransformState::setScalePoint(const double newScale, const ScreenCoordinate
double constrainedScale = newScale;
ScreenCoordinate constrainedPoint = point;
constrain(constrainedScale, constrainedPoint.x, constrainedPoint.y);
-
+
scale = constrainedScale;
x = constrainedPoint.x;
y = constrainedPoint.y;
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp
index 83e4f64b07..1e4b2054f7 100644
--- a/src/mbgl/map/transform_state.hpp
+++ b/src/mbgl/map/transform_state.hpp
@@ -92,7 +92,7 @@ private:
mat4 coordinatePointMatrix(double z) const;
mat4 getPixelMatrix() const;
-
+
/** Recenter the map so that the given coordinate is located at the given
point on screen. */
void moveLatLng(const LatLng&, const ScreenCoordinate&);
diff --git a/src/mbgl/renderer/debug_bucket.cpp b/src/mbgl/renderer/debug_bucket.cpp
index 8c7a25c675..b4218485b2 100644
--- a/src/mbgl/renderer/debug_bucket.cpp
+++ b/src/mbgl/renderer/debug_bucket.cpp
@@ -8,7 +8,7 @@
#include <cassert>
#include <string>
-using namespace mbgl;
+namespace mbgl {
DebugBucket::DebugBucket(const OverscaledTileID& id,
const bool renderable_,
@@ -51,3 +51,5 @@ void DebugBucket::drawPoints(PlainShader& shader, gl::ObjectStore& store) {
MBGL_CHECK_ERROR(glDrawArrays(GL_POINTS, 0, (GLsizei)(fontBuffer.index())));
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp
index 5173d9d5a1..68b6bf863e 100644
--- a/src/mbgl/renderer/frame_history.cpp
+++ b/src/mbgl/renderer/frame_history.cpp
@@ -1,7 +1,7 @@
#include <mbgl/renderer/frame_history.hpp>
#include <mbgl/math/minmax.hpp>
-using namespace mbgl;
+namespace mbgl {
FrameHistory::FrameHistory() {
changeOpacities.fill(0);
@@ -110,3 +110,5 @@ void FrameHistory::bind(gl::ObjectStore& store) {
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/painter_clipping.cpp b/src/mbgl/renderer/painter_clipping.cpp
index e6ce1a040e..f0fc836f74 100644
--- a/src/mbgl/renderer/painter_clipping.cpp
+++ b/src/mbgl/renderer/painter_clipping.cpp
@@ -5,7 +5,7 @@
#include <mbgl/util/string.hpp>
#include <mbgl/gl/debugging.hpp>
-using namespace mbgl;
+namespace mbgl {
void Painter::drawClippingMasks(const std::map<UnwrappedTileID, ClipID>& stencils) {
@@ -38,3 +38,5 @@ void Painter::drawClippingMasks(const std::map<UnwrappedTileID, ClipID>& stencil
MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLES, 0, (GLsizei)tileStencilBuffer.index()));
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/painter_debug.cpp b/src/mbgl/renderer/painter_debug.cpp
index 9ddae289ee..7e751aa016 100644
--- a/src/mbgl/renderer/painter_debug.cpp
+++ b/src/mbgl/renderer/painter_debug.cpp
@@ -10,7 +10,7 @@
#include <mbgl/gl/gl_helper.hpp>
#include <mbgl/util/color.hpp>
-using namespace mbgl;
+namespace mbgl {
void Painter::renderTileDebug(const RenderTile& tile) {
MBGL_DEBUG_GROUP(std::string { "debug " } + util::toString(tile.id));
@@ -118,3 +118,5 @@ void Painter::renderClipMasks() {
MBGL_CHECK_ERROR(glDrawPixels(fbSize[0], fbSize[1], GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels.get()));
#endif // GL_ES_VERSION_2_0
}
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp
index 206255095d..638d0b6f82 100644
--- a/src/mbgl/renderer/painter_line.cpp
+++ b/src/mbgl/renderer/painter_line.cpp
@@ -98,7 +98,7 @@ void Painter::renderLine(LineBucket& bucket,
} else if (!properties.linePattern.value.from.empty()) {
optional<SpriteAtlasPosition> imagePosA = spriteAtlas->getPosition(properties.linePattern.value.from, true);
optional<SpriteAtlasPosition> imagePosB = spriteAtlas->getPosition(properties.linePattern.value.to, true);
-
+
if (!imagePosA || !imagePosB)
return;
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index 2f407a2895..513515ddf0 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -1,3 +1,5 @@
#include <mbgl/renderer/render_tile.hpp>
-using namespace mbgl;
+namespace mbgl {
+
+} // namespace mbgl
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index d853265861..c198ac8a38 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -370,7 +370,7 @@ void SymbolBucket::addFeature(const GeometryCollection &lines,
}
}
}
-
+
bool SymbolBucket::anchorIsTooClose(const std::u32string &text, const float repeatDistance, Anchor &anchor) {
if (compareText.find(text) == compareText.end()) {
compareText.emplace(text, Anchors());
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 98b8116c26..6f16cccf34 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -98,7 +98,7 @@ private:
const size_t index);
bool anchorIsTooClose(const std::u32string &text, const float repeatDistance, Anchor &anchor);
std::map<std::u32string, std::vector<Anchor>> compareText;
-
+
void addToDebugBuffers(CollisionTile &collisionTile);
void swapRenderData() override;
diff --git a/src/mbgl/shader/circle_shader.cpp b/src/mbgl/shader/circle_shader.cpp
index e1328bcbf1..9df5b01271 100644
--- a/src/mbgl/shader/circle_shader.cpp
+++ b/src/mbgl/shader/circle_shader.cpp
@@ -3,14 +3,15 @@
#include <mbgl/shader/circle.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::circle;
+namespace mbgl {
CircleShader::CircleShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store) {
+ : Shader(shaders::circle::name, shaders::circle::vertex, shaders::circle::fragment, store) {
}
void CircleShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 4, offset));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/collision_box_shader.cpp b/src/mbgl/shader/collision_box_shader.cpp
index 7d6473ee29..81f44b44e6 100644
--- a/src/mbgl/shader/collision_box_shader.cpp
+++ b/src/mbgl/shader/collision_box_shader.cpp
@@ -3,13 +3,15 @@
#include <mbgl/shader/collisionbox.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::collisionbox;
+namespace mbgl {
CollisionBoxShader::CollisionBoxShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store)
- , a_extrude(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_extrude")))
- , a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
+ : Shader(shaders::collisionbox::name,
+ shaders::collisionbox::vertex,
+ shaders::collisionbox::fragment,
+ store),
+ a_extrude(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_extrude"))),
+ a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
}
void CollisionBoxShader::bind(GLbyte *offset) {
@@ -25,3 +27,5 @@ void CollisionBoxShader::bind(GLbyte *offset) {
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 2, GL_UNSIGNED_BYTE, false, stride, offset + 8));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/icon_shader.cpp b/src/mbgl/shader/icon_shader.cpp
index f4568e6c3d..a6099a00cf 100644
--- a/src/mbgl/shader/icon_shader.cpp
+++ b/src/mbgl/shader/icon_shader.cpp
@@ -3,14 +3,13 @@
#include <mbgl/shader/icon.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::icon;
+namespace mbgl {
IconShader::IconShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store)
- , a_offset(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_offset")))
- , a_data1(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data1")))
- , a_data2(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data2"))) {
+ : Shader(shaders::icon::name, shaders::icon::vertex, shaders::icon::fragment, store),
+ a_offset(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_offset"))),
+ a_data1(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data1"))),
+ a_data2(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data2"))) {
}
void IconShader::bind(GLbyte* offset) {
@@ -28,3 +27,5 @@ void IconShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data2));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data2, 4, GL_UNSIGNED_BYTE, false, stride, offset + 12));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/line_shader.cpp b/src/mbgl/shader/line_shader.cpp
index 729b34d557..300dc9f598 100644
--- a/src/mbgl/shader/line_shader.cpp
+++ b/src/mbgl/shader/line_shader.cpp
@@ -3,12 +3,11 @@
#include <mbgl/shader/line.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::line;
+namespace mbgl {
LineShader::LineShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store)
- , a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
+ : Shader(shaders::line::name, shaders::line::vertex, shaders::line::fragment, store),
+ a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
}
void LineShader::bind(GLbyte* offset) {
@@ -18,3 +17,5 @@ void LineShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 4, GL_UNSIGNED_BYTE, false, 8, offset + 4));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/linepattern_shader.cpp b/src/mbgl/shader/linepattern_shader.cpp
index dc970a5661..2f3d93c03e 100644
--- a/src/mbgl/shader/linepattern_shader.cpp
+++ b/src/mbgl/shader/linepattern_shader.cpp
@@ -3,12 +3,14 @@
#include <mbgl/shader/linepattern.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::linepattern;
+namespace mbgl {
LinepatternShader::LinepatternShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store)
- , a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
+ : Shader(shaders::linepattern::name,
+ shaders::linepattern::vertex,
+ shaders::linepattern::fragment,
+ store),
+ a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
}
void LinepatternShader::bind(GLbyte* offset) {
@@ -18,3 +20,5 @@ void LinepatternShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 4, GL_UNSIGNED_BYTE, false, 8, offset + 4));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/linesdf_shader.cpp b/src/mbgl/shader/linesdf_shader.cpp
index 29b67f4de5..8b6e2e1900 100644
--- a/src/mbgl/shader/linesdf_shader.cpp
+++ b/src/mbgl/shader/linesdf_shader.cpp
@@ -3,12 +3,14 @@
#include <mbgl/shader/linesdfpattern.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::linesdfpattern;
+namespace mbgl {
LineSDFShader::LineSDFShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store)
- , a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
+ : Shader(shaders::linesdfpattern::name,
+ shaders::linesdfpattern::vertex,
+ shaders::linesdfpattern::fragment,
+ store),
+ a_data(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"))) {
}
void LineSDFShader::bind(GLbyte* offset) {
@@ -18,3 +20,5 @@ void LineSDFShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 4, GL_UNSIGNED_BYTE, false, 8, offset + 4));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/outline_shader.cpp b/src/mbgl/shader/outline_shader.cpp
index 09aff361c3..aadbc08ada 100644
--- a/src/mbgl/shader/outline_shader.cpp
+++ b/src/mbgl/shader/outline_shader.cpp
@@ -3,14 +3,15 @@
#include <mbgl/shader/outline.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::outline;
+namespace mbgl {
OutlineShader::OutlineShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store) {
+ : Shader(shaders::outline::name, shaders::outline::vertex, shaders::outline::fragment, store) {
}
void OutlineShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/outlinepattern_shader.cpp b/src/mbgl/shader/outlinepattern_shader.cpp
index 0af8558587..8fde8dee74 100644
--- a/src/mbgl/shader/outlinepattern_shader.cpp
+++ b/src/mbgl/shader/outlinepattern_shader.cpp
@@ -3,14 +3,18 @@
#include <mbgl/shader/outlinepattern.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::outlinepattern;
+namespace mbgl {
OutlinePatternShader::OutlinePatternShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store) {
+ : Shader(shaders::outlinepattern::name,
+ shaders::outlinepattern::vertex,
+ shaders::outlinepattern::fragment,
+ store) {
}
void OutlinePatternShader::bind(GLbyte *offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/pattern_shader.cpp b/src/mbgl/shader/pattern_shader.cpp
index a7ddc681d4..f3027514f9 100644
--- a/src/mbgl/shader/pattern_shader.cpp
+++ b/src/mbgl/shader/pattern_shader.cpp
@@ -3,14 +3,15 @@
#include <mbgl/shader/pattern.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::pattern;
+namespace mbgl {
PatternShader::PatternShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store) {
+ : Shader(shaders::pattern::name, shaders::pattern::vertex, shaders::pattern::fragment, store) {
}
void PatternShader::bind(GLbyte *offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/plain_shader.cpp b/src/mbgl/shader/plain_shader.cpp
index 257f49e1e2..120481c272 100644
--- a/src/mbgl/shader/plain_shader.cpp
+++ b/src/mbgl/shader/plain_shader.cpp
@@ -3,14 +3,15 @@
#include <mbgl/shader/fill.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::fill;
+namespace mbgl {
PlainShader::PlainShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store) {
+ : Shader(shaders::fill::name, shaders::fill::vertex, shaders::fill::fragment, store) {
}
void PlainShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/raster_shader.cpp b/src/mbgl/shader/raster_shader.cpp
index b310212731..109c6e0d29 100644
--- a/src/mbgl/shader/raster_shader.cpp
+++ b/src/mbgl/shader/raster_shader.cpp
@@ -3,14 +3,15 @@
#include <mbgl/shader/raster.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::raster;
+namespace mbgl {
RasterShader::RasterShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store) {
+ : Shader(shaders::raster::name, shaders::raster::vertex, shaders::raster::fragment, store) {
}
void RasterShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/shader/sdf_shader.cpp b/src/mbgl/shader/sdf_shader.cpp
index 1a08bef16e..faee224373 100644
--- a/src/mbgl/shader/sdf_shader.cpp
+++ b/src/mbgl/shader/sdf_shader.cpp
@@ -3,14 +3,13 @@
#include <mbgl/shader/sdf.fragment.hpp>
#include <mbgl/gl/gl.hpp>
-using namespace mbgl;
-using namespace shaders::sdf;
+namespace mbgl {
SDFShader::SDFShader(gl::ObjectStore& store)
- : Shader(::name, ::vertex, ::fragment, store)
- , a_offset(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_offset")))
- , a_data1(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data1")))
- , a_data2(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data2"))) {
+ : Shader(shaders::sdf::name, shaders::sdf::vertex, shaders::sdf::fragment, store),
+ a_offset(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_offset"))),
+ a_data1(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data1"))),
+ a_data2(MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data2"))) {
}
void SDFGlyphShader::bind(GLbyte* offset) {
@@ -44,3 +43,5 @@ void SDFIconShader::bind(GLbyte* offset) {
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data2));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data2, 4, GL_UNSIGNED_BYTE, false, stride, offset + 12));
}
+
+} // namespace mbgl
diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp
index 2e1616669f..581bc01ed8 100644
--- a/src/mbgl/sprite/sprite_atlas.cpp
+++ b/src/mbgl/sprite/sprite_atlas.cpp
@@ -11,7 +11,7 @@
#include <cmath>
#include <algorithm>
-using namespace mbgl;
+namespace mbgl {
SpriteAtlas::SpriteAtlas(dimension width_, dimension height_, float pixelRatio_, SpriteStore& store_)
: width(width_),
@@ -253,3 +253,5 @@ SpriteAtlas::Holder::Holder(std::shared_ptr<const SpriteImage> spriteImage_, Rec
SpriteAtlas::Holder::Holder(Holder&& h) : spriteImage(std::move(h.spriteImage)), pos(h.pos) {
}
+
+} // namespace mbgl
diff --git a/src/mbgl/text/get_anchors.cpp b/src/mbgl/text/get_anchors.cpp
index c55f238e52..ce45e05d9c 100644
--- a/src/mbgl/text/get_anchors.cpp
+++ b/src/mbgl/text/get_anchors.cpp
@@ -80,25 +80,25 @@ Anchors getAnchors(const GeometryCoordinates &line, float spacing,
const float angleWindowSize = (textLeft - textRight) != 0.0f ?
3.0f / 5.0f * glyphSize * boxScale :
0;
-
+
const float labelLength = fmax(textRight - textLeft, iconRight - iconLeft);
-
+
// Is the line continued from outside the tile boundary?
const bool continuedLine = (line[0].x == 0 || line[0].x == util::EXTENT || line[0].y == 0 || line[0].y == util::EXTENT);
-
+
// Is the label long, relative to the spacing?
// If so, adjust the spacing so there is always a minimum space of `spacing / 4` between label edges.
if (spacing - labelLength * boxScale < spacing / 4) {
spacing = labelLength * boxScale + spacing / 4;
}
-
+
// Offset the first anchor by:
// Either half the label length plus a fixed extra offset if the line is not continued
// Or half the spacing if the line is continued.
// For non-continued lines, add a bit of fixed extra offset to avoid collisions at T intersections.
const float fixedExtraOffset = glyphSize * 2;
-
+
const float offset = !continuedLine ?
std::fmod((labelLength / 2 + fixedExtraOffset) * boxScale * overscaling, spacing) :
std::fmod(spacing / 2 * overscaling, spacing);
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index a0f172a017..2460aac8f9 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -9,7 +9,7 @@
#include <mbgl/util/worker.hpp>
#include <mbgl/util/work_request.hpp>
-using namespace mbgl;
+namespace mbgl {
RasterTile::RasterTile(const OverscaledTileID& id_,
const style::UpdateParameters& parameters,
@@ -67,3 +67,5 @@ void RasterTile::setNecessity(Necessity necessity) {
void RasterTile::cancel() {
workRequest.reset();
}
+
+} // namespace mbgl
diff --git a/src/mbgl/tile/tile_worker.cpp b/src/mbgl/tile/tile_worker.cpp
index c21a4a4ad7..fe75c86741 100644
--- a/src/mbgl/tile/tile_worker.cpp
+++ b/src/mbgl/tile/tile_worker.cpp
@@ -16,7 +16,7 @@
namespace mbgl {
-using namespace mbgl::style;
+using namespace style;
TileWorker::TileWorker(OverscaledTileID id_,
SpriteStore& spriteStore_,
diff --git a/src/mbgl/util/mat2.cpp b/src/mbgl/util/mat2.cpp
index ca60dce9c5..4fb5abafb8 100644
--- a/src/mbgl/util/mat2.cpp
+++ b/src/mbgl/util/mat2.cpp
@@ -24,7 +24,7 @@
#include <cmath>
-using namespace mbgl;
+namespace mbgl {
void matrix::identity(mat2& out) {
out[0] = 1.0f;
@@ -50,3 +50,5 @@ void matrix::scale(mat2& out, const mat2& a, double v0, double v1) {
out[2] = a2 * v1;
out[3] = a3 * v1;
}
+
+} // namespace mbgl
diff --git a/src/mbgl/util/mat3.cpp b/src/mbgl/util/mat3.cpp
index 88c769790e..e2200867ce 100644
--- a/src/mbgl/util/mat3.cpp
+++ b/src/mbgl/util/mat3.cpp
@@ -24,7 +24,7 @@
#include <cmath>
-using namespace mbgl;
+namespace mbgl {
void matrix::identity(mat3& out) {
out[0] = 1.0f;
@@ -93,3 +93,5 @@ void matrix::scale(mat3& out, const mat3& a, double x, double y) {
out[7] = a[7];
out[8] = a[8];
}
+
+} // namespace mbgl
diff --git a/src/mbgl/util/raster.cpp b/src/mbgl/util/raster.cpp
index fc9cc1c256..b4e838ec00 100644
--- a/src/mbgl/util/raster.cpp
+++ b/src/mbgl/util/raster.cpp
@@ -7,7 +7,7 @@
#include <cassert>
#include <cstring>
-using namespace mbgl;
+namespace mbgl {
bool Raster::isLoaded() const {
std::lock_guard<std::mutex> lock(mtx);
@@ -59,3 +59,5 @@ void Raster::upload(gl::ObjectStore& store) {
img.data.reset();
}
}
+
+} // namespace mbgl
diff --git a/src/mbgl/util/stopwatch.cpp b/src/mbgl/util/stopwatch.cpp
index 8cf0f7fd22..d588b79254 100644
--- a/src/mbgl/util/stopwatch.cpp
+++ b/src/mbgl/util/stopwatch.cpp
@@ -7,7 +7,8 @@
#include <iostream>
#include <atomic>
-using namespace mbgl::util;
+namespace mbgl {
+namespace util {
stopwatch::stopwatch(Event event_)
: event(event_), start(Clock::now()) {}
@@ -33,4 +34,8 @@ stopwatch::~stopwatch() {
report(name);
}
}
+
+} // namespace util
+} // namespace mbgl
+
#endif
diff --git a/src/mbgl/util/version_info.cpp b/src/mbgl/util/version_info.cpp
index c545ddcc40..f0fb139bca 100644
--- a/src/mbgl/util/version_info.cpp
+++ b/src/mbgl/util/version_info.cpp
@@ -11,4 +11,4 @@ const char *string = MBGL_VERSION_STRING;
const unsigned int number = MBGL_VERSION;
} // namespace version
-} // namespace mbgl \ No newline at end of file
+} // namespace mbgl