From 77e784675687d13439a8104c97c5bb0a9ccd8b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 1 Jul 2016 11:51:54 +0200 Subject: [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 --- src/csscolorparser/csscolorparser.cpp | 6 ++- src/mbgl/annotation/annotation_manager.cpp | 2 +- src/mbgl/geometry/circle_buffer.cpp | 4 +- src/mbgl/geometry/debug_font_buffer.cpp | 4 +- src/mbgl/geometry/elements_buffer.cpp | 4 +- src/mbgl/geometry/fill_buffer.cpp | 4 +- src/mbgl/geometry/glyph_atlas.cpp | 4 +- src/mbgl/geometry/line_atlas.cpp | 4 +- src/mbgl/geometry/line_buffer.cpp | 4 +- src/mbgl/gl/gl.cpp | 4 +- src/mbgl/map/map.cpp | 2 +- src/mbgl/map/transform.cpp | 72 +++++++++++++++--------------- src/mbgl/map/transform.hpp | 6 +-- src/mbgl/map/transform_state.cpp | 6 +-- src/mbgl/map/transform_state.hpp | 2 +- src/mbgl/renderer/debug_bucket.cpp | 4 +- src/mbgl/renderer/frame_history.cpp | 4 +- src/mbgl/renderer/painter_clipping.cpp | 4 +- src/mbgl/renderer/painter_debug.cpp | 4 +- src/mbgl/renderer/painter_line.cpp | 2 +- src/mbgl/renderer/render_tile.cpp | 4 +- src/mbgl/renderer/symbol_bucket.cpp | 2 +- src/mbgl/renderer/symbol_bucket.hpp | 2 +- src/mbgl/shader/circle_shader.cpp | 7 +-- src/mbgl/shader/collision_box_shader.cpp | 14 +++--- src/mbgl/shader/icon_shader.cpp | 13 +++--- src/mbgl/shader/line_shader.cpp | 9 ++-- src/mbgl/shader/linepattern_shader.cpp | 12 +++-- src/mbgl/shader/linesdf_shader.cpp | 12 +++-- src/mbgl/shader/outline_shader.cpp | 7 +-- src/mbgl/shader/outlinepattern_shader.cpp | 10 +++-- src/mbgl/shader/pattern_shader.cpp | 7 +-- src/mbgl/shader/plain_shader.cpp | 7 +-- src/mbgl/shader/raster_shader.cpp | 7 +-- src/mbgl/shader/sdf_shader.cpp | 13 +++--- src/mbgl/sprite/sprite_atlas.cpp | 4 +- src/mbgl/text/get_anchors.cpp | 10 ++--- src/mbgl/tile/raster_tile.cpp | 4 +- src/mbgl/tile/tile_worker.cpp | 2 +- src/mbgl/util/mat2.cpp | 4 +- src/mbgl/util/mat3.cpp | 4 +- src/mbgl/util/raster.cpp | 4 +- src/mbgl/util/stopwatch.cpp | 7 ++- src/mbgl/util/version_info.cpp | 2 +- 44 files changed, 190 insertions(+), 123 deletions(-) (limited to 'src') 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 #include -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 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 -using namespace mbgl; +namespace mbgl { void CircleVertexBuffer::add(vertex_type x, vertex_type y, float ex, float ey) { vertex_type *vertices = static_cast(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 #include -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 -using namespace mbgl; +namespace mbgl { void TriangleElementsBuffer::add(element_type a, element_type b, element_type c) { element_type *elements = static_cast(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 -using namespace mbgl; +namespace mbgl { void FillVertexBuffer::add(vertex_type x, vertex_type y) { vertex_type *vertices = static_cast(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 -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 #include -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 -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 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 #include -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. . - + 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 screenful. 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¼ would be equivalent to the root mean squared average velocity, VRMS. 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 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) 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 #include -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 #include -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 #include -using namespace mbgl; +namespace mbgl { void Painter::drawClippingMasks(const std::map& stencils) { @@ -38,3 +38,5 @@ void Painter::drawClippingMasks(const std::map& 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 #include -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 imagePosA = spriteAtlas->getPosition(properties.linePattern.value.from, true); optional 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 -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> 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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 #include -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 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 #include -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 -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 -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 #include -using namespace mbgl; +namespace mbgl { bool Raster::isLoaded() const { std::lock_guard 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 #include -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 -- cgit v1.2.1