From 5a752061fe9d84588d4bd70a37d1c3a861eaa206 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Fri, 9 Aug 2019 17:51:26 +0300 Subject: [core] Enable two-component text radial offset --- include/mbgl/style/conversion/constant.hpp | 5 +++ include/mbgl/style/expression/value.hpp | 7 ++++ include/mbgl/style/layers/symbol_layer.hpp | 6 +-- include/mbgl/style/types.hpp | 7 ++++ mapbox-gl-js | 2 +- .../mapboxsdk/style/layers/PropertyFactory.java | 10 ++--- .../mapbox/mapboxsdk/style/layers/SymbolLayer.java | 6 +-- .../mapboxsdk/testapp/style/SymbolLayerTest.java | 2 +- platform/android/src/conversion/constant.hpp | 4 ++ scripts/generate-style-code.js | 3 ++ scripts/style-spec.js | 1 + src/mbgl/layout/symbol_instance.cpp | 2 +- src/mbgl/layout/symbol_instance.hpp | 4 +- src/mbgl/layout/symbol_layout.cpp | 45 +++++++++++++++------- src/mbgl/layout/symbol_layout.hpp | 2 +- src/mbgl/style/conversion/constant.cpp | 18 +++++++++ src/mbgl/style/conversion/function.cpp | 4 ++ src/mbgl/style/conversion/property_value.cpp | 1 + src/mbgl/style/expression/value.cpp | 20 ++++++++++ src/mbgl/style/layers/symbol_layer.cpp | 25 +++++++----- src/mbgl/style/layers/symbol_layer_properties.hpp | 4 +- src/mbgl/text/placement.cpp | 4 +- src/mbgl/text/placement.hpp | 2 +- test/text/cross_tile_symbol_index.test.cpp | 2 +- 24 files changed, 140 insertions(+), 46 deletions(-) diff --git a/include/mbgl/style/conversion/constant.hpp b/include/mbgl/style/conversion/constant.hpp index 3a5833be64..f82029c885 100644 --- a/include/mbgl/style/conversion/constant.hpp +++ b/include/mbgl/style/conversion/constant.hpp @@ -59,6 +59,11 @@ struct Converter> { optional> operator()(const Convertible& value, Error& error) const; }; +template <> +struct Converter { + optional operator()(const Convertible& value, Error& error) const; +}; + } // namespace conversion } // namespace style } // namespace mbgl diff --git a/include/mbgl/style/expression/value.hpp b/include/mbgl/style/expression/value.hpp index 91239d083f..5cb0535184 100644 --- a/include/mbgl/style/expression/value.hpp +++ b/include/mbgl/style/expression/value.hpp @@ -113,6 +113,13 @@ struct ValueConverter> { static optional> fromExpressionValue(const Value& value); }; +template <> +struct ValueConverter { + static type::Type expressionType() { return type::Array(type::Number); } + static Value toExpressionValue(const mbgl::style::RadialOffsetType& value); + static optional fromExpressionValue(const Value& v); +}; + template <> struct ValueConverter { static type::Type expressionType() { return type::Array(type::Number, 3); } diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index 2493df6046..ee0c91fd14 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -162,9 +162,9 @@ public: const PropertyValue& getTextPitchAlignment() const; void setTextPitchAlignment(const PropertyValue&); - static PropertyValue getDefaultTextRadialOffset(); - const PropertyValue& getTextRadialOffset() const; - void setTextRadialOffset(const PropertyValue&); + static PropertyValue getDefaultTextRadialOffset(); + const PropertyValue& getTextRadialOffset() const; + void setTextRadialOffset(const PropertyValue&); static PropertyValue getDefaultTextRotate(); const PropertyValue& getTextRotate() const; diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index 13a2e50f01..06e549e37d 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace mbgl { @@ -120,5 +121,11 @@ enum class LightAnchorType: bool { Viewport }; +class RadialOffsetType: public std::vector { +public: + template + RadialOffsetType(Args&&... args) : std::vector(std::forward(args)...) {} +}; + } // namespace style } // namespace mbgl diff --git a/mapbox-gl-js b/mapbox-gl-js index 3abd5d518b..6d54ca6870 160000 --- a/mapbox-gl-js +++ b/mapbox-gl-js @@ -1 +1 @@ -Subproject commit 3abd5d518bade8d83eb609598b861432a83f8693 +Subproject commit 6d54ca68702ab1db707f372d0f7b49ddcd1fadf1 diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java index 3f2771a307..dc35fb85cc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java @@ -2298,18 +2298,18 @@ public class PropertyFactory { /** * Radial offset of text, in the direction of the symbol's anchor. Useful in combination with {@link PropertyFactory#textVariableAnchor}, which doesn't support the two-dimensional {@link PropertyFactory#textOffset}. * - * @param value a Float value - * @return property wrapper around Float + * @param value a Float[] value + * @return property wrapper around Float[] */ - public static PropertyValue textRadialOffset(Float value) { + public static PropertyValue textRadialOffset(Float[] value) { return new LayoutPropertyValue<>("text-radial-offset", value); } /** * Radial offset of text, in the direction of the symbol's anchor. Useful in combination with {@link PropertyFactory#textVariableAnchor}, which doesn't support the two-dimensional {@link PropertyFactory#textOffset}. * - * @param value a Float value - * @return property wrapper around Float + * @param value a Float[] value + * @return property wrapper around Float[] */ public static PropertyValue textRadialOffset(Expression value) { return new LayoutPropertyValue<>("text-radial-offset", value); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java index 1d8bad7e8e..89d1ffd0cc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java @@ -484,13 +484,13 @@ public class SymbolLayer extends Layer { /** * Get the TextRadialOffset property * - * @return property wrapper value around Float + * @return property wrapper value around Float[] */ @NonNull @SuppressWarnings("unchecked") - public PropertyValue getTextRadialOffset() { + public PropertyValue getTextRadialOffset() { checkThread(); - return (PropertyValue) new PropertyValue("text-radial-offset", nativeGetTextRadialOffset()); + return (PropertyValue) new PropertyValue("text-radial-offset", nativeGetTextRadialOffset()); } /** diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index 60e305d607..515962e325 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java @@ -611,7 +611,7 @@ public class SymbolLayerTest extends BaseLayerTest { assertNull(layer.getTextRadialOffset().getValue()); // Set and Get - Float propertyValue = 0.3f; + Float[] propertyValue = new Float[] {}; layer.setProperties(textRadialOffset(propertyValue)); assertEquals(layer.getTextRadialOffset().getValue(), propertyValue); } diff --git a/platform/android/src/conversion/constant.hpp b/platform/android/src/conversion/constant.hpp index 839e6e84dc..298fb7faa1 100644 --- a/platform/android/src/conversion/constant.hpp +++ b/platform/android/src/conversion/constant.hpp @@ -81,6 +81,10 @@ struct Converter>, std::vector> { Result>> operator()(jni::JNIEnv& env, const std::vector& value) const; }; +template <> +struct Converter>, style::RadialOffsetType> : public Converter>, std::vector> { +}; + template struct Converter>, T, typename std::enable_if_t::value>> { Result>> operator()(jni::JNIEnv& env, const T& value) const { diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index 1f26e6fd86..04ace18354 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -60,6 +60,9 @@ global.evaluatedType = function (property) { if (/position/.test(property.name)) { return 'Position'; } + if (/-radial-offset/.test(property.name)) { + return 'RadialOffsetType'; + } switch (property.type) { case 'boolean': return 'bool'; diff --git a/scripts/style-spec.js b/scripts/style-spec.js index 8a9c9d4144..3d7ea605d5 100644 --- a/scripts/style-spec.js +++ b/scripts/style-spec.js @@ -1 +1,2 @@ var spec = module.exports = require('../mapbox-gl-js/src/style-spec/reference/v8'); +delete spec.layout_symbol['text-writing-mode']; diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp index 133cdec698..da26c26b59 100644 --- a/src/mbgl/layout/symbol_instance.cpp +++ b/src/mbgl/layout/symbol_instance.cpp @@ -81,7 +81,7 @@ SymbolInstance::SymbolInstance(Anchor& anchor_, std::u16string key_, const float overscaling, const float rotate, - float radialTextOffset_) : + Point radialTextOffset_) : sharedData(std::move(sharedData_)), anchor(anchor_), // 'hasText' depends on finding at least one glyph in the shaping that's also in the GlyphPositionMap diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp index 48bb2f0cbc..c0fe5177cf 100644 --- a/src/mbgl/layout/symbol_instance.hpp +++ b/src/mbgl/layout/symbol_instance.hpp @@ -59,7 +59,7 @@ public: std::u16string key, const float overscaling, const float rotate, - float radialTextOffset); + Point radialTextOffset); optional getDefaultHorizontalPlacedTextIndex() const; const GeometryCoordinates& line() const; @@ -98,7 +98,7 @@ public: optional placedVerticalTextIndex; optional placedIconIndex; float textBoxScale; - float radialTextOffset; + Point radialTextOffset; bool singleLine; uint32_t crossTileID = 0; }; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index d269ca4144..6548281a06 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -225,26 +225,27 @@ Shaping& shapingForTextJustifyType(ShapedTextOrientations& shapedTextOrientation } // namespace // static -Point SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float radialOffset) { +Point SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, Point radialOffset) { Point result{}; // solve for r where r^2 + r^2 = radialOffset^2 const float sqrt2 = 1.41421356237f; - const float hypotenuse = radialOffset / sqrt2; + const float hypotenuseX = radialOffset.x / sqrt2; + const float hypotenuseY = radialOffset.y / sqrt2; switch (anchor) { case SymbolAnchorType::TopRight: case SymbolAnchorType::TopLeft: - result.y = hypotenuse - baselineOffset; + result.y = hypotenuseY - baselineOffset; break; case SymbolAnchorType::BottomRight: case SymbolAnchorType::BottomLeft: - result.y = -hypotenuse + baselineOffset; + result.y = -hypotenuseY + baselineOffset; break; case SymbolAnchorType::Bottom: - result.y = -radialOffset + baselineOffset; + result.y = -radialOffset.y + baselineOffset; break; case SymbolAnchorType::Top: - result.y = radialOffset - baselineOffset; + result.y = radialOffset.y - baselineOffset; break; default: break; @@ -253,17 +254,17 @@ Point SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float r switch (anchor) { case SymbolAnchorType::TopRight: case SymbolAnchorType::BottomRight: - result.x = -hypotenuse; + result.x = -hypotenuseX; break; case SymbolAnchorType::TopLeft: case SymbolAnchorType::BottomLeft: - result.x = hypotenuse; + result.x = hypotenuseX; break; case SymbolAnchorType::Left: - result.x = radialOffset; + result.x = radialOffset.x; break; case SymbolAnchorType::Right: - result.x = -radialOffset; + result.x = -radialOffset.x; break; default: break; @@ -272,6 +273,22 @@ Point SymbolLayout::evaluateRadialOffset(SymbolAnchorType anchor, float r return result; } +namespace { + +Point handleRadialTextOffset(const std::vector& value) { + switch (value.size()) + { + case 0: + return { 0.0f, 0.0f }; + case 1: + return { value[0] * util::ONE_EM, value[0] * util::ONE_EM }; + default: + return { value[0] * util::ONE_EM, value[1] * util::ONE_EM }; + }; +} + +} // namespace + void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions& glyphPositions, const ImageMap& imageMap, const ImagePositions& imagePositions) { const bool isPointPlacement = layout->get() == SymbolPlacementType::Point; @@ -306,15 +323,15 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions return result; }; const std::vector variableTextAnchor = layout->evaluate(zoom, feature); - const float radialOffset = layout->evaluate(zoom, feature); + const Point radialOffset = handleRadialTextOffset(layout->evaluate(zoom, feature)); const SymbolAnchorType textAnchor = layout->evaluate(zoom, feature); if (variableTextAnchor.empty()) { // Layers with variable anchors use the `text-radial-offset` property and the [x, y] offset vector // is calculated at placement time instead of layout time - if (radialOffset > 0.0f) { + if (radialOffset.x > 0.0f && radialOffset.y > 0.0f) { // The style spec says don't use `text-offset` and `text-radial-offset` together // but doesn't actually specify what happens if you use both. We go with the radial offset. - textOffset = evaluateRadialOffset(textAnchor, radialOffset * util::ONE_EM); + textOffset = evaluateRadialOffset(textAnchor, radialOffset); } else { textOffset = { layout->evaluate(zoom, feature)[0] * util::ONE_EM, layout->evaluate(zoom, feature)[1] * util::ONE_EM}; @@ -424,7 +441,7 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex, const float iconPadding = layout->get() * tilePixelRatio; const float textMaxAngle = layout->get() * util::DEG2RAD; const float rotation = layout->evaluate(zoom, feature); - const float radialTextOffset = layout->evaluate(zoom, feature) * util::ONE_EM; + const Point radialTextOffset = handleRadialTextOffset(layout->evaluate(zoom, feature)); const SymbolPlacementType textPlacement = layout->get() != AlignmentType::Map ? SymbolPlacementType::Point : layout->get(); diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 581c3ccb04..82bbc1179b 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -45,7 +45,7 @@ public: const std::string bucketLeaderID; std::vector symbolInstances; - static Point evaluateRadialOffset(style::SymbolAnchorType anchor, float radialOffset); + static Point evaluateRadialOffset(style::SymbolAnchorType anchor, Point radialOffset); private: void addFeature(const size_t, diff --git a/src/mbgl/style/conversion/constant.cpp b/src/mbgl/style/conversion/constant.cpp index 0fcaab433b..0ed5fad425 100644 --- a/src/mbgl/style/conversion/constant.cpp +++ b/src/mbgl/style/conversion/constant.cpp @@ -168,6 +168,24 @@ optional> Converter>::operator return result; } +optional Converter::operator()(const Convertible& value, Error& error) const { + Converter> arrayConverter; + if (auto val = arrayConverter(value, error)) { + RadialOffsetType result = std::move(*val); + return result; + } + + Converter numberConverter; + if (auto val = numberConverter(value, error)) { + RadialOffsetType result(2, *val); + return result; + } + + error.message = "value must be an array of numbers or a number"; + + return nullopt; +} + } // namespace conversion } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp index 086bc4e277..ade5a5dc5e 100644 --- a/src/mbgl/style/conversion/function.cpp +++ b/src/mbgl/style/conversion/function.cpp @@ -153,6 +153,10 @@ template optional> template optional> convertFunctionToExpression(const Convertible&, Error&, bool); +template optional> + convertFunctionToExpression(const Convertible&, Error&, bool); + + // Ad-hoc Converters for double and int64_t. We should replace float with double wholesale, // and promote the int64_t Converter to general use (and it should check that the input is // an integer). diff --git a/src/mbgl/style/conversion/property_value.cpp b/src/mbgl/style/conversion/property_value.cpp index 6e1d747324..91e61ec5cb 100644 --- a/src/mbgl/style/conversion/property_value.cpp +++ b/src/mbgl/style/conversion/property_value.cpp @@ -80,6 +80,7 @@ template optional> Converter> Converter>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; template optional> Converter>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; template optional> Converter>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; +template optional> Converter>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; } // namespace conversion } // namespace style diff --git a/src/mbgl/style/expression/value.cpp b/src/mbgl/style/expression/value.cpp index 7e11efaa09..6fce98e4d6 100644 --- a/src/mbgl/style/expression/value.cpp +++ b/src/mbgl/style/expression/value.cpp @@ -276,6 +276,22 @@ optional ValueConverter::fromExpressionValue(const Value& v) return pos ? optional(Position(*pos)) : optional(); } +Value ValueConverter::toExpressionValue(const mbgl::style::RadialOffsetType& value) { + return ValueConverter>::toExpressionValue(value); +} + +optional ValueConverter::fromExpressionValue(const Value& v) { + if (auto val = ValueConverter>::fromExpressionValue(v)) { + RadialOffsetType result(std::move(*val)); + return result; + } + if (auto val = ValueConverter::fromExpressionValue(v)) { + RadialOffsetType result(2, *val); + return result; + } + return nullopt; +} + template Value ValueConverter::value >>::toExpressionValue(const T& value) { return std::string(Enum::toString(value)); @@ -374,6 +390,10 @@ template struct ValueConverter; template type::Type valueTypeToExpressionType(); template struct ValueConverter; +template<> type::Type valueTypeToExpressionType() { + return valueTypeToExpressionType>(); +} + } // namespace expression } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 6748fbd4aa..c5a32acd12 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -605,15 +605,15 @@ void SymbolLayer::setTextPitchAlignment(const PropertyValue& valu baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -PropertyValue SymbolLayer::getDefaultTextRadialOffset() { +PropertyValue SymbolLayer::getDefaultTextRadialOffset() { return TextRadialOffset::defaultValue(); } -const PropertyValue& SymbolLayer::getTextRadialOffset() const { +const PropertyValue& SymbolLayer::getTextRadialOffset() const { return impl().layout.get(); } -void SymbolLayer::setTextRadialOffset(const PropertyValue& value) { +void SymbolLayer::setTextRadialOffset(const PropertyValue& value) { if (value == getTextRadialOffset()) return; auto impl_ = mutableImpl(); @@ -1606,7 +1606,7 @@ optional SymbolLayer::setLayoutProperty(const std::string& name, const Co } - if (property == Property::IconRotate || property == Property::IconSize || property == Property::SymbolSortKey || property == Property::TextLetterSpacing || property == Property::TextMaxWidth || property == Property::TextRadialOffset || property == Property::TextRotate || property == Property::TextSize) { + if (property == Property::IconRotate || property == Property::IconSize || property == Property::SymbolSortKey || property == Property::TextLetterSpacing || property == Property::TextMaxWidth || property == Property::TextRotate || property == Property::TextSize) { Error error; optional> typedValue = convert>(value, error, true, false); if (!typedValue) { @@ -1638,11 +1638,6 @@ optional SymbolLayer::setLayoutProperty(const std::string& name, const Co return nullopt; } - if (property == Property::TextRadialOffset) { - setTextRadialOffset(*typedValue); - return nullopt; - } - if (property == Property::TextRotate) { setTextRotate(*typedValue); return nullopt; @@ -1739,6 +1734,18 @@ optional SymbolLayer::setLayoutProperty(const std::string& name, const Co } + if (property == Property::TextRadialOffset) { + Error error; + optional> typedValue = convert>(value, error, true, false); + if (!typedValue) { + return error; + } + + setTextRadialOffset(*typedValue); + return nullopt; + + } + if (property == Property::TextTransform) { Error error; optional> typedValue = convert>(value, error, true, false); diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp index 0c2bcd2661..4215819abe 100644 --- a/src/mbgl/style/layers/symbol_layer_properties.hpp +++ b/src/mbgl/style/layers/symbol_layer_properties.hpp @@ -184,9 +184,9 @@ struct TextPitchAlignment : LayoutProperty { static AlignmentType defaultValue() { return AlignmentType::Auto; } }; -struct TextRadialOffset : DataDrivenLayoutProperty { +struct TextRadialOffset : DataDrivenLayoutProperty { static constexpr const char *name() { return "text-radial-offset"; } - static float defaultValue() { return 0; } + static RadialOffsetType defaultValue() { return { 0, 0 }; } }; struct TextRotate : DataDrivenLayoutProperty { diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index f7d13dcb26..c28842069a 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -85,7 +85,7 @@ void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix, boo } namespace { -Point calculateVariableLayoutOffset(style::SymbolAnchorType anchor, float width, float height, float radialOffset, float textBoxScale) { +Point calculateVariableLayoutOffset(style::SymbolAnchorType anchor, float width, float height, Point radialOffset, float textBoxScale) { AnchorAlignment alignment = AnchorAlignment::getAnchorAlignment(anchor); float shiftX = -(alignment.horizontalAlign - 0.5f) * width; float shiftY = -(alignment.verticalAlign - 0.5f) * height; @@ -410,7 +410,7 @@ void Placement::updateLayerBuckets(const RenderLayer& layer, const TransformStat } namespace { -Point calculateVariableRenderShift(style::SymbolAnchorType anchor, float width, float height, float radialOffset, float textBoxScale, float renderTextSize) { +Point calculateVariableRenderShift(style::SymbolAnchorType anchor, float width, float height, Point radialOffset, float textBoxScale, float renderTextSize) { AnchorAlignment alignment = AnchorAlignment::getAnchorAlignment(anchor); float shiftX = -(alignment.horizontalAlign - 0.5f) * width; float shiftY = -(alignment.verticalAlign - 0.5f) * height; diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp index 2a6a2e1d6e..6a372c1a58 100644 --- a/src/mbgl/text/placement.hpp +++ b/src/mbgl/text/placement.hpp @@ -33,7 +33,7 @@ public: class VariableOffset { public: - float radialOffset; + Point radialOffset; float width; float height; style::TextVariableAnchorType anchor; diff --git a/test/text/cross_tile_symbol_index.test.cpp b/test/text/cross_tile_symbol_index.test.cpp index 7cef287b00..e0979b8835 100644 --- a/test/text/cross_tile_symbol_index.test.cpp +++ b/test/text/cross_tile_symbol_index.test.cpp @@ -18,7 +18,7 @@ SymbolInstance makeSymbolInstance(float x, float y, std::u16string key) { auto sharedData = std::make_shared(std::move(line), shaping, nullopt, layout_, 0.0f, placementType, textOffset, positions); - return SymbolInstance(anchor, std::move(sharedData), shaping, nullopt, 0, 0, placementType, textOffset, 0, 0, iconOffset, subfeature, 0, 0, key, 0, 0, 0.0f); + return SymbolInstance(anchor, std::move(sharedData), shaping, nullopt, 0, 0, placementType, textOffset, 0, 0, iconOffset, subfeature, 0, 0, key, 0, 0, Point()); } -- cgit v1.2.1