[msvc] Fix compilation errors and warnings (#141)
This commit is contained in:
@@ -17,6 +17,11 @@
|
||||
// Note: LayerManager::annotationsEnabled is defined
|
||||
// at compile time, so that linker (with LTO on) is able
|
||||
// to optimize out the unreachable code.
|
||||
#define CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG() \
|
||||
if (!LayerManager::annotationsEnabled) { \
|
||||
assert(false); \
|
||||
return; \
|
||||
}
|
||||
#define CHECK_ANNOTATIONS_ENABLED_AND_RETURN(result) \
|
||||
if (!LayerManager::annotationsEnabled) { \
|
||||
assert(false); \
|
||||
@@ -38,12 +43,12 @@ AnnotationManager::AnnotationManager(Style& style_)
|
||||
AnnotationManager::~AnnotationManager() = default;
|
||||
|
||||
void AnnotationManager::setStyle(Style& style_) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
style = style_;
|
||||
}
|
||||
|
||||
void AnnotationManager::onStyleLoaded() {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
updateStyle();
|
||||
}
|
||||
|
||||
@@ -68,7 +73,7 @@ bool AnnotationManager::updateAnnotation(const AnnotationID& id, const Annotatio
|
||||
}
|
||||
|
||||
void AnnotationManager::removeAnnotation(const AnnotationID& id) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
remove(id);
|
||||
dirty = true;
|
||||
@@ -134,13 +139,13 @@ void AnnotationManager::update(const AnnotationID& id, const FillAnnotation& ann
|
||||
}
|
||||
|
||||
void AnnotationManager::remove(const AnnotationID& id) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
if (symbolAnnotations.find(id) != symbolAnnotations.end()) {
|
||||
symbolTree.remove(symbolAnnotations.at(id));
|
||||
symbolAnnotations.erase(id);
|
||||
} else if (shapeAnnotations.find(id) != shapeAnnotations.end()) {
|
||||
auto it = shapeAnnotations.find(id);
|
||||
*style.get().impl->removeLayer(it->second->layerID);
|
||||
(void)*style.get().impl->removeLayer(it->second->layerID);
|
||||
shapeAnnotations.erase(it);
|
||||
} else {
|
||||
assert(false); // Should never happen
|
||||
@@ -211,7 +216,7 @@ void AnnotationManager::updateStyle() {
|
||||
}
|
||||
|
||||
void AnnotationManager::updateData() {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
if (dirty) {
|
||||
for (auto& tile : tiles) {
|
||||
@@ -222,14 +227,14 @@ void AnnotationManager::updateData() {
|
||||
}
|
||||
|
||||
void AnnotationManager::addTile(AnnotationTile& tile) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
tiles.insert(&tile);
|
||||
tile.setData(getTileData(tile.id.canonical));
|
||||
}
|
||||
|
||||
void AnnotationManager::removeTile(AnnotationTile& tile) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
tiles.erase(&tile);
|
||||
}
|
||||
@@ -241,7 +246,7 @@ static std::string prefixedImageID(const std::string& id) {
|
||||
}
|
||||
|
||||
void AnnotationManager::addImage(std::unique_ptr<style::Image> image) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
const std::string id = prefixedImageID(image->getID());
|
||||
images.erase(id);
|
||||
@@ -251,7 +256,7 @@ void AnnotationManager::addImage(std::unique_ptr<style::Image> image) {
|
||||
}
|
||||
|
||||
void AnnotationManager::removeImage(const std::string& id_) {
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN();
|
||||
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
const std::string id = prefixedImageID(id_);
|
||||
images.erase(id);
|
||||
|
||||
@@ -90,9 +90,9 @@ int32_t DEMData::get(const int32_t x, const int32_t y) const {
|
||||
|
||||
const std::array<float, 4>& DEMData::getUnpackVector() const {
|
||||
// https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb
|
||||
static const std::array<float, 4> unpackMapbox = {{ 6553.6, 25.6, 0.1, 10000.0 }};
|
||||
static const std::array<float, 4> unpackMapbox = {{ 6553.6f, 25.6f, 0.1f, 10000.0f }};
|
||||
// https://aws.amazon.com/public-datasets/terrain/
|
||||
static const std::array<float, 4> unpackTerrarium = {{ 256.0, 1.0, 1.0 / 256.0, 32768.0 }};
|
||||
static const std::array<float, 4> unpackTerrarium = {{ 256.0f, 1.0f, 1.0f / 256.0f, 32768.0f }};
|
||||
|
||||
return encoding == Tileset::DEMEncoding::Terrarium ? unpackTerrarium : unpackMapbox;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
|
||||
virtual const RenderingStats& renderingStats() const = 0;
|
||||
|
||||
#if not defined(NDEBUG)
|
||||
#if !defined(NDEBUG)
|
||||
public:
|
||||
virtual void visualizeStencilBuffer() = 0;
|
||||
virtual void visualizeDepthBuffer(float depthRangeSize) = 0;
|
||||
|
||||
@@ -316,7 +316,7 @@ std::unique_ptr<uint8_t[]> Context::readFramebuffer(const Size size, const gfx::
|
||||
return data;
|
||||
}
|
||||
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
void Context::drawPixels(const Size size, const void* data, gfx::TexturePixelType format) {
|
||||
pixelStoreUnpack = { 1 };
|
||||
// TODO
|
||||
@@ -486,7 +486,7 @@ void Context::setDirtyState() {
|
||||
activeTextureUnit.setDirty();
|
||||
pixelStorePack.setDirty();
|
||||
pixelStoreUnpack.setDirty();
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
pointSize.setDirty();
|
||||
pixelZoom.setDirty();
|
||||
rasterPos.setDirty();
|
||||
@@ -610,7 +610,7 @@ void Context::draw(const gfx::DrawMode& drawMode,
|
||||
std::size_t indexLength) {
|
||||
switch (drawMode.type) {
|
||||
case gfx::DrawModeType::Points:
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
// In OpenGL ES 2, the point size is set in the vertex shader.
|
||||
pointSize = drawMode.size;
|
||||
#endif // MBGL_USE_GLES2
|
||||
@@ -725,7 +725,7 @@ void Context::reduceMemoryUsage() {
|
||||
MBGL_CHECK_ERROR(glFinish());
|
||||
}
|
||||
|
||||
#if not defined(NDEBUG)
|
||||
#if !defined(NDEBUG)
|
||||
void Context::visualizeStencilBuffer() {
|
||||
#if not MBGL_USE_GLES2
|
||||
setStencilMode(gfx::StencilMode::disabled());
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
return { size, readFramebuffer(size, format, flip) };
|
||||
}
|
||||
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
template <typename Image>
|
||||
void drawPixels(const Image& image) {
|
||||
auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha;
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
State<value::PixelStorePack> pixelStorePack;
|
||||
State<value::PixelStoreUnpack> pixelStoreUnpack;
|
||||
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
State<value::PixelZoom> pixelZoom;
|
||||
State<value::RasterPos> rasterPos;
|
||||
State<value::PixelTransferDepth> pixelTransferDepth;
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
State<value::CullFace> cullFace;
|
||||
State<value::CullFaceSide> cullFaceSide;
|
||||
State<value::CullFaceWinding> cullFaceWinding;
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
State<value::PointSize> pointSize;
|
||||
#endif // MBGL_USE_GLES2
|
||||
|
||||
@@ -198,7 +198,7 @@ private:
|
||||
|
||||
UniqueFramebuffer createFramebuffer();
|
||||
std::unique_ptr<uint8_t[]> readFramebuffer(Size, gfx::TexturePixelType, bool flip);
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
void drawPixels(Size size, const void* data, gfx::TexturePixelType);
|
||||
#endif // MBGL_USE_GLES2
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
// For testing
|
||||
bool disableVAOExtension = false;
|
||||
|
||||
#if not defined(NDEBUG)
|
||||
#if !defined(NDEBUG)
|
||||
public:
|
||||
void visualizeStencilBuffer() override;
|
||||
void visualizeDepthBuffer(float depthRangeSize) override;
|
||||
|
||||
@@ -286,7 +286,7 @@ platform::GLenum Enum<gfx::TextureChannelDataType>::to(const gfx::TextureChannel
|
||||
template <>
|
||||
gfx::RenderbufferPixelType Enum<gfx::RenderbufferPixelType>::from(const platform::GLint value) {
|
||||
switch (value) {
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
case GL_RGBA8: return gfx::RenderbufferPixelType::RGBA;
|
||||
case GL_DEPTH_COMPONENT: return gfx::RenderbufferPixelType::Depth;
|
||||
case GL_DEPTH24_STENCIL8: return gfx::RenderbufferPixelType::DepthStencil;
|
||||
@@ -302,7 +302,7 @@ gfx::RenderbufferPixelType Enum<gfx::RenderbufferPixelType>::from(const platform
|
||||
template <>
|
||||
platform::GLenum Enum<gfx::RenderbufferPixelType>::to(const gfx::RenderbufferPixelType value) {
|
||||
switch (value) {
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
case gfx::RenderbufferPixelType::RGBA: return GL_RGBA8;
|
||||
case gfx::RenderbufferPixelType::Depth: return GL_DEPTH_COMPONENT;
|
||||
case gfx::RenderbufferPixelType::DepthStencil: return GL_DEPTH24_STENCIL8;
|
||||
|
||||
@@ -60,7 +60,7 @@ bool OffscreenTexture::isRenderable() {
|
||||
try {
|
||||
getResource<OffscreenTextureResource>().bind();
|
||||
return true;
|
||||
} catch (const std::runtime_error& ex) {
|
||||
} catch (const std::runtime_error&) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ PixelStoreUnpack::Type PixelStoreUnpack::Get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
|
||||
const constexpr PointSize::Type PointSize::Default;
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ struct PixelStoreUnpack {
|
||||
static Type Get();
|
||||
};
|
||||
|
||||
#if not MBGL_USE_GLES2
|
||||
#if !MBGL_USE_GLES2
|
||||
|
||||
struct PointSize {
|
||||
using Type = float;
|
||||
|
||||
@@ -16,7 +16,7 @@ void VertexArray::bind(Context& context,
|
||||
// NOLINTNEXTLINE(bugprone-too-small-loop-variable)
|
||||
for (AttributeLocation location = 0; location < bindings.size(); ++location) {
|
||||
if (state->bindings.size() <= location) {
|
||||
state->bindings.emplace_back(context, AttributeLocation(location));
|
||||
state->bindings.emplace_back(context, std::move(AttributeLocation(location)));
|
||||
}
|
||||
state->bindings[location] = bindings[location];
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ private:
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t index = segment.vertexLength;
|
||||
auto index = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
// 1, 2, 3
|
||||
// 1, 4, 3
|
||||
|
||||
@@ -974,7 +974,7 @@ size_t SymbolLayout::addSymbol(SymbolBucket::Buffer& buffer,
|
||||
// coordinate in this polygon.
|
||||
auto& segment = buffer.segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t index = segment.vertexLength;
|
||||
auto index = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
// coordinates (2 triangles)
|
||||
buffer.vertices.emplace_back(SymbolSDFIconProgram::layoutVertex(labelAnchor.point,
|
||||
@@ -1092,7 +1092,7 @@ void SymbolLayout::addToDebugBuffers(SymbolBucket& bucket) {
|
||||
}
|
||||
|
||||
auto& segment = collisionBuffer.segments.back();
|
||||
uint16_t index = segment.vertexLength;
|
||||
auto index = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.anchor.point, tl));
|
||||
collisionBuffer.vertices.emplace_back(CollisionBoxProgram::layoutVertex(anchor, symbolInstance.anchor.point, tr));
|
||||
|
||||
@@ -169,10 +169,10 @@ namespace mbgl {
|
||||
// The label needs to be flipped to keep text upright.
|
||||
// Iterate in the reverse direction.
|
||||
dir *= -1;
|
||||
angle = M_PI;
|
||||
angle = static_cast<float>(M_PI);
|
||||
}
|
||||
|
||||
if (dir < 0) angle += M_PI;
|
||||
if (dir < 0) angle += static_cast<float>(M_PI);
|
||||
|
||||
int32_t currentIndex = dir > 0 ? anchorSegment : anchorSegment + 1;
|
||||
|
||||
@@ -248,10 +248,10 @@ namespace mbgl {
|
||||
const float firstGlyphOffset = symbol.glyphOffsets.front();
|
||||
const float lastGlyphOffset = symbol.glyphOffsets.back();;
|
||||
|
||||
optional<PlacedGlyph> firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance);
|
||||
optional<PlacedGlyph> firstPlacedGlyph = placeGlyphAlongLine(fontScale * firstGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, static_cast<uint16_t>(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance);
|
||||
if (!firstPlacedGlyph) return {};
|
||||
|
||||
optional<PlacedGlyph> lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, symbol.segment, symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance);
|
||||
optional<PlacedGlyph> lastPlacedGlyph = placeGlyphAlongLine(fontScale * lastGlyphOffset, lineOffsetX, lineOffsetY, flip, anchorPoint, tileAnchorPoint, static_cast<uint16_t>(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, returnTileDistance);
|
||||
if (!lastPlacedGlyph) return {};
|
||||
|
||||
return std::make_pair(*firstPlacedGlyph, *lastPlacedGlyph);
|
||||
@@ -316,7 +316,7 @@ namespace mbgl {
|
||||
for (size_t glyphIndex = 1; glyphIndex < symbol.glyphOffsets.size() - 1; glyphIndex++) {
|
||||
const float glyphOffsetX = symbol.glyphOffsets[glyphIndex];
|
||||
// Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed
|
||||
auto placedGlyph = placeGlyphAlongLine(glyphOffsetX * fontScale, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, symbol.segment, symbol.line, symbol.tileDistances, labelPlaneMatrix, false);
|
||||
auto placedGlyph = placeGlyphAlongLine(glyphOffsetX * fontScale, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, static_cast<uint16_t>(symbol.segment), symbol.line, symbol.tileDistances, labelPlaneMatrix, false);
|
||||
if (placedGlyph) {
|
||||
placedGlyphs.push_back(*placedGlyph);
|
||||
} else {
|
||||
@@ -344,7 +344,7 @@ namespace mbgl {
|
||||
}
|
||||
}
|
||||
const float glyphOffsetX = symbol.glyphOffsets.front();
|
||||
optional<PlacedGlyph> singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetX, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, symbol.segment,
|
||||
optional<PlacedGlyph> singleGlyph = placeGlyphAlongLine(fontScale * glyphOffsetX, lineOffsetX, lineOffsetY, flip, projectedAnchorPoint, symbol.anchorPoint, static_cast<uint16_t>(symbol.segment),
|
||||
symbol.line, symbol.tileDistances, labelPlaneMatrix, false);
|
||||
if (!singleGlyph)
|
||||
return PlacementResult::NotEnoughRoom;
|
||||
|
||||
@@ -698,7 +698,7 @@ TileCoordinate TransformState::screenCoordinateToTileCoordinate(const ScreenCoor
|
||||
|
||||
LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, LatLng::WrapMode wrapMode) const {
|
||||
auto coord = screenCoordinateToTileCoordinate(point, 0);
|
||||
return Projection::unproject(coord.p, 1 / util::tileSize, wrapMode);
|
||||
return Projection::unproject(coord.p, 1. / util::tileSize, wrapMode);
|
||||
}
|
||||
|
||||
mat4 TransformState::coordinatePointMatrix(const mat4& projMatrix) const {
|
||||
|
||||
@@ -40,8 +40,8 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
|
||||
vertices.emplace_back(FillProgram::layoutVertex(p));
|
||||
|
||||
if (prev) {
|
||||
indices.emplace_back(vertices.elements() - 2,
|
||||
vertices.elements() - 1);
|
||||
indices.emplace_back(static_cast<uint16_t>(vertices.elements() - 2),
|
||||
static_cast<uint16_t>(vertices.elements() - 1));
|
||||
}
|
||||
|
||||
prev = p;
|
||||
|
||||
@@ -75,14 +75,14 @@ void FillBucket::addFeature(const GeometryTileFeature& feature,
|
||||
|
||||
auto& lineSegment = lineSegments.back();
|
||||
assert(lineSegment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t lineIndex = lineSegment.vertexLength;
|
||||
const auto lineIndex = static_cast<uint16_t>(lineSegment.vertexLength);
|
||||
|
||||
vertices.emplace_back(FillProgram::layoutVertex(ring[0]));
|
||||
lines.emplace_back(lineIndex + nVertices - 1, lineIndex);
|
||||
lines.emplace_back(static_cast<uint16_t>(lineIndex + nVertices - 1), lineIndex);
|
||||
|
||||
for (std::size_t i = 1; i < nVertices; i++) {
|
||||
vertices.emplace_back(FillProgram::layoutVertex(ring[i]));
|
||||
lines.emplace_back(lineIndex + i - 1, lineIndex + i);
|
||||
lines.emplace_back(static_cast<uint16_t>(lineIndex + i - 1), static_cast<uint16_t>(lineIndex + i));
|
||||
}
|
||||
|
||||
lineSegment.vertexLength += nVertices;
|
||||
@@ -100,7 +100,7 @@ void FillBucket::addFeature(const GeometryTileFeature& feature,
|
||||
|
||||
auto& triangleSegment = triangleSegments.back();
|
||||
assert(triangleSegment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t triangleIndex = triangleSegment.vertexLength;
|
||||
const auto triangleIndex = static_cast<uint16_t>(triangleSegment.vertexLength);
|
||||
|
||||
for (std::size_t i = 0; i < nIndicies; i += 3) {
|
||||
triangles.emplace_back(triangleIndex + indices[i],
|
||||
|
||||
@@ -83,7 +83,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
|
||||
|
||||
auto& triangleSegment = triangleSegments.back();
|
||||
assert(triangleSegment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t triangleIndex = triangleSegment.vertexLength;
|
||||
auto triangleIndex = static_cast<uint16_t>(triangleSegment.vertexLength);
|
||||
|
||||
assert(triangleIndex + (5 * (totalVertices - 1) + 1) <=
|
||||
std::numeric_limits<uint16_t>::max());
|
||||
@@ -100,7 +100,7 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
|
||||
const auto& p1 = ring[i];
|
||||
|
||||
vertices.emplace_back(
|
||||
FillExtrusionProgram::layoutVertex(p1, 0, 0, 1, 1, edgeDistance));
|
||||
FillExtrusionProgram::layoutVertex(p1, 0, 0, 1, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
flatIndices.emplace_back(triangleIndex);
|
||||
triangleIndex++;
|
||||
|
||||
@@ -117,16 +117,16 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
|
||||
}
|
||||
|
||||
vertices.emplace_back(
|
||||
FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 0, edgeDistance));
|
||||
FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 0, static_cast<uint16_t>(edgeDistance)));
|
||||
vertices.emplace_back(
|
||||
FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 1, edgeDistance));
|
||||
FillExtrusionProgram::layoutVertex(p1, perp.x, perp.y, 0, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
|
||||
edgeDistance += dist;
|
||||
|
||||
vertices.emplace_back(
|
||||
FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 0, edgeDistance));
|
||||
FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 0, static_cast<uint16_t>(edgeDistance)));
|
||||
vertices.emplace_back(
|
||||
FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 1, edgeDistance));
|
||||
FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 1, static_cast<uint16_t>(edgeDistance)));
|
||||
|
||||
// ┌──────┐
|
||||
// │ 0 1 │ Counter-Clockwise winding order.
|
||||
|
||||
@@ -78,7 +78,7 @@ void HeatmapBucket::addFeature(const GeometryTileFeature& feature,
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t index = segment.vertexLength;
|
||||
const auto index = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
// 1, 2, 3
|
||||
// 1, 4, 3
|
||||
|
||||
@@ -100,7 +100,7 @@ void HillshadeBucket::setMask(TileMask&& mask_) {
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
const uint16_t offset = segment.vertexLength;
|
||||
const auto offset = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
// 0, 1, 2
|
||||
// 1, 2, 3
|
||||
|
||||
@@ -441,7 +441,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates,
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
uint16_t index = segment.vertexLength;
|
||||
const auto index = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
for (const auto& triangle : triangleStore) {
|
||||
triangles.emplace_back(index + triangle.a, index + triangle.b, index + triangle.c);
|
||||
|
||||
@@ -92,7 +92,7 @@ void RasterBucket::setMask(TileMask&& mask_) {
|
||||
|
||||
auto& segment = segments.back();
|
||||
assert(segment.vertexLength <= std::numeric_limits<uint16_t>::max());
|
||||
const uint16_t offset = segment.vertexLength;
|
||||
const auto offset = static_cast<uint16_t>(segment.vertexLength);
|
||||
|
||||
// 0, 1, 2
|
||||
// 1, 2, 3
|
||||
|
||||
@@ -209,8 +209,8 @@ bool SymbolBucket::hasTextCollisionCircleData() const {
|
||||
void addPlacedSymbol(gfx::IndexVector<gfx::Triangles>& triangles, const PlacedSymbol& placedSymbol) {
|
||||
auto endIndex = placedSymbol.vertexStartIndex + placedSymbol.glyphOffsets.size() * 4;
|
||||
for (auto vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {
|
||||
triangles.emplace_back(vertexIndex + 0, vertexIndex + 1, vertexIndex + 2);
|
||||
triangles.emplace_back(vertexIndex + 1, vertexIndex + 2, vertexIndex + 3);
|
||||
triangles.emplace_back(static_cast<uint16_t>(vertexIndex + 0), static_cast<uint16_t>(vertexIndex + 1), static_cast<uint16_t>(vertexIndex + 2));
|
||||
triangles.emplace_back(static_cast<uint16_t>(vertexIndex + 1), static_cast<uint16_t>(vertexIndex + 2), static_cast<uint16_t>(vertexIndex + 3));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ protected:
|
||||
|
||||
void updateRadius(const mbgl::LocationIndicatorRenderParameters& params) {
|
||||
const TransformState& s = *params.state;
|
||||
const unsigned long numVtxCircumference = circle.size() - 1;
|
||||
const auto numVtxCircumference = static_cast<unsigned long>(circle.size() - 1);
|
||||
const float bearingStep = 360.0f / float(numVtxCircumference - 1); // first and last points are the same
|
||||
const mapbox::cheap_ruler::point centerPoint(params.puckPosition.longitude(), params.puckPosition.latitude());
|
||||
Point<double> center = project(params.puckPosition, s);
|
||||
|
||||
@@ -52,7 +52,7 @@ bool RenderRasterLayer::hasCrossfade() const {
|
||||
|
||||
static float saturationFactor(float saturation) {
|
||||
if (saturation > 0) {
|
||||
return 1 - 1 / (1.001 - saturation);
|
||||
return 1.f - 1.f / (1.001f - saturation);
|
||||
} else {
|
||||
return -saturation;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ TransformParameters::TransformParameters(const TransformState& state_)
|
||||
// to a tenth of the far value, so as not to waste depth buffer precision on
|
||||
// very close empty space, for layer types (fill-extrusion) that use the
|
||||
// depth buffer to emulate real-world space.
|
||||
state.getProjMatrix(nearClippedProjMatrix, 0.1 * state.getCameraToCenterDistance());
|
||||
state.getProjMatrix(nearClippedProjMatrix, static_cast<uint16_t>(0.1 * state.getCameraToCenterDistance()));
|
||||
}
|
||||
|
||||
PaintParameters::PaintParameters(gfx::Context& context_,
|
||||
|
||||
@@ -322,7 +322,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
if (zoomFitsLayer) {
|
||||
sourceNeedsRendering = true;
|
||||
renderItemsEmplaceHint =
|
||||
layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, source, index);
|
||||
layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, source, static_cast<uint32_t>(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
// items.
|
||||
}
|
||||
}
|
||||
renderItemsEmplaceHint = layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, nullptr, index);
|
||||
renderItemsEmplaceHint = layerRenderItems.emplace_hint(renderItemsEmplaceHint, layer, nullptr, static_cast<uint32_t>(index));
|
||||
}
|
||||
}
|
||||
source->update(sourceImpl,
|
||||
|
||||
@@ -184,7 +184,7 @@ void Renderer::Impl::render(const RenderTree& renderTree) {
|
||||
}
|
||||
}
|
||||
|
||||
#if not defined(NDEBUG)
|
||||
#if !defined(NDEBUG)
|
||||
if (parameters.debugOptions & MapDebugOptions::StencilClip) {
|
||||
// Render tile clip boundaries, using stencil buffer to calculate fill color.
|
||||
parameters.context.visualizeStencilBuffer();
|
||||
|
||||
@@ -301,7 +301,7 @@ TransitionOptions LocationIndicatorLayer::getLocationTransition() const {
|
||||
}
|
||||
|
||||
PropertyValue<float> LocationIndicatorLayer::getDefaultPerspectiveCompensation() {
|
||||
return {0.85};
|
||||
return {0.85f};
|
||||
}
|
||||
|
||||
const PropertyValue<float>& LocationIndicatorLayer::getPerspectiveCompensation() const {
|
||||
|
||||
@@ -32,7 +32,7 @@ struct TopImage : LayoutProperty<expression::Image> {
|
||||
};
|
||||
|
||||
struct AccuracyRadius : PaintProperty<float> {
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct AccuracyRadiusBorderColor : PaintProperty<Color> {
|
||||
@@ -48,11 +48,11 @@ struct Bearing : PaintProperty<Rotation> {
|
||||
};
|
||||
|
||||
struct BearingImageSize : PaintProperty<float> {
|
||||
static float defaultValue() { return 1; }
|
||||
static float defaultValue() { return 1.f; }
|
||||
};
|
||||
|
||||
struct ImageTiltDisplacement : PaintProperty<float> {
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct Location : PaintProperty<std::array<double, 3>> {
|
||||
@@ -60,15 +60,15 @@ struct Location : PaintProperty<std::array<double, 3>> {
|
||||
};
|
||||
|
||||
struct PerspectiveCompensation : PaintProperty<float> {
|
||||
static float defaultValue() { return 0.85; }
|
||||
static float defaultValue() { return 0.85f; }
|
||||
};
|
||||
|
||||
struct ShadowImageSize : PaintProperty<float> {
|
||||
static float defaultValue() { return 1; }
|
||||
static float defaultValue() { return 1.f; }
|
||||
};
|
||||
|
||||
struct TopImageSize : PaintProperty<float> {
|
||||
static float defaultValue() { return 1; }
|
||||
static float defaultValue() { return 1.f; }
|
||||
};
|
||||
|
||||
class LocationIndicatorLayoutProperties : public Properties<
|
||||
|
||||
@@ -53,7 +53,7 @@ struct IconOptional : LayoutProperty<bool> {
|
||||
|
||||
struct IconPadding : LayoutProperty<float> {
|
||||
static constexpr const char *name() { return "icon-padding"; }
|
||||
static float defaultValue() { return 2; }
|
||||
static float defaultValue() { return 2.f; }
|
||||
};
|
||||
|
||||
struct IconPitchAlignment : LayoutProperty<AlignmentType> {
|
||||
@@ -63,7 +63,7 @@ struct IconPitchAlignment : LayoutProperty<AlignmentType> {
|
||||
|
||||
struct IconRotate : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "icon-rotate"; }
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct IconRotationAlignment : LayoutProperty<AlignmentType> {
|
||||
@@ -73,7 +73,7 @@ struct IconRotationAlignment : LayoutProperty<AlignmentType> {
|
||||
|
||||
struct IconSize : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "icon-size"; }
|
||||
static float defaultValue() { return 1; }
|
||||
static float defaultValue() { return 1.f; }
|
||||
};
|
||||
|
||||
struct IconTextFit : LayoutProperty<IconTextFitType> {
|
||||
@@ -83,7 +83,7 @@ struct IconTextFit : LayoutProperty<IconTextFitType> {
|
||||
|
||||
struct IconTextFitPadding : LayoutProperty<std::array<float, 4>> {
|
||||
static constexpr const char *name() { return "icon-text-fit-padding"; }
|
||||
static std::array<float, 4> defaultValue() { return {{0, 0, 0, 0}}; }
|
||||
static std::array<float, 4> defaultValue() { return {{0.f, 0.f, 0.f, 0.f}}; }
|
||||
};
|
||||
|
||||
struct SymbolAvoidEdges : LayoutProperty<bool> {
|
||||
@@ -98,12 +98,12 @@ struct SymbolPlacement : LayoutProperty<SymbolPlacementType> {
|
||||
|
||||
struct SymbolSortKey : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "symbol-sort-key"; }
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct SymbolSpacing : LayoutProperty<float> {
|
||||
static constexpr const char *name() { return "symbol-spacing"; }
|
||||
static float defaultValue() { return 250; }
|
||||
static float defaultValue() { return 250.f; }
|
||||
};
|
||||
|
||||
struct SymbolZOrder : LayoutProperty<SymbolZOrderType> {
|
||||
@@ -148,22 +148,22 @@ struct TextKeepUpright : LayoutProperty<bool> {
|
||||
|
||||
struct TextLetterSpacing : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-letter-spacing"; }
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct TextLineHeight : LayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-line-height"; }
|
||||
static float defaultValue() { return 1.2; }
|
||||
static float defaultValue() { return 1.2f; }
|
||||
};
|
||||
|
||||
struct TextMaxAngle : LayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-max-angle"; }
|
||||
static float defaultValue() { return 45; }
|
||||
static float defaultValue() { return 45.f; }
|
||||
};
|
||||
|
||||
struct TextMaxWidth : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-max-width"; }
|
||||
static float defaultValue() { return 10; }
|
||||
static float defaultValue() { return 10.f; }
|
||||
};
|
||||
|
||||
struct TextOffset : DataDrivenLayoutProperty<std::array<float, 2>> {
|
||||
@@ -178,7 +178,7 @@ struct TextOptional : LayoutProperty<bool> {
|
||||
|
||||
struct TextPadding : LayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-padding"; }
|
||||
static float defaultValue() { return 2; }
|
||||
static float defaultValue() { return 2.f; }
|
||||
};
|
||||
|
||||
struct TextPitchAlignment : LayoutProperty<AlignmentType> {
|
||||
@@ -188,12 +188,12 @@ struct TextPitchAlignment : LayoutProperty<AlignmentType> {
|
||||
|
||||
struct TextRadialOffset : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-radial-offset"; }
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct TextRotate : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-rotate"; }
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct TextRotationAlignment : LayoutProperty<AlignmentType> {
|
||||
@@ -203,7 +203,7 @@ struct TextRotationAlignment : LayoutProperty<AlignmentType> {
|
||||
|
||||
struct TextSize : DataDrivenLayoutProperty<float> {
|
||||
static constexpr const char *name() { return "text-size"; }
|
||||
static float defaultValue() { return 16; }
|
||||
static float defaultValue() { return 16.f; }
|
||||
};
|
||||
|
||||
struct TextTransform : DataDrivenLayoutProperty<TextTransformType> {
|
||||
@@ -226,7 +226,7 @@ struct IconColor : DataDrivenPaintProperty<Color, attributes::fill_color, unifor
|
||||
};
|
||||
|
||||
struct IconHaloBlur : DataDrivenPaintProperty<float, attributes::halo_blur, uniforms::halo_blur> {
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct IconHaloColor : DataDrivenPaintProperty<Color, attributes::halo_color, uniforms::halo_color> {
|
||||
@@ -234,15 +234,15 @@ struct IconHaloColor : DataDrivenPaintProperty<Color, attributes::halo_color, un
|
||||
};
|
||||
|
||||
struct IconHaloWidth : DataDrivenPaintProperty<float, attributes::halo_width, uniforms::halo_width> {
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct IconOpacity : DataDrivenPaintProperty<float, attributes::opacity, uniforms::opacity> {
|
||||
static float defaultValue() { return 1; }
|
||||
static float defaultValue() { return 1.f; }
|
||||
};
|
||||
|
||||
struct IconTranslate : PaintProperty<std::array<float, 2>> {
|
||||
static std::array<float, 2> defaultValue() { return {{0, 0}}; }
|
||||
static std::array<float, 2> defaultValue() { return {{0.f, 0.f}}; }
|
||||
};
|
||||
|
||||
struct IconTranslateAnchor : PaintProperty<TranslateAnchorType> {
|
||||
@@ -257,7 +257,7 @@ struct TextColor : DataDrivenPaintProperty<Color, attributes::fill_color, unifor
|
||||
};
|
||||
|
||||
struct TextHaloBlur : DataDrivenPaintProperty<float, attributes::halo_blur, uniforms::halo_blur> {
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct TextHaloColor : DataDrivenPaintProperty<Color, attributes::halo_color, uniforms::halo_color> {
|
||||
@@ -265,15 +265,15 @@ struct TextHaloColor : DataDrivenPaintProperty<Color, attributes::halo_color, un
|
||||
};
|
||||
|
||||
struct TextHaloWidth : DataDrivenPaintProperty<float, attributes::halo_width, uniforms::halo_width> {
|
||||
static float defaultValue() { return 0; }
|
||||
static float defaultValue() { return 0.f; }
|
||||
};
|
||||
|
||||
struct TextOpacity : DataDrivenPaintProperty<float, attributes::opacity, uniforms::opacity> {
|
||||
static float defaultValue() { return 1; }
|
||||
static float defaultValue() { return 1.f; }
|
||||
};
|
||||
|
||||
struct TextTranslate : PaintProperty<std::array<float, 2>> {
|
||||
static std::array<float, 2> defaultValue() { return {{0, 0}}; }
|
||||
static std::array<float, 2> defaultValue() { return {{0.f, 0.f}}; }
|
||||
};
|
||||
|
||||
struct TextTranslateAnchor : PaintProperty<TranslateAnchorType> {
|
||||
|
||||
@@ -32,7 +32,7 @@ struct LightAnchor : LightProperty<LightAnchorType> {
|
||||
|
||||
struct LightPosition : LightProperty<Position> {
|
||||
static Position defaultValue() {
|
||||
std::array<float, 3> default_ = { { 1.15, 210, 30 } };
|
||||
std::array<float, 3> default_ = { { 1.15f, 210.f, 30.f } };
|
||||
return Position{ { default_ } };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -276,11 +276,11 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText,
|
||||
// for when glyph is rotated and translated.
|
||||
|
||||
const Point<float> center{-halfAdvance, halfAdvance - Shaping::yOffset};
|
||||
const float verticalRotation = -M_PI_2;
|
||||
const float verticalRotation = static_cast<float>(-M_PI_2);
|
||||
|
||||
// xHalfWidhtOffsetcorrection is a difference between full-width and half-width
|
||||
// advance, should be 0 for full-width glyphs and will pull up half-width glyphs.
|
||||
const float xHalfWidhtOffsetcorrection = util::ONE_EM / 2 - halfAdvance;
|
||||
const float xHalfWidhtOffsetcorrection = util::ONE_EM / 2.f - halfAdvance;
|
||||
const float yImageOffsetCorrection = positionedGlyph.imageID ? xHalfWidhtOffsetcorrection : 0.0f;
|
||||
const Point<float> xOffsetCorrection{5.0f - Shaping::yOffset - xHalfWidhtOffsetcorrection,
|
||||
-yImageOffsetCorrection};
|
||||
|
||||
@@ -37,10 +37,10 @@ public:
|
||||
const double scale = std::pow(2.0, tileID.canonical.z);
|
||||
auto zoomed = TileCoordinate { point, 0 }.zoomTo(tileID.canonical.z);
|
||||
return {
|
||||
int16_t(util::clamp<int64_t>((zoomed.p.x - tileID.canonical.x - tileID.wrap * scale) * util::EXTENT,
|
||||
int16_t(util::clamp<int64_t>(static_cast<int64_t>(zoomed.p.x - tileID.canonical.x - tileID.wrap * scale) * util::EXTENT,
|
||||
std::numeric_limits<int16_t>::min(),
|
||||
std::numeric_limits<int16_t>::max())),
|
||||
int16_t(util::clamp<int64_t>((zoomed.p.y - tileID.canonical.y) * util::EXTENT,
|
||||
int16_t(util::clamp<int64_t>(static_cast<int64_t>(zoomed.p.y - tileID.canonical.y) * util::EXTENT,
|
||||
std::numeric_limits<int16_t>::min(),
|
||||
std::numeric_limits<int16_t>::max()))
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user