From b7823b27b6d300f84457e0e2cefbd7a7e650b746 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Fri, 21 Mar 2025 15:42:43 +0100 Subject: [PATCH] Apply clang-tidy fixes (mostly use designated initializers) (#3328) --- .clang-tidy | 5 +- include/mbgl/actor/established_actor.hpp | 22 +-- include/mbgl/gfx/shader_group.hpp | 12 +- include/mbgl/gfx/vertex_attribute.hpp | 3 +- include/mbgl/text/glyph.hpp | 5 +- include/mbgl/util/event.hpp | 2 +- include/mbgl/util/immutable.hpp | 2 +- include/mbgl/util/logging.hpp | 2 +- src/mbgl/gfx/color_mode.hpp | 16 +- src/mbgl/gfx/command_encoder.hpp | 1 + src/mbgl/gfx/cull_face_mode.hpp | 8 +- src/mbgl/gfx/depth_mode.hpp | 4 +- src/mbgl/gfx/drawable_atlases_tweaker.cpp | 11 +- src/mbgl/gfx/drawable_builder_impl.cpp | 58 +++--- src/mbgl/gfx/gpu_expression.cpp | 4 +- src/mbgl/gfx/stencil_mode.hpp | 7 +- src/mbgl/gfx/upload_pass.hpp | 1 + src/mbgl/layout/pattern_layout.hpp | 4 +- src/mbgl/programs/symbol_program.hpp | 17 +- .../layers/background_layer_tweaker.cpp | 51 ++--- .../renderer/layers/circle_layer_tweaker.cpp | 44 ++--- .../layers/collision_layer_tweaker.cpp | 6 +- .../layers/fill_extrusion_layer_tweaker.cpp | 60 +++--- .../renderer/layers/fill_layer_tweaker.cpp | 105 +++++------ .../renderer/layers/heatmap_layer_tweaker.cpp | 18 +- .../layers/heatmap_texture_layer_tweaker.cpp | 10 +- .../layers/hillshade_layer_tweaker.cpp | 11 +- .../hillshade_prepare_layer_tweaker.cpp | 8 +- .../renderer/layers/line_layer_tweaker.cpp | 175 +++++++++--------- .../location_indicator_layer_tweaker.cpp | 13 +- .../renderer/layers/raster_layer_tweaker.cpp | 24 +-- .../renderer/layers/symbol_layer_tweaker.cpp | 66 +++---- .../property_evaluation_parameters.hpp | 5 +- src/mbgl/renderer/render_target.cpp | 7 +- src/mbgl/renderer/tile_layer_group.cpp | 6 +- src/mbgl/style/layers/background_layer.cpp | 15 +- src/mbgl/style/layers/circle_layer.cpp | 15 +- .../style/layers/fill_extrusion_layer.cpp | 15 +- src/mbgl/style/layers/fill_layer.cpp | 15 +- src/mbgl/style/layers/heatmap_layer.cpp | 15 +- src/mbgl/style/layers/hillshade_layer.cpp | 15 +- src/mbgl/style/layers/layer.cpp.ejs | 18 +- src/mbgl/style/layers/line_layer.cpp | 15 +- .../style/layers/location_indicator_layer.cpp | 15 +- src/mbgl/style/layers/raster_layer.cpp | 15 +- src/mbgl/style/layers/symbol_layer.cpp | 18 +- src/mbgl/util/tile_coordinate.hpp | 6 +- 47 files changed, 505 insertions(+), 465 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1b2bae9a6..03f7c8e0a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -113,7 +113,10 @@ Checks: [ -performance-enum-size, -misc-include-cleaner, -readability-redundant-inline-specifier, - -readability-avoid-nested-conditional-operator + -readability-avoid-nested-conditional-operator, + -readability-math-missing-parentheses, + -readability-enum-initial-value, + -boost-use-ranges ] WarningsAsErrors: '*' HeaderFilterRegex: '.*' diff --git a/include/mbgl/actor/established_actor.hpp b/include/mbgl/actor/established_actor.hpp index 1e948e3b5..6eb0fd75e 100644 --- a/include/mbgl/actor/established_actor.hpp +++ b/include/mbgl/actor/established_actor.hpp @@ -38,11 +38,9 @@ public: } // Construct the Object from a parameter pack `args` (i.e. `Object(args...)`) - template || - std::is_constructible_v, Args...>>* = nullptr> + template EstablishedActor(const TaggedScheduler& scheduler, AspiringActor& parent_, Args&&... args) + requires(std::is_constructible_v || std::is_constructible_v, Args...>) : parent(parent_) { emplaceObject(std::forward(args)...); parent.mailbox->open(scheduler); @@ -71,18 +69,18 @@ public: private: // Enabled for Objects with a constructor taking ActorRef as the first parameter - template , Args...>>* = nullptr> - void emplaceObject(Args&&... args_) { + template + void emplaceObject(Args&&... args_) + requires(std::is_constructible_v, Args...>) + { new (&parent.objectStorage) Object(parent.self(), std::forward(args_)...); } // Enabled for plain Objects - template >* = nullptr> - void emplaceObject(Args&&... args_) { + template + void emplaceObject(Args&&... args_) + requires(std::is_constructible_v) + { new (&parent.objectStorage) Object(std::forward(args_)...); } diff --git a/include/mbgl/gfx/shader_group.hpp b/include/mbgl/gfx/shader_group.hpp index 6b99628f0..5b5843015 100644 --- a/include/mbgl/gfx/shader_group.hpp +++ b/include/mbgl/gfx/shader_group.hpp @@ -80,8 +80,10 @@ public: /// @tparam T Derived type, inheriting `gfx::Shader` /// @param shaderName The group name to look up /// @return T or nullptr if not found in the group - template , bool>* = nullptr> - std::shared_ptr get(const std::string& shaderName) noexcept { + template + std::shared_ptr get(const std::string& shaderName) noexcept + requires(is_shader_v) + { auto shader = getShader(shaderName); if (!shader || shader->typeName() != T::Name) { return nullptr; @@ -110,8 +112,10 @@ public: /// @param to Location to store the shader /// @param shaderName The group name to look up /// @return True if 'to' has a valid program object, false otherwise. - template , bool>* = nullptr> - bool populate(std::shared_ptr& to, const std::string& shaderName) noexcept { + template + bool populate(std::shared_ptr& to, const std::string& shaderName) noexcept + requires(is_shader_v) + { if (to) { return true; } diff --git a/include/mbgl/gfx/vertex_attribute.hpp b/include/mbgl/gfx/vertex_attribute.hpp index 4048c0de2..cef74f616 100644 --- a/include/mbgl/gfx/vertex_attribute.hpp +++ b/include/mbgl/gfx/vertex_attribute.hpp @@ -321,8 +321,7 @@ public: /// Indicates whether any values have changed bool isModifiedAfter(std::chrono::duration time) const { - return std::any_of( - attrs.begin(), attrs.end(), [&](const auto& attr) { return attr && attr->isModifiedAfter(time); }); + return std::ranges::any_of(attrs, [&](const auto& attr) { return attr && attr->isModifiedAfter(time); }); } /// Clear the collection diff --git a/include/mbgl/text/glyph.hpp b/include/mbgl/text/glyph.hpp index 36383c0a1..10cee1fba 100644 --- a/include/mbgl/text/glyph.hpp +++ b/include/mbgl/text/glyph.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -113,9 +114,7 @@ public: float right = 0; WritingModeType writingMode; explicit operator bool() const { - return std::any_of(positionedLines.begin(), positionedLines.end(), [](const auto& line) { - return !line.positionedGlyphs.empty(); - }); + return std::ranges::any_of(positionedLines, [](const auto& line) { return !line.positionedGlyphs.empty(); }); } // The y offset *should* be part of the font metadata. static constexpr int32_t yOffset = -17; diff --git a/include/mbgl/util/event.hpp b/include/mbgl/util/event.hpp index aa4359179..13c5f8980 100644 --- a/include/mbgl/util/event.hpp +++ b/include/mbgl/util/event.hpp @@ -53,6 +53,6 @@ constexpr Event disabledEvents[] = { Event(-1) // Avoid zero size array }; -constexpr EventPermutation disabledEventPermutations[] = {{EventSeverity::Debug, Event::Shader}}; +constexpr EventPermutation disabledEventPermutations[] = {{.severity = EventSeverity::Debug, .event = Event::Shader}}; } // namespace mbgl diff --git a/include/mbgl/util/immutable.hpp b/include/mbgl/util/immutable.hpp index 0543d61d8..6a2092723 100644 --- a/include/mbgl/util/immutable.hpp +++ b/include/mbgl/util/immutable.hpp @@ -84,7 +84,7 @@ public: Immutable(const Immutable&) = default; template - Immutable& operator=(Mutable&& s) noexcept { + Immutable& operator=([[maybe_unused]] Mutable&& s) noexcept { ptr = std::const_pointer_cast(std::move(s.ptr)); return *this; } diff --git a/include/mbgl/util/logging.hpp b/include/mbgl/util/logging.hpp index ab3e7a332..9eb7e09a7 100644 --- a/include/mbgl/util/logging.hpp +++ b/include/mbgl/util/logging.hpp @@ -67,7 +67,7 @@ public: template static void Record(EventSeverity severity, Event event, Args&&... args) noexcept { if (!includes(severity, disabledEventSeverities) && !includes(event, disabledEvents) && - !includes({severity, event}, disabledEventPermutations)) { + !includes({.severity = severity, .event = event}, disabledEventPermutations)) { record(severity, event, ::std::forward(args)...); } } diff --git a/src/mbgl/gfx/color_mode.hpp b/src/mbgl/gfx/color_mode.hpp index 29f282568..851af1f2a 100644 --- a/src/mbgl/gfx/color_mode.hpp +++ b/src/mbgl/gfx/color_mode.hpp @@ -48,16 +48,24 @@ public: Mask mask; - static ColorMode disabled() { return {Replace{}, {}, {false, false, false, false}}; } + static ColorMode disabled() { + return {.blendFunction = Replace{}, .blendColor = {}, .mask = {.r = false, .g = false, .b = false, .a = false}}; + } - static ColorMode unblended() { return {Replace{}, {}, {true, true, true, true}}; } + static ColorMode unblended() { + return {.blendFunction = Replace{}, .blendColor = {}, .mask = {.r = true, .g = true, .b = true, .a = true}}; + } static ColorMode alphaBlended() { - return {Add{ColorBlendFactorType::One, ColorBlendFactorType::OneMinusSrcAlpha}, {}, {true, true, true, true}}; + return {.blendFunction = Add{ColorBlendFactorType::One, ColorBlendFactorType::OneMinusSrcAlpha}, + .blendColor = {}, + .mask = {.r = true, .g = true, .b = true, .a = true}}; } static ColorMode additive() { - return {Add{ColorBlendFactorType::One, ColorBlendFactorType::One}, {}, {true, true, true, true}}; + return {.blendFunction = Add{ColorBlendFactorType::One, ColorBlendFactorType::One}, + .blendColor = {}, + .mask = {.r = true, .g = true, .b = true, .a = true}}; } std::size_t hash() const { diff --git a/src/mbgl/gfx/command_encoder.hpp b/src/mbgl/gfx/command_encoder.hpp index c632e4843..e6018907b 100644 --- a/src/mbgl/gfx/command_encoder.hpp +++ b/src/mbgl/gfx/command_encoder.hpp @@ -27,6 +27,7 @@ public: CommandEncoder& operator=(const CommandEncoder&) = delete; DebugGroup createDebugGroup(const char* name) { return {*this, name}; } + // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage) DebugGroup createDebugGroup(std::string_view name) { return createDebugGroup(name.data()); } virtual std::unique_ptr createUploadPass(const char* name, Renderable&) = 0; diff --git a/src/mbgl/gfx/cull_face_mode.hpp b/src/mbgl/gfx/cull_face_mode.hpp index f71a66225..214289cde 100644 --- a/src/mbgl/gfx/cull_face_mode.hpp +++ b/src/mbgl/gfx/cull_face_mode.hpp @@ -11,9 +11,13 @@ public: CullFaceSideType side; CullFaceWindingType winding; - static CullFaceMode disabled() { return {false, CullFaceSideType::Back, CullFaceWindingType::CounterClockwise}; } + static CullFaceMode disabled() { + return {.enabled = false, .side = CullFaceSideType::Back, .winding = CullFaceWindingType::CounterClockwise}; + } - static CullFaceMode backCCW() { return {true, CullFaceSideType::Back, CullFaceWindingType::CounterClockwise}; } + static CullFaceMode backCCW() { + return {.enabled = true, .side = CullFaceSideType::Back, .winding = CullFaceWindingType::CounterClockwise}; + } }; } // namespace gfx diff --git a/src/mbgl/gfx/depth_mode.hpp b/src/mbgl/gfx/depth_mode.hpp index d1ece4e06..95723f060 100644 --- a/src/mbgl/gfx/depth_mode.hpp +++ b/src/mbgl/gfx/depth_mode.hpp @@ -17,7 +17,9 @@ public: #if MLN_RENDER_BACKEND_OPENGL static DepthMode disabled() { return DepthMode{DepthFunctionType::Always, DepthMaskType::ReadOnly, {0.0, 1.0}}; } #else - static DepthMode disabled() { return DepthMode{DepthFunctionType::Always, DepthMaskType::ReadOnly}; } + static DepthMode disabled() { + return DepthMode{.func = DepthFunctionType::Always, .mask = DepthMaskType::ReadOnly}; + } #endif }; diff --git a/src/mbgl/gfx/drawable_atlases_tweaker.cpp b/src/mbgl/gfx/drawable_atlases_tweaker.cpp index 1c03101b3..96c9b7385 100644 --- a/src/mbgl/gfx/drawable_atlases_tweaker.cpp +++ b/src/mbgl/gfx/drawable_atlases_tweaker.cpp @@ -12,12 +12,13 @@ void DrawableAtlasesTweaker::setupTextures(gfx::Drawable& drawable, const bool l if (const auto& shader = drawable.getShader()) { if (glyphTextureId) { if (atlases) { - atlases->glyph->setSamplerConfiguration( - {TextureFilterType::Linear, TextureWrapType::Clamp, TextureWrapType::Clamp}); + atlases->glyph->setSamplerConfiguration({.filter = TextureFilterType::Linear, + .wrapU = TextureWrapType::Clamp, + .wrapV = TextureWrapType::Clamp}); atlases->icon->setSamplerConfiguration( - {linearFilterForIcons ? TextureFilterType::Linear : TextureFilterType::Nearest, - TextureWrapType::Clamp, - TextureWrapType::Clamp}); + {.filter = linearFilterForIcons ? TextureFilterType::Linear : TextureFilterType::Nearest, + .wrapU = TextureWrapType::Clamp, + .wrapV = TextureWrapType::Clamp}); } if (iconTextureId && shader->getSamplerLocation(*iconTextureId)) { assert(*glyphTextureId != *iconTextureId); diff --git a/src/mbgl/gfx/drawable_builder_impl.cpp b/src/mbgl/gfx/drawable_builder_impl.cpp index 523b00b82..781a0a857 100644 --- a/src/mbgl/gfx/drawable_builder_impl.cpp +++ b/src/mbgl/gfx/drawable_builder_impl.cpp @@ -27,25 +27,25 @@ DrawableBuilder::Impl::LineLayoutVertex DrawableBuilder::Impl::layoutVertex( */ static const int8_t extrudeScale = 63; return LineLayoutVertex{ - {{static_cast((p.x * 2) | (round ? 1 : 0)), static_cast((p.y * 2) | (up ? 1 : 0))}}, - {{// add 128 to store a byte in an unsigned byte - static_cast(::round(extrudeScale * e.x) + 128), - static_cast(::round(extrudeScale * e.y) + 128), + .a1 = {{static_cast((p.x * 2) | (round ? 1 : 0)), static_cast((p.y * 2) | (up ? 1 : 0))}}, + .a2 = {{// add 128 to store a byte in an unsigned byte + static_cast(::round(extrudeScale * e.x) + 128), + static_cast(::round(extrudeScale * e.y) + 128), - // Encode the -1/0/1 direction value into the first two bits of .z - // of a_data. Combine it with the lower 6 bits of `linesofar` - // (shifted by 2 bites to make room for the direction value). The - // upper 8 bits of `linesofar` are placed in the `w` component. - // `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that we - // can store longer distances while sacrificing precision. + // Encode the -1/0/1 direction value into the first two bits of .z + // of a_data. Combine it with the lower 6 bits of `linesofar` + // (shifted by 2 bites to make room for the direction value). The + // upper 8 bits of `linesofar` are placed in the `w` component. + // `linesofar` is scaled down by `LINE_DISTANCE_SCALE` so that we + // can store longer distances while sacrificing precision. - // Encode the -1/0/1 direction value into .zw coordinates of - // a_data, which is normally covered by linesofar, so we need to - // merge them. The z component's first bit, as well as the sign - // bit is reserved for the direction, so we need to shift the - // linesofar. - static_cast(((dir == 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofar & 0x3F) << 2)), - static_cast(linesofar >> 6)}}}; + // Encode the -1/0/1 direction value into .zw coordinates of + // a_data, which is normally covered by linesofar, so we need to + // merge them. The z component's first bit, as well as the sign + // bit is reserved for the direction, so we need to shift the + // linesofar. + static_cast(((dir == 0 ? 0 : (dir < 0 ? -1 : 1)) + 1) | ((linesofar & 0x3F) << 2)), + static_cast(linesofar >> 6)}}}; } void DrawableBuilder::Impl::addPolyline(gfx::DrawableBuilder& builder, @@ -169,20 +169,20 @@ void DrawableBuilder::Impl::setupForWideVectors(gfx::Context& context, gfx::Draw // vertices if (!wideVectorVertices) { constexpr shaders::VertexTriWideVecB kWideVectorVertices[]{ - {{0}, {0}, (0 << 16) + 0}, - {{0}, {0}, (1 << 16) + 0}, - {{0}, {0}, (2 << 16) + 0}, - {{0}, {0}, (3 << 16) + 0}, + {.screenPos = {0}, .color = {0}, .index = (0 << 16) + 0}, + {.screenPos = {0}, .color = {0}, .index = (1 << 16) + 0}, + {.screenPos = {0}, .color = {0}, .index = (2 << 16) + 0}, + {.screenPos = {0}, .color = {0}, .index = (3 << 16) + 0}, - {{0}, {0}, (4 << 16) + 1}, - {{0}, {0}, (5 << 16) + 1}, - {{0}, {0}, (6 << 16) + 1}, - {{0}, {0}, (7 << 16) + 1}, + {.screenPos = {0}, .color = {0}, .index = (4 << 16) + 1}, + {.screenPos = {0}, .color = {0}, .index = (5 << 16) + 1}, + {.screenPos = {0}, .color = {0}, .index = (6 << 16) + 1}, + {.screenPos = {0}, .color = {0}, .index = (7 << 16) + 1}, - {{0}, {0}, (8 << 16) + 2}, - {{0}, {0}, (9 << 16) + 2}, - {{0}, {0}, (10 << 16) + 2}, - {{0}, {0}, (11 << 16) + 2}, + {.screenPos = {0}, .color = {0}, .index = (8 << 16) + 2}, + {.screenPos = {0}, .color = {0}, .index = (9 << 16) + 2}, + {.screenPos = {0}, .color = {0}, .index = (10 << 16) + 2}, + {.screenPos = {0}, .color = {0}, .index = (11 << 16) + 2}, }; wideVectorVertices = std::make_shared>(); for (auto& v : kWideVectorVertices) { diff --git a/src/mbgl/gfx/gpu_expression.cpp b/src/mbgl/gfx/gpu_expression.cpp index ae64a8da2..b43afc1e4 100644 --- a/src/mbgl/gfx/gpu_expression.cpp +++ b/src/mbgl/gfx/gpu_expression.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace mbgl { namespace gfx { @@ -53,7 +55,7 @@ auto addStop(UniqueGPUExpression& expr, GPUOutputType outType, std::size_t& inde assert(value.is()); if (value.is()) { const auto& color = attributeValue(value.get()); - std::copy(color.begin(), color.end(), &expr->stops.colors[2 * index++]); + std::ranges::copy(color, &expr->stops.colors[2 * index++]); } else { // Evaluation error, cancel expr.reset(); diff --git a/src/mbgl/gfx/stencil_mode.hpp b/src/mbgl/gfx/stencil_mode.hpp index 92d2265e8..599f5e880 100644 --- a/src/mbgl/gfx/stencil_mode.hpp +++ b/src/mbgl/gfx/stencil_mode.hpp @@ -40,7 +40,12 @@ public: StencilOpType pass; static StencilMode disabled() { - return StencilMode{Always(), 0, 0, StencilOpType::Keep, StencilOpType::Keep, StencilOpType::Keep}; + return StencilMode{.test = Always(), + .ref = 0, + .mask = 0, + .fail = StencilOpType::Keep, + .depthFail = StencilOpType::Keep, + .pass = StencilOpType::Keep}; } }; diff --git a/src/mbgl/gfx/upload_pass.hpp b/src/mbgl/gfx/upload_pass.hpp index f70b432fe..f59fbc956 100644 --- a/src/mbgl/gfx/upload_pass.hpp +++ b/src/mbgl/gfx/upload_pass.hpp @@ -44,6 +44,7 @@ public: UploadPass& operator=(const UploadPass&) = delete; DebugGroup createDebugGroup(const char* name) { return {*this, name}; } + // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage) DebugGroup createDebugGroup(std::string_view name) { return createDebugGroup(name.data()); } #if MLN_DRAWABLE_RENDERER diff --git a/src/mbgl/layout/pattern_layout.hpp b/src/mbgl/layout/pattern_layout.hpp index df1565053..af28c1b92 100644 --- a/src/mbgl/layout/pattern_layout.hpp +++ b/src/mbgl/layout/pattern_layout.hpp @@ -69,6 +69,7 @@ struct PatternFeatureInserter { const auto& sortKeyProperty = properties.template get(); float sortKey = sortKeyProperty.evaluate(*feature, zoom, canonical, SortKeyPropertyType::defaultValue()); PatternFeature patternFeature{index, std::move(feature), std::move(patternDependencyMap), sortKey}; + // NOLINTNEXTLINE(modernize-use-ranges) C++26 const auto lowerBound = std::lower_bound(features.cbegin(), features.cend(), patternFeature); features.insert(lowerBound, std::move(patternFeature)); } @@ -99,7 +100,8 @@ public: const std::string& layerId = layerProperties->baseImpl->id; const auto& evaluated = style::getEvaluated(layerProperties); const auto& patternProperty = evaluated.template get(); - const auto constantPattern = patternProperty.constantOr(Faded{"", ""}); + const auto constantPattern = patternProperty.constantOr( + Faded{.from = "", .to = ""}); // determine if layer group has any layers that use *-pattern // property and add constant pattern dependencies. if (!patternProperty.isConstant()) { diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index 6ece031e9..4aadbbc1b 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -131,7 +131,11 @@ public: } const float unused = 0.0f; - return {isZoomConstant, true, unused, size, layoutSize}; + return {.isZoomConstant = isZoomConstant, + .isFeatureConstant = true, + .sizeT = unused, + .size = size, + .layoutSize = layoutSize}; } float layoutSize; @@ -154,7 +158,8 @@ public: ZoomEvaluatedSize evaluateForZoom(float) const noexcept override { const float unused = 0.0f; - return {true, false, unused, unused, unused}; + return { + .isZoomConstant = true, .isFeatureConstant = false, .sizeT = unused, .size = unused, .layoutSize = unused}; } style::PropertyExpression expression; @@ -181,7 +186,11 @@ public: expression.interpolationFactor(coveringZoomStops, currentZoom), 0.0f, 1.0f); const float unused = 0.0f; - return {false, false, sizeInterpolationT, unused, unused}; + return {.isZoomConstant = false, + .isFeatureConstant = false, + .sizeT = sizeInterpolationT, + .size = unused, + .layoutSize = unused}; } style::PropertyExpression expression; @@ -261,6 +270,7 @@ public: std::unique_ptr> program; + // NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility) SymbolProgram([[maybe_unused]] const ProgramParameters& programParameters) { switch (gfx::Backend::GetType()) { #if MLN_RENDER_BACKEND_OPENGL @@ -441,6 +451,7 @@ using SymbolSDFProgramUniforms = TypeList; template +// NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility) class SymbolSDFProgram : public SymbolProgram(imagePosA->tl()), - /* .pattern_br_a = */ util::cast(imagePosA->br()), - /* .pattern_tl_b = */ util::cast(imagePosB->tl()), - /* .pattern_br_b = */ util::cast(imagePosB->br()), - /* .pattern_size_a = */ imagePosA->displaySize(), - /* .pattern_size_b = */ imagePosB->displaySize(), - /* .scale_a = */ crossfade.fromScale, - /* .scale_b = */ crossfade.toScale, - /* .mix = */ crossfade.t, - /* .opacity = */ evaluated.get()}; + const BackgroundPatternPropsUBO propsUBO = {.pattern_tl_a = util::cast(imagePosA->tl()), + .pattern_br_a = util::cast(imagePosA->br()), + .pattern_tl_b = util::cast(imagePosB->tl()), + .pattern_br_b = util::cast(imagePosB->br()), + .pattern_size_a = imagePosA->displaySize(), + .pattern_size_b = imagePosB->displaySize(), + .scale_a = crossfade.fromScale, + .scale_b = crossfade.toScale, + .mix = crossfade.t, + .opacity = evaluated.get()}; layerUniforms.createOrUpdate(idBackgroundPropsUBO, &propsUBO, context); } else { - const BackgroundPropsUBO propsUBO = {/* .color = */ evaluated.get(), - /* .opacity = */ evaluated.get(), - /* .pad1 = */ 0, - /* .pad2 = */ 0, - /* .pad3 = */ 0}; + const BackgroundPropsUBO propsUBO = {.color = evaluated.get(), + .opacity = evaluated.get(), + .pad1 = 0, + .pad2 = 0, + .pad3 = 0}; layerUniforms.createOrUpdate(idBackgroundPropsUBO, &propsUBO, context); } @@ -98,8 +98,9 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintPara if (hasPattern) { if (const auto& tex = parameters.patternAtlas.texture()) { - tex->setSamplerConfiguration( - {gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); + tex->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear, + .wrapU = gfx::TextureWrapType::Clamp, + .wrapV = gfx::TextureWrapType::Clamp}); drawable.setTexture(tex, idBackgroundImageTexture); } @@ -115,13 +116,13 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintPara #else const BackgroundPatternDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .pixel_coord_upper = */ {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /* .pixel_coord_lower = */ {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, - /* .tile_units_to_pixels = */ (pixToTile != 0) ? 1.0f / pixToTile : 0.0f, - /* .pad1 = */ 0, - /* .pad2 = */ 0, - /* .pad3 = */ 0 + .matrix = util::cast(matrix), + .pixel_coord_upper = {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, + .pixel_coord_lower = {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, + .tile_units_to_pixels = (pixToTile != 0) ? 1.0f / pixToTile : 0.0f, + .pad1 = 0, + .pad2 = 0, + .pad3 = 0 }; #if !MLN_UBO_CONSOLIDATION drawableUniforms.createOrUpdate(idBackgroundDrawableUBO, &drawableUBO, context); @@ -133,7 +134,7 @@ void BackgroundLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintPara #else const BackgroundDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix) + util::cast(matrix) }; #if !MLN_UBO_CONSOLIDATION drawableUniforms.createOrUpdate(idBackgroundDrawableUBO, &drawableUBO, context); diff --git a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp index e8c674392..80d94fdf0 100644 --- a/src/mbgl/renderer/layers/circle_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/circle_layer_tweaker.cpp @@ -42,16 +42,16 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete // Updated only with evaluated properties if (!evaluatedPropsUniformBuffer || propertiesUpdated) { const CircleEvaluatedPropsUBO evaluatedPropsUBO = { - /* .color = */ constOrDefault(evaluated), - /* .stroke_color = */ constOrDefault(evaluated), - /* .radius = */ constOrDefault(evaluated), - /* .blur = */ constOrDefault(evaluated), - /* .opacity = */ constOrDefault(evaluated), - /* .stroke_width = */ constOrDefault(evaluated), - /* .stroke_opacity = */ constOrDefault(evaluated), - /* .scale_with_map = */ scaleWithMap, - /* .pitch_with_map = */ pitchWithMap, - /* .pad1 = */ 0}; + .color = constOrDefault(evaluated), + .stroke_color = constOrDefault(evaluated), + .radius = constOrDefault(evaluated), + .blur = constOrDefault(evaluated), + .opacity = constOrDefault(evaluated), + .stroke_width = constOrDefault(evaluated), + .stroke_opacity = constOrDefault(evaluated), + .scale_with_map = scaleWithMap, + .pitch_with_map = pitchWithMap, + .pad1 = 0}; context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &evaluatedPropsUBO); propertiesUpdated = false; } @@ -93,19 +93,19 @@ void CircleLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete const CircleDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .extrude_scale = */ extrudeScale, + .matrix = util::cast(matrix), + .extrude_scale = extrudeScale, - /* .color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .radius_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .blur_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .stroke_color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .stroke_width_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .stroke_opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0, - /* .pad2 = */ 0, - /* .pad3 = */ 0 + .color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .radius_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .blur_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .stroke_color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .stroke_width_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .stroke_opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0, + .pad2 = 0, + .pad3 = 0 }; #if MLN_UBO_CONSOLIDATION drawable.setUBOIndex(i++); diff --git a/src/mbgl/renderer/layers/collision_layer_tweaker.cpp b/src/mbgl/renderer/layers/collision_layer_tweaker.cpp index 76f653d1e..c853ce801 100644 --- a/src/mbgl/renderer/layers/collision_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/collision_layer_tweaker.cpp @@ -61,9 +61,9 @@ void CollisionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParam const CollisionDrawableUBO drawableUBO = {/* .matrix = */ util::cast(matrix)}; const CollisionTilePropsUBO tilePropsUBO = { - /* .extrude_scale = */ extrudeScale, - /* .overscale_factor = */ static_cast(drawable.getTileID()->overscaleFactor()), - /* .pad1 = */ 0}; + .extrude_scale = extrudeScale, + .overscale_factor = static_cast(drawable.getTileID()->overscaleFactor()), + .pad1 = 0}; auto& drawableUniforms = drawable.mutableUniformBuffers(); drawableUniforms.createOrUpdate(idCollisionDrawableUBO, &drawableUBO, context); diff --git a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp index becf5863d..d474e0c3a 100644 --- a/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp @@ -42,26 +42,26 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP // UBO depends on more than just evaluated properties, so we need to update every time, // but the resulting buffer can be shared across all the drawables from the layer. const FillExtrusionPropsUBO propsUBO = { - /* .color = */ constOrDefault(evaluated), - /* .light_color = */ FillExtrusionProgram::lightColor(parameters.evaluatedLight), - /* .pad1 = */ 0, - /* .light_position = */ FillExtrusionProgram::lightPosition(parameters.evaluatedLight, state), - /* .base = */ constOrDefault(evaluated), - /* .height = */ constOrDefault(evaluated), - /* .light_intensity = */ FillExtrusionProgram::lightIntensity(parameters.evaluatedLight), - /* .vertical_gradient = */ evaluated.get() ? 1.0f : 0.0f, - /* .opacity = */ evaluated.get(), - /* .fade = */ crossfade.t, - /* .from_scale = */ crossfade.fromScale, - /* .to_scale = */ crossfade.toScale, - /* .pad2 = */ 0}; + .color = constOrDefault(evaluated), + .light_color = FillExtrusionProgram::lightColor(parameters.evaluatedLight), + .pad1 = 0, + .light_position = FillExtrusionProgram::lightPosition(parameters.evaluatedLight, state), + .base = constOrDefault(evaluated), + .height = constOrDefault(evaluated), + .light_intensity = FillExtrusionProgram::lightIntensity(parameters.evaluatedLight), + .vertical_gradient = evaluated.get() ? 1.0f : 0.0f, + .opacity = evaluated.get(), + .fade = crossfade.t, + .from_scale = crossfade.fromScale, + .to_scale = crossfade.toScale, + .pad2 = 0}; auto& layerUniforms = layerGroup.mutableUniformBuffers(); layerUniforms.createOrUpdate(idFillExtrusionPropsUBO, &propsUBO, context); propertiesUpdated = false; const auto zoom = static_cast(parameters.state.getZoom()); - const auto defPattern = mbgl::Faded{"", ""}; + const auto defPattern = mbgl::Faded{.from = "", .to = ""}; const auto fillPatternValue = evaluated.get().constantOr(defPattern); #if MLN_UBO_CONSOLIDATION @@ -117,18 +117,18 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP #else const FillExtrusionDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .pixel_coord_upper = */ {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /* .pixel_coord_lower = */ {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, - /* .height_factor = */ heightFactor, - /* .tile_ratio = */ tileRatio, + .matrix = util::cast(matrix), + .pixel_coord_upper = {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, + .pixel_coord_lower = {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, + .height_factor = heightFactor, + .tile_ratio = tileRatio, - /* .base_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .height_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pattern_from_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pattern_to_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0 + .base_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .height_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pattern_from_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pattern_to_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0 }; #if MLN_UBO_CONSOLIDATION @@ -136,11 +136,11 @@ void FillExtrusionLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintP #else const FillExtrusionTilePropsUBO tilePropsUBO = { #endif - /* .pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, - /* .pattern_to = */ patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, - /* .texsize = */ {static_cast(textureSize.width), static_cast(textureSize.height)}, - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .pattern_from = patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, + .pattern_to = patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + .texsize = {static_cast(textureSize.width), static_cast(textureSize.height)}, + .pad1 = 0, + .pad2 = 0 }; #if MLN_UBO_CONSOLIDATION diff --git a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp index 398c9dc87..83979102c 100644 --- a/src/mbgl/renderer/layers/fill_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/fill_layer_tweaker.cpp @@ -39,12 +39,12 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters if (!evaluatedPropsUniformBuffer || propertiesUpdated) { const FillEvaluatedPropsUBO propsUBO = { - /* .color = */ evaluated.get().constantOr(FillColor::defaultValue()), - /* .outline_color = */ evaluated.get().constantOr(FillOutlineColor::defaultValue()), - /* .opacity = */ evaluated.get().constantOr(FillOpacity::defaultValue()), - /* .fade = */ crossfade.t, - /* .from_scale = */ crossfade.fromScale, - /* .to_scale = */ crossfade.toScale, + .color = evaluated.get().constantOr(FillColor::defaultValue()), + .outline_color = evaluated.get().constantOr(FillOutlineColor::defaultValue()), + .opacity = evaluated.get().constantOr(FillOpacity::defaultValue()), + .fade = crossfade.t, + .from_scale = crossfade.fromScale, + .to_scale = crossfade.toScale, }; context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &propsUBO); propertiesUpdated = false; @@ -77,7 +77,8 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters return; } - const auto& fillPatternValue = evaluated.get().constantOr(Faded{"", ""}); + const auto& fillPatternValue = evaluated.get().constantOr( + Faded{.from = "", .to = ""}); const auto patternPosA = tile->getPattern(fillPatternValue.from.id()); const auto patternPosB = tile->getPattern(fillPatternValue.to.id()); binders->setPatternParameters(patternPosA, patternPosB, crossfade); @@ -111,12 +112,12 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), + .matrix = util::cast(matrix), - /* .color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0, + .pad2 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -130,12 +131,12 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillOutlineDrawableUBO drawableUBO = { #endif - /* .matrix=*/util::cast(matrix), + .matrix = util::cast(matrix), - /* .outline_color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .outline_color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0, + .pad2 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -149,15 +150,15 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillPatternDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .pixel_coord_upper = */ {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /* .pixel_coord_lower = */ - {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, - /* .tile_ratio = */ tileRatio, + .matrix = util::cast(matrix), + .pixel_coord_upper = {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /* .pattern_from_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pattern_to_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)) + .pixel_coord_lower = {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, + .tile_ratio = tileRatio, + + .pattern_from_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pattern_to_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)) }; #if MLN_UBO_CONSOLIDATION @@ -165,14 +166,12 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillPatternTilePropsUBO tilePropsUBO = { #endif - /* .pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) - : std::array{0}, - /* .pattern_to = */ - patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, - /* .texsize = */ - {static_cast(textureSize.width), static_cast(textureSize.height)}, - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .pattern_from = patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, + + .pattern_to = patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + + .texsize = {static_cast(textureSize.width), static_cast(textureSize.height)}, + .pad1 = 0, .pad2 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -187,15 +186,15 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillOutlinePatternDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .pixel_coord_upper = */ {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /* .pixel_coord_lower = */ - {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, - /* .tile_ratio = */ tileRatio, + .matrix = util::cast(matrix), + .pixel_coord_upper = {static_cast(pixelX >> 16), static_cast(pixelY >> 16)}, - /* .pattern_from_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pattern_to_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)) + .pixel_coord_lower = {static_cast(pixelX & 0xFFFF), static_cast(pixelY & 0xFFFF)}, + .tile_ratio = tileRatio, + + .pattern_from_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pattern_to_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)) }; #if MLN_UBO_CONSOLIDATION @@ -203,14 +202,12 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillOutlinePatternTilePropsUBO tilePropsUBO = { #endif - /* .pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) - : std::array{0}, - /* .pattern_to = */ - patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, - /* .texsize = */ - {static_cast(textureSize.width), static_cast(textureSize.height)}, - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .pattern_from = patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, + + .pattern_to = patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + + .texsize = {static_cast(textureSize.width), static_cast(textureSize.height)}, + .pad1 = 0, .pad2 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -225,11 +222,11 @@ void FillLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const FillOutlineTriangulatedDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, parameters.state.getZoom()), - /* .pad1 = */ 0, - /* .pad2 = */ 0, - /* .pad3 = */ 0 + .matrix = util::cast(matrix), + .ratio = 1.0f / tileID.pixelsToTileUnits(1.0f, parameters.state.getZoom()), + .pad1 = 0, + .pad2 = 0, + .pad3 = 0 }; #if !MLN_UBO_CONSOLIDATION diff --git a/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp b/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp index 9172150e8..ed22ad2f6 100644 --- a/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp @@ -36,10 +36,10 @@ void HeatmapLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamet if (!evaluatedPropsUniformBuffer || propertiesUpdated) { const HeatmapEvaluatedPropsUBO evaluatedPropsUBO = { - /* .weight = */ evaluated.get().constantOr(HeatmapWeight::defaultValue()), - /* .radius = */ evaluated.get().constantOr(HeatmapRadius::defaultValue()), - /* .intensity = */ evaluated.get(), - /* .padding = */ 0}; + .weight = evaluated.get().constantOr(HeatmapWeight::defaultValue()), + .radius = evaluated.get().constantOr(HeatmapRadius::defaultValue()), + .intensity = evaluated.get(), + .padding = 0}; parameters.context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &evaluatedPropsUBO); propertiesUpdated = false; } @@ -75,12 +75,12 @@ void HeatmapLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamet #else const HeatmapDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .extrude_scale = */ tileID.pixelsToTileUnits(1.0f, zoom), + .matrix = util::cast(matrix), + .extrude_scale = tileID.pixelsToTileUnits(1.0f, zoom), - /* .weight_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .radius_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0 + .weight_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .radius_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0 }; #if MLN_UBO_CONSOLIDATION drawable.setUBOIndex(i++); diff --git a/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.cpp b/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.cpp index 889ecfabe..fc67f4380 100644 --- a/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.cpp @@ -33,11 +33,11 @@ void HeatmapTextureLayerTweaker::execute(LayerGroupBase& layerGroup, const Paint const auto& size = parameters.staticData.backendSize; matrix::ortho(matrix, 0, size.width, size.height, 0, -1, 1); - const HeatmapTexturePropsUBO propsUBO = {/* .matrix = */ util::cast(matrix), - /* .opacity = */ evaluated.get(), - /* .pad1 = */ 0, - /* .pad2 = */ 0, - /* .pad3 = */ 0}; + const HeatmapTexturePropsUBO propsUBO = {.matrix = util::cast(matrix), + .opacity = evaluated.get(), + .pad1 = 0, + .pad2 = 0, + .pad3 = 0}; auto& layerUniforms = layerGroup.mutableUniformBuffers(); layerUniforms.createOrUpdate(idHeatmapTexturePropsUBO, &propsUBO, parameters.context); } diff --git a/src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp b/src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp index d7c6d2b23..4382452b1 100644 --- a/src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp @@ -44,10 +44,9 @@ void HillshadeLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParam #endif if (!evaluatedPropsUniformBuffer || propertiesUpdated) { - const HillshadeEvaluatedPropsUBO evaluatedPropsUBO = { - /* .highlight = */ evaluated.get(), - /* .shadow = */ evaluated.get(), - /* .accent = */ evaluated.get()}; + const HillshadeEvaluatedPropsUBO evaluatedPropsUBO = {.highlight = evaluated.get(), + .shadow = evaluated.get(), + .accent = evaluated.get()}; parameters.context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &evaluatedPropsUBO); propertiesUpdated = false; } @@ -83,8 +82,8 @@ void HillshadeLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParam #else const HillshadeTilePropsUBO tilePropsUBO = { #endif - /* .latrange = */ getLatRange(tileID), - /* .light = */ getLight(parameters, evaluated) + .latrange = getLatRange(tileID), + .light = getLight(parameters, evaluated) }; #if MLN_UBO_CONSOLIDATION diff --git a/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.cpp b/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.cpp index 3a9e337d1..24fa2452b 100644 --- a/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.cpp @@ -52,10 +52,10 @@ void HillshadePrepareLayerTweaker::execute(LayerGroupBase& layerGroup, const Pai const HillshadePrepareDrawableUBO drawableUBO = {/* .matrix = */ util::cast(matrix)}; const HillshadePrepareTilePropsUBO tilePropsUBO = { - /* .unpack = */ getUnpackVector(drawableData.encoding), - /* .dimension = */ {static_cast(drawableData.stride), static_cast(drawableData.stride)}, - /* .zoom = */ static_cast(tileID.canonical.z), - /* .maxzoom = */ static_cast(drawableData.maxzoom)}; + .unpack = getUnpackVector(drawableData.encoding), + .dimension = {static_cast(drawableData.stride), static_cast(drawableData.stride)}, + .zoom = static_cast(tileID.canonical.z), + .maxzoom = static_cast(drawableData.maxzoom)}; auto& drawableUniforms = drawable.mutableUniformBuffers(); drawableUniforms.createOrUpdate(idHillshadePrepareDrawableUBO, &drawableUBO, parameters.context); diff --git a/src/mbgl/renderer/layers/line_layer_tweaker.cpp b/src/mbgl/renderer/layers/line_layer_tweaker.cpp index 93591f92d..8b1fa69c6 100644 --- a/src/mbgl/renderer/layers/line_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/line_layer_tweaker.cpp @@ -74,7 +74,8 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters const auto& evaluated = static_cast(*evaluatedProperties).evaluated; const auto& crossfade = static_cast(*evaluatedProperties).crossfade; - const auto& linePatternValue = evaluated.get().constantOr(Faded{"", ""}); + const auto& linePatternValue = evaluated.get().constantOr( + Faded{.from = "", .to = ""}); const auto zoom = static_cast(parameters.state.getZoom()); const auto intZoom = parameters.state.getIntegerZoom(); @@ -84,13 +85,13 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters const bool enableEval = gfx::Backend::getEnableGPUExpressionEval(); if (!expressionUniformBuffer || (gpuExpressionsUpdated && enableEval)) { LineExpressionUBO exprUBO = { - /* color = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, - /* blur = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, - /* opacity = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, - /* gapwidth = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, - /* offset = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, - /* width = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, - /* floorWidth = */ enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .color = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .blur = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .opacity = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .gapwidth = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .offset = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .width = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, + .floorWidth = enableEval ? gpuExpressions[propertyIndex()].get() : nullptr, }; context.emplaceOrUpdateUniformBuffer(expressionUniformBuffer, &exprUBO); gpuExpressionsUpdated = false; @@ -116,26 +117,28 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters (gpuExpressions[propertyIndex()] ? LineExpressionMask::FloorWidth : LineExpressionMask::None)); const LineEvaluatedPropsUBO propsUBO{ - /*color =*/(expressionMask & LineExpressionMask::Color) ? LineColor::defaultValue() - : evaluate(parameters), - /*blur =*/ - (expressionMask & LineExpressionMask::Blur) ? LineBlur::defaultValue() : evaluate(parameters), - /*opacity =*/ - (expressionMask & LineExpressionMask::Opacity) ? LineOpacity::defaultValue() - : evaluate(parameters), - /*gapwidth =*/ - (expressionMask & LineExpressionMask::GapWidth) ? LineGapWidth::defaultValue() - : evaluate(parameters), - /*offset =*/ - (expressionMask & LineExpressionMask::Offset) ? LineOffset::defaultValue() - : evaluate(parameters), - /*width =*/ - (expressionMask & LineExpressionMask::Width) ? LineWidth::defaultValue() : evaluate(parameters), - /*floorwidth =*/ - (expressionMask & LineExpressionMask::FloorWidth) ? LineFloorWidth::defaultValue() - : evaluate(parameters), - expressionMask, - 0}; + .color = (expressionMask & LineExpressionMask::Color) ? LineColor::defaultValue() + : evaluate(parameters), + + .blur = (expressionMask & LineExpressionMask::Blur) ? LineBlur::defaultValue() + : evaluate(parameters), + + .opacity = (expressionMask & LineExpressionMask::Opacity) ? LineOpacity::defaultValue() + : evaluate(parameters), + + .gapwidth = (expressionMask & LineExpressionMask::GapWidth) ? LineGapWidth::defaultValue() + : evaluate(parameters), + + .offset = (expressionMask & LineExpressionMask::Offset) ? LineOffset::defaultValue() + : evaluate(parameters), + + .width = (expressionMask & LineExpressionMask::Width) ? LineWidth::defaultValue() + : evaluate(parameters), + + .floorwidth = (expressionMask & LineExpressionMask::FloorWidth) ? LineFloorWidth::defaultValue() + : evaluate(parameters), + .expressionMask = expressionMask, + .pad1 = 0}; #else const LineEvaluatedPropsUBO propsUBO{/*color =*/evaluate(parameters), /*blur =*/evaluate(parameters), @@ -201,16 +204,16 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const LineDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), + .matrix = util::cast(matrix), + .ratio = 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), - /* .color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .blur_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .gapwidth_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .offset_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .width_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0 + .color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .blur_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .gapwidth_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .offset_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .width_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -225,16 +228,16 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const LineGradientDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), + .matrix = util::cast(matrix), + .ratio = 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), - /* .blur_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .gapwidth_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .offset_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .width_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .blur_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .gapwidth_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .offset_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .width_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0, + .pad2 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -252,16 +255,16 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const LinePatternDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), + .matrix = util::cast(matrix), + .ratio = 1.0f / tileID.pixelsToTileUnits(1.0f, static_cast(zoom)), - /* .blur_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .offset_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .gapwidth_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .width_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pattern_from_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pattern_to_t = */ std::get<1>(binders->get()->interpolationFactor(zoom)) + .blur_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .gapwidth_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .offset_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .width_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pattern_from_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pattern_to_t = std::get<1>(binders->get()->interpolationFactor(zoom)) }; #if MLN_UBO_CONSOLIDATION @@ -269,19 +272,17 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const LinePatternTilePropsUBO tilePropsUBO = { #endif - /* .pattern_from = */ patternPosA ? util::cast(patternPosA->tlbr()) - : std::array{0}, - /* .pattern_to = */ - patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, - /* .scale = */ - {parameters.pixelRatio, - 1 / tileID.pixelsToTileUnits(1, intZoom), - crossfade.fromScale, - crossfade.toScale}, - /* .texsize = */ - {static_cast(textureSize.width), static_cast(textureSize.height)}, - /* .fade = */ crossfade.t, - /* .pad1 = */ 0 + .pattern_from = patternPosA ? util::cast(patternPosA->tlbr()) : std::array{0}, + + .pattern_to = patternPosB ? util::cast(patternPosB->tlbr()) : std::array{0}, + + .scale = {parameters.pixelRatio, + 1 / tileID.pixelsToTileUnits(1, intZoom), + crossfade.fromScale, + crossfade.toScale}, + + .texsize = {static_cast(textureSize.width), static_cast(textureSize.height)}, + .fade = crossfade.t, .pad1 = 0 }; #if !MLN_UBO_CONSOLIDATION @@ -317,22 +318,22 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const LineSDFDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .patternscale_a = */ {1.0f / tileID.pixelsToTileUnits(widthA, intZoom), -posA.height / 2.0f}, - /* .patternscale_b = */ {1.0f / tileID.pixelsToTileUnits(widthB, intZoom), -posB.height / 2.0f}, - /* .tex_y_a = */ posA.y, - /* .tex_y_b = */ posB.y, - /* .ratio = */ 1.0f / tileID.pixelsToTileUnits(1.0f, zoom), + .matrix = util::cast(matrix), + .patternscale_a = {1.0f / tileID.pixelsToTileUnits(widthA, intZoom), -posA.height / 2.0f}, + .patternscale_b = {1.0f / tileID.pixelsToTileUnits(widthB, intZoom), -posB.height / 2.0f}, + .tex_y_a = posA.y, + .tex_y_b = posB.y, + .ratio = 1.0f / tileID.pixelsToTileUnits(1.0f, zoom), - /* .color_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .blur_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .opacity_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .gapwidth_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .offset_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .width_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .floorwidth_t = */ std::get<0>(binders->get()->interpolationFactor(zoom)), - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .color_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .blur_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .opacity_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .gapwidth_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .offset_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .width_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .floorwidth_t = std::get<0>(binders->get()->interpolationFactor(zoom)), + .pad1 = 0, + .pad2 = 0 }; #if MLN_UBO_CONSOLIDATION @@ -340,11 +341,9 @@ void LineLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParameters #else const LineSDFTilePropsUBO tilePropsUBO = { #endif - /* .sdfgamma = */ static_cast(dashPatternTexture.getSize().width) / - (std::min(widthA, widthB) * 256.0f * parameters.pixelRatio) / 2.0f, - /* .mix = */ crossfade.t, - /* .pad1 = */ 0, - /* .pad2 = */ 0 + .sdfgamma = static_cast(dashPatternTexture.getSize().width) / + (std::min(widthA, widthB) * 256.0f * parameters.pixelRatio) / 2.0f, + .mix = crossfade.t, .pad1 = 0, .pad2 = 0 }; #if !MLN_UBO_CONSOLIDATION diff --git a/src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp b/src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp index 8d60a3a45..cbd9f0913 100644 --- a/src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp @@ -27,16 +27,15 @@ void LocationIndicatorLayerTweaker::execute(LayerGroupBase& layerGroup, const Pa switch (static_cast(drawable.getType())) { case RenderLocationIndicatorLayer::LocationIndicatorComponentType::Circle: { - LocationIndicatorDrawableUBO drawableUBO = {/* .matrix = */ util::cast(projectionCircle), - /* .color = */ props.evaluated.get()}; + LocationIndicatorDrawableUBO drawableUBO = {.matrix = util::cast(projectionCircle), + .color = props.evaluated.get()}; drawableUniforms.createOrUpdate(idLocationIndicatorDrawableUBO, &drawableUBO, params.context); break; } case RenderLocationIndicatorLayer::LocationIndicatorComponentType::CircleOutline: { - LocationIndicatorDrawableUBO drawableUBO = { - /* .matrix = */ util::cast(projectionCircle), - /* .color = */ props.evaluated.get()}; + LocationIndicatorDrawableUBO drawableUBO = {.matrix = util::cast(projectionCircle), + .color = props.evaluated.get()}; drawableUniforms.createOrUpdate(idLocationIndicatorDrawableUBO, &drawableUBO, params.context); break; } @@ -46,8 +45,8 @@ void LocationIndicatorLayerTweaker::execute(LayerGroupBase& layerGroup, const Pa case RenderLocationIndicatorLayer::LocationIndicatorComponentType::Puck: [[fallthrough]]; case RenderLocationIndicatorLayer::LocationIndicatorComponentType::PuckHat: { - const LocationIndicatorDrawableUBO drawableUBO = {/* .matrix = */ util::cast(projectionPuck), - /* .color = */ Color::black()}; + const LocationIndicatorDrawableUBO drawableUBO = {.matrix = util::cast(projectionPuck), + .color = Color::black()}; drawableUniforms.createOrUpdate(idLocationIndicatorDrawableUBO, &drawableUBO, params.context); break; } diff --git a/src/mbgl/renderer/layers/raster_layer_tweaker.cpp b/src/mbgl/renderer/layers/raster_layer_tweaker.cpp index 7a89414e1..d508c60bf 100644 --- a/src/mbgl/renderer/layers/raster_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/raster_layer_tweaker.cpp @@ -51,18 +51,18 @@ void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup, if (!evaluatedPropsUniformBuffer || propertiesUpdated) { const RasterEvaluatedPropsUBO propsUBO = { - /* .spin_weigths = */ spinWeights(evaluated.get()), - /* .tl_parent = */ {{0.0f, 0.0f}}, - /* .scale_parent = */ 1.0f, - /* .buffer_scale = */ 1.0f, - /* .fade_t = */ 1.0f, - /* .opacity = */ evaluated.get(), - /* .brightness_low = */ evaluated.get(), - /* .brightness_high = */ evaluated.get(), - /* .saturation_factor = */ saturationFactor(evaluated.get()), - /* .contrast_factor = */ contrastFactor(evaluated.get()), - /* .pad1 = */ 0, - /* .pad2 = */ 0}; + .spin_weights = spinWeights(evaluated.get()), + .tl_parent = {{0.0f, 0.0f}}, + .scale_parent = 1.0f, + .buffer_scale = 1.0f, + .fade_t = 1.0f, + .opacity = evaluated.get(), + .brightness_low = evaluated.get(), + .brightness_high = evaluated.get(), + .saturation_factor = saturationFactor(evaluated.get()), + .contrast_factor = contrastFactor(evaluated.get()), + .pad1 = 0, + .pad2 = 0}; parameters.context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &propsUBO); propertiesUpdated = false; } diff --git a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp index 9f737ded6..2553b8241 100644 --- a/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp +++ b/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp @@ -69,19 +69,19 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete const auto zoom = static_cast(state.getZoom()); if (!evaluatedPropsUniformBuffer || propertiesUpdated) { - const SymbolEvaluatedPropsUBO propsUBO = {/* .text_fill_color = */ constOrDefault(evaluated), - /* .text_halo_color = */ constOrDefault(evaluated), - /* .text_opacity = */ constOrDefault(evaluated), - /* .text_halo_width = */ constOrDefault(evaluated), - /* .text_halo_blur = */ constOrDefault(evaluated), - /* .pad1 */ 0, + const SymbolEvaluatedPropsUBO propsUBO = {.text_fill_color = constOrDefault(evaluated), + .text_halo_color = constOrDefault(evaluated), + .text_opacity = constOrDefault(evaluated), + .text_halo_width = constOrDefault(evaluated), + .text_halo_blur = constOrDefault(evaluated), + .pad1 = 0, - /* .icon_fill_color = */ constOrDefault(evaluated), - /* .icon_halo_color = */ constOrDefault(evaluated), - /* .icon_opacity = */ constOrDefault(evaluated), - /* .icon_halo_width = */ constOrDefault(evaluated), - /* .icon_halo_blur = */ constOrDefault(evaluated), - /* .pad2 */ 0}; + .icon_fill_color = constOrDefault(evaluated), + .icon_halo_color = constOrDefault(evaluated), + .icon_opacity = constOrDefault(evaluated), + .icon_halo_width = constOrDefault(evaluated), + .icon_halo_blur = constOrDefault(evaluated), + .pad2 = 0}; context.emplaceOrUpdateUniformBuffer(evaluatedPropsUniformBuffer, &propsUBO); propertiesUpdated = false; } @@ -157,27 +157,27 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete #else const SymbolDrawableUBO drawableUBO = { #endif - /* .matrix = */ util::cast(matrix), - /* .label_plane_matrix = */ util::cast(labelPlaneMatrix), - /* .coord_matrix = */ util::cast(glCoordMatrix), + .matrix = util::cast(matrix), + .label_plane_matrix = util::cast(labelPlaneMatrix), + .coord_matrix = util::cast(glCoordMatrix), - /* .texsize = */ toArray(getTexSize(drawable, idSymbolImageTexture)), - /* .texsize_icon = */ toArray(getTexSize(drawable, idSymbolImageIconTexture)), + .texsize = toArray(getTexSize(drawable, idSymbolImageTexture)), + .texsize_icon = toArray(getTexSize(drawable, idSymbolImageIconTexture)), - /* .is_text_prop = */ isText, - /* .rotate_symbol = */ rotateInShader, - /* .pitch_with_map = */ (symbolData.pitchAlignment == style::AlignmentType::Map), - /* .is_size_zoom_constant = */ size.isZoomConstant, - /* .is_size_feature_constant = */ size.isFeatureConstant, + .is_text_prop = isText, + .rotate_symbol = rotateInShader, + .pitch_with_map = (symbolData.pitchAlignment == style::AlignmentType::Map), + .is_size_zoom_constant = size.isZoomConstant, + .is_size_feature_constant = size.isFeatureConstant, - /* .size_t = */ size.sizeT, - /* .size = */ size.size, + .size_t = size.sizeT, + .size = size.size, - /* .fill_color_t = */ getInterpFactor(paintProperties, isText, zoom), - /* .halo_color_t = */ getInterpFactor(paintProperties, isText, zoom), - /* .opacity_t = */ getInterpFactor(paintProperties, isText, zoom), - /* .halo_width_t = */ getInterpFactor(paintProperties, isText, zoom), - /* .halo_blur_t = */ getInterpFactor(paintProperties, isText, zoom), + .fill_color_t = getInterpFactor(paintProperties, isText, zoom), + .halo_color_t = getInterpFactor(paintProperties, isText, zoom), + .opacity_t = getInterpFactor(paintProperties, isText, zoom), + .halo_width_t = getInterpFactor(paintProperties, isText, zoom), + .halo_blur_t = getInterpFactor(paintProperties, isText, zoom), }; #if MLN_UBO_CONSOLIDATION @@ -185,10 +185,10 @@ void SymbolLayerTweaker::execute(LayerGroupBase& layerGroup, const PaintParamete #else const SymbolTilePropsUBO tilePropsUBO = { #endif - /* .is_text = */ isText, - /* .is_halo = */ symbolData.isHalo, - /* .gamma_scale= */ gammaScale, - /* .pad1 = */ 0, + .is_text = isText, + .is_halo = symbolData.isHalo, + .gamma_scale = gammaScale, + .pad1 = 0, }; #if MLN_UBO_CONSOLIDATION diff --git a/src/mbgl/renderer/property_evaluation_parameters.hpp b/src/mbgl/renderer/property_evaluation_parameters.hpp index c9aae14da..3fe07ea1c 100644 --- a/src/mbgl/renderer/property_evaluation_parameters.hpp +++ b/src/mbgl/renderer/property_evaluation_parameters.hpp @@ -33,8 +33,9 @@ public: ? std::min((now - zoomHistory.lastIntegerZoomTime) / d, 1.0f) : 1.0f; - return z > zoomHistory.lastIntegerZoom ? CrossfadeParameters{2.0f, 1.0f, fraction + (1.0f - fraction) * t} - : CrossfadeParameters{0.5f, 1.0f, 1 - (1 - t) * fraction}; + return z > zoomHistory.lastIntegerZoom + ? CrossfadeParameters{.fromScale = 2.0f, .toScale = 1.0f, .t = fraction + (1.0f - fraction) * t} + : CrossfadeParameters{.fromScale = 0.5f, .toScale = 1.0f, .t = 1 - (1 - t) * fraction}; } float z; diff --git a/src/mbgl/renderer/render_target.cpp b/src/mbgl/renderer/render_target.cpp index 01d6765b3..ef75e44be 100644 --- a/src/mbgl/renderer/render_target.cpp +++ b/src/mbgl/renderer/render_target.cpp @@ -65,8 +65,11 @@ void RenderTarget::upload(gfx::UploadPass& uploadPass) { } void RenderTarget::render(RenderOrchestrator& orchestrator, const RenderTree& renderTree, PaintParameters& parameters) { - parameters.renderPass = parameters.encoder->createRenderPass( - "render target", {*offscreenTexture, Color{0.0f, 0.0f, 0.0f, 1.0f}, {}, {}}); + parameters.renderPass = parameters.encoder->createRenderPass("render target", + {.renderable = *offscreenTexture, + .clearColor = Color{0.0f, 0.0f, 0.0f, 1.0f}, + .clearDepth = {}, + .clearStencil = {}}); // Run layer tweakers to update any dynamic elements parameters.currentLayer = 0; diff --git a/src/mbgl/renderer/tile_layer_group.cpp b/src/mbgl/renderer/tile_layer_group.cpp index 303a14774..c2a049193 100644 --- a/src/mbgl/renderer/tile_layer_group.cpp +++ b/src/mbgl/renderer/tile_layer_group.cpp @@ -2,6 +2,7 @@ #include +#include #include #include @@ -40,7 +41,7 @@ std::vector TileLayerGroup::removeDrawables(mbgl::RenderPas return std::move(pair.second); }); drawablesByTile.erase(range.first, range.second); - std::for_each(result.begin(), result.end(), [&](const auto& item) { + std::ranges::for_each(result, [&](const auto& item) { const auto hit = sortedDrawables.find(item.get()); assert(hit != sortedDrawables.end()); if (hit != sortedDrawables.end()) { @@ -56,7 +57,8 @@ void TileLayerGroup::addDrawable(mbgl::RenderPass pass, const OverscaledTileID& LayerGroupBase::addDrawable(drawable); [[maybe_unused]] const auto result = sortedDrawables.insert(drawable.get()); assert(result.second); - drawablesByTile.insert(std::make_pair(TileLayerGroupTileKey{pass, id}, std::move(drawable))); + drawablesByTile.insert( + std::make_pair(TileLayerGroupTileKey{.renderPass = pass, .tileID = id}, std::move(drawable))); } } diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index 9a228c7a9..8f8fb1242 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* BackgroundLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"background", - LayerTypeInfo::Source::NotRequired, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::NotRequired}; + const static LayerTypeInfo typeInfo{.type="background", + .source=LayerTypeInfo::Source::NotRequired, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::NotRequired, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::NotRequired}; return &typeInfo; } - BackgroundLayer::BackgroundLayer(const std::string& layerID) : Layer(makeMutable(layerID, std::string())) { } diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index 6e1c748e6..fd6a979ad 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* CircleLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"circle", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::Geometry}; + const static LayerTypeInfo typeInfo{.type="circle", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::Required, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } - CircleLayer::CircleLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 2df96887f..ccb2df981 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* FillExtrusionLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"fill-extrusion", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::Required, - LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::Geometry}; + const static LayerTypeInfo typeInfo{.type="fill-extrusion", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::Required, + .layout=LayerTypeInfo::Layout::Required, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } - FillExtrusionLayer::FillExtrusionLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index 3076e179b..9bc0ae55f 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* FillLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"fill", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::Geometry}; + const static LayerTypeInfo typeInfo{.type="fill", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::Required, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } - FillLayer::FillLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index 342db81aa..f0469c1b4 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* HeatmapLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"heatmap", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::Required, - LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::Geometry}; + const static LayerTypeInfo typeInfo{.type="heatmap", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::Required, + .layout=LayerTypeInfo::Layout::NotRequired, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } - HeatmapLayer::HeatmapLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp index c4784bd42..410979118 100644 --- a/src/mbgl/style/layers/hillshade_layer.cpp +++ b/src/mbgl/style/layers/hillshade_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* HillshadeLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"hillshade", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::Required, - LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::RasterDEM}; + const static LayerTypeInfo typeInfo{.type="hillshade", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::Required, + .layout=LayerTypeInfo::Layout::NotRequired, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::RasterDEM}; return &typeInfo; } - HillshadeLayer::HillshadeLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index 2e6647608..eea2a85d4 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -3,6 +3,16 @@ const layoutProperties = locals.layoutProperties; const paintProperties = locals.paintProperties; const allProperties = paintProperties.concat(layoutProperties); + + // Define the mapping from capability keys to struct member names + const memberMap = { + 'Source': 'source', + 'Pass3D': 'pass3d', + 'Layout': 'layout', + 'FadingTiles': 'fadingTiles', + 'CrossTileIndex': 'crossTileIndex', + 'TileKind': 'tileKind' + }; -%> // clang-format off @@ -97,12 +107,14 @@ const split120Line = line => { %> // static const LayerTypeInfo* <%- camelize(type) %>Layer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"<%- type %>", - <%-`${layerCapabilities[type].map(cap => `LayerTypeInfo::${cap}`).join(',\n ')}` %>}; + const static LayerTypeInfo typeInfo{.type="<%- type %>", + <%- layerCapabilities[type].map(cap => { + const key = cap.split('::')[0]; + return `.${memberMap[key]}=LayerTypeInfo::${cap}`; + }).join(',\n ') %>}; return &typeInfo; } - <% if ((type === 'background') || (type === 'location-indicator')) { -%> <%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID) : Layer(makeMutable(layerID, std::string())) { diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 6d9032079..a18ba5776 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* LineLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"line", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::Geometry}; + const static LayerTypeInfo typeInfo{.type="line", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::Required, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } - LineLayer::LineLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/location_indicator_layer.cpp b/src/mbgl/style/layers/location_indicator_layer.cpp index cd450c5eb..580018130 100644 --- a/src/mbgl/style/layers/location_indicator_layer.cpp +++ b/src/mbgl/style/layers/location_indicator_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* LocationIndicatorLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"location-indicator", - LayerTypeInfo::Source::NotRequired, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::NotRequired}; + const static LayerTypeInfo typeInfo{.type="location-indicator", + .source=LayerTypeInfo::Source::NotRequired, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::NotRequired, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::NotRequired}; return &typeInfo; } - LocationIndicatorLayer::LocationIndicatorLayer(const std::string& layerID) : Layer(makeMutable(layerID, std::string())) { } diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index a97ad7d2f..092766536 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* RasterLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"raster", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired, - LayerTypeInfo::CrossTileIndex::NotRequired, - LayerTypeInfo::TileKind::Raster}; + const static LayerTypeInfo typeInfo{.type="raster", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::NotRequired, + .fadingTiles=LayerTypeInfo::FadingTiles::NotRequired, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::NotRequired, + .tileKind=LayerTypeInfo::TileKind::Raster}; return &typeInfo; } - RasterLayer::RasterLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 6aec283b0..6f7b736c1 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -21,17 +21,16 @@ namespace style { // static const LayerTypeInfo* SymbolLayer::Impl::staticTypeInfo() noexcept { - const static LayerTypeInfo typeInfo{"symbol", - LayerTypeInfo::Source::Required, - LayerTypeInfo::Pass3D::NotRequired, - LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::Required, - LayerTypeInfo::CrossTileIndex::Required, - LayerTypeInfo::TileKind::Geometry}; + const static LayerTypeInfo typeInfo{.type="symbol", + .source=LayerTypeInfo::Source::Required, + .pass3d=LayerTypeInfo::Pass3D::NotRequired, + .layout=LayerTypeInfo::Layout::Required, + .fadingTiles=LayerTypeInfo::FadingTiles::Required, + .crossTileIndex=LayerTypeInfo::CrossTileIndex::Required, + .tileKind=LayerTypeInfo::TileKind::Geometry}; return &typeInfo; } - SymbolLayer::SymbolLayer(const std::string& layerID, const std::string& sourceID) : Layer(makeMutable(layerID, sourceID)) { } @@ -648,7 +647,6 @@ void SymbolLayer::setTextTransform(const PropertyValue& value baseImpl = std::move(impl_); observer->onLayerChanged(*this); } - PropertyValue> SymbolLayer::getDefaultTextVariableAnchor() { return TextVariableAnchor::defaultValue(); } @@ -664,7 +662,6 @@ void SymbolLayer::setTextVariableAnchor(const PropertyValueonLayerChanged(*this); } - PropertyValue SymbolLayer::getDefaultTextVariableAnchorOffset() { return TextVariableAnchorOffset::defaultValue(); } @@ -680,7 +677,6 @@ void SymbolLayer::setTextVariableAnchorOffset(const PropertyValueonLayerChanged(*this); } - PropertyValue> SymbolLayer::getDefaultTextWritingMode() { return TextWritingMode::defaultValue(); } diff --git a/src/mbgl/util/tile_coordinate.hpp b/src/mbgl/util/tile_coordinate.hpp index d3ac22985..0b6ebe2b2 100644 --- a/src/mbgl/util/tile_coordinate.hpp +++ b/src/mbgl/util/tile_coordinate.hpp @@ -21,7 +21,7 @@ public: static TileCoordinate fromLatLng(double zoom, const LatLng& latLng) { const double scale = std::pow(2.0, zoom); - return {Projection::project(latLng, scale) / util::tileSize_D, zoom}; + return {.p = Projection::project(latLng, scale) / util::tileSize_D, .z = zoom}; } static TileCoordinate fromScreenCoordinate(const TransformState& state, @@ -32,12 +32,12 @@ public: TileCoordinate zoomTo(double zoom) const { const double scaleDiff = std::pow(2.0, zoom - z); - return {p * scaleDiff, zoom}; + return {.p = p * scaleDiff, .z = zoom}; } static GeometryCoordinate toGeometryCoordinate(const UnwrappedTileID& tileID, const TileCoordinatePoint& point) { const double scale = std::pow(2.0, tileID.canonical.z); - auto zoomed = TileCoordinate{point, 0}.zoomTo(tileID.canonical.z); + auto zoomed = TileCoordinate{.p = point, .z = 0}.zoomTo(tileID.canonical.z); return {int16_t(util::clamp( static_cast((zoomed.p.x - tileID.canonical.x - tileID.wrap * scale) * util::EXTENT), std::numeric_limits::min(),