Skip to content

Commit fc0832b

Browse files
authored
Merge branch 'main' into opaque-cutoff-compared-to-right-layer-index
2 parents 2381e37 + ab00edf commit fc0832b

File tree

209 files changed

+6246
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+6246
-151
lines changed

.clang-tidy

+5-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ Checks: [
109109
-readability-suspicious-call-argument,
110110
-readability-uppercase-literal-suffix,
111111
-readability-use-anyofallof,
112-
-modernize-loop-convert # since C++20 this complains about reverse loops with iterators, but good ranges support only landed in clang 15
112+
-modernize-loop-convert, # since C++20 this complains about reverse loops with iterators, but good ranges support only landed in clang 15
113+
-performance-enum-size,
114+
-misc-include-cleaner,
115+
-readability-redundant-inline-specifier,
116+
-readability-avoid-nested-conditional-operator
113117
]
114118
WarningsAsErrors: '*'
115119
HeaderFilterRegex: '.*'

.github/workflows/android-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Get all Android files that have changed
3131
if: github.event_name != 'workflow_dispatch'
3232
id: changed-files
33-
uses: tj-actions/changed-files@v44
33+
uses: tj-actions/changed-files@v45
3434
with:
3535
files_yaml_from_source_file: .github/changed-files.yml
3636

.github/workflows/gh-pages-android-api.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: ./gradlew dokkaHtml
2727

2828
- name: Deploy 🚀
29-
uses: JamesIves/[email protected].3
29+
uses: JamesIves/[email protected].8
3030
with:
3131
branch: gh-pages
3232
folder: platform/android/MapLibreAndroid/build/dokka/html

.github/workflows/gh-pages-cpp-api.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
run: doxygen
2121

2222
- name: Deploy 🚀
23-
uses: JamesIves/[email protected].3
23+
uses: JamesIves/[email protected].8
2424
with:
2525
branch: gh-pages
2626
folder: docs/doxygen/html

.github/workflows/gh-pages-mdbook.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
name: book
4040
path: artifacts/book
4141
- name: Deploy
42-
uses: JamesIves/[email protected].3
42+
uses: JamesIves/[email protected].8
4343
with:
4444
branch: gh-pages
4545
folder: artifacts/book

.github/workflows/ios-ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Get all iOS files that have changed
4444
if: github.event_name != 'workflow_dispatch'
4545
id: changed-files-yaml
46-
uses: tj-actions/changed-files@v44
46+
uses: tj-actions/changed-files@v45
4747
with:
4848
files_yaml_from_source_file: .github/changed-files.yml
4949

@@ -201,7 +201,7 @@ jobs:
201201
202202
- name: Deploy DocC documentation (main) 🚀
203203
if: github.ref == 'refs/heads/main'
204-
uses: JamesIves/[email protected].4
204+
uses: JamesIves/[email protected].8
205205
continue-on-error: true
206206
with:
207207
branch: gh-pages
@@ -224,7 +224,7 @@ jobs:
224224

225225
- name: VERSION file changed
226226
id: version-file-ios-changed
227-
uses: tj-actions/changed-files@v44
227+
uses: tj-actions/changed-files@v45
228228
with:
229229
files: platform/ios/VERSION
230230

.github/workflows/linux-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: Get all Linux files that have changed
3838
if: github.event_name != 'workflow_dispatch'
3939
id: changed-files
40-
uses: tj-actions/changed-files@v44
40+
uses: tj-actions/changed-files@v45
4141
with:
4242
files_yaml_from_source_file: .github/changed-files.yml
4343

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ list(APPEND INCLUDE_FILES
379379
${PROJECT_SOURCE_DIR}/include/mbgl/style/transition_options.hpp
380380
${PROJECT_SOURCE_DIR}/include/mbgl/style/types.hpp
381381
${PROJECT_SOURCE_DIR}/include/mbgl/style/undefined.hpp
382+
${PROJECT_SOURCE_DIR}/include/mbgl/style/variable_anchor_offset_collection.hpp
382383
${PROJECT_SOURCE_DIR}/include/mbgl/text/glyph.hpp
383384
${PROJECT_SOURCE_DIR}/include/mbgl/text/glyph_range.hpp
384385
${PROJECT_SOURCE_DIR}/include/mbgl/tile/tile_id.hpp
@@ -864,6 +865,7 @@ list(APPEND SRC_FILES
864865
${PROJECT_SOURCE_DIR}/src/mbgl/style/style_impl.cpp
865866
${PROJECT_SOURCE_DIR}/src/mbgl/style/style_impl.hpp
866867
${PROJECT_SOURCE_DIR}/src/mbgl/style/types.cpp
868+
${PROJECT_SOURCE_DIR}/src/mbgl/style/variable_anchor_offset_collection.cpp
867869
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_layer.cpp
868870
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_layer_render_parameters.cpp
869871
${PROJECT_SOURCE_DIR}/src/mbgl/layermanager/custom_layer_factory.cpp

bazel/core.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ MLN_CORE_SOURCE = [
511511
"src/mbgl/style/style_impl.cpp",
512512
"src/mbgl/style/style_impl.hpp",
513513
"src/mbgl/style/types.cpp",
514+
"src/mbgl/style/variable_anchor_offset_collection.cpp",
514515
"src/mbgl/text/bidi.hpp",
515516
"src/mbgl/text/check_max_angle.cpp",
516517
"src/mbgl/text/check_max_angle.hpp",
@@ -802,6 +803,7 @@ MLN_CORE_HEADERS = [
802803
"include/mbgl/style/transition_options.hpp",
803804
"include/mbgl/style/types.hpp",
804805
"include/mbgl/style/undefined.hpp",
806+
"include/mbgl/style/variable_anchor_offset_collection.hpp",
805807
"include/mbgl/text/glyph.hpp",
806808
"include/mbgl/text/glyph_range.hpp",
807809
"include/mbgl/tile/tile_id.hpp",

include/mbgl/gfx/shader_group.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ class ShaderGroup {
130130
/// @tparam T Derived type, inheriting `gfx::Shader`
131131
/// @param to Location to store the shader
132132
/// @return True if 'to' has a valid program object, false otherwise.
133-
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
134-
bool populate(std::shared_ptr<T>& to) noexcept {
133+
template <typename T>
134+
bool populate(std::shared_ptr<T>& to) noexcept
135+
requires(is_shader_v<T>)
136+
{
135137
if (to) {
136138
return true;
137139
}

include/mbgl/gfx/vertex_attribute.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ class VertexAttribute {
191191
}
192192

193193
template <std::size_t I = 0, typename... Tp>
194-
inline typename std::enable_if_t<I == sizeof...(Tp), void> set(std::size_t, std::tuple<Tp...>, std::size_t) {}
194+
inline void set(std::size_t, std::tuple<Tp...>, std::size_t)
195+
requires(I == sizeof...(Tp))
196+
{}
195197

196198
/// Set item value
197199
template <std::size_t I = 0, typename... Tp>
198-
inline typename std::enable_if_t <
199-
I<sizeof...(Tp), void> set(std::size_t i, std::tuple<Tp...> tuple, std::size_t tupleIndex) {
200+
inline void set(std::size_t i, std::tuple<Tp...> tuple, std::size_t tupleIndex)
201+
requires(I < sizeof...(Tp))
202+
{
200203
if (tupleIndex == 0) {
201204
set(i, std::get<I>(tuple).a1);
202205
} else {

include/mbgl/style/conversion/constant.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <mbgl/style/conversion.hpp>
44
#include <mbgl/style/types.hpp>
5+
#include <mbgl/style/variable_anchor_offset_collection.hpp>
56
#include <mbgl/util/color.hpp>
67
#include <mbgl/util/enum.hpp>
78
#include <mbgl/util/padding.hpp>
@@ -50,6 +51,11 @@ struct Converter<Padding> {
5051
std::optional<Padding> operator()(const Convertible& value, Error& error) const;
5152
};
5253

54+
template <>
55+
struct Converter<VariableAnchorOffsetCollection> {
56+
std::optional<VariableAnchorOffsetCollection> operator()(const Convertible& value, Error& error) const;
57+
};
58+
5359
template <size_t N>
5460
struct Converter<std::array<float, N>> {
5561
std::optional<std::array<float, N>> operator()(const Convertible& value, Error& error) const;

include/mbgl/style/conversion_impl.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,13 @@ struct ValueFactory<Padding> {
320320
static Value make(const Padding& padding) { return padding.serialize(); }
321321
};
322322

323+
template <>
324+
struct ValueFactory<VariableAnchorOffsetCollection> {
325+
static Value make(const VariableAnchorOffsetCollection& variableAnchorOffset) {
326+
return variableAnchorOffset.serialize();
327+
}
328+
};
329+
323330
template <typename T>
324331
struct ValueFactory<T, typename std::enable_if_t<(!std::is_enum_v<T> && !is_linear_container<T>::value)>> {
325332
static Value make(const T& arg) { return {arg}; }
@@ -370,6 +377,9 @@ StyleProperty makeStyleProperty(const PropertyValue<T>& value) {
370377
[](const Undefined&) -> StyleProperty { return {}; },
371378
[](const Color& c) -> StyleProperty { return {makeValue(c), StyleProperty::Kind::Expression}; },
372379
[](const Padding& p) -> StyleProperty { return {makeValue(p), StyleProperty::Kind::Expression}; },
380+
[](const VariableAnchorOffsetCollection& v) -> StyleProperty {
381+
return {makeValue(v), StyleProperty::Kind::Expression};
382+
},
373383
[](const PropertyExpression<T>& fn) -> StyleProperty {
374384
return {fn.getExpression().serialize(), StyleProperty::Kind::Expression};
375385
},

include/mbgl/style/expression/dsl.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ std::unique_ptr<Expression> boolean(std::unique_ptr<Expression>, std::unique_ptr
4343

4444
std::unique_ptr<Expression> toColor(std::unique_ptr<Expression>, std::unique_ptr<Expression> def = nullptr);
4545
std::unique_ptr<Expression> toPadding(std::unique_ptr<Expression> value, std::unique_ptr<Expression> def = nullptr);
46+
std::unique_ptr<Expression> toVariableAnchorOffset(std::unique_ptr<Expression>,
47+
std::unique_ptr<Expression> def = nullptr);
4648
std::unique_ptr<Expression> toString(std::unique_ptr<Expression>, std::unique_ptr<Expression> def = nullptr);
4749
std::unique_ptr<Expression> toFormatted(std::unique_ptr<Expression>, std::unique_ptr<Expression> def = nullptr);
4850
std::unique_ptr<Expression> toImage(std::unique_ptr<Expression>, std::unique_ptr<Expression> def = nullptr);

include/mbgl/style/expression/type.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ struct PaddingType {
5050
bool operator==(const PaddingType&) const { return true; }
5151
};
5252

53+
struct VariableAnchorOffsetCollectionType {
54+
constexpr VariableAnchorOffsetCollectionType() = default;
55+
std::string getName() const { return "variableAnchorOffsetCollection"; }
56+
bool operator==(const VariableAnchorOffsetCollectionType&) const { return true; }
57+
};
58+
5359
struct ObjectType {
5460
constexpr ObjectType() = default;
5561
std::string getName() const { return "object"; }
@@ -92,6 +98,7 @@ constexpr StringType String;
9298
constexpr BooleanType Boolean;
9399
constexpr ColorType Color;
94100
constexpr PaddingType Padding;
101+
constexpr VariableAnchorOffsetCollectionType VariableAnchorOffsetCollection;
95102
constexpr ValueType Value;
96103
constexpr ObjectType Object;
97104
constexpr CollatorType Collator;
@@ -107,6 +114,7 @@ using Type = variant<NullType,
107114
StringType,
108115
ColorType,
109116
PaddingType,
117+
VariableAnchorOffsetCollectionType,
110118
ObjectType,
111119
ValueType,
112120
mapbox::util::recursive_wrapper<Array>,

include/mbgl/style/expression/value.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <mbgl/style/position.hpp>
88
#include <mbgl/style/rotation.hpp>
99
#include <mbgl/style/types.hpp>
10+
#include <mbgl/style/variable_anchor_offset_collection.hpp>
1011
#include <mbgl/util/color.hpp>
1112
#include <mbgl/util/enum.hpp>
1213
#include <mbgl/util/feature.hpp>
@@ -28,6 +29,7 @@ using ValueBase = variant<NullValue,
2829
double,
2930
std::string,
3031
Color,
32+
VariableAnchorOffsetCollection,
3133
Collator,
3234
Formatted,
3335
Image,

include/mbgl/style/layers/layer.hpp.ejs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<% } -%>
2121
<% if (type === 'symbol') { -%>
2222
#include <mbgl/style/expression/formatted.hpp>
23+
#include <mbgl/style/variable_anchor_offset_collection.hpp>
2324
<% } -%>
2425
#include <mbgl/util/color.hpp>
2526

include/mbgl/style/layers/symbol_layer.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <mbgl/style/filter.hpp>
99
#include <mbgl/style/property_value.hpp>
1010
#include <mbgl/style/expression/formatted.hpp>
11+
#include <mbgl/style/variable_anchor_offset_collection.hpp>
1112
#include <mbgl/util/color.hpp>
1213

1314
#include <vector>
@@ -184,6 +185,10 @@ class SymbolLayer final : public Layer {
184185
const PropertyValue<std::vector<TextVariableAnchorType>>& getTextVariableAnchor() const;
185186
void setTextVariableAnchor(const PropertyValue<std::vector<TextVariableAnchorType>>&);
186187

188+
static PropertyValue<VariableAnchorOffsetCollection> getDefaultTextVariableAnchorOffset();
189+
const PropertyValue<VariableAnchorOffsetCollection>& getTextVariableAnchorOffset() const;
190+
void setTextVariableAnchorOffset(const PropertyValue<VariableAnchorOffsetCollection>&);
191+
187192
static PropertyValue<std::vector<TextWritingModeType>> getDefaultTextWritingMode();
188193
const PropertyValue<std::vector<TextWritingModeType>>& getTextWritingMode() const;
189194
void setTextWritingMode(const PropertyValue<std::vector<TextWritingModeType>>&);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#pragma once
2+
3+
#include <mbgl/style/types.hpp>
4+
#include <mbgl/util/feature.hpp>
5+
#include <mbgl/util/geometry.hpp>
6+
7+
#include <array>
8+
#include <string>
9+
#include <vector>
10+
11+
namespace mbgl {
12+
13+
struct AnchorOffsetPair {
14+
style::SymbolAnchorType anchorType;
15+
std::array<float, 2> offset;
16+
17+
AnchorOffsetPair(style::SymbolAnchorType anchorType_, std::array<float, 2> offset_)
18+
: anchorType(anchorType_),
19+
offset(offset_) {}
20+
21+
bool operator==(const AnchorOffsetPair& other) const = default;
22+
};
23+
24+
class VariableAnchorOffsetCollection {
25+
private:
26+
using CollectionType = std::vector<AnchorOffsetPair>;
27+
CollectionType anchorOffsets;
28+
29+
public:
30+
VariableAnchorOffsetCollection() = default;
31+
32+
VariableAnchorOffsetCollection(const VariableAnchorOffsetCollection& other) = default;
33+
34+
VariableAnchorOffsetCollection(VariableAnchorOffsetCollection&& other) noexcept = default;
35+
36+
VariableAnchorOffsetCollection(std::vector<AnchorOffsetPair>&& values) { anchorOffsets = std::move(values); }
37+
38+
std::array<float, 2> getOffsetByAnchor(const style::SymbolAnchorType& anchorType) const;
39+
40+
std::string toString() const;
41+
42+
mbgl::Value serialize() const;
43+
44+
bool empty() const { return anchorOffsets.size() == 0; }
45+
46+
CollectionType::size_type size() const { return anchorOffsets.size(); }
47+
48+
CollectionType::const_iterator begin() const { return anchorOffsets.begin(); }
49+
50+
CollectionType::const_iterator end() const { return anchorOffsets.end(); }
51+
52+
const AnchorOffsetPair& operator[](size_t index) const { return anchorOffsets[index]; }
53+
54+
VariableAnchorOffsetCollection& operator=(const VariableAnchorOffsetCollection& other) = default;
55+
56+
VariableAnchorOffsetCollection& operator=(VariableAnchorOffsetCollection&& other) noexcept = default;
57+
58+
bool operator==(const VariableAnchorOffsetCollection& other) const = default;
59+
};
60+
61+
} // namespace mbgl

include/mbgl/util/interpolate.hpp

+34
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
#include <mbgl/style/expression/value.hpp>
44
#include <mbgl/style/position.hpp>
55
#include <mbgl/style/rotation.hpp>
6+
#include <mbgl/style/types.hpp>
7+
#include <mbgl/style/variable_anchor_offset_collection.hpp>
8+
#include <mbgl/util/enum.hpp>
69
#include <mbgl/util/color.hpp>
710
#include <mbgl/util/range.hpp>
11+
#include <mbgl/util/string.hpp>
812

913
#include <array>
1014
#include <vector>
@@ -143,6 +147,36 @@ struct Interpolator<Padding> {
143147
}
144148
};
145149

150+
template <>
151+
struct Interpolator<VariableAnchorOffsetCollection> {
152+
public:
153+
VariableAnchorOffsetCollection operator()(const VariableAnchorOffsetCollection& a,
154+
const VariableAnchorOffsetCollection& b,
155+
const float t) const {
156+
if (a.size() != b.size()) {
157+
throw std::runtime_error("Cannot interpolate values of different length. from: " + a.toString() +
158+
", to: " + b.toString());
159+
}
160+
std::vector<AnchorOffsetPair> offsetMap;
161+
offsetMap.reserve(a.size());
162+
for (size_t index = 0; index < a.size(); index++) {
163+
const auto& aPair = a[index];
164+
const auto& bPair = b[index];
165+
if (aPair.anchorType != bPair.anchorType) {
166+
throw std::runtime_error(
167+
"Cannot interpolate values containing mismatched anchors. index: " + util::toString(index) +
168+
"from: " + Enum<style::SymbolAnchorType>::toString(aPair.anchorType) +
169+
", to: " + Enum<style::SymbolAnchorType>::toString(bPair.anchorType));
170+
}
171+
auto offset = std::array<float, 2>{interpolate(aPair.offset[0], bPair.offset[0], t),
172+
interpolate(aPair.offset[1], bPair.offset[1], t)};
173+
offsetMap.emplace_back(aPair.anchorType, offset);
174+
}
175+
176+
return VariableAnchorOffsetCollection(std::move(offsetMap));
177+
}
178+
};
179+
146180
template <>
147181
struct Interpolator<style::Rotation> {
148182
public:

0 commit comments

Comments
 (0)