Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -14,16 +14,16 @@ using namespace style;
static_assert(sizeof(SymbolLayoutVertex) == 24, "expected SymbolLayoutVertex size");
std::unique_ptr<SymbolSizeBinder> SymbolSizeBinder::create(const float tileZoom,
const style::PropertyValue<float>& sizeProperty,
const float defaultValue) {
const style::PropertyValue<float>& sizeProperty,
const float defaultValue) {
return sizeProperty.match(
[&] (const Undefined& value) -> std::unique_ptr<SymbolSizeBinder> {
[&](const Undefined& value) -> std::unique_ptr<SymbolSizeBinder> {
return std::make_unique<ConstantSymbolSizeBinder>(tileZoom, value, defaultValue);
},
[&] (float value) -> std::unique_ptr<SymbolSizeBinder> {
[&](float value) -> std::unique_ptr<SymbolSizeBinder> {
return std::make_unique<ConstantSymbolSizeBinder>(tileZoom, value, defaultValue);
},
[&] (const style::PropertyExpression<float>& expression) -> std::unique_ptr<SymbolSizeBinder> {
[&](const style::PropertyExpression<float>& expression) -> std::unique_ptr<SymbolSizeBinder> {
if (expression.isFeatureConstant()) {
return std::make_unique<ConstantSymbolSizeBinder>(tileZoom, expression, defaultValue);
} else if (expression.isZoomConstant()) {
@@ -31,11 +31,10 @@ std::unique_ptr<SymbolSizeBinder> SymbolSizeBinder::create(const float tileZoom,
} else {
return std::make_unique<CompositeFunctionSymbolSizeBinder>(tileZoom, expression, defaultValue);
}
}
);
});
}
template <class Values, class...Args>
template <class Values, class... Args>
Values makeValues(const bool isText,
const bool hasVariablePacement,
const style::SymbolPropertyValues& values,
@@ -51,10 +50,8 @@ Values makeValues(const bool isText,
if (values.pitchAlignment == AlignmentType::Map) {
extrudeScale.fill(tile.id.pixelsToTileUnits(1.f, static_cast<float>(state.getZoom())));
} else {
extrudeScale = {{
pixelsToGLUnits[0] * state.getCameraToCenterDistance(),
pixelsToGLUnits[1] * state.getCameraToCenterDistance()
}};
extrudeScale = {{pixelsToGLUnits[0] * state.getCameraToCenterDistance(),
pixelsToGLUnits[1] * state.getCameraToCenterDistance()}};
}
const float pixelsToTileUnits = tile.id.pixelsToTileUnits(1.f, static_cast<float>(state.getZoom()));
@@ -68,8 +65,9 @@ Values makeValues(const bool isText,
mat4 labelPlaneMatrix;
if (alongLine || hasVariablePacement) {
// For labels that follow lines the first part of the projection is handled on the cpu.
// Pass an identity matrix because no transformation needs to be done in the vertex shader.
// For labels that follow lines the first part of the projection is
// handled on the cpu. Pass an identity matrix because no transformation
// needs to be done in the vertex shader.
matrix::identity(labelPlaneMatrix);
} else {
labelPlaneMatrix = getLabelPlaneMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits);
@@ -77,68 +75,52 @@ Values makeValues(const bool isText,
mat4 glCoordMatrix = getGlCoordMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits);
return Values {
uniforms::matrix::Value( tile.translatedMatrix(values.translate,
values.translateAnchor,
state) ),
uniforms::label_plane_matrix::Value(labelPlaneMatrix),
uniforms::coord_matrix::Value( tile.translateVtxMatrix(glCoordMatrix,
values.translate,
values.translateAnchor,
state,
true) ),
uniforms::extrude_scale::Value( extrudeScale ),
uniforms::texsize::Value( texsize ),
uniforms::fade_change::Value( symbolFadeChange ),
uniforms::is_text::Value( isText ),
uniforms::camera_to_center_distance::Value( state.getCameraToCenterDistance() ),
uniforms::pitch::Value( state.getPitch() ),
uniforms::pitch_with_map::Value( pitchWithMap ),
uniforms::rotate_symbol::Value( rotateInShader ),
uniforms::aspect_ratio::Value( state.getSize().aspectRatio() ),
std::forward<Args>(args)...
};
return Values{uniforms::matrix::Value(tile.translatedMatrix(values.translate, values.translateAnchor, state)),
uniforms::label_plane_matrix::Value(labelPlaneMatrix),
uniforms::coord_matrix::Value(
tile.translateVtxMatrix(glCoordMatrix, values.translate, values.translateAnchor, state, true)),
uniforms::extrude_scale::Value(extrudeScale),
uniforms::texsize::Value(texsize),
uniforms::fade_change::Value(symbolFadeChange),
uniforms::is_text::Value(isText),
uniforms::camera_to_center_distance::Value(state.getCameraToCenterDistance()),
uniforms::pitch::Value(state.getPitch()),
uniforms::pitch_with_map::Value(pitchWithMap),
uniforms::rotate_symbol::Value(rotateInShader),
uniforms::aspect_ratio::Value(state.getSize().aspectRatio()),
std::forward<Args>(args)...};
}
SymbolIconProgram::LayoutUniformValues
SymbolIconProgram::layoutUniformValues(const bool isText,
const bool hasVariablePacement,
const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const bool alongLine,
const RenderTile& tile,
const TransformState& state,
const float symbolFadeChange) {
SymbolIconProgram::LayoutUniformValues SymbolIconProgram::layoutUniformValues(
const bool isText,
const bool hasVariablePacement,
const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const bool alongLine,
const RenderTile& tile,
const TransformState& state,
const float symbolFadeChange) {
return makeValues<SymbolIconProgram::LayoutUniformValues>(
isText,
hasVariablePacement,
values,
texsize,
pixelsToGLUnits,
alongLine,
tile,
state,
symbolFadeChange
);
isText, hasVariablePacement, values, texsize, pixelsToGLUnits, alongLine, tile, state, symbolFadeChange);
}
template <class Name, shaders::BuiltIn ShaderSource, class PaintProperties>
typename SymbolSDFProgram<Name, ShaderSource, PaintProperties>::LayoutUniformValues
SymbolSDFProgram<Name, ShaderSource, PaintProperties>::layoutUniformValues(const bool isText,
const bool hasVariablePacement,
const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const float pixelRatio,
const bool alongLine,
const RenderTile& tile,
const TransformState& state,
const float symbolFadeChange,
const SymbolSDFPart part) {
const bool hasVariablePacement,
const style::SymbolPropertyValues& values,
const Size& texsize,
const std::array<float, 2>& pixelsToGLUnits,
const float pixelRatio,
const bool alongLine,
const RenderTile& tile,
const TransformState& state,
const float symbolFadeChange,
const SymbolSDFPart part) {
const float gammaScale = (values.pitchAlignment == AlignmentType::Map
? static_cast<float>(std::cos(state.getPitch())) * state.getCameraToCenterDistance()
: 1.0f);
? static_cast<float>(std::cos(state.getPitch())) * state.getCameraToCenterDistance()
: 1.0f);
return makeValues<SymbolSDFProgram<Name, ShaderSource, PaintProperties>::LayoutUniformValues>(
isText,
@@ -150,10 +132,9 @@ SymbolSDFProgram<Name, ShaderSource, PaintProperties>::layoutUniformValues(const
tile,
state,
symbolFadeChange,
uniforms::gamma_scale::Value( gammaScale ),
uniforms::device_pixel_ratio::Value( pixelRatio ),
uniforms::is_halo::Value( part == SymbolSDFPart::Halo )
);
uniforms::gamma_scale::Value(gammaScale),
uniforms::device_pixel_ratio::Value(pixelRatio),
uniforms::is_halo::Value(part == SymbolSDFPart::Halo));
}
SymbolTextAndIconProgram::LayoutUniformValues SymbolTextAndIconProgram::layoutUniformValues(
@@ -168,23 +149,27 @@ SymbolTextAndIconProgram::LayoutUniformValues SymbolTextAndIconProgram::layoutUn
const TransformState& state,
const float symbolFadeChange,
const SymbolSDFPart part) {
return {SymbolSDFProgram<SymbolSDFTextProgram, shaders::BuiltIn::SymbolSDFTextProgram, style::TextPaintProperties>
::layoutUniformValues(
true,
hasVariablePacement,
values,
texsize,
pixelsToGLUnits,
pixelRatio,
alongLine,
tile,
state,
symbolFadeChange,
part)
.concat(gfx::UniformValues<SymbolTextAndIconProgramUniforms>(uniforms::texsize::Value(texsize_icon)))};
return {SymbolSDFProgram<SymbolSDFTextProgram,
shaders::BuiltIn::SymbolSDFTextProgram,
style::TextPaintProperties>::layoutUniformValues(true,
hasVariablePacement,
values,
texsize,
pixelsToGLUnits,
pixelRatio,
alongLine,
tile,
state,
symbolFadeChange,
part)
.concat(gfx::UniformValues<SymbolTextAndIconProgramUniforms>(uniforms::texsize::Value(texsize_icon)))};
}
template class SymbolSDFProgram<SymbolSDFIconProgram, shaders::BuiltIn::SymbolSDFIconProgram, style::IconPaintProperties>;
template class SymbolSDFProgram<SymbolSDFTextProgram, shaders::BuiltIn::SymbolSDFTextProgram, style::TextPaintProperties>;
template class SymbolSDFProgram<SymbolSDFIconProgram,
shaders::BuiltIn::SymbolSDFIconProgram,
style::IconPaintProperties>;
template class SymbolSDFProgram<SymbolSDFTextProgram,
shaders::BuiltIn::SymbolSDFTextProgram,
style::TextPaintProperties>;
} // namespace mbgl