Fix clang-tidy 18.1.8 issues (#3800)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gl {
|
||||
@@ -41,9 +42,9 @@ public:
|
||||
static constexpr const char* getFirstAttribName() {
|
||||
// Static assert that attribute list starts with position: we bind it on location 0.
|
||||
using TypeOfFirst = typename std::tuple_element_t<0, std::tuple<As...>>;
|
||||
static_assert(std::is_same<attributes::pos, TypeOfFirst>::value ||
|
||||
std::is_same<attributes::pos_offset, TypeOfFirst>::value ||
|
||||
std::is_same<attributes::pos_normal, TypeOfFirst>::value,
|
||||
static_assert(std::is_same_v<attributes::pos, TypeOfFirst> ||
|
||||
std::is_same_v<attributes::pos_offset, TypeOfFirst> ||
|
||||
std::is_same_v<attributes::pos_normal, TypeOfFirst>,
|
||||
"Program must start with position related attribute.");
|
||||
return concat_literals<&string_literal<'a', '_'>::value, TypeOfFirst::name>::value();
|
||||
}
|
||||
|
||||
@@ -35,8 +35,9 @@ gfx::ColorBlendEquationType Enum<gfx::ColorBlendEquationType>::from(const platfo
|
||||
return gfx::ColorBlendEquationType::Subtract;
|
||||
case GL_FUNC_REVERSE_SUBTRACT:
|
||||
return gfx::ColorBlendEquationType::ReverseSubtract;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -85,8 +86,9 @@ gfx::ColorBlendFactorType Enum<gfx::ColorBlendFactorType>::from(const platform::
|
||||
return gfx::ColorBlendFactorType::OneMinusConstantAlpha;
|
||||
case GL_SRC_ALPHA_SATURATE:
|
||||
return gfx::ColorBlendFactorType::SrcAlphaSaturate;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -145,8 +147,9 @@ gfx::DepthFunctionType Enum<gfx::DepthFunctionType>::from(const platform::GLint
|
||||
return gfx::DepthFunctionType::GreaterEqual;
|
||||
case GL_ALWAYS:
|
||||
return gfx::DepthFunctionType::Always;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -201,8 +204,9 @@ gfx::StencilFunctionType Enum<gfx::StencilFunctionType>::from(const platform::GL
|
||||
return gfx::StencilFunctionType::GreaterEqual;
|
||||
case GL_ALWAYS:
|
||||
return gfx::StencilFunctionType::Always;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -247,8 +251,9 @@ gfx::StencilOpType Enum<gfx::StencilOpType>::from(const platform::GLint value) {
|
||||
return gfx::StencilOpType::DecrementWrap;
|
||||
case GL_INVERT:
|
||||
return gfx::StencilOpType::Invert;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -283,8 +288,9 @@ gfx::CullFaceSideType Enum<gfx::CullFaceSideType>::from(const platform::GLint va
|
||||
return gfx::CullFaceSideType::Back;
|
||||
case GL_FRONT_AND_BACK:
|
||||
return gfx::CullFaceSideType::FrontAndBack;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -307,8 +313,9 @@ gfx::CullFaceWindingType Enum<gfx::CullFaceWindingType>::from(const platform::GL
|
||||
return gfx::CullFaceWindingType::Clockwise;
|
||||
case GL_CCW:
|
||||
return gfx::CullFaceWindingType::CounterClockwise;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -331,8 +338,9 @@ gfx::BufferUsageType Enum<gfx::BufferUsageType>::from(const platform::GLint valu
|
||||
return gfx::BufferUsageType::StaticDraw;
|
||||
case GL_DYNAMIC_DRAW:
|
||||
return gfx::BufferUsageType::DynamicDraw;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -361,8 +369,9 @@ gfx::TexturePixelType Enum<gfx::TexturePixelType>::from(const platform::GLint va
|
||||
return gfx::TexturePixelType::Depth;
|
||||
case GL_LUMINANCE:
|
||||
return gfx::TexturePixelType::Luminance;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -422,8 +431,9 @@ gfx::TextureChannelDataType Enum<gfx::TextureChannelDataType>::from(const platfo
|
||||
return gfx::TextureChannelDataType::HalfFloat;
|
||||
case GL_FLOAT:
|
||||
return gfx::TextureChannelDataType::Float;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -448,8 +458,9 @@ gfx::RenderbufferPixelType Enum<gfx::RenderbufferPixelType>::from(const platform
|
||||
return gfx::RenderbufferPixelType::Depth;
|
||||
case GL_DEPTH24_STENCIL8:
|
||||
return gfx::RenderbufferPixelType::DepthStencil;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -54,12 +54,12 @@ std::unique_ptr<TimestampQueryLoader> &singleton() {
|
||||
|
||||
void glGenQueries(GLsizei n, GLuint *ids) {
|
||||
assert(singleton() && singleton()->glGenQueries);
|
||||
return singleton()->glGenQueries(n, ids);
|
||||
singleton()->glGenQueries(n, ids);
|
||||
}
|
||||
|
||||
void glDeleteQueries(GLsizei n, const GLuint *ids) {
|
||||
assert(singleton() && singleton()->glDeleteQueries);
|
||||
return singleton()->glDeleteQueries(n, ids);
|
||||
singleton()->glDeleteQueries(n, ids);
|
||||
}
|
||||
|
||||
GLboolean glIsQuery(GLuint id) {
|
||||
@@ -69,47 +69,47 @@ GLboolean glIsQuery(GLuint id) {
|
||||
|
||||
void glBeginQuery(GLenum target, GLuint id) {
|
||||
assert(singleton() && singleton()->glBeginQuery);
|
||||
return singleton()->glBeginQuery(target, id);
|
||||
singleton()->glBeginQuery(target, id);
|
||||
}
|
||||
|
||||
void glEndQuery(GLenum target) {
|
||||
assert(singleton() && singleton()->glEndQuery);
|
||||
return singleton()->glEndQuery(target);
|
||||
singleton()->glEndQuery(target);
|
||||
}
|
||||
|
||||
void glQueryCounter(GLuint id, GLenum target) {
|
||||
assert(singleton() && singleton()->glQueryCounter);
|
||||
return singleton()->glQueryCounter(id, target);
|
||||
singleton()->glQueryCounter(id, target);
|
||||
}
|
||||
|
||||
void glGetQueryiv(GLenum target, GLenum pname, GLint *params) {
|
||||
assert(singleton() && singleton()->glGetQueryiv);
|
||||
return singleton()->glGetQueryiv(target, pname, params);
|
||||
singleton()->glGetQueryiv(target, pname, params);
|
||||
}
|
||||
|
||||
void glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params) {
|
||||
assert(singleton() && singleton()->glGetQueryObjectiv);
|
||||
return singleton()->glGetQueryObjectiv(id, pname, params);
|
||||
singleton()->glGetQueryObjectiv(id, pname, params);
|
||||
}
|
||||
|
||||
void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params) {
|
||||
assert(singleton() && singleton()->glGetQueryObjectuiv);
|
||||
return singleton()->glGetQueryObjectuiv(id, pname, params);
|
||||
singleton()->glGetQueryObjectuiv(id, pname, params);
|
||||
}
|
||||
|
||||
void glGetQueryObjecti64v(GLuint id, GLenum pname, GLint64 *params) {
|
||||
assert(singleton() && singleton()->glGetQueryObjecti64v);
|
||||
return singleton()->glGetQueryObjecti64v(id, pname, params);
|
||||
singleton()->glGetQueryObjecti64v(id, pname, params);
|
||||
}
|
||||
|
||||
void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params) {
|
||||
assert(singleton() && singleton()->glGetQueryObjectui64v);
|
||||
return singleton()->glGetQueryObjectui64v(id, pname, params);
|
||||
singleton()->glGetQueryObjectui64v(id, pname, params);
|
||||
}
|
||||
|
||||
void glGetInteger64v(GLenum pname, GLint64 *data) {
|
||||
assert(singleton() && singleton()->glGetInteger64v);
|
||||
return singleton()->glGetInteger64v(pname, data);
|
||||
singleton()->glGetInteger64v(pname, data);
|
||||
}
|
||||
|
||||
void loadTimeStampQueryExtension(const GlContexsLoader &loadExtension) {
|
||||
|
||||
@@ -63,7 +63,7 @@ void bindUniform<std::array<double, 16>>(UniformLocation location, const std::ar
|
||||
|
||||
template <>
|
||||
void bindUniform<bool>(UniformLocation location, const bool& t) {
|
||||
return bindUniform(location, int32_t(t));
|
||||
bindUniform(location, int32_t(t));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
||||
@@ -117,15 +117,17 @@ const gfx::UniqueVertexBufferResource& UploadPass::getBuffer(const gfx::VertexVe
|
||||
return noBuffer;
|
||||
}
|
||||
|
||||
static std::size_t padSize(std::size_t size, std::size_t padding) {
|
||||
namespace {
|
||||
[[maybe_unused]] std::size_t padSize(std::size_t size, std::size_t padding) {
|
||||
return (padding - (size % padding)) % padding;
|
||||
}
|
||||
template <typename T>
|
||||
static std::size_t pad(std::vector<T>& vector, std::size_t size, T value) {
|
||||
std::size_t pad(std::vector<T>& vector, std::size_t size, T value) {
|
||||
const auto count = padSize(vector.size(), size);
|
||||
vector.insert(vector.end(), count, value);
|
||||
return count;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
|
||||
const std::size_t vertexCount,
|
||||
|
||||
@@ -14,7 +14,8 @@ void VertexArray::bind(Context& context, const gfx::IndexBuffer& indexBuffer, co
|
||||
// NOLINTNEXTLINE(bugprone-too-small-loop-variable)
|
||||
for (AttributeLocation location = 0; location < bindings.size(); ++location) {
|
||||
if (state->bindings.size() <= location) {
|
||||
state->bindings.emplace_back(context, std::move(AttributeLocation(location)));
|
||||
AttributeLocation loc = location;
|
||||
state->bindings.emplace_back(context, std::move(loc));
|
||||
}
|
||||
state->bindings[location] = bindings[location];
|
||||
}
|
||||
|
||||
@@ -72,9 +72,10 @@ int VertexAttributeGL::getStride(GLenum glType) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
// Copy the transformed type into the buffer, returning true if it works.
|
||||
template <typename T, typename R, typename Func /* R(T) */>
|
||||
static bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffer, Func func) {
|
||||
bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffer, Func func) {
|
||||
if (auto* p = std::get_if<T>(&element)) {
|
||||
*reinterpret_cast<R*>(buffer) = func(*p);
|
||||
return true;
|
||||
@@ -84,15 +85,16 @@ static bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffe
|
||||
|
||||
// Copy the value into the buffer with a simple cast, returning true if it works.
|
||||
template <typename T, typename R>
|
||||
static bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffer) {
|
||||
bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffer) {
|
||||
return get<T, R>(element, buffer, [](T x) -> R { return static_cast<R>(x); });
|
||||
}
|
||||
|
||||
// Copy a particular type from the variant into the specified buffer, returning true if it works.
|
||||
template <typename T>
|
||||
static bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffer) {
|
||||
bool get(const gfx::VertexAttribute::ElementType& element, uint8_t* buffer) {
|
||||
return get<T, T>(element, buffer, [](T x) -> T { return x; });
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename T, typename R>
|
||||
R cast(T x) {
|
||||
@@ -104,39 +106,39 @@ bool VertexAttributeGL::get(const gfx::VertexAttribute::ElementType& element, GL
|
||||
// TODO: do we need to handle unsigned inputs?
|
||||
switch (glType) {
|
||||
case GL_FLOAT:
|
||||
return gl::get<float>(element, buffer) || gl::get<float, std::int32_t>(element, buffer);
|
||||
return detail::get<float>(element, buffer) || detail::get<float, std::int32_t>(element, buffer);
|
||||
case GL_FLOAT_VEC2:
|
||||
return gl::get<float2>(element, buffer) ||
|
||||
gl::get<int2, float2>(element, buffer, [](int2 x) { return float2{(float)x[0], (float)x[1]}; });
|
||||
return detail::get<float2>(element, buffer) ||
|
||||
detail::get<int2, float2>(element, buffer, [](int2 x) { return float2{(float)x[0], (float)x[1]}; });
|
||||
case GL_FLOAT_VEC3:
|
||||
return gl::get<float3>(element, buffer);
|
||||
return detail::get<float3>(element, buffer);
|
||||
case GL_FLOAT_VEC4:
|
||||
case GL_FLOAT_MAT2:
|
||||
return gl::get<float4>(element, buffer) ||
|
||||
gl::get<int4, float4>(
|
||||
return detail::get<float4>(element, buffer) ||
|
||||
detail::get<int4, float4>(
|
||||
element,
|
||||
buffer,
|
||||
[](int4 x) { return float4{(float)x[0], (float)x[1], (float)x[2], (float)x[3]}; }) ||
|
||||
gl::get<ushort8, float4>(element, buffer, [](ushort8 x) {
|
||||
detail::get<ushort8, float4>(element, buffer, [](ushort8 x) {
|
||||
return float4{(float)x[0], (float)x[1], (float)x[2], (float)x[3]};
|
||||
});
|
||||
case GL_INT:
|
||||
return gl::get<std::int32_t>(element, buffer) || gl::get<float, std::int32_t>(element, buffer);
|
||||
return detail::get<std::int32_t>(element, buffer) || detail::get<float, std::int32_t>(element, buffer);
|
||||
case GL_UNSIGNED_INT:
|
||||
return gl::get<std::int32_t, std::uint32_t>(element, buffer) ||
|
||||
gl::get<float, std::uint32_t>(element, buffer);
|
||||
return detail::get<std::int32_t, std::uint32_t>(element, buffer) ||
|
||||
detail::get<float, std::uint32_t>(element, buffer);
|
||||
case GL_INT_VEC2:
|
||||
return gl::get<int2>(element, buffer) || gl::get<float2, int2>(element, buffer, [](float2 x) {
|
||||
return detail::get<int2>(element, buffer) || detail::get<float2, int2>(element, buffer, [](float2 x) {
|
||||
return int2{(std::int32_t)x[0], (std::int32_t)x[1]};
|
||||
});
|
||||
case GL_UNSIGNED_INT_VEC2:
|
||||
return false; // TODO
|
||||
case GL_INT_VEC3:
|
||||
return gl::get<int3>(element, buffer);
|
||||
return detail::get<int3>(element, buffer);
|
||||
case GL_UNSIGNED_INT_VEC3:
|
||||
return false; // TODO
|
||||
case GL_INT_VEC4:
|
||||
return gl::get<int4>(element, buffer);
|
||||
return detail::get<int4>(element, buffer);
|
||||
case GL_UNSIGNED_INT_VEC4:
|
||||
return false; // TODO
|
||||
default:
|
||||
|
||||
@@ -28,11 +28,13 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
|
||||
namespace {
|
||||
|
||||
template <class Property>
|
||||
bool has(const style::SymbolLayoutProperties::PossiblyEvaluated& layout) {
|
||||
return layout.get<Property>().match([](const typename Property::Type& t) { return !t.empty(); },
|
||||
[](const auto&) { return true; });
|
||||
}
|
||||
} // namespace
|
||||
|
||||
expression::Value sectionOptionsToValue(const SectionOptions& options) {
|
||||
std::unordered_map<std::string, expression::Value> result;
|
||||
@@ -108,7 +110,9 @@ GlyphIDType getCharGlyphIDType(char16_t ch,
|
||||
return GlyphIDType::FontPBF;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace mbgl
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
SymbolLayout::SymbolLayout(const BucketParameters& parameters,
|
||||
const std::vector<Immutable<style::LayerProperties>>& layers,
|
||||
|
||||
@@ -22,7 +22,8 @@ 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) {
|
||||
namespace {
|
||||
double _normalizeAngle(double angle, double anchorAngle) {
|
||||
if (std::isnan(angle) || std::isnan(anchorAngle)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -39,6 +40,7 @@ static double _normalizeAngle(double angle, double anchorAngle) {
|
||||
|
||||
return angle;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Transform::Transform(TransformObserver& observer_, ConstrainMode constrainMode, ViewportMode viewportMode)
|
||||
: observer(observer_),
|
||||
@@ -109,7 +111,8 @@ void Transform::easeTo(const CameraOptions& inputCamera, const AnimationOptions&
|
||||
Duration duration = animation.duration.value_or(Duration::zero());
|
||||
if (state.getLatLngBounds() == LatLngBounds() && !isGestureInProgress() && duration != Duration::zero()) {
|
||||
// reuse flyTo, without exaggerated animation, to achieve constant ground speed.
|
||||
return flyTo(camera, animation, true);
|
||||
flyTo(camera, animation, true);
|
||||
return;
|
||||
}
|
||||
|
||||
double zoom = camera.zoom.value_or(getZoom());
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/style/conversion_impl.hpp>
|
||||
#include <mbgl/renderer/bucket.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -126,7 +125,7 @@ void jsonStringFromConvertible(const style::conversion::Convertible& value, std:
|
||||
|
||||
} else if (auto s = v.value().getString()) {
|
||||
output.append("\"");
|
||||
output.append(s->c_str());
|
||||
output.append(*s);
|
||||
output.append("\"");
|
||||
|
||||
} else if (auto d = v.value().getDouble()) {
|
||||
|
||||
@@ -46,7 +46,7 @@ void PluginLayerProperty::setCurrentSingleFloatValue(float value) {
|
||||
}
|
||||
|
||||
PluginLayerProperty* PluginLayerPropertyManager::getProperty(const std::string& propertyName) {
|
||||
if (_properties.count(propertyName) > 0) {
|
||||
if (_properties.contains(propertyName)) {
|
||||
return _properties[propertyName];
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -10,12 +10,9 @@
|
||||
#include <mbgl/style/layers/custom_layer_render_parameters.hpp>
|
||||
#endif
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/context.hpp>
|
||||
#include <mbgl/gfx/renderer_backend.hpp>
|
||||
#include <mbgl/style/properties.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -32,10 +32,11 @@ bool CircleBucket::hasData() const {
|
||||
return !segments.empty();
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <class Property>
|
||||
static float get(const CirclePaintProperties::PossiblyEvaluated& evaluated,
|
||||
const std::string& id,
|
||||
const std::map<std::string, CircleBinders>& paintPropertyBinders) {
|
||||
float get(const CirclePaintProperties::PossiblyEvaluated& evaluated,
|
||||
const std::string& id,
|
||||
const std::map<std::string, CircleBinders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(id);
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
@@ -43,6 +44,7 @@ static float get(const CirclePaintProperties::PossiblyEvaluated& evaluated,
|
||||
return *it->second.statistics<Property>().max();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
float CircleBucket::getQueryRadius(const RenderLayer& layer) const {
|
||||
const auto& evaluated = getEvaluated<CircleLayerProperties>(layer.evaluatedProperties);
|
||||
|
||||
@@ -134,10 +134,11 @@ bool LineBucket::hasData() const {
|
||||
return !segments.empty();
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <class Property>
|
||||
static float get(const LinePaintProperties::PossiblyEvaluated& evaluated,
|
||||
const std::string& id,
|
||||
const std::map<std::string, LineBinders>& paintPropertyBinders) {
|
||||
float get(const LinePaintProperties::PossiblyEvaluated& evaluated,
|
||||
const std::string& id,
|
||||
const std::map<std::string, LineBinders>& paintPropertyBinders) {
|
||||
auto it = paintPropertyBinders.find(id);
|
||||
if (it == paintPropertyBinders.end() || !it->second.statistics<Property>().max()) {
|
||||
return evaluated.get<Property>().constantOr(Property::defaultValue());
|
||||
@@ -145,6 +146,7 @@ static float get(const LinePaintProperties::PossiblyEvaluated& evaluated,
|
||||
return *it->second.statistics<Property>().max();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
float LineBucket::getQueryRadius(const RenderLayer& layer) const {
|
||||
const auto& evaluated = getEvaluated<LineLayerProperties>(layer.evaluatedProperties);
|
||||
|
||||
@@ -459,8 +459,9 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
|
||||
|
||||
const auto& getCollisionTileLayerGroup = [&] {
|
||||
if (!collisionTileLayerGroup) {
|
||||
if ((collisionTileLayerGroup = context.createTileLayerGroup(
|
||||
layerIndex, /*initialCapacity=*/64, getID() + "-collision"))) {
|
||||
collisionTileLayerGroup = context.createTileLayerGroup(
|
||||
layerIndex, /*initialCapacity=*/64, getID() + "-collision");
|
||||
if (collisionTileLayerGroup) {
|
||||
activateLayerGroup(collisionTileLayerGroup, true, changes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ void RenderLayer::addRenderPassesFromTiles() {
|
||||
|
||||
const LayerRenderData* RenderLayer::getRenderDataForPass(const RenderTile& tile, RenderPass pass) const {
|
||||
if (const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl)) {
|
||||
return bool(RenderPass(renderData->layerProperties->renderPasses) & pass) ? renderData : nullptr;
|
||||
return (RenderPass(renderData->layerProperties->renderPasses) & pass) ? renderData : nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,9 @@ std::unique_ptr<RenderSource> RenderSource::create(const Immutable<Source::Impl>
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static RenderSourceObserver nullObserver;
|
||||
namespace {
|
||||
RenderSourceObserver nullObserver;
|
||||
}
|
||||
|
||||
RenderSource::RenderSource(Immutable<style::Source::Impl> impl)
|
||||
: baseImpl(std::move(impl)),
|
||||
|
||||
@@ -348,7 +348,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
for (auto& lg : {outlineLayerGroup, textLayerGroup}) {
|
||||
lg->removeDrawablesIf([&](gfx::Drawable& drawable) {
|
||||
return drawable.getName() == drawableName &&
|
||||
!(drawable.getTileID().has_value() && newTiles.count(*drawable.getTileID()) > 0);
|
||||
!(drawable.getTileID().has_value() && newTiles.contains(*drawable.getTileID()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ void TileSourceRenderItem::updateDebugDrawables(DebugLayerGroupMap& debugLayerGr
|
||||
// erase drawables that are not in the current tile set
|
||||
tileLayerGroup->removeDrawablesIf([&](gfx::Drawable& drawable) {
|
||||
return drawable.getName() == drawableName &&
|
||||
!(drawable.getTileID().has_value() && newTiles.count(*drawable.getTileID()) > 0);
|
||||
!(drawable.getTileID().has_value() && newTiles.contains(*drawable.getTileID()));
|
||||
});
|
||||
|
||||
// add new drawables and update existing ones
|
||||
|
||||
@@ -22,8 +22,10 @@ namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
static TileObserver nullObserver;
|
||||
static const std::map<OverscaledTileID, std::unique_ptr<Tile>> emptyPrefetchedTiles;
|
||||
namespace {
|
||||
TileObserver nullObserver;
|
||||
const std::map<OverscaledTileID, std::unique_ptr<Tile>> emptyPrefetchedTiles;
|
||||
} // namespace
|
||||
|
||||
TilePyramid::TilePyramid(const TaggedScheduler& threadPool_)
|
||||
: cache(threadPool_),
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static SpriteLoaderObserver nullObserver;
|
||||
namespace {
|
||||
SpriteLoaderObserver nullObserver;
|
||||
}
|
||||
|
||||
struct SpriteLoader::Data {
|
||||
std::shared_ptr<const std::string> image;
|
||||
@@ -50,7 +52,7 @@ void SpriteLoader::load(const std::optional<style::Sprite> sprite, FileSource& f
|
||||
std::lock_guard<std::mutex> lock(dataMapMutex);
|
||||
Data* data = dataMap[sprite->id].get();
|
||||
if (res.error) {
|
||||
observer->onSpriteError(*sprite, std::make_exception_ptr(std::runtime_error(res.error->message)));
|
||||
observer->onSpriteError(sprite, std::make_exception_ptr(std::runtime_error(res.error->message)));
|
||||
} else if (res.notModified) {
|
||||
return;
|
||||
} else if (res.noContent) {
|
||||
@@ -69,7 +71,7 @@ void SpriteLoader::load(const std::optional<style::Sprite> sprite, FileSource& f
|
||||
std::lock_guard<std::mutex> lock(dataMapMutex);
|
||||
Data* data = dataMap[sprite->id].get();
|
||||
if (res.error) {
|
||||
observer->onSpriteError(*sprite, std::make_exception_ptr(std::runtime_error(res.error->message)));
|
||||
observer->onSpriteError(sprite, std::make_exception_ptr(std::runtime_error(res.error->message)));
|
||||
} else if (res.notModified) {
|
||||
return;
|
||||
} else if (res.noContent) {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static std::string getQuadKey(int32_t x, int32_t y, int8_t z) {
|
||||
namespace {
|
||||
std::string getQuadKey(int32_t x, int32_t y, int8_t z) {
|
||||
std::string quadKey;
|
||||
quadKey.reserve(z);
|
||||
int32_t mask;
|
||||
@@ -20,7 +21,7 @@ static std::string getQuadKey(int32_t x, int32_t y, int8_t z) {
|
||||
return quadKey;
|
||||
}
|
||||
|
||||
static mapbox::geometry::point<double> getMercCoord(int32_t x, int32_t y, int8_t z) {
|
||||
mapbox::geometry::point<double> getMercCoord(int32_t x, int32_t y, int8_t z) {
|
||||
double resolution = (util::M2PI * util::EARTH_RADIUS_M / 256) / std::pow(2, z);
|
||||
return {
|
||||
x * resolution - util::M2PI * util::EARTH_RADIUS_M / 2,
|
||||
@@ -28,7 +29,7 @@ static mapbox::geometry::point<double> getMercCoord(int32_t x, int32_t y, int8_t
|
||||
};
|
||||
}
|
||||
|
||||
static std::string getTileBBox(int32_t x, int32_t y, int8_t z) {
|
||||
std::string getTileBBox(int32_t x, int32_t y, int8_t z) {
|
||||
// Alter the y for the Google/OSM tile scheme.
|
||||
y = static_cast<int32_t>(std::pow(2, z)) - y - 1;
|
||||
|
||||
@@ -38,6 +39,7 @@ static std::string getTileBBox(int32_t x, int32_t y, int8_t z) {
|
||||
return (util::toString(min.x) + "," + util::toString(min.y) + "," + util::toString(max.x) + "," +
|
||||
util::toString(max.y));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Resource Resource::style(const std::string& url) {
|
||||
return Resource{Resource::Kind::Style, url};
|
||||
|
||||
@@ -11,7 +11,7 @@ std::optional<bool> Converter<bool>::operator()(const Convertible& value, Error&
|
||||
error.message = "value must be a boolean";
|
||||
return std::nullopt;
|
||||
}
|
||||
return *converted;
|
||||
return converted;
|
||||
}
|
||||
|
||||
std::optional<float> Converter<float>::operator()(const Convertible& value, Error& error) const {
|
||||
@@ -20,7 +20,7 @@ std::optional<float> Converter<float>::operator()(const Convertible& value, Erro
|
||||
error.message = "value must be a number";
|
||||
return std::nullopt;
|
||||
}
|
||||
return *converted;
|
||||
return converted;
|
||||
}
|
||||
|
||||
std::optional<std::string> Converter<std::string>::operator()(const Convertible& value, Error& error) const {
|
||||
@@ -29,7 +29,7 @@ std::optional<std::string> Converter<std::string>::operator()(const Convertible&
|
||||
error.message = "value must be a string";
|
||||
return std::nullopt;
|
||||
}
|
||||
return *converted;
|
||||
return converted;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -47,7 +47,7 @@ std::optional<T> Converter<T, typename std::enable_if_t<std::is_enum_v<T>>>::ope
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *result;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -111,7 +111,7 @@ std::optional<Color> Converter<Color>::operator()(const Convertible& value, Erro
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *color;
|
||||
return color;
|
||||
}
|
||||
|
||||
std::optional<Padding> Converter<Padding>::operator()(const Convertible& value, Error& error) const {
|
||||
|
||||
@@ -14,7 +14,9 @@ namespace conversion {
|
||||
|
||||
using namespace mbgl::style::expression;
|
||||
|
||||
static bool isExpression(const Convertible& filter);
|
||||
namespace {
|
||||
bool isExpression(const Convertible& filter);
|
||||
}
|
||||
ParseResult convertLegacyFilter(const Convertible& values, Error& error);
|
||||
std::optional<mbgl::Value> serializeLegacyFilter(const Convertible& values);
|
||||
|
||||
@@ -34,12 +36,13 @@ std::optional<Filter> Converter<Filter>::operator()(const Convertible& value, Er
|
||||
assert(error.message.size() > 0);
|
||||
return std::nullopt;
|
||||
}
|
||||
return Filter(std::optional<std::unique_ptr<Expression>>(std::move(*expression)), serializeLegacyFilter(value));
|
||||
return Filter(std::optional<std::unique_ptr<Expression>>(std::move(expression)), serializeLegacyFilter(value));
|
||||
}
|
||||
}
|
||||
|
||||
// This is a port from
|
||||
// https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/feature_filter/index.js
|
||||
namespace {
|
||||
bool isExpression(const Convertible& filter) {
|
||||
if (!isArray(filter) || arrayLength(filter) == 0) {
|
||||
return false;
|
||||
@@ -79,6 +82,7 @@ bool isExpression(const Convertible& filter) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ParseResult createExpression(const std::string& op,
|
||||
std::optional<std::vector<std::unique_ptr<Expression>>> args,
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace style {
|
||||
namespace conversion {
|
||||
|
||||
// A tile source can either specify a URL to TileJSON, or inline TileJSON.
|
||||
static std::optional<variant<std::string, Tileset>> convertURLOrTileset(const Convertible& value, Error& error) {
|
||||
namespace {
|
||||
std::optional<variant<std::string, Tileset>> convertURLOrTileset(const Convertible& value, Error& error) {
|
||||
auto urlVal = objectMember(value, "url");
|
||||
if (!urlVal) {
|
||||
std::optional<Tileset> tileset = convert<Tileset>(value, error);
|
||||
@@ -36,9 +37,9 @@ static std::optional<variant<std::string, Tileset>> convertURLOrTileset(const Co
|
||||
return {*url};
|
||||
}
|
||||
|
||||
static std::optional<std::unique_ptr<Source>> convertRasterSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<std::unique_ptr<Source>> convertRasterSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<variant<std::string, Tileset>> urlOrTileset = convertURLOrTileset(value, error);
|
||||
if (!urlOrTileset) {
|
||||
return std::nullopt;
|
||||
@@ -58,9 +59,9 @@ static std::optional<std::unique_ptr<Source>> convertRasterSource(const std::str
|
||||
return {std::make_unique<RasterSource>(id, std::move(*urlOrTileset), tileSize)};
|
||||
}
|
||||
|
||||
static std::optional<std::unique_ptr<Source>> convertRasterDEMSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<std::unique_ptr<Source>> convertRasterDEMSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<variant<std::string, Tileset>> urlOrTileset = convertURLOrTileset(value, error);
|
||||
if (!urlOrTileset) {
|
||||
return std::nullopt;
|
||||
@@ -87,9 +88,9 @@ static std::optional<std::unique_ptr<Source>> convertRasterDEMSource(const std::
|
||||
return {std::make_unique<RasterDEMSource>(id, std::move(*urlOrTileset), tileSize, options)};
|
||||
}
|
||||
|
||||
static std::optional<std::unique_ptr<Source>> convertVectorSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<std::unique_ptr<Source>> convertVectorSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<variant<std::string, Tileset>> urlOrTileset = convertURLOrTileset(value, error);
|
||||
if (!urlOrTileset) {
|
||||
return std::nullopt;
|
||||
@@ -115,9 +116,9 @@ static std::optional<std::unique_ptr<Source>> convertVectorSource(const std::str
|
||||
return {std::make_unique<VectorSource>(id, std::move(*urlOrTileset), std::move(maxzoom), std::move(minzoom))};
|
||||
}
|
||||
|
||||
static std::optional<std::unique_ptr<Source>> convertGeoJSONSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<std::unique_ptr<Source>> convertGeoJSONSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
auto dataValue = objectMember(value, "data");
|
||||
if (!dataValue) {
|
||||
error.message = "GeoJSON source must have a data value";
|
||||
@@ -147,9 +148,9 @@ static std::optional<std::unique_ptr<Source>> convertGeoJSONSource(const std::st
|
||||
return {std::move(result)};
|
||||
}
|
||||
|
||||
static std::optional<std::unique_ptr<Source>> convertImageSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
std::optional<std::unique_ptr<Source>> convertImageSource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
auto urlValue = objectMember(value, "url");
|
||||
if (!urlValue) {
|
||||
error.message = "Image source must have a url value";
|
||||
@@ -188,6 +189,7 @@ static std::optional<std::unique_ptr<Source>> convertImageSource(const std::stri
|
||||
|
||||
return {std::move(result)};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::optional<std::unique_ptr<Source>> Converter<std::unique_ptr<Source>>::operator()(const Convertible& value,
|
||||
Error& error,
|
||||
|
||||
@@ -25,8 +25,7 @@ std::optional<Sprite> Converter<Sprite>::operator()(const Convertible& value, Er
|
||||
}
|
||||
spriteURL = toString(*urlValue);
|
||||
|
||||
const Sprite sprite(*id, *spriteURL);
|
||||
return sprite;
|
||||
return Sprite(*id, *spriteURL);
|
||||
}
|
||||
|
||||
} // namespace conversion
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
namespace expression {
|
||||
|
||||
static bool isComparableType(const std::string& op, const type::Type& type) noexcept {
|
||||
namespace {
|
||||
bool isComparableType(const std::string& op, const type::Type& type) noexcept {
|
||||
if (op == "==" || op == "!=") {
|
||||
return type == type::String || type == type::Number || type == type::Boolean || type == type::Null ||
|
||||
type == type::Value;
|
||||
@@ -75,7 +75,7 @@ bool gteqCollate(const std::string& a, const std::string& b, const Collator& c)
|
||||
return c.compare(a, b) >= 0;
|
||||
}
|
||||
|
||||
static BasicComparison::CompareFunctionType getBasicCompareFunction(const std::string& op) noexcept {
|
||||
BasicComparison::CompareFunctionType getBasicCompareFunction(const std::string& op) noexcept {
|
||||
if (op == "==")
|
||||
return eq;
|
||||
else if (op == "!=")
|
||||
@@ -92,7 +92,7 @@ static BasicComparison::CompareFunctionType getBasicCompareFunction(const std::s
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static CollatorComparison::CompareFunctionType getCollatorComparisonFunction(const std::string& op) noexcept {
|
||||
CollatorComparison::CompareFunctionType getCollatorComparisonFunction(const std::string& op) noexcept {
|
||||
if (op == "==")
|
||||
return eqCollate;
|
||||
else if (op == "!=")
|
||||
@@ -108,6 +108,7 @@ static CollatorComparison::CompareFunctionType getCollatorComparisonFunction(con
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
BasicComparison::BasicComparison(std::string op_, std::unique_ptr<Expression> lhs_, std::unique_ptr<Expression> rhs_)
|
||||
: Expression(Kind::Comparison, type::Boolean, depsOf(lhs_) | depsOf(rhs_)),
|
||||
|
||||
@@ -237,6 +237,7 @@ std::unique_ptr<detail::SignatureBase> makeSignature(std::string name,
|
||||
}
|
||||
} // namespace
|
||||
} // namespace detail
|
||||
|
||||
namespace {
|
||||
Value featureIdAsExpressionValue(const EvaluationContext& params) {
|
||||
assert(params.feature);
|
||||
@@ -299,6 +300,8 @@ std::optional<std::string> featureIdAsString(const EvaluationContext& params) {
|
||||
return id.match([](std::string value) { return value; }, [](const auto&) { return std::optional<std::string>(); });
|
||||
};
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
const auto& eCompoundExpression() {
|
||||
static auto signature = detail::makeSignature("e", []() -> Result<double> { return std::numbers::e; });
|
||||
return signature;
|
||||
@@ -990,6 +993,8 @@ const auto& filterInCompoundExpression() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
using ParseCompoundFunction = const std::unique_ptr<detail::SignatureBase>& (*)();
|
||||
constexpr const auto compoundExpressionRegistry =
|
||||
mapbox::eternal::hash_map<mapbox::eternal::string, ParseCompoundFunction>({
|
||||
@@ -1069,11 +1074,15 @@ constexpr const auto compoundExpressionRegistry =
|
||||
{"filter-in", filterInCompoundExpression},
|
||||
});
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
using namespace mbgl::style::conversion;
|
||||
|
||||
using DefinitionIterator = decltype(compoundExpressionRegistry)::const_iterator;
|
||||
using Definitions = std::pair<DefinitionIterator, DefinitionIterator>;
|
||||
|
||||
namespace {
|
||||
|
||||
std::string expectedTypesError(const Definitions& definitions, const std::vector<std::unique_ptr<Expression>>& args) {
|
||||
std::vector<std::string> availableOverloads; // Only used if there are no overloads
|
||||
// with matching number of args
|
||||
|
||||
@@ -839,7 +839,7 @@ std::optional<GeoJSON> parseValue(const style::conversion::Convertible& value, s
|
||||
style::conversion::Error error;
|
||||
auto geojson = toGeoJSON(argument, error);
|
||||
if (geojson && error.message.empty()) {
|
||||
return *geojson;
|
||||
return geojson;
|
||||
}
|
||||
ctx.error(error.message);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ mbgl::Value Formatted::toObject() const {
|
||||
serializedSection.emplace("scale", NullValue());
|
||||
}
|
||||
if (section.fontStack) {
|
||||
std::string fontStackString;
|
||||
serializedSection.emplace("fontStack", fontStackToString(*section.fontStack));
|
||||
} else {
|
||||
serializedSection.emplace("fontStack", NullValue());
|
||||
|
||||
@@ -18,7 +18,7 @@ bool isFeatureConstant(const Expression& expression) {
|
||||
return false;
|
||||
} else if (name == "properties" || name == "geometry-type" || name == "id" || name == "feature-state") {
|
||||
return false;
|
||||
} else if (0u == name.rfind(filter, 0u)) {
|
||||
} else if (name.starts_with(filter)) {
|
||||
// Legacy filters begin with "filter-" and are never constant.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -196,12 +196,14 @@ std::optional<InputType> parseInputValue(const Convertible& input,
|
||||
return result;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T>
|
||||
static ParseResult create(type::Type outputType,
|
||||
std::unique_ptr<Expression> input,
|
||||
std::vector<std::pair<std::vector<InputType>, std::unique_ptr<Expression>>> branches,
|
||||
std::unique_ptr<Expression> otherwise,
|
||||
ParsingContext& ctx) {
|
||||
ParseResult create(type::Type outputType,
|
||||
std::unique_ptr<Expression> input,
|
||||
std::vector<std::pair<std::vector<InputType>, std::unique_ptr<Expression>>> branches,
|
||||
std::unique_ptr<Expression> otherwise,
|
||||
ParsingContext& ctx) {
|
||||
typename Match<T>::Branches typedBranches;
|
||||
|
||||
std::size_t index = 2;
|
||||
@@ -224,6 +226,8 @@ static ParseResult create(type::Type outputType,
|
||||
std::move(outputType), std::move(input), std::move(typedBranches), std::move(otherwise)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ParseResult parseMatch(const Convertible& value, ParsingContext& ctx) {
|
||||
assert(isArray(value));
|
||||
auto length = arrayLength(value);
|
||||
|
||||
@@ -27,7 +27,9 @@ static_assert(mbgl::underlying_type(Tile::Kind::Raster) == mbgl::underlying_type
|
||||
static_assert(mbgl::underlying_type(Tile::Kind::RasterDEM) == mbgl::underlying_type(LayerTypeInfo::TileKind::RasterDEM),
|
||||
"tile kind error");
|
||||
|
||||
static LayerObserver nullObserver;
|
||||
namespace {
|
||||
LayerObserver nullObserver;
|
||||
}
|
||||
|
||||
Layer::Layer(Immutable<Impl> impl)
|
||||
: baseImpl(std::move(impl)),
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
static LightObserver nullObserver;
|
||||
namespace {
|
||||
LightObserver nullObserver;
|
||||
}
|
||||
|
||||
Light::Light(Immutable<Light::Impl> impl_)
|
||||
: impl(std::move(impl_)),
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
static SourceObserver nullObserver;
|
||||
namespace {
|
||||
SourceObserver nullObserver;
|
||||
}
|
||||
|
||||
Source::Source(Immutable<Impl> impl)
|
||||
: baseImpl(std::move(impl)),
|
||||
|
||||
@@ -20,14 +20,16 @@ float getLineLength(const GeometryCoordinates& line) {
|
||||
return lineLength;
|
||||
}
|
||||
|
||||
static Anchors resample(const GeometryCoordinates& line,
|
||||
const float offset,
|
||||
const float spacing,
|
||||
const float angleWindowSize,
|
||||
const float maxAngle,
|
||||
const float labelLength,
|
||||
const bool continuedLine,
|
||||
const bool placeAtMiddle) {
|
||||
namespace {
|
||||
|
||||
Anchors resample(const GeometryCoordinates& line,
|
||||
const float offset,
|
||||
const float spacing,
|
||||
const float angleWindowSize,
|
||||
const float maxAngle,
|
||||
const float labelLength,
|
||||
const bool continuedLine,
|
||||
const bool placeAtMiddle) {
|
||||
const float halfLabelLength = labelLength / 2.0f;
|
||||
const float lineLength = getLineLength(line);
|
||||
|
||||
@@ -82,6 +84,8 @@ static Anchors resample(const GeometryCoordinates& line,
|
||||
return anchors;
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
Anchors getAnchors(const GeometryCoordinates& line,
|
||||
float spacing,
|
||||
const float maxAngle,
|
||||
|
||||
@@ -26,6 +26,8 @@ GlyphIDType genNewGlyphIDType() {
|
||||
static short glyphType = GlyphIDType::FontPBF;
|
||||
++glyphType;
|
||||
if (glyphType == GlyphIDType::FontPBF) ++glyphType;
|
||||
// Intentionally casting to extend the enum's value space for runtime-generated IDs.
|
||||
// NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
|
||||
return static_cast<GlyphIDType>(glyphType);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static GlyphManagerObserver nullObserver;
|
||||
namespace {
|
||||
GlyphManagerObserver nullObserver;
|
||||
}
|
||||
|
||||
GlyphManager::GlyphManager(std::unique_ptr<LocalGlyphRasterizer> localGlyphRasterizer_)
|
||||
: observer(&nullObserver),
|
||||
|
||||
@@ -38,7 +38,7 @@ HBShaper::~HBShaper() {
|
||||
void HBShaper::createComplexGlyphIDs(const std::u16string &text,
|
||||
std::vector<GlyphID> &glyphIDs,
|
||||
std::vector<HBShapeAdjust> &adjusts) {
|
||||
return impl->createComplexGlyphIDs(text, glyphIDs, adjusts);
|
||||
impl->createComplexGlyphIDs(text, glyphIDs, adjusts);
|
||||
}
|
||||
|
||||
Glyph HBShaper::rasterizeGlyph(const GlyphID &glyph) {
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static hb_language_t getDefaultLanguage() {
|
||||
namespace {
|
||||
hb_language_t getDefaultLanguage() {
|
||||
static hb_language_t language = hb_language_get_default();
|
||||
return language;
|
||||
}
|
||||
|
||||
static hb_script_t getUnicodeScript(hb_codepoint_t u) {
|
||||
hb_script_t getUnicodeScript(hb_codepoint_t u) {
|
||||
static hb_unicode_funcs_t *unicode_funcs;
|
||||
|
||||
unicode_funcs = hb_unicode_funcs_get_default();
|
||||
@@ -23,6 +24,8 @@ static hb_script_t getUnicodeScript(hb_codepoint_t u) {
|
||||
return hb_unicode_script(unicode_funcs, u);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
HBShaper::Impl::Impl(GlyphIDType type_, const std::string &fontFileData, const FreeTypeLibrary &lib)
|
||||
: type(type_),
|
||||
face(fontFileData.data(), fontFileData.size(), lib) {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
using namespace std::numbers;
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace {
|
||||
|
||||
double signedArea(const GeometryCoordinates& ring) {
|
||||
double sum = 0;
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
static TileObserver nullObserver;
|
||||
namespace {
|
||||
TileObserver nullObserver;
|
||||
}
|
||||
|
||||
Tile::Tile(Kind kind_, OverscaledTileID id_, std::string sourceID_, TileObserver* observer_)
|
||||
: kind(kind_),
|
||||
|
||||
@@ -18,7 +18,7 @@ class ActionJournalEvent;
|
||||
class ActionJournal::Impl : public MapObserver {
|
||||
public:
|
||||
Impl(const Map& map, const ActionJournalOptions& options);
|
||||
~Impl();
|
||||
~Impl() override;
|
||||
|
||||
const Map& getMap() const { return map; }
|
||||
std::string getLogDirectory() const;
|
||||
|
||||
@@ -29,34 +29,35 @@ vec2 vec2Scale(const vec2& v, double s) noexcept {
|
||||
} // namespace
|
||||
|
||||
namespace util {
|
||||
namespace {
|
||||
|
||||
static double mercatorXfromLng(double lng) noexcept {
|
||||
double mercatorXfromLng(double lng) noexcept {
|
||||
return (180.0 + lng) / 360.0;
|
||||
}
|
||||
|
||||
static double mercatorYfromLat(double lat) noexcept {
|
||||
double mercatorYfromLat(double lat) noexcept {
|
||||
return (180.0 - (180.0 / pi * std::log(std::tan((pi / 4) + lat * pi / 360.0)))) / 360.0;
|
||||
}
|
||||
|
||||
static double latFromMercatorY(double y) noexcept {
|
||||
double latFromMercatorY(double y) noexcept {
|
||||
return util::rad2deg(2.0 * std::atan(std::exp(pi - y * util::M2PI)) - (pi / 2));
|
||||
}
|
||||
|
||||
static double lngFromMercatorX(double x) noexcept {
|
||||
double lngFromMercatorX(double x) noexcept {
|
||||
return x * 360.0 - 180.0;
|
||||
}
|
||||
|
||||
static double* getColumn(mat4& matrix, int col) noexcept {
|
||||
double* getColumn(mat4& matrix, int col) noexcept {
|
||||
assert(col >= 0 && col < 4);
|
||||
return &matrix[col * 4];
|
||||
}
|
||||
|
||||
static const double* getColumn(const mat4& matrix, int col) noexcept {
|
||||
const double* getColumn(const mat4& matrix, int col) noexcept {
|
||||
assert(col >= 0 && col < 4);
|
||||
return &matrix[col * 4];
|
||||
}
|
||||
|
||||
static vec3 toMercator(const LatLng& location, double altitudeMeters) noexcept {
|
||||
vec3 toMercator(const LatLng& location, double altitudeMeters) noexcept {
|
||||
const double pixelsPerMeter = 1.0 / Projection::getMetersPerPixelAtLatitude(location.latitude(), 0.0);
|
||||
const double worldSize = Projection::worldSize(std::pow(2.0, 0.0));
|
||||
|
||||
@@ -65,7 +66,7 @@ static vec3 toMercator(const LatLng& location, double altitudeMeters) noexcept {
|
||||
altitudeMeters * pixelsPerMeter / worldSize}};
|
||||
}
|
||||
|
||||
static Quaternion orientationFromPitchBearing(double pitch, double bearing) noexcept {
|
||||
Quaternion orientationFromPitchBearing(double pitch, double bearing) noexcept {
|
||||
// Both angles have to be negated to achieve CW rotation around the axis of rotation
|
||||
const Quaternion rotBearing = Quaternion::fromAxisAngle({{0.0, 0.0, 1.0}}, -bearing);
|
||||
const Quaternion rotPitch = Quaternion::fromAxisAngle({{1.0, 0.0, 0.0}}, -pitch);
|
||||
@@ -73,7 +74,7 @@ static Quaternion orientationFromPitchBearing(double pitch, double bearing) noex
|
||||
return rotBearing.multiply(rotPitch);
|
||||
}
|
||||
|
||||
static void updateTransform(mat4& transform, const Quaternion& orientation) noexcept {
|
||||
void updateTransform(mat4& transform, const Quaternion& orientation) noexcept {
|
||||
// Construct rotation matrix from orientation
|
||||
mat4 m = orientation.toRotationMatrix();
|
||||
|
||||
@@ -87,12 +88,14 @@ static void updateTransform(mat4& transform, const Quaternion& orientation) noex
|
||||
transform = m;
|
||||
}
|
||||
|
||||
static void updateTransform(mat4& transform, const vec3& position) {
|
||||
void updateTransform(mat4& transform, const vec3& position) {
|
||||
getColumn(transform, 3)[0] = position[0];
|
||||
getColumn(transform, 3)[1] = position[1];
|
||||
getColumn(transform, 3)[2] = position[2];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Camera::Camera() noexcept
|
||||
: orientation(Quaternion::identity) {
|
||||
matrix::identity(transform);
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
static const char *week[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
static const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
namespace {
|
||||
const char* week[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
} // namespace
|
||||
|
||||
std::string rfc1123(Timestamp timestamp) {
|
||||
std::time_t time = std::chrono::system_clock::to_time_t(timestamp);
|
||||
@@ -67,7 +69,7 @@ std::string iso8601(std::chrono::time_point<std::chrono::system_clock, Milliseco
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Timestamp parseTimestamp(const char *timestamp) {
|
||||
Timestamp parseTimestamp(const char* timestamp) {
|
||||
return std::chrono::time_point_cast<Seconds>(std::chrono::system_clock::from_time_t(parse_date(timestamp)));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ std::optional<std::string> readFile(const std::string &filename,
|
||||
size_t size = static_cast<size_t>(dataRange->second - dataRange->first + 1);
|
||||
std::string data(size, '\0');
|
||||
file.seekg(static_cast<std::streampos>(dataRange->first));
|
||||
file.read(&data[0], static_cast<std::streamsize>(size));
|
||||
file.read(data.data(), static_cast<std::streamsize>(size));
|
||||
return data;
|
||||
} else {
|
||||
std::stringstream data;
|
||||
|
||||
@@ -33,9 +33,9 @@ public:
|
||||
} else {
|
||||
Log::record(severity, event, code, msg, {});
|
||||
}
|
||||
} catch (...) {
|
||||
// ignore exceptions during logging
|
||||
// What would we do, log them?
|
||||
} catch (...) { // NOLINT(bugprone-empty-catch)
|
||||
// ignore exceptions during logging
|
||||
// What would we do, log them?
|
||||
#if !defined(NDEBUG)
|
||||
[[maybe_unused]] auto ex = std::current_exception();
|
||||
assert(!"unhandled exception while logging");
|
||||
|
||||
@@ -155,9 +155,11 @@ std::string makeQueryString(const TileServerOptions& tileServerOptions, const st
|
||||
return queryString;
|
||||
}
|
||||
|
||||
static bool equals(const std::string& str, const URL::Segment& segment, std::string& ref) {
|
||||
namespace {
|
||||
bool equals(const std::string& str, const URL::Segment& segment, std::string& ref) {
|
||||
return str.compare(segment.first, segment.second, ref) == 0;
|
||||
}
|
||||
} // unnamed namespace
|
||||
|
||||
std::string normalizeSourceURL(const TileServerOptions& tileServerOptions,
|
||||
const std::string& str,
|
||||
|
||||
@@ -41,7 +41,9 @@ constexpr uint32_t layerDescriptorPoolSize = 3 * 256;
|
||||
constexpr uint32_t drawableUniformDescriptorPoolSize = 3 * 1024;
|
||||
constexpr uint32_t drawableImageDescriptorPoolSize = drawableUniformDescriptorPoolSize / 2;
|
||||
|
||||
static uint32_t glslangRefCount = 0;
|
||||
namespace {
|
||||
uint32_t glslangRefCount = 0;
|
||||
}
|
||||
|
||||
class RenderbufferResource : public gfx::RenderbufferResource {
|
||||
public:
|
||||
@@ -568,7 +570,8 @@ bool Context::renderTileClippingMasks(gfx::RenderPass& renderPass,
|
||||
|
||||
auto& renderableResource = renderPassImpl.getDescriptor().renderable.getResource<SurfaceRenderableResource>();
|
||||
const float rad = renderableResource.getRotation();
|
||||
const mat4 rotationMat = {cos(rad), -sin(rad), 0, 0, sin(rad), cos(rad), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
|
||||
const mat4 rotationMat = {
|
||||
std::cos(rad), -std::sin(rad), 0, 0, std::sin(rad), std::cos(rad), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
|
||||
|
||||
for (const auto& tileInfo : tileUBOs) {
|
||||
commandBuffer->setStencilReference(vk::StencilFaceFlagBits::eFrontAndBack, tileInfo.stencil_ref, dispatcher);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <mbgl/util/monotonic_timer.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
#define USE_DESCRIPTOR_POOL_RESET
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ bool OffscreenTexture::isRenderable() {
|
||||
}
|
||||
|
||||
PremultipliedImage OffscreenTexture::readStillImage() {
|
||||
return getResource<OffscreenTextureResource>().readStillImage();
|
||||
return getResource<OffscreenTextureResource>().readStillImage(); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
|
||||
}
|
||||
|
||||
const gfx::Texture2DPtr& OffscreenTexture::getTexture() {
|
||||
|
||||
@@ -72,10 +72,12 @@ static struct {
|
||||
namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename T, typename F>
|
||||
static bool checkAvailability(const std::vector<T>& availableValues,
|
||||
const std::vector<const char*>& requiredValues,
|
||||
const F& getter) {
|
||||
bool checkAvailability(const std::vector<T>& availableValues,
|
||||
const std::vector<const char*>& requiredValues,
|
||||
const F& getter) {
|
||||
for (const auto& requiredValue : requiredValues) {
|
||||
bool found = false;
|
||||
for (const auto& availableValue : availableValues) {
|
||||
@@ -91,12 +93,14 @@ static bool checkAvailability(const std::vector<T>& availableValues,
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RendererBackend::RendererBackend(const gfx::ContextMode contextMode_)
|
||||
: gfx::RendererBackend(contextMode_),
|
||||
allocator(nullptr) {}
|
||||
|
||||
RendererBackend::~RendererBackend() {
|
||||
destroyResources();
|
||||
destroyResources(); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
|
||||
}
|
||||
|
||||
std::unique_ptr<gfx::Context> RendererBackend::createContext() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <mbgl/vulkan/command_encoder.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace mbgl {
|
||||
namespace vulkan {
|
||||
|
||||
@@ -19,7 +19,7 @@ UniformBuffer::UniformBuffer(BufferResource&& buffer_)
|
||||
|
||||
UniformBuffer::UniformBuffer(UniformBuffer&& other)
|
||||
: gfx::UniformBuffer(std::move(other)),
|
||||
buffer(std::move(other.buffer)) {}
|
||||
buffer(std::move(other.buffer)) {} // NOLINT(bugprone-use-after-move)
|
||||
|
||||
UniformBuffer::~UniformBuffer() {
|
||||
buffer.getContext().renderingStats().numUniformBuffers--;
|
||||
|
||||
Reference in New Issue
Block a user