[core] Eliminate use of ClassProperties for layout

This commit is contained in:
John Firebaugh
2015-10-26 10:14:24 -07:00
parent 728a9858ea
commit a562567589
33 changed files with 237 additions and 323 deletions

View File

@@ -24,10 +24,6 @@ public:
} }
}; };
class FillLayoutProperties {
public:
};
class LinePaintProperties { class LinePaintProperties {
public: public:
float opacity = 1.0f; float opacity = 1.0f;
@@ -46,14 +42,6 @@ public:
} }
}; };
class LineLayoutProperties {
public:
CapType cap = CapType::Butt;
JoinType join = JoinType::Miter;
float miter_limit = 2.0f;
float round_limit = 1.0f;
};
class SymbolPaintProperties { class SymbolPaintProperties {
public: public:
struct { struct {
@@ -84,50 +72,6 @@ public:
} }
}; };
class SymbolLayoutProperties {
public:
PlacementType placement = PlacementType::Point;
float spacing = 250.0f;
bool avoid_edges = false;
struct {
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
float size = 1.0f;
float max_size = 1.0f;
std::string image;
float rotate = 0.0f;
float padding = 2.0f;
bool keep_upright = false;
std::array<float, 2> offset = {{ 0, 0 }};
} icon;
struct {
RotationAlignmentType rotation_alignment = RotationAlignmentType::Viewport;
std::string field;
std::string font = "Open Sans Regular, Arial Unicode MS Regular";
float size = 16.0f;
float max_size = 16.0f;
float max_width = 15.0f /* em */;
float line_height = 1.2f /* em */;
float letter_spacing = 0.0f /* em */;
TextJustifyType justify = TextJustifyType::Center;
TextAnchorType anchor = TextAnchorType::Center;
float max_angle = 45.0f /* degrees */;
float rotate = 0.0f;
float padding = 2.0f;
bool keep_upright = true;
TextTransformType transform = TextTransformType::None;
std::array<float, 2> offset = {{ 0, 0 }};
bool allow_overlap = false;
bool ignore_placement = false;
bool optional = false;
} text;
};
class CirclePaintProperties { class CirclePaintProperties {
public: public:
float radius = 5.0f; float radius = 5.0f;
@@ -156,10 +100,6 @@ public:
} }
}; };
class RasterLayoutProperties {
public:
};
class BackgroundPaintProperties { class BackgroundPaintProperties {
public: public:
float opacity = 1.0f; float opacity = 1.0f;
@@ -171,10 +111,6 @@ public:
} }
}; };
class BackgroundLayoutProperties {
public:
};
} }
#endif #endif

View File

@@ -120,8 +120,8 @@ void AnnotationManager::updateStyle(Style& style) {
layer->source = SourceID; layer->source = SourceID;
layer->sourceLayer = PointLayerID; layer->sourceLayer = PointLayerID;
layer->layout.set(PropertyKey::IconImage, Function<std::string>("{sprite}")); layer->layout.icon.image = std::string("{sprite}");
layer->layout.set(PropertyKey::IconAllowOverlap, Function<bool>(true)); layer->layout.icon.allowOverlap = true;
style.addLayer(std::move(layer)); style.addLayer(std::move(layer));
} }

View File

@@ -31,8 +31,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) {
std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>(); std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>();
layer->type = StyleLayerType::Line; layer->type = StyleLayerType::Line;
layer->layout.join = JoinType::Round;
layer->layout.set(PropertyKey::LineJoin, Function<JoinType>(JoinType::Round));
const LinePaintProperties& properties = shape.properties.get<LinePaintProperties>(); const LinePaintProperties& properties = shape.properties.get<LinePaintProperties>();
ClassProperties paintProperties; ClassProperties paintProperties;

View File

@@ -7,7 +7,6 @@ namespace mbgl {
std::unique_ptr<StyleLayer> BackgroundLayer::clone() const { std::unique_ptr<StyleLayer> BackgroundLayer::clone() const {
std::unique_ptr<BackgroundLayer> result = std::make_unique<BackgroundLayer>(); std::unique_ptr<BackgroundLayer> result = std::make_unique<BackgroundLayer>();
result->copy(*this); result->copy(*this);
result->layout = layout;
result->paints.paints = paints.paints; result->paints.paints = paints.paints;
return std::move(result); return std::move(result);
} }

View File

@@ -4,7 +4,6 @@
#include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp> #include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/class_properties.hpp>
namespace mbgl { namespace mbgl {
@@ -22,7 +21,6 @@ public:
bool hasTransitions() const override; bool hasTransitions() const override;
ClassProperties layout;
PaintPropertiesMap paints; PaintPropertiesMap paints;
BackgroundPaintProperties properties; BackgroundPaintProperties properties;

View File

@@ -8,7 +8,6 @@ namespace mbgl {
std::unique_ptr<StyleLayer> CircleLayer::clone() const { std::unique_ptr<StyleLayer> CircleLayer::clone() const {
std::unique_ptr<CircleLayer> result = std::make_unique<CircleLayer>(); std::unique_ptr<CircleLayer> result = std::make_unique<CircleLayer>();
result->copy(*this); result->copy(*this);
result->layout = layout;
result->paints.paints = paints.paints; result->paints.paints = paints.paints;
return std::move(result); return std::move(result);
} }

View File

@@ -4,7 +4,6 @@
#include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp> #include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/class_properties.hpp>
namespace mbgl { namespace mbgl {
@@ -22,7 +21,6 @@ public:
bool hasTransitions() const override; bool hasTransitions() const override;
ClassProperties layout;
PaintPropertiesMap paints; PaintPropertiesMap paints;
CirclePaintProperties properties; CirclePaintProperties properties;

View File

@@ -8,7 +8,6 @@ namespace mbgl {
std::unique_ptr<StyleLayer> FillLayer::clone() const { std::unique_ptr<StyleLayer> FillLayer::clone() const {
std::unique_ptr<FillLayer> result = std::make_unique<FillLayer>(); std::unique_ptr<FillLayer> result = std::make_unique<FillLayer>();
result->copy(*this); result->copy(*this);
result->layout = layout;
result->paints.paints = paints.paints; result->paints.paints = paints.paints;
return std::move(result); return std::move(result);
} }

View File

@@ -4,7 +4,6 @@
#include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp> #include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/class_properties.hpp>
namespace mbgl { namespace mbgl {
@@ -22,7 +21,6 @@ public:
bool hasTransitions() const override; bool hasTransitions() const override;
ClassProperties layout;
PaintPropertiesMap paints; PaintPropertiesMap paints;
FillPaintProperties properties; FillPaintProperties properties;

View File

@@ -15,10 +15,10 @@ std::unique_ptr<StyleLayer> LineLayer::clone() const {
} }
void LineLayer::parseLayout(const JSVal& value) { void LineLayer::parseLayout(const JSVal& value) {
parseProperty<Function<CapType>>("line-cap", PropertyKey::LineCap, layout, value); layout.cap.parse("line-cap", value);
parseProperty<Function<JoinType>>("line-join", PropertyKey::LineJoin, layout, value); layout.join.parse("line-join", value);
parseProperty<Function<float>>("line-miter-limit", PropertyKey::LineMiterLimit, layout, value); layout.miterLimit.parse("line-miter-limit", value);
parseProperty<Function<float>>("line-round-limit", PropertyKey::LineRoundLimit, layout, value); layout.roundLimit.parse("line-round-limit", value);
} }
void LineLayer::parsePaints(const JSVal& layer) { void LineLayer::parsePaints(const JSVal& layer) {
@@ -73,12 +73,13 @@ void LineLayer::recalculate(const StyleCalculationParameters& parameters) {
std::unique_ptr<Bucket> LineLayer::createBucket(StyleBucketParameters& parameters) const { std::unique_ptr<Bucket> LineLayer::createBucket(StyleBucketParameters& parameters) const {
auto bucket = std::make_unique<LineBucket>(); auto bucket = std::make_unique<LineBucket>();
const float z = parameters.tileID.z; bucket->layout = layout;
layout.calculate(PropertyKey::LineCap, bucket->layout.cap, z); StyleCalculationParameters p(parameters.tileID.z);
layout.calculate(PropertyKey::LineJoin, bucket->layout.join, z); bucket->layout.cap.calculate(p);
layout.calculate(PropertyKey::LineMiterLimit, bucket->layout.miter_limit, z); bucket->layout.join.calculate(p);
layout.calculate(PropertyKey::LineRoundLimit, bucket->layout.round_limit, z); bucket->layout.miterLimit.calculate(p);
bucket->layout.roundLimit.calculate(p);
parameters.eachFilteredFeature(filter, [&] (const auto& feature) { parameters.eachFilteredFeature(filter, [&] (const auto& feature) {
bucket->addGeometry(feature.getGeometries()); bucket->addGeometry(feature.getGeometries());

View File

@@ -4,10 +4,18 @@
#include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp> #include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/class_properties.hpp> #include <mbgl/style/layout_property.hpp>
namespace mbgl { namespace mbgl {
class LineLayoutProperties {
public:
LayoutProperty<CapType> cap = CapType::Butt;
LayoutProperty<JoinType> join = JoinType::Miter;
LayoutProperty<float> miterLimit = 2.0f;
LayoutProperty<float> roundLimit = 1.0f;
};
class LineLayer : public StyleLayer { class LineLayer : public StyleLayer {
public: public:
std::unique_ptr<StyleLayer> clone() const override; std::unique_ptr<StyleLayer> clone() const override;
@@ -22,7 +30,7 @@ public:
bool hasTransitions() const override; bool hasTransitions() const override;
ClassProperties layout; LineLayoutProperties layout;
PaintPropertiesMap paints; PaintPropertiesMap paints;
LinePaintProperties properties; LinePaintProperties properties;

View File

@@ -7,7 +7,6 @@ namespace mbgl {
std::unique_ptr<StyleLayer> RasterLayer::clone() const { std::unique_ptr<StyleLayer> RasterLayer::clone() const {
std::unique_ptr<RasterLayer> result = std::make_unique<RasterLayer>(); std::unique_ptr<RasterLayer> result = std::make_unique<RasterLayer>();
result->copy(*this); result->copy(*this);
result->layout = layout;
result->paints.paints = paints.paints; result->paints.paints = paints.paints;
return std::move(result); return std::move(result);
} }

View File

@@ -4,7 +4,6 @@
#include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp> #include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/class_properties.hpp>
namespace mbgl { namespace mbgl {
@@ -22,7 +21,6 @@ public:
bool hasTransitions() const override; bool hasTransitions() const override;
ClassProperties layout;
PaintPropertiesMap paints; PaintPropertiesMap paints;
RasterPaintProperties properties; RasterPaintProperties properties;

View File

@@ -16,45 +16,45 @@ std::unique_ptr<StyleLayer> SymbolLayer::clone() const {
} }
void SymbolLayer::parseLayout(const JSVal& value) { void SymbolLayer::parseLayout(const JSVal& value) {
parseProperty<Function<PlacementType>>("symbol-placement", PropertyKey::SymbolPlacement, layout, value); layout.placement.parse("symbol-placement", value);
parseProperty<Function<float>>("symbol-spacing", PropertyKey::SymbolSpacing, layout, value); layout.spacing.parse("symbol-spacing", value);
parseProperty<Function<bool>>("symbol-avoid-edges", PropertyKey::SymbolAvoidEdges, layout, value); layout.avoidEdges.parse("symbol-avoid-edges", value);
parseProperty<Function<bool>>("icon-allow-overlap", PropertyKey::IconAllowOverlap, layout, value);
parseProperty<Function<bool>>("icon-ignore-placement", PropertyKey::IconIgnorePlacement, layout, value); layout.icon.allowOverlap.parse("icon-allow-overlap", value);
parseProperty<Function<bool>>("icon-optional", PropertyKey::IconOptional, layout, value); layout.icon.ignorePlacement.parse("icon-ignore-placement", value);
parseProperty<Function<RotationAlignmentType>>("icon-rotation-alignment", PropertyKey::IconRotationAlignment, layout, value); layout.icon.optional.parse("icon-optional", value);
parseProperty<Function<float>>("icon-size", PropertyKey::IconSize, layout, value); layout.icon.rotationAlignment.parse("icon-rotation-alignment", value);
parseProperty<Function<std::string>>("icon-image", PropertyKey::IconImage, layout, value); layout.icon.size.parse("icon-size", value);
parseProperty<Function<float>>("icon-rotate", PropertyKey::IconRotate, layout, value); layout.icon.image.parse("icon-image", value);
parseProperty<Function<float>>("icon-padding", PropertyKey::IconPadding, layout, value); layout.icon.rotate.parse("icon-rotate", value);
parseProperty<Function<bool>>("icon-keep-upright", PropertyKey::IconKeepUpright, layout, value); layout.icon.padding.parse("icon-padding", value);
parseProperty<Function<std::array<float, 2>>>("icon-offset", PropertyKey::IconOffset, layout, value); layout.icon.keepUpright.parse("icon-keep-upright", value);
parseProperty<Function<RotationAlignmentType>>("text-rotation-alignment", PropertyKey::TextRotationAlignment, layout, value); layout.icon.offset.parse("icon-offset", value);
parseProperty<Function<std::string>>("text-field", PropertyKey::TextField, layout, value);
parseProperty<Function<std::string>>("text-font", PropertyKey::TextFont, layout, value); layout.text.rotationAlignment.parse("text-rotation-alignment", value);
parseProperty<Function<float>>("text-size", PropertyKey::TextSize, layout, value); layout.text.field.parse("text-field", value);
parseProperty<Function<float>>("text-max-width", PropertyKey::TextMaxWidth, layout, value); layout.text.font.parse("text-font", value);
parseProperty<Function<float>>("text-line-height", PropertyKey::TextLineHeight, layout, value); layout.text.size.parse("text-size", value);
parseProperty<Function<float>>("text-letter-spacing", PropertyKey::TextLetterSpacing, layout, value); layout.text.maxWidth.parse("text-max-width", value);
parseProperty<Function<TextJustifyType>>("text-justify", PropertyKey::TextJustify, layout, value); layout.text.lineHeight.parse("text-line-height", value);
parseProperty<Function<TextAnchorType>>("text-anchor", PropertyKey::TextAnchor, layout, value); layout.text.letterSpacing.parse("text-letter-spacing", value);
parseProperty<Function<float>>("text-max-angle", PropertyKey::TextMaxAngle, layout, value); layout.text.justify.parse("text-justify", value);
parseProperty<Function<float>>("text-rotate", PropertyKey::TextRotate, layout, value); layout.text.anchor.parse("text-anchor", value);
parseProperty<Function<float>>("text-padding", PropertyKey::TextPadding, layout, value); layout.text.maxAngle.parse("text-max-angle", value);
parseProperty<Function<bool>>("text-keep-upright", PropertyKey::TextKeepUpright, layout, value); layout.text.rotate.parse("text-rotate", value);
parseProperty<Function<TextTransformType>>("text-transform", PropertyKey::TextTransform, layout, value); layout.text.padding.parse("text-padding", value);
parseProperty<Function<std::array<float, 2>>>("text-offset", PropertyKey::TextOffset, layout, value); layout.text.keepUpright.parse("text-keep-upright", value);
parseProperty<Function<bool>>("text-allow-overlap", PropertyKey::TextAllowOverlap, layout, value); layout.text.transform.parse("text-transform", value);
parseProperty<Function<bool>>("text-ignore-placement", PropertyKey::TextIgnorePlacement, layout, value); layout.text.offset.parse("text-offset", value);
parseProperty<Function<bool>>("text-optional", PropertyKey::TextOptional, layout, value); layout.text.allowOverlap.parse("text-allow-overlap", value);
layout.text.ignorePlacement.parse("text-ignore-placement", value);
layout.text.optional.parse("text-optional", value);
} }
void SymbolLayer::parsePaints(const JSVal& layer) { void SymbolLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) { paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<float>>("icon-opacity", PropertyKey::IconOpacity, paint, value); parseProperty<Function<float>>("icon-opacity", PropertyKey::IconOpacity, paint, value);
parseProperty<PropertyTransition>("icon-opacity-transition", PropertyKey::IconOpacity, paint, value); parseProperty<PropertyTransition>("icon-opacity-transition", PropertyKey::IconOpacity, paint, value);
parseProperty<Function<float>>("icon-size", PropertyKey::IconSize, paint, value);
parseProperty<PropertyTransition>("icon-size-transition", PropertyKey::IconSize, paint, value);
parseProperty<Function<Color>>("icon-color", PropertyKey::IconColor, paint, value); parseProperty<Function<Color>>("icon-color", PropertyKey::IconColor, paint, value);
parseProperty<PropertyTransition>("icon-color-transition", PropertyKey::IconColor, paint, value); parseProperty<PropertyTransition>("icon-color-transition", PropertyKey::IconColor, paint, value);
parseProperty<Function<Color>>("icon-halo-color", PropertyKey::IconHaloColor, paint, value); parseProperty<Function<Color>>("icon-halo-color", PropertyKey::IconHaloColor, paint, value);
@@ -69,8 +69,6 @@ void SymbolLayer::parsePaints(const JSVal& layer) {
parseProperty<Function<float>>("text-opacity", PropertyKey::TextOpacity, paint, value); parseProperty<Function<float>>("text-opacity", PropertyKey::TextOpacity, paint, value);
parseProperty<PropertyTransition>("text-opacity-transition", PropertyKey::TextOpacity, paint, value); parseProperty<PropertyTransition>("text-opacity-transition", PropertyKey::TextOpacity, paint, value);
parseProperty<Function<float>>("text-size", PropertyKey::TextSize, paint, value);
parseProperty<PropertyTransition>("text-size-transition", PropertyKey::TextSize, paint, value);
parseProperty<Function<Color>>("text-color", PropertyKey::TextColor, paint, value); parseProperty<Function<Color>>("text-color", PropertyKey::TextColor, paint, value);
parseProperty<PropertyTransition>("text-color-transition", PropertyKey::TextColor, paint, value); parseProperty<PropertyTransition>("text-color-transition", PropertyKey::TextColor, paint, value);
parseProperty<Function<Color>>("text-halo-color", PropertyKey::TextHaloColor, paint, value); parseProperty<Function<Color>>("text-halo-color", PropertyKey::TextHaloColor, paint, value);
@@ -113,64 +111,63 @@ void SymbolLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.calculate(PropertyKey::TextTranslateAnchor, properties.text.translate_anchor, parameters); paints.calculate(PropertyKey::TextTranslateAnchor, properties.text.translate_anchor, parameters);
// text-size and icon-size are layout properties but they also need to be evaluated as paint properties: // text-size and icon-size are layout properties but they also need to be evaluated as paint properties:
auto it = layout.properties.find(PropertyKey::IconSize); layout.icon.size.calculate(parameters);
if (it != layout.properties.end()) { layout.text.size.calculate(parameters);
const PropertyEvaluator<float> evaluator(parameters); properties.icon.size = layout.icon.size;
properties.icon.size = mapbox::util::apply_visitor(evaluator, it->second); properties.text.size = layout.text.size;
}
it = layout.properties.find(PropertyKey::TextSize);
if (it != layout.properties.end()) {
const PropertyEvaluator<float> evaluator(parameters);
properties.text.size = mapbox::util::apply_visitor(evaluator, it->second);
}
passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None; passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
} }
std::unique_ptr<Bucket> SymbolLayer::createBucket(StyleBucketParameters& parameters) const { std::unique_ptr<Bucket> SymbolLayer::createBucket(StyleBucketParameters& parameters) const {
const float z = parameters.tileID.z; auto bucket = std::make_unique<SymbolBucket>(parameters.tileID.overscaling,
auto bucket = std::make_unique<SymbolBucket>(parameters.tileID.overscaling, z); parameters.tileID.z);
layout.calculate(PropertyKey::SymbolPlacement, bucket->layout.placement, z); bucket->layout = layout;
if (bucket->layout.placement == PlacementType::Line) {
bucket->layout.icon.rotation_alignment = RotationAlignmentType::Map; StyleCalculationParameters p(parameters.tileID.z);
bucket->layout.text.rotation_alignment = RotationAlignmentType::Map; bucket->layout.placement.calculate(p);
if (bucket->layout.placement.value == PlacementType::Line) {
bucket->layout.icon.rotationAlignment = RotationAlignmentType::Map;
bucket->layout.text.rotationAlignment = RotationAlignmentType::Map;
}; };
layout.calculate(PropertyKey::SymbolSpacing, bucket->layout.spacing, z); bucket->layout.spacing.calculate(p);
layout.calculate(PropertyKey::SymbolAvoidEdges, bucket->layout.avoid_edges, z); bucket->layout.avoidEdges.calculate(p);
layout.calculate(PropertyKey::IconAllowOverlap, bucket->layout.icon.allow_overlap, z); bucket->layout.icon.allowOverlap.calculate(p);
layout.calculate(PropertyKey::IconIgnorePlacement, bucket->layout.icon.ignore_placement, z); bucket->layout.icon.ignorePlacement.calculate(p);
layout.calculate(PropertyKey::IconOptional, bucket->layout.icon.optional, z); bucket->layout.icon.optional.calculate(p);
layout.calculate(PropertyKey::IconRotationAlignment, bucket->layout.icon.rotation_alignment, z); bucket->layout.icon.rotationAlignment.calculate(p);
layout.calculate(PropertyKey::IconImage, bucket->layout.icon.image, z); bucket->layout.icon.image.calculate(p);
layout.calculate(PropertyKey::IconPadding, bucket->layout.icon.padding, z); bucket->layout.icon.padding.calculate(p);
layout.calculate(PropertyKey::IconRotate, bucket->layout.icon.rotate, z); bucket->layout.icon.rotate.calculate(p);
layout.calculate(PropertyKey::IconKeepUpright, bucket->layout.icon.keep_upright, z); bucket->layout.icon.keepUpright.calculate(p);
layout.calculate(PropertyKey::IconOffset, bucket->layout.icon.offset, z); bucket->layout.icon.offset.calculate(p);
layout.calculate(PropertyKey::TextRotationAlignment, bucket->layout.text.rotation_alignment, z); bucket->layout.text.rotationAlignment.calculate(p);
layout.calculate(PropertyKey::TextField, bucket->layout.text.field, z); bucket->layout.text.field.calculate(p);
layout.calculate(PropertyKey::TextFont, bucket->layout.text.font, z); bucket->layout.text.font.calculate(p);
layout.calculate(PropertyKey::TextMaxWidth, bucket->layout.text.max_width, z); bucket->layout.text.maxWidth.calculate(p);
layout.calculate(PropertyKey::TextLineHeight, bucket->layout.text.line_height, z); bucket->layout.text.lineHeight.calculate(p);
layout.calculate(PropertyKey::TextLetterSpacing, bucket->layout.text.letter_spacing, z); bucket->layout.text.letterSpacing.calculate(p);
layout.calculate(PropertyKey::TextMaxAngle, bucket->layout.text.max_angle, z); bucket->layout.text.maxAngle.calculate(p);
layout.calculate(PropertyKey::TextRotate, bucket->layout.text.rotate, z); bucket->layout.text.rotate.calculate(p);
layout.calculate(PropertyKey::TextPadding, bucket->layout.text.padding, z); bucket->layout.text.padding.calculate(p);
layout.calculate(PropertyKey::TextIgnorePlacement, bucket->layout.text.ignore_placement, z); bucket->layout.text.ignorePlacement.calculate(p);
layout.calculate(PropertyKey::TextOptional, bucket->layout.text.optional, z); bucket->layout.text.optional.calculate(p);
layout.calculate(PropertyKey::TextJustify, bucket->layout.text.justify, z); bucket->layout.text.justify.calculate(p);
layout.calculate(PropertyKey::TextAnchor, bucket->layout.text.anchor, z); bucket->layout.text.anchor.calculate(p);
layout.calculate(PropertyKey::TextKeepUpright, bucket->layout.text.keep_upright, z); bucket->layout.text.keepUpright.calculate(p);
layout.calculate(PropertyKey::TextTransform, bucket->layout.text.transform, z); bucket->layout.text.transform.calculate(p);
layout.calculate(PropertyKey::TextOffset, bucket->layout.text.offset, z); bucket->layout.text.offset.calculate(p);
layout.calculate(PropertyKey::TextAllowOverlap, bucket->layout.text.allow_overlap, z); bucket->layout.text.allowOverlap.calculate(p);
layout.calculate(PropertyKey::IconSize, bucket->layout.icon.size, z + 1); bucket->layout.icon.size.calculate(StyleCalculationParameters(18));
layout.calculate(PropertyKey::IconSize, bucket->layout.icon.max_size, 18); bucket->layout.text.size.calculate(StyleCalculationParameters(18));
layout.calculate(PropertyKey::TextSize, bucket->layout.text.size, z + 1); bucket->layout.iconMaxSize = bucket->layout.icon.size;
layout.calculate(PropertyKey::TextSize, bucket->layout.text.max_size, 18); bucket->layout.textMaxSize = bucket->layout.text.size;
bucket->layout.icon.size.calculate(StyleCalculationParameters(p.z + 1));
bucket->layout.text.size.calculate(StyleCalculationParameters(p.z + 1));
bucket->parseFeatures(parameters.layer, filter); bucket->parseFeatures(parameters.layer, filter);

View File

@@ -4,10 +4,57 @@
#include <mbgl/style/style_layer.hpp> #include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp> #include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/class_properties.hpp> #include <mbgl/style/layout_property.hpp>
namespace mbgl { namespace mbgl {
class SymbolLayoutProperties {
public:
LayoutProperty<PlacementType> placement = PlacementType::Point;
LayoutProperty<float> spacing = 250.0f;
LayoutProperty<bool> avoidEdges = false;
class IconProperties {
public:
LayoutProperty<bool> allowOverlap = false;
LayoutProperty<bool> ignorePlacement = false;
LayoutProperty<bool> optional = false;
LayoutProperty<RotationAlignmentType> rotationAlignment = RotationAlignmentType::Viewport;
LayoutProperty<float> size = 1.0f;
LayoutProperty<std::string> image = { "" };
LayoutProperty<float> rotate = 0.0f;
LayoutProperty<float> padding = 2.0f;
LayoutProperty<bool> keepUpright = false;
LayoutProperty<std::array<float, 2>> offset = { {{ 0, 0 }} };
} icon;
class TextProperties {
public:
LayoutProperty<RotationAlignmentType> rotationAlignment = RotationAlignmentType::Viewport;
LayoutProperty<std::string> field = { "" };
LayoutProperty<std::string> font = { "Open Sans Regular, Arial Unicode MS Regular" };
LayoutProperty<float> size = 16.0f;
LayoutProperty<float> maxWidth = 15.0f /* em */;
LayoutProperty<float> lineHeight = 1.2f /* em */;
LayoutProperty<float> letterSpacing = 0.0f /* em */;
LayoutProperty<TextJustifyType> justify = TextJustifyType::Center;
LayoutProperty<TextAnchorType> anchor = TextAnchorType::Center;
LayoutProperty<float> maxAngle = 45.0f /* degrees */;
LayoutProperty<float> rotate = 0.0f;
LayoutProperty<float> padding = 2.0f;
LayoutProperty<bool> keepUpright = true;
LayoutProperty<TextTransformType> transform = TextTransformType::None;
LayoutProperty<std::array<float, 2>> offset = { {{ 0, 0 }} };
LayoutProperty<bool> allowOverlap = false;
LayoutProperty<bool> ignorePlacement = false;
LayoutProperty<bool> optional = false;
} text;
// Special case.
float iconMaxSize = 1.0f;
float textMaxSize = 16.0f;
};
class SymbolLayer : public StyleLayer { class SymbolLayer : public StyleLayer {
public: public:
std::unique_ptr<StyleLayer> clone() const override; std::unique_ptr<StyleLayer> clone() const override;
@@ -22,7 +69,7 @@ public:
bool hasTransitions() const override; bool hasTransitions() const override;
ClassProperties layout; SymbolLayoutProperties layout;
PaintPropertiesMap paints; PaintPropertiesMap paints;
SymbolPaintProperties properties; SymbolPaintProperties properties;

View File

@@ -55,7 +55,7 @@ void RasterTileData::request(float pixelRatio,
state = State::loaded; state = State::loaded;
} }
workRequest = worker.parseRasterTile(std::make_unique<RasterBucket>(texturePool, layout), res.data, [this, callback] (RasterTileParseResult result) { workRequest = worker.parseRasterTile(std::make_unique<RasterBucket>(texturePool), res.data, [this, callback] (RasterTileParseResult result) {
workRequest.reset(); workRequest.reset();
if (state != State::loaded) { if (state != State::loaded) {
return; return;

View File

@@ -2,7 +2,6 @@
#define MBGL_MAP_RASTER_TILE_DATA #define MBGL_MAP_RASTER_TILE_DATA
#include <mbgl/map/tile_data.hpp> #include <mbgl/map/tile_data.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/renderer/raster_bucket.hpp> #include <mbgl/renderer/raster_bucket.hpp>
#include <mbgl/storage/request_holder.hpp> #include <mbgl/storage/request_holder.hpp>
@@ -32,7 +31,6 @@ private:
Worker& worker; Worker& worker;
RequestHolder req; RequestHolder req;
RasterLayoutProperties layout;
std::unique_ptr<Bucket> bucket; std::unique_ptr<Bucket> bucket;
std::unique_ptr<WorkRequest> workRequest; std::unique_ptr<WorkRequest> workRequest;

View File

@@ -8,8 +8,6 @@
#include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/circle_buffer.hpp> #include <mbgl/geometry/circle_buffer.hpp>
#include <mbgl/style/style_properties.hpp>
namespace mbgl { namespace mbgl {
class CircleVertexBuffer; class CircleVertexBuffer;

View File

@@ -3,8 +3,6 @@
#include <mbgl/layer/fill_layer.hpp> #include <mbgl/layer/fill_layer.hpp>
#include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/renderer/painter.hpp> #include <mbgl/renderer/painter.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/shader/plain_shader.hpp> #include <mbgl/shader/plain_shader.hpp>
#include <mbgl/shader/pattern_shader.hpp> #include <mbgl/shader/pattern_shader.hpp>
#include <mbgl/shader/outline_shader.hpp> #include <mbgl/shader/outline_shader.hpp>

View File

@@ -2,8 +2,6 @@
#include <mbgl/layer/line_layer.hpp> #include <mbgl/layer/line_layer.hpp>
#include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/renderer/painter.hpp> #include <mbgl/renderer/painter.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/shader/line_shader.hpp> #include <mbgl/shader/line_shader.hpp>
#include <mbgl/shader/linesdf_shader.hpp> #include <mbgl/shader/linesdf_shader.hpp>
#include <mbgl/shader/linepattern_shader.hpp> #include <mbgl/shader/linepattern_shader.hpp>
@@ -42,7 +40,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
return; return;
} }
const float miterLimit = layout.join == JoinType::Bevel ? 1.05f : layout.miter_limit; const float miterLimit = layout.join == JoinType::Bevel ? 1.05f : float(layout.miterLimit);
const Coordinate firstVertex = vertices.front(); const Coordinate firstVertex = vertices.front();
const Coordinate lastVertex = vertices[len - 1]; const Coordinate lastVertex = vertices[len - 1];
@@ -54,7 +52,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
} }
const CapType beginCap = layout.cap; const CapType beginCap = layout.cap;
const CapType endCap = closed ? CapType::Butt : layout.cap; const CapType endCap = closed ? CapType::Butt : CapType(layout.cap);
int8_t flip = 1; int8_t flip = 1;
double distance = 0; double distance = 0;
@@ -143,7 +141,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices) {
if (middleVertex) { if (middleVertex) {
if (currentJoin == JoinType::Round) { if (currentJoin == JoinType::Round) {
if (miterLength < layout.round_limit) { if (miterLength < layout.roundLimit) {
currentJoin = JoinType::Miter; currentJoin = JoinType::Miter;
} else if (miterLength <= 2) { } else if (miterLength <= 2) {
currentJoin = JoinType::FakeRound; currentJoin = JoinType::FakeRound;

View File

@@ -6,8 +6,8 @@
#include <mbgl/geometry/vao.hpp> #include <mbgl/geometry/vao.hpp>
#include <mbgl/geometry/elements_buffer.hpp> #include <mbgl/geometry/elements_buffer.hpp>
#include <mbgl/geometry/line_buffer.hpp> #include <mbgl/geometry/line_buffer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/util/vec.hpp> #include <mbgl/util/vec.hpp>
#include <mbgl/layer/line_layer.hpp>
#include <vector> #include <vector>

View File

@@ -27,8 +27,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
{ {
mat4 vtxMatrix = translatedMatrix(matrix, styleProperties.translate, id, styleProperties.translate_anchor); mat4 vtxMatrix = translatedMatrix(matrix, styleProperties.translate, id, styleProperties.translate_anchor);
bool aligned_with_map = (bucketProperties.rotation_alignment == RotationAlignmentType::Map); bool skewed = (bucketProperties.rotationAlignment == RotationAlignmentType::Map);
bool skewed = aligned_with_map;
mat4 exMatrix; mat4 exMatrix;
float s; float s;
float gammaScale; float gammaScale;
@@ -160,8 +159,8 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
} }
// TODO remove the `true ||` when #1673 is implemented // TODO remove the `true ||` when #1673 is implemented
const bool drawAcrossEdges = true || !(layout.text.allow_overlap || layout.icon.allow_overlap || const bool drawAcrossEdges = true || !(layout.text.allowOverlap || layout.icon.allowOverlap ||
layout.text.ignore_placement || layout.icon.ignore_placement); layout.text.ignorePlacement || layout.icon.ignorePlacement);
// Disable the stencil test so that labels aren't clipped to tile boundaries. // Disable the stencil test so that labels aren't clipped to tile boundaries.
// //
@@ -176,7 +175,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
} }
if (bucket.hasIconData()) { if (bucket.hasIconData()) {
if (layout.icon.rotation_alignment == RotationAlignmentType::Map) { if (layout.icon.rotationAlignment == RotationAlignmentType::Map) {
config.depthFunc.reset(); config.depthFunc.reset();
config.depthTest = GL_TRUE; config.depthTest = GL_TRUE;
} else { } else {
@@ -186,7 +185,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
bool sdf = bucket.sdfIcons; bool sdf = bucket.sdfIcons;
const float angleOffset = const float angleOffset =
layout.icon.rotation_alignment == RotationAlignmentType::Map layout.icon.rotationAlignment == RotationAlignmentType::Map
? state.getAngle() ? state.getAngle()
: 0; : 0;
@@ -209,7 +208,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
} else { } else {
mat4 vtxMatrix = translatedMatrix(matrix, properties.icon.translate, id, properties.icon.translate_anchor); mat4 vtxMatrix = translatedMatrix(matrix, properties.icon.translate, id, properties.icon.translate_anchor);
bool skewed = layout.icon.rotation_alignment == RotationAlignmentType::Map; bool skewed = layout.icon.rotationAlignment == RotationAlignmentType::Map;
mat4 exMatrix; mat4 exMatrix;
float s; float s;
@@ -253,7 +252,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
} }
if (bucket.hasTextData()) { if (bucket.hasTextData()) {
if (layout.text.rotation_alignment == RotationAlignmentType::Map) { if (layout.text.rotationAlignment == RotationAlignmentType::Map) {
config.depthFunc.reset(); config.depthFunc.reset();
config.depthTest = GL_TRUE; config.depthTest = GL_TRUE;
} else { } else {

View File

@@ -5,9 +5,8 @@
using namespace mbgl; using namespace mbgl;
RasterBucket::RasterBucket(TexturePool& texturePool, const RasterLayoutProperties& layout_) RasterBucket::RasterBucket(TexturePool& texturePool)
: layout(layout_), : raster(texturePool) {
raster(texturePool) {
} }
void RasterBucket::upload() { void RasterBucket::upload() {

View File

@@ -6,14 +6,13 @@
namespace mbgl { namespace mbgl {
class RasterLayoutProperties;
class RasterShader; class RasterShader;
class StaticVertexBuffer; class StaticVertexBuffer;
class VertexArrayObject; class VertexArrayObject;
class RasterBucket : public Bucket { class RasterBucket : public Bucket {
public: public:
RasterBucket(TexturePool&, const RasterLayoutProperties&); RasterBucket(TexturePool&);
void upload() override; void upload() override;
void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override;
@@ -21,8 +20,6 @@ public:
bool setImage(std::unique_ptr<util::Image> image); bool setImage(std::unique_ptr<util::Image> image);
const RasterLayoutProperties& layout;
void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array); void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array);
Raster raster; Raster raster;

View File

@@ -1,7 +1,6 @@
#include <mbgl/renderer/symbol_bucket.hpp> #include <mbgl/renderer/symbol_bucket.hpp>
#include <mbgl/layer/symbol_layer.hpp> #include <mbgl/layer/symbol_layer.hpp>
#include <mbgl/map/geometry_tile.hpp> #include <mbgl/map/geometry_tile.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/annotation/sprite_image.hpp> #include <mbgl/annotation/sprite_image.hpp>
#include <mbgl/geometry/text_buffer.hpp> #include <mbgl/geometry/text_buffer.hpp>
#include <mbgl/geometry/icon_buffer.hpp> #include <mbgl/geometry/icon_buffer.hpp>
@@ -92,8 +91,8 @@ bool SymbolBucket::hasCollisionBoxData() const { return renderData && !renderDat
void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, void SymbolBucket::parseFeatures(const GeometryTileLayer& layer,
const FilterExpression& filter) { const FilterExpression& filter) {
const bool has_text = !layout.text.field.empty() && !layout.text.font.empty(); const bool has_text = !layout.text.field.value.empty() && !layout.text.font.value.empty();
const bool has_icon = !layout.icon.image.empty(); const bool has_icon = !layout.icon.image.value.empty();
if (!has_text && !has_icon) { if (!has_text && !has_icon) {
return; return;
@@ -161,11 +160,11 @@ void SymbolBucket::parseFeatures(const GeometryTileLayer& layer,
bool SymbolBucket::needsDependencies(GlyphStore& glyphStore, bool SymbolBucket::needsDependencies(GlyphStore& glyphStore,
Sprite& sprite) { Sprite& sprite) {
if (!layout.text.field.empty() && !layout.text.font.empty() && !glyphStore.hasGlyphRanges(layout.text.font, ranges)) { if (!layout.text.field.value.empty() && !layout.text.font.value.empty() && !glyphStore.hasGlyphRanges(layout.text.font, ranges)) {
return true; return true;
} }
if (!layout.icon.image.empty() && !sprite.isLoaded()) { if (!layout.icon.image.value.empty() && !sprite.isLoaded()) {
return true; return true;
} }
@@ -232,13 +231,13 @@ void SymbolBucket::addFeatures(uintptr_t tileUID,
shapedText = fontStack->getShaping( shapedText = fontStack->getShaping(
/* string */ feature.label, /* string */ feature.label,
/* maxWidth: ems */ layout.placement != PlacementType::Line ? /* maxWidth: ems */ layout.placement != PlacementType::Line ?
layout.text.max_width * 24 : 0, layout.text.maxWidth * 24 : 0,
/* lineHeight: ems */ layout.text.line_height * 24, /* lineHeight: ems */ layout.text.lineHeight * 24,
/* horizontalAlign */ horizontalAlign, /* horizontalAlign */ horizontalAlign,
/* verticalAlign */ verticalAlign, /* verticalAlign */ verticalAlign,
/* justify */ justify, /* justify */ justify,
/* spacing: ems */ layout.text.letter_spacing * 24, /* spacing: ems */ layout.text.letterSpacing * 24,
/* translate */ vec2<float>(layout.text.offset[0], layout.text.offset[1])); /* translate */ vec2<float>(layout.text.offset.value[0], layout.text.offset.value[1]));
// Add the glyphs we need for this label to the glyph atlas. // Add the glyphs we need for this label to the glyph atlas.
if (shapedText) { if (shapedText) {
@@ -278,21 +277,21 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
const float fontScale = layout.text.size / glyphSize; const float fontScale = layout.text.size / glyphSize;
const float textBoxScale = tilePixelRatio * fontScale; const float textBoxScale = tilePixelRatio * fontScale;
const float textMaxBoxScale = tilePixelRatio * layout.text.max_size / glyphSize; const float textMaxBoxScale = tilePixelRatio * layout.textMaxSize / glyphSize;
const float iconBoxScale = tilePixelRatio * layout.icon.size; const float iconBoxScale = tilePixelRatio * layout.icon.size;
const float symbolSpacing = tilePixelRatio * layout.spacing; const float symbolSpacing = tilePixelRatio * layout.spacing;
const bool avoidEdges = layout.avoid_edges && layout.placement != PlacementType::Line; const bool avoidEdges = layout.avoidEdges && layout.placement != PlacementType::Line;
const float textPadding = layout.text.padding * tilePixelRatio; const float textPadding = layout.text.padding * tilePixelRatio;
const float iconPadding = layout.icon.padding * tilePixelRatio; const float iconPadding = layout.icon.padding * tilePixelRatio;
const float textMaxAngle = layout.text.max_angle * M_PI / 180; const float textMaxAngle = layout.text.maxAngle * M_PI / 180;
const bool textAlongLine = const bool textAlongLine =
layout.text.rotation_alignment == RotationAlignmentType::Map && layout.text.rotationAlignment == RotationAlignmentType::Map &&
layout.placement == PlacementType::Line; layout.placement == PlacementType::Line;
const bool iconAlongLine = const bool iconAlongLine =
layout.icon.rotation_alignment == RotationAlignmentType::Map && layout.icon.rotationAlignment == RotationAlignmentType::Map &&
layout.placement == PlacementType::Line; layout.placement == PlacementType::Line;
const bool mayOverlap = layout.text.allow_overlap || layout.icon.allow_overlap || const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap ||
layout.text.ignore_placement || layout.icon.ignore_placement; layout.text.ignorePlacement || layout.icon.ignorePlacement;
const bool isLine = layout.placement == PlacementType::Line; const bool isLine = layout.placement == PlacementType::Line;
const float textRepeatDistance = symbolSpacing / 2; const float textRepeatDistance = symbolSpacing / 2;
@@ -368,14 +367,14 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile, bool swapImmediat
// create the bufers used for rendering. // create the bufers used for rendering.
const bool textAlongLine = const bool textAlongLine =
layout.text.rotation_alignment == RotationAlignmentType::Map && layout.text.rotationAlignment == RotationAlignmentType::Map &&
layout.placement == PlacementType::Line; layout.placement == PlacementType::Line;
const bool iconAlongLine = const bool iconAlongLine =
layout.icon.rotation_alignment == RotationAlignmentType::Map && layout.icon.rotationAlignment == RotationAlignmentType::Map &&
layout.placement == PlacementType::Line; layout.placement == PlacementType::Line;
const bool mayOverlap = layout.text.allow_overlap || layout.icon.allow_overlap || const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap ||
layout.text.ignore_placement || layout.icon.ignore_placement; layout.text.ignorePlacement || layout.icon.ignorePlacement;
// Sort symbols by their y position on the canvas so that they lower symbols // Sort symbols by their y position on the canvas so that they lower symbols
// are drawn on top of higher symbols. // are drawn on top of higher symbols.
@@ -402,9 +401,9 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile, bool swapImmediat
// Calculate the scales at which the text and icon can be placed without collision. // Calculate the scales at which the text and icon can be placed without collision.
float glyphScale = hasText && !layout.text.allow_overlap ? float glyphScale = hasText && !layout.text.allowOverlap ?
collisionTile.placeFeature(symbolInstance.textCollisionFeature) : collisionTile.minScale; collisionTile.placeFeature(symbolInstance.textCollisionFeature) : collisionTile.minScale;
float iconScale = hasIcon && !layout.icon.allow_overlap ? float iconScale = hasIcon && !layout.icon.allowOverlap ?
collisionTile.placeFeature(symbolInstance.iconCollisionFeature) : collisionTile.minScale; collisionTile.placeFeature(symbolInstance.iconCollisionFeature) : collisionTile.minScale;
@@ -422,24 +421,24 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile, bool swapImmediat
// Insert final placement into collision tree and add glyphs/icons to buffers // Insert final placement into collision tree and add glyphs/icons to buffers
if (hasText) { if (hasText) {
if (!layout.text.ignore_placement) { if (!layout.text.ignorePlacement) {
collisionTile.insertFeature(symbolInstance.textCollisionFeature, glyphScale); collisionTile.insertFeature(symbolInstance.textCollisionFeature, glyphScale);
} }
if (glyphScale < collisionTile.maxScale) { if (glyphScale < collisionTile.maxScale) {
addSymbols<SymbolRenderData::TextBuffer, TextElementGroup>( addSymbols<SymbolRenderData::TextBuffer, TextElementGroup>(
renderDataInProgress->text, symbolInstance.glyphQuads, glyphScale, renderDataInProgress->text, symbolInstance.glyphQuads, glyphScale,
layout.text.keep_upright, textAlongLine, collisionTile.config.angle); layout.text.keepUpright, textAlongLine, collisionTile.config.angle);
} }
} }
if (hasIcon) { if (hasIcon) {
if (!layout.icon.ignore_placement) { if (!layout.icon.ignorePlacement) {
collisionTile.insertFeature(symbolInstance.iconCollisionFeature, iconScale); collisionTile.insertFeature(symbolInstance.iconCollisionFeature, iconScale);
} }
if (iconScale < collisionTile.maxScale) { if (iconScale < collisionTile.maxScale) {
addSymbols<SymbolRenderData::IconBuffer, IconElementGroup>( addSymbols<SymbolRenderData::IconBuffer, IconElementGroup>(
renderDataInProgress->icon, symbolInstance.iconQuads, iconScale, renderDataInProgress->icon, symbolInstance.iconQuads, iconScale,
layout.icon.keep_upright, iconAlongLine, collisionTile.config.angle); layout.icon.keepUpright, iconAlongLine, collisionTile.config.angle);
} }
} }
} }

View File

@@ -12,8 +12,8 @@
#include <mbgl/text/collision_feature.hpp> #include <mbgl/text/collision_feature.hpp>
#include <mbgl/text/shaping.hpp> #include <mbgl/text/shaping.hpp>
#include <mbgl/text/quads.hpp> #include <mbgl/text/quads.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/filter_expression.hpp> #include <mbgl/style/filter_expression.hpp>
#include <mbgl/layer/symbol_layer.hpp>
#include <memory> #include <memory>
#include <map> #include <map>

View File

@@ -0,0 +1,38 @@
#ifndef MBGL_LAYOUT_PROPERTY
#define MBGL_LAYOUT_PROPERTY
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/function.hpp>
#include <rapidjson/document.h>
namespace mbgl {
using JSVal = rapidjson::Value;
template <typename T>
class LayoutProperty {
public:
LayoutProperty(T v) : value(v) {}
void parse(const char * name, const JSVal& layout) {
if (layout.HasMember(name)) {
parsedValue = detail::parseProperty<Function<T>>(name, layout[name]);
}
}
void calculate(const StyleCalculationParameters& parameters) {
if (parsedValue) {
value = (*parsedValue).evaluate(parameters);
}
}
operator T() const { return value; }
mapbox::util::optional<Function<T>> parsedValue;
T value;
};
}
#endif

View File

@@ -27,7 +27,6 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
{ PropertyKey::CircleBlur, CirclePaintProperties().blur }, { PropertyKey::CircleBlur, CirclePaintProperties().blur },
{ PropertyKey::IconOpacity, SymbolPaintProperties().icon.opacity }, { PropertyKey::IconOpacity, SymbolPaintProperties().icon.opacity },
{ PropertyKey::IconSize, SymbolPaintProperties().icon.size },
{ PropertyKey::IconColor, SymbolPaintProperties().icon.color }, { PropertyKey::IconColor, SymbolPaintProperties().icon.color },
{ PropertyKey::IconHaloColor, SymbolPaintProperties().icon.halo_color }, { PropertyKey::IconHaloColor, SymbolPaintProperties().icon.halo_color },
{ PropertyKey::IconHaloWidth, SymbolPaintProperties().icon.halo_width }, { PropertyKey::IconHaloWidth, SymbolPaintProperties().icon.halo_width },
@@ -36,7 +35,6 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
{ PropertyKey::IconTranslateAnchor, SymbolPaintProperties().icon.translate_anchor }, { PropertyKey::IconTranslateAnchor, SymbolPaintProperties().icon.translate_anchor },
{ PropertyKey::TextOpacity, SymbolPaintProperties().text.opacity }, { PropertyKey::TextOpacity, SymbolPaintProperties().text.opacity },
{ PropertyKey::TextSize, SymbolPaintProperties().text.size },
{ PropertyKey::TextColor, SymbolPaintProperties().text.color }, { PropertyKey::TextColor, SymbolPaintProperties().text.color },
{ PropertyKey::TextHaloColor, SymbolPaintProperties().text.halo_color }, { PropertyKey::TextHaloColor, SymbolPaintProperties().text.halo_color },
{ PropertyKey::TextHaloWidth, SymbolPaintProperties().text.halo_width }, { PropertyKey::TextHaloWidth, SymbolPaintProperties().text.halo_width },
@@ -54,44 +52,6 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
{ PropertyKey::BackgroundOpacity, BackgroundPaintProperties().opacity }, { PropertyKey::BackgroundOpacity, BackgroundPaintProperties().opacity },
{ PropertyKey::BackgroundColor, BackgroundPaintProperties().color }, { PropertyKey::BackgroundColor, BackgroundPaintProperties().color },
{ PropertyKey::LineCap, LineLayoutProperties().cap },
{ PropertyKey::LineJoin, LineLayoutProperties().join },
{ PropertyKey::LineMiterLimit, LineLayoutProperties().miter_limit },
{ PropertyKey::LineRoundLimit, LineLayoutProperties().round_limit },
{ PropertyKey::SymbolPlacement, SymbolLayoutProperties().placement },
{ PropertyKey::SymbolSpacing, SymbolLayoutProperties().spacing },
{ PropertyKey::SymbolAvoidEdges, SymbolLayoutProperties().avoid_edges },
{ PropertyKey::IconAllowOverlap, SymbolLayoutProperties().icon.allow_overlap },
{ PropertyKey::IconIgnorePlacement, SymbolLayoutProperties().icon.ignore_placement },
{ PropertyKey::IconOptional, SymbolLayoutProperties().icon.optional },
{ PropertyKey::IconRotationAlignment, SymbolLayoutProperties().icon.rotation_alignment },
{ PropertyKey::IconImage, SymbolLayoutProperties().icon.image },
{ PropertyKey::IconRotate, SymbolLayoutProperties().icon.rotate },
{ PropertyKey::IconPadding, SymbolLayoutProperties().icon.padding },
{ PropertyKey::IconKeepUpright, SymbolLayoutProperties().icon.keep_upright },
{ PropertyKey::IconOffset, SymbolLayoutProperties().icon.offset },
{ PropertyKey::TextRotationAlignment, SymbolLayoutProperties().text.rotation_alignment },
{ PropertyKey::TextField, SymbolLayoutProperties().text.field },
{ PropertyKey::TextFont, SymbolLayoutProperties().text.font },
{ PropertyKey::TextMaxWidth, SymbolLayoutProperties().text.max_width },
{ PropertyKey::TextLineHeight, SymbolLayoutProperties().text.line_height },
{ PropertyKey::TextLetterSpacing, SymbolLayoutProperties().text.letter_spacing },
{ PropertyKey::TextJustify, SymbolLayoutProperties().text.justify },
{ PropertyKey::TextAnchor, SymbolLayoutProperties().text.anchor },
{ PropertyKey::TextMaxAngle, SymbolLayoutProperties().text.max_angle },
{ PropertyKey::TextRotate, SymbolLayoutProperties().text.rotate },
{ PropertyKey::TextPadding, SymbolLayoutProperties().text.padding },
{ PropertyKey::TextKeepUpright, SymbolLayoutProperties().text.keep_upright },
{ PropertyKey::TextTransform, SymbolLayoutProperties().text.transform },
{ PropertyKey::TextOffset, SymbolLayoutProperties().text.offset },
{ PropertyKey::TextAllowOverlap, SymbolLayoutProperties().text.allow_overlap },
{ PropertyKey::TextIgnorePlacement, SymbolLayoutProperties().text.ignore_placement },
{ PropertyKey::TextOptional, SymbolLayoutProperties().text.optional },
}; };
const PropertyValue PropertyFallbackValue::defaultProperty = false; const PropertyValue PropertyFallbackValue::defaultProperty = false;

View File

@@ -22,11 +22,6 @@ enum class PropertyKey {
LineDashArray, // for transitions only LineDashArray, // for transitions only
LineImage, LineImage,
LineCap,
LineJoin,
LineMiterLimit,
LineRoundLimit,
CircleRadius, CircleRadius,
CircleColor, CircleColor,
CircleOpacity, CircleOpacity,
@@ -34,12 +29,7 @@ enum class PropertyKey {
CircleTranslateAnchor, CircleTranslateAnchor,
CircleBlur, CircleBlur,
SymbolPlacement,
SymbolSpacing,
SymbolAvoidEdges,
IconOpacity, IconOpacity,
IconSize,
IconColor, IconColor,
IconHaloColor, IconHaloColor,
IconHaloWidth, IconHaloWidth,
@@ -47,16 +37,6 @@ enum class PropertyKey {
IconTranslate, IconTranslate,
IconTranslateAnchor, IconTranslateAnchor,
IconAllowOverlap,
IconIgnorePlacement,
IconOptional,
IconRotationAlignment,
IconImage,
IconOffset,
IconPadding,
IconRotate,
IconKeepUpright,
TextOpacity, TextOpacity,
TextColor, TextColor,
TextHaloColor, TextHaloColor,
@@ -65,25 +45,6 @@ enum class PropertyKey {
TextTranslate, TextTranslate,
TextTranslateAnchor, TextTranslateAnchor,
TextRotationAlignment,
TextField,
TextFont,
TextSize,
TextMaxWidth,
TextLineHeight,
TextLetterSpacing,
TextMaxAngle,
TextRotate,
TextPadding,
TextIgnorePlacement,
TextOptional,
TextJustify,
TextAnchor,
TextKeepUpright,
TextTransform,
TextOffset,
TextAllowOverlap,
RasterOpacity, RasterOpacity,
RasterHueRotate, RasterHueRotate,
RasterBrightness, // for transitions only RasterBrightness, // for transitions only
@@ -96,8 +57,6 @@ enum class PropertyKey {
BackgroundOpacity, BackgroundOpacity,
BackgroundColor, BackgroundColor,
BackgroundImage, BackgroundImage,
Visibilty
}; };
} }

View File

@@ -1,5 +0,0 @@
#include <mbgl/style/style_properties.hpp>
namespace mbgl {
}

View File

@@ -1,7 +1,7 @@
#include <mbgl/text/quads.hpp> #include <mbgl/text/quads.hpp>
#include <mbgl/text/shaping.hpp> #include <mbgl/text/shaping.hpp>
#include <mbgl/geometry/anchor.hpp> #include <mbgl/geometry/anchor.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/layer/symbol_layer.hpp>
#include <mbgl/util/math.hpp> #include <mbgl/util/math.hpp>
#include <cassert> #include <cassert>
@@ -133,7 +133,7 @@ SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText,
const bool alongLine, const GlyphPositions& face) { const bool alongLine, const GlyphPositions& face) {
const float textRotate = layout.text.rotate * M_PI / 180; const float textRotate = layout.text.rotate * M_PI / 180;
const bool keepUpright = layout.text.keep_upright; const bool keepUpright = layout.text.keepUpright;
SymbolQuads quads; SymbolQuads quads;

View File

@@ -1,11 +1,11 @@
#include <mbgl/text/shaping.hpp> #include <mbgl/text/shaping.hpp>
#include <mbgl/style/style_properties.hpp> #include <mbgl/layer/symbol_layer.hpp>
namespace mbgl { namespace mbgl {
PositionedIcon shapeIcon(const Rect<uint16_t>& image, const SymbolLayoutProperties& layout) { PositionedIcon shapeIcon(const Rect<uint16_t>& image, const SymbolLayoutProperties& layout) {
float dx = layout.icon.offset[0]; float dx = layout.icon.offset.value[0];
float dy = layout.icon.offset[1]; float dy = layout.icon.offset.value[1];
float x1 = dx - image.originalW / 2.0f; float x1 = dx - image.originalW / 2.0f;
float x2 = x1 + image.originalW; float x2 = x1 + image.originalW;
float y1 = dy - image.originalH / 2.0f; float y1 = dy - image.originalH / 2.0f;

View File

@@ -13,7 +13,7 @@
"source": "mapbox", "source": "mapbox",
"source-layer": "country_label", "source-layer": "country_label",
"filter": ["==", "$type", "Point"], "filter": ["==", "$type", "Point"],
"paint": { "layout": {
"text-size": null "text-size": null
} }
}] }]