[core] Eliminate use of ClassProperties for paint

This commit is contained in:
John Firebaugh
2015-10-26 15:12:43 -07:00
parent a562567589
commit 54e08b1f83
48 changed files with 580 additions and 1097 deletions

View File

@@ -2,7 +2,7 @@
#define MBGL_ANNOTATION_SHAPE_ANNOTATION
#include <mbgl/annotation/annotation.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/util/geo.hpp>
@@ -13,12 +13,24 @@ namespace mbgl {
using AnnotationSegment = std::vector<LatLng>;
using AnnotationSegments = std::vector<AnnotationSegment>;
struct FillAnnotationProperties {
float opacity = 1;
Color color = {{ 0, 0, 0, 1 }};
Color outlineColor = {{ 0, 0, 0, -1 }};
};
struct LineAnnotationProperties {
float opacity = 1;
float width = 1;
Color color = {{ 0, 0, 0, 1 }};
};
class ShapeAnnotation {
public:
using Properties = mapbox::util::variant<
FillPaintProperties, // creates a fill annotation
LinePaintProperties, // creates a line annotation
std::string>; // creates an annotation whose type and properties are sourced from a style layer
FillAnnotationProperties, // creates a fill annotation
LineAnnotationProperties, // creates a line annotation
std::string>; // creates an annotation whose type and properties are sourced from a style layer
ShapeAnnotation(const AnnotationSegments& segments_, const Properties& properties_)
: segments(segments_), properties(properties_) {

View File

@@ -1,116 +0,0 @@
#ifndef MBGL_STYLE_STYLE_PROPERTIES
#define MBGL_STYLE_STYLE_PROPERTIES
#include <mbgl/style/types.hpp>
#include <array>
#include <string>
#include <vector>
namespace mbgl {
class FillPaintProperties {
public:
bool antialias = true;
float opacity = 1.0f;
Color fill_color = {{ 0, 0, 0, 1 }};
Color stroke_color = {{ 0, 0, 0, -1 }};
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
Faded<std::string> image;
inline bool isVisible() const {
return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0);
}
};
class LinePaintProperties {
public:
float opacity = 1.0f;
Color color = {{ 0, 0, 0, 1 }};
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
float width = 1;
float gap_width = 0;
float blur = 0;
Faded<std::vector<float>> dash_array;
float dash_line_width = 1;
Faded<std::string> image;
inline bool isVisible() const {
return opacity > 0 && color[3] > 0 && width > 0;
}
};
class SymbolPaintProperties {
public:
struct {
float opacity = 1.0f;
float size = 1.0f;
Color color = {{ 0, 0, 0, 1 }};
Color halo_color = {{ 0, 0, 0, 0 }};
float halo_width = 0.0f;
float halo_blur = 0.0f;
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translate_anchor = TranslateAnchorType::Map;
} icon;
struct {
float opacity = 1.0f;
float size = 16.0f;
Color color = {{ 0, 0, 0, 1 }};
Color halo_color = {{ 0, 0, 0, 0 }};
float halo_width = 0.0f;
float halo_blur = 0.0f;
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translate_anchor = TranslateAnchorType::Map;
} text;
inline bool isVisible() const {
return (icon.opacity > 0 && (icon.color[3] > 0 || icon.halo_color[3] > 0) && icon.size > 0) ||
(text.opacity > 0 && (text.color[3] > 0 || text.halo_color[3] > 0) && text.size > 0);
}
};
class CirclePaintProperties {
public:
float radius = 5.0f;
Color color = {{ 0, 0, 0, 1 }};
float opacity = 1.0f;
std::array<float, 2> translate = {{ 0, 0 }};
TranslateAnchorType translateAnchor = TranslateAnchorType::Map;
float blur = 0;
inline bool isVisible() const {
return radius > 0 && color[3] > 0 && opacity > 0;
}
};
class RasterPaintProperties {
public:
float opacity = 1.0f;
float hue_rotate = 0.0f;
std::array<float, 2> brightness = {{ 0, 1 }};
float saturation = 0.0f;
float contrast = 0.0f;
float fade = 0.0f;
inline bool isVisible() const {
return opacity > 0;
}
};
class BackgroundPaintProperties {
public:
float opacity = 1.0f;
Color color = {{ 0, 0, 0, 1 }};
Faded<std::string> image;
inline bool isVisible() const {
return opacity > 0;
}
};
}
#endif

View File

@@ -14,6 +14,9 @@ typedef std::array<float, 4> Color;
template <typename T>
struct Faded {
Faded() = default;
Faded(const T& v) : to(v) {}
T from;
float fromScale;
T to;

View File

@@ -356,11 +356,11 @@ std::pair<mbgl::AnnotationSegment, mbgl::ShapeAnnotation::Properties> annotation
int aS = (strokeColor >> 24) & 0xFF;
mbgl::ShapeAnnotation::Properties shapeProperties;
mbgl::FillPaintProperties fillProperties;
mbgl::FillAnnotationProperties fillProperties;
fillProperties.opacity = alpha;
fillProperties.stroke_color = {{ static_cast<float>(rS) / 255.0f, static_cast<float>(gS) / 255.0f, static_cast<float>(bS) / 255.0f, static_cast<float>(aS) / 255.0f }};
fillProperties.fill_color = {{ static_cast<float>(rF) / 255.0f, static_cast<float>(gF) / 255.0f, static_cast<float>(bF) / 255.0f, static_cast<float>(aF) / 255.0f }};
shapeProperties.set<mbgl::FillPaintProperties>(fillProperties);
fillProperties.outlineColor = {{ static_cast<float>(rS) / 255.0f, static_cast<float>(gS) / 255.0f, static_cast<float>(bS) / 255.0f, static_cast<float>(aS) / 255.0f }};
fillProperties.color = {{ static_cast<float>(rF) / 255.0f, static_cast<float>(gF) / 255.0f, static_cast<float>(bF) / 255.0f, static_cast<float>(aF) / 255.0f }};
shapeProperties.set<mbgl::FillAnnotationProperties>(fillProperties);
jobject points = env->GetObjectField(polygon, polygonPointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);
@@ -941,11 +941,11 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr
}
mbgl::ShapeAnnotation::Properties shapeProperties;
mbgl::LinePaintProperties lineProperties;
mbgl::LineAnnotationProperties lineProperties;
lineProperties.opacity = alpha;
lineProperties.color = {{ static_cast<float>(r) / 255.0f, static_cast<float>(g) / 255.0f, static_cast<float>(b) / 255.0f, static_cast<float>(a) / 255.0f }};
lineProperties.width = width;
shapeProperties.set<mbgl::LinePaintProperties>(lineProperties);
shapeProperties.set<mbgl::LineAnnotationProperties>(lineProperties);
jobject points = env->GetObjectField(polyline, polylinePointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);
@@ -1016,11 +1016,11 @@ jlongArray JNICALL nativeAddPolylines(JNIEnv *env, jobject obj, jlong nativeMapV
}
mbgl::ShapeAnnotation::Properties shapeProperties;
mbgl::LinePaintProperties lineProperties;
mbgl::LineAnnotationProperties lineProperties;
lineProperties.opacity = alpha;
lineProperties.color = {{ static_cast<float>(r) / 255.0f, static_cast<float>(g) / 255.0f, static_cast<float>(b) / 255.0f, static_cast<float>(a) / 255.0f }};
lineProperties.width = width;
shapeProperties.set<mbgl::LinePaintProperties>(lineProperties);
shapeProperties.set<mbgl::LineAnnotationProperties>(lineProperties);
jobject points = env->GetObjectField(polyline, polylinePointsId);
mbgl::AnnotationSegment segment = annotation_segment_from_latlng_jlist(env, points);

View File

@@ -223,7 +223,7 @@ void GLFWView::addRandomPointAnnotations(int count) {
void GLFWView::addRandomShapeAnnotations(int count) {
std::vector<mbgl::ShapeAnnotation> shapes;
mbgl::FillPaintProperties properties;
mbgl::FillAnnotationProperties properties;
properties.opacity = .1;
for (int i = 0; i < count; i++) {

View File

@@ -2171,11 +2171,11 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
[self.delegate mapView:self lineWidthForPolylineAnnotation:(MGLPolyline *)annotation] :
3.0);
mbgl::LinePaintProperties lineProperties;
mbgl::LineAnnotationProperties lineProperties;
lineProperties.opacity = alpha;
lineProperties.color = strokeNativeColor;
lineProperties.width = lineWidth;
shapeProperties.set<mbgl::LinePaintProperties>(lineProperties);
shapeProperties.set<mbgl::LineAnnotationProperties>(lineProperties);
}
else if ([annotation isKindOfClass:[MGLPolygon class]])
@@ -2189,11 +2189,11 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
[fillColor getRed:&r green:&g blue:&b alpha:&a];
mbgl::Color fillNativeColor({{ (float)r, (float)g, (float)b, (float)a }});
mbgl::FillPaintProperties fillProperties;
mbgl::FillAnnotationProperties fillProperties;
fillProperties.opacity = alpha;
fillProperties.stroke_color = strokeNativeColor;
fillProperties.fill_color = fillNativeColor;
shapeProperties.set<mbgl::FillPaintProperties>(fillProperties);
fillProperties.outlineColor = strokeNativeColor;
fillProperties.color = fillNativeColor;
shapeProperties.set<mbgl::FillAnnotationProperties>(fillProperties);
}
else
{

View File

@@ -26,19 +26,17 @@ void ShapeAnnotationImpl::updateStyle(Style& style) {
if (style.getLayer(layerID))
return;
if (shape.properties.is<LinePaintProperties>()) {
if (shape.properties.is<LineAnnotationProperties>()) {
type = ProjectedFeatureType::LineString;
std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>();
layer->type = StyleLayerType::Line;
layer->layout.join = JoinType::Round;
const LinePaintProperties& properties = shape.properties.get<LinePaintProperties>();
ClassProperties paintProperties;
paintProperties.set(PropertyKey::LineOpacity, Function<float>(properties.opacity));
paintProperties.set(PropertyKey::LineWidth, Function<float>(properties.width));
paintProperties.set(PropertyKey::LineColor, Function<Color>(properties.color));
layer->paints.paints.emplace(ClassID::Default, std::move(paintProperties));
const LineAnnotationProperties& properties = shape.properties.get<LineAnnotationProperties>();
layer->paint.opacity = properties.opacity;
layer->paint.width = properties.width;
layer->paint.color = properties.color;
layer->id = layerID;
layer->source = AnnotationManager::SourceID;
@@ -46,18 +44,16 @@ void ShapeAnnotationImpl::updateStyle(Style& style) {
style.addLayer(std::move(layer), AnnotationManager::PointLayerID);
} else if (shape.properties.is<FillPaintProperties>()) {
} else if (shape.properties.is<FillAnnotationProperties>()) {
type = ProjectedFeatureType::Polygon;
std::unique_ptr<FillLayer> layer = std::make_unique<FillLayer>();
layer->type = StyleLayerType::Fill;
const FillPaintProperties& properties = shape.properties.get<FillPaintProperties>();
ClassProperties paintProperties;
paintProperties.set(PropertyKey::FillOpacity, Function<float>(properties.opacity));
paintProperties.set(PropertyKey::FillColor, Function<Color>(properties.fill_color));
paintProperties.set(PropertyKey::FillOutlineColor, Function<Color>(properties.stroke_color));
layer->paints.paints.emplace(ClassID::Default, std::move(paintProperties));
const FillAnnotationProperties& properties = shape.properties.get<FillAnnotationProperties>();
layer->paint.opacity = properties.opacity;
layer->paint.color = properties.color;
layer->paint.outlineColor = properties.outlineColor;
layer->id = layerID;
layer->source = AnnotationManager::SourceID;

View File

@@ -1,5 +1,4 @@
#include <mbgl/layer/background_layer.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/renderer/bucket.hpp>
namespace mbgl {
@@ -7,34 +6,32 @@ namespace mbgl {
std::unique_ptr<StyleLayer> BackgroundLayer::clone() const {
std::unique_ptr<BackgroundLayer> result = std::make_unique<BackgroundLayer>();
result->copy(*this);
result->paints.paints = paints.paints;
result->paint = paint;
return std::move(result);
}
void BackgroundLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<float>>("background-opacity", PropertyKey::BackgroundOpacity, paint, value);
parseProperty<Function<Color>>("background-color", PropertyKey::BackgroundColor, paint, value);
parseProperty<Function<Faded<std::string>>>("background-pattern", PropertyKey::BackgroundImage, paint, value);
});
paint.opacity.parse("background-opacity", layer);
paint.color.parse("background-color", layer);
paint.pattern.parse("background-pattern", layer);
}
void BackgroundLayer::cascade(const StyleCascadeParameters& parameters) {
paints.cascade(parameters);
paint.opacity.cascade(parameters);
paint.color.cascade(parameters);
paint.pattern.cascade(parameters);
}
bool BackgroundLayer::hasTransitions() const {
return paints.hasTransitions();
}
bool BackgroundLayer::recalculate(const StyleCalculationParameters& parameters) {
bool hasTransitions = false;
void BackgroundLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.removeExpiredTransitions(parameters.now);
hasTransitions |= paint.opacity.calculate(parameters);
hasTransitions |= paint.color.calculate(parameters);
hasTransitions |= paint.pattern.calculate(parameters);
paints.calculateTransitioned(PropertyKey::BackgroundOpacity, properties.opacity, parameters);
paints.calculateTransitioned(PropertyKey::BackgroundColor, properties.color, parameters);
paints.calculate(PropertyKey::BackgroundImage, properties.image, parameters);
passes = paint.opacity > 0 ? RenderPass::Translucent : RenderPass::None;
passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
return hasTransitions;
}
std::unique_ptr<Bucket> BackgroundLayer::createBucket(StyleBucketParameters&) const {

View File

@@ -2,11 +2,17 @@
#define MBGL_BACKGROUND_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
class BackgroundPaintProperties {
public:
PaintProperty<float> opacity = 1.0f;
PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
PaintProperty<std::string, Faded<std::string>> pattern = { "" };
};
class BackgroundLayer : public StyleLayer {
public:
std::unique_ptr<StyleLayer> clone() const override;
@@ -15,15 +21,11 @@ public:
void parsePaints(const JSVal&) override;
void cascade(const StyleCascadeParameters&) override;
void recalculate(const StyleCalculationParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
bool hasTransitions() const override;
PaintPropertiesMap paints;
BackgroundPaintProperties properties;
BackgroundPaintProperties paint;
};
}

View File

@@ -1,5 +1,4 @@
#include <mbgl/layer/circle_layer.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/style_bucket_parameters.hpp>
#include <mbgl/renderer/circle_bucket.hpp>
@@ -8,40 +7,41 @@ namespace mbgl {
std::unique_ptr<StyleLayer> CircleLayer::clone() const {
std::unique_ptr<CircleLayer> result = std::make_unique<CircleLayer>();
result->copy(*this);
result->paints.paints = paints.paints;
result->paint = paint;
return std::move(result);
}
void CircleLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<float>>("circle-radius", PropertyKey::CircleRadius, paint, value);
parseProperty<Function<Color>>("circle-color", PropertyKey::CircleColor, paint, value);
parseProperty<Function<float>>("circle-opacity", PropertyKey::CircleOpacity, paint, value);
parseProperty<Function<std::array<float,2>>>("circle-translate", PropertyKey::CircleTranslate, paint, value);
parseProperty<Function<TranslateAnchorType>>("circle-translate-anchor", PropertyKey::CircleTranslateAnchor, paint, value);
parseProperty<Function<float>>("circle-blur", PropertyKey::CircleBlur, paint, value);
});
paint.radius.parse("circle-radius", layer);
paint.color.parse("circle-color", layer);
paint.opacity.parse("circle-opacity", layer);
paint.translate.parse("circle-translate", layer);
paint.translateAnchor.parse("circle-translate-anchor", layer);
paint.blur.parse("circle-blur", layer);
}
void CircleLayer::cascade(const StyleCascadeParameters& parameters) {
paints.cascade(parameters);
paint.radius.cascade(parameters);
paint.color.cascade(parameters);
paint.opacity.cascade(parameters);
paint.translate.cascade(parameters);
paint.translateAnchor.cascade(parameters);
paint.blur.cascade(parameters);
}
bool CircleLayer::hasTransitions() const {
return paints.hasTransitions();
}
bool CircleLayer::recalculate(const StyleCalculationParameters& parameters) {
bool hasTransitions = false;
void CircleLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.removeExpiredTransitions(parameters.now);
hasTransitions |= paint.radius.calculate(parameters);
hasTransitions |= paint.color.calculate(parameters);
hasTransitions |= paint.opacity.calculate(parameters);
hasTransitions |= paint.translate.calculate(parameters);
hasTransitions |= paint.translateAnchor.calculate(parameters);
hasTransitions |= paint.blur.calculate(parameters);
paints.calculateTransitioned(PropertyKey::CircleRadius, properties.radius, parameters);
paints.calculateTransitioned(PropertyKey::CircleColor, properties.color, parameters);
paints.calculateTransitioned(PropertyKey::CircleOpacity, properties.opacity, parameters);
paints.calculateTransitioned(PropertyKey::CircleTranslate, properties.translate, parameters);
paints.calculate(PropertyKey::CircleTranslateAnchor, properties.translateAnchor, parameters);
paints.calculateTransitioned(PropertyKey::CircleBlur, properties.blur, parameters);
passes = paint.isVisible() ? RenderPass::Translucent : RenderPass::None;
passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
return hasTransitions;
}
std::unique_ptr<Bucket> CircleLayer::createBucket(StyleBucketParameters& parameters) const {

View File

@@ -2,11 +2,24 @@
#define MBGL_CIRCLE_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
class CirclePaintProperties {
public:
PaintProperty<float> radius = 5.0f;
PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
PaintProperty<float> opacity = 1.0f;
PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
PaintProperty<float> blur = 0;
bool isVisible() const {
return radius > 0 && color.value[3] > 0 && opacity > 0;
}
};
class CircleLayer : public StyleLayer {
public:
std::unique_ptr<StyleLayer> clone() const override;
@@ -15,15 +28,11 @@ public:
void parsePaints(const JSVal&) override;
void cascade(const StyleCascadeParameters&) override;
void recalculate(const StyleCalculationParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
bool hasTransitions() const override;
PaintPropertiesMap paints;
CirclePaintProperties properties;
CirclePaintProperties paint;
};
}

View File

@@ -1,5 +1,4 @@
#include <mbgl/layer/fill_layer.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/style_bucket_parameters.hpp>
#include <mbgl/renderer/fill_bucket.hpp>
@@ -8,56 +7,54 @@ namespace mbgl {
std::unique_ptr<StyleLayer> FillLayer::clone() const {
std::unique_ptr<FillLayer> result = std::make_unique<FillLayer>();
result->copy(*this);
result->paints.paints = paints.paints;
result->paint = paint;
return std::move(result);
}
void FillLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<bool>>("fill-antialias", PropertyKey::FillAntialias, paint, value);
parseProperty<Function<float>>("fill-opacity", PropertyKey::FillOpacity, paint, value);
parseProperty<PropertyTransition>("fill-opacity-transition", PropertyKey::FillOpacity, paint, value);
parseProperty<Function<Color>>("fill-color", PropertyKey::FillColor, paint, value);
parseProperty<PropertyTransition>("fill-color-transition", PropertyKey::FillColor, paint, value);
parseProperty<Function<Color>>("fill-outline-color", PropertyKey::FillOutlineColor, paint, value);
parseProperty<PropertyTransition>("fill-outline-color-transition", PropertyKey::FillOutlineColor, paint, value);
parseProperty<Function<std::array<float, 2>>>("fill-translate", PropertyKey::FillTranslate, paint, value);
parseProperty<PropertyTransition>("fill-translate-transition", PropertyKey::FillTranslate, paint, value);
parseProperty<Function<TranslateAnchorType>>("fill-translate-anchor", PropertyKey::FillTranslateAnchor, paint, value);
parseProperty<Function<Faded<std::string>>>("fill-pattern", PropertyKey::FillImage, paint, value);
});
paint.antialias.parse("fill-antialias", layer);
paint.opacity.parse("fill-opacity", layer);
paint.color.parse("fill-color", layer);
paint.outlineColor.parse("fill-outline-color", layer);
paint.translate.parse("fill-translate", layer);
paint.translateAnchor.parse("fill-translate-anchor", layer);
paint.pattern.parse("fill-pattern", layer);
}
void FillLayer::cascade(const StyleCascadeParameters& parameters) {
paints.cascade(parameters);
paint.antialias.cascade(parameters);
paint.opacity.cascade(parameters);
paint.color.cascade(parameters);
paint.outlineColor.cascade(parameters);
paint.translate.cascade(parameters);
paint.translateAnchor.cascade(parameters);
paint.pattern.cascade(parameters);
}
bool FillLayer::hasTransitions() const {
return paints.hasTransitions();
}
bool FillLayer::recalculate(const StyleCalculationParameters& parameters) {
bool hasTransitions = false;
void FillLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.removeExpiredTransitions(parameters.now);
paints.calculate(PropertyKey::FillAntialias, properties.antialias, parameters);
paints.calculateTransitioned(PropertyKey::FillOpacity, properties.opacity, parameters);
paints.calculateTransitioned(PropertyKey::FillColor, properties.fill_color, parameters);
paints.calculateTransitioned(PropertyKey::FillOutlineColor, properties.stroke_color, parameters);
paints.calculateTransitioned(PropertyKey::FillTranslate, properties.translate, parameters);
paints.calculate(PropertyKey::FillTranslateAnchor, properties.translateAnchor, parameters);
paints.calculate(PropertyKey::FillImage, properties.image, parameters);
hasTransitions |= paint.antialias.calculate(parameters);
hasTransitions |= paint.opacity.calculate(parameters);
hasTransitions |= paint.color.calculate(parameters);
hasTransitions |= paint.outlineColor.calculate(parameters);
hasTransitions |= paint.translate.calculate(parameters);
hasTransitions |= paint.translateAnchor.calculate(parameters);
hasTransitions |= paint.pattern.calculate(parameters);
passes = RenderPass::None;
if (properties.antialias) {
if (paint.antialias) {
passes |= RenderPass::Translucent;
}
if (!properties.image.from.empty() || (properties.fill_color[3] * properties.opacity) < 1.0f) {
if (!paint.pattern.value.from.empty() || (paint.color.value[3] * paint.opacity) < 1.0f) {
passes |= RenderPass::Translucent;
} else {
passes |= RenderPass::Opaque;
}
return hasTransitions;
}
std::unique_ptr<Bucket> FillLayer::createBucket(StyleBucketParameters& parameters) const {

View File

@@ -2,11 +2,21 @@
#define MBGL_FILL_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
class FillPaintProperties {
public:
PaintProperty<bool> antialias = true;
PaintProperty<float> opacity = 1.0f;
PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
PaintProperty<Color> outlineColor = { {{ 0, 0, 0, -1 }} };
PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
PaintProperty<std::string, Faded<std::string>> pattern = { "" };
};
class FillLayer : public StyleLayer {
public:
std::unique_ptr<StyleLayer> clone() const override;
@@ -15,15 +25,11 @@ public:
void parsePaints(const JSVal&) override;
void cascade(const StyleCascadeParameters&) override;
void recalculate(const StyleCalculationParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
bool hasTransitions() const override;
PaintPropertiesMap paints;
FillPaintProperties properties;
FillPaintProperties paint;
};
}

View File

@@ -1,5 +1,4 @@
#include <mbgl/layer/line_layer.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/style_bucket_parameters.hpp>
#include <mbgl/renderer/line_bucket.hpp>
#include <mbgl/map/tile_id.hpp>
@@ -10,7 +9,7 @@ std::unique_ptr<StyleLayer> LineLayer::clone() const {
std::unique_ptr<LineLayer> result = std::make_unique<LineLayer>();
result->copy(*this);
result->layout = layout;
result->paints.paints = paints.paints;
result->paint = paint;
return std::move(result);
}
@@ -22,52 +21,51 @@ void LineLayer::parseLayout(const JSVal& value) {
}
void LineLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<float>>("line-opacity", PropertyKey::LineOpacity, paint, value);
parseProperty<PropertyTransition>("line-opacity-transition", PropertyKey::LineOpacity, paint, value);
parseProperty<Function<Color>>("line-color", PropertyKey::LineColor, paint, value);
parseProperty<PropertyTransition>("line-color-transition", PropertyKey::LineColor, paint, value);
parseProperty<Function<std::array<float,2>>>("line-translate", PropertyKey::LineTranslate, paint, value);
parseProperty<PropertyTransition>("line-translate-transition", PropertyKey::LineTranslate, paint, value);
parseProperty<Function<TranslateAnchorType>>("line-translate-anchor", PropertyKey::LineTranslateAnchor, paint, value);
parseProperty<Function<float>>("line-width", PropertyKey::LineWidth, paint, value);
parseProperty<PropertyTransition>("line-width-transition", PropertyKey::LineWidth, paint, value);
parseProperty<Function<float>>("line-gap-width", PropertyKey::LineGapWidth, paint, value);
parseProperty<PropertyTransition>("line-gap-width-transition", PropertyKey::LineGapWidth, paint, value);
parseProperty<Function<float>>("line-blur", PropertyKey::LineBlur, paint, value);
parseProperty<PropertyTransition>("line-blur-transition", PropertyKey::LineBlur, paint, value);
parseProperty<Function<Faded<std::vector<float>>>>("line-dasharray", PropertyKey::LineDashArray, paint, value);
parseProperty<Function<Faded<std::string>>>("line-pattern", PropertyKey::LineImage, paint, value);
});
paint.opacity.parse("line-opacity", layer);
paint.color.parse("line-color", layer);
paint.translate.parse("line-translate", layer);
paint.translateAnchor.parse("line-translate-anchor", layer);
paint.width.parse("line-width", layer);
paint.gapWidth.parse("line-gap-width", layer);
paint.blur.parse("line-blur", layer);
paint.dasharray.parse("line-dasharray", layer);
paint.pattern.parse("line-pattern", layer);
}
void LineLayer::cascade(const StyleCascadeParameters& parameters) {
paints.cascade(parameters);
paint.opacity.cascade(parameters);
paint.color.cascade(parameters);
paint.translate.cascade(parameters);
paint.translateAnchor.cascade(parameters);
paint.width.cascade(parameters);
paint.gapWidth.cascade(parameters);
paint.blur.cascade(parameters);
paint.dasharray.cascade(parameters);
paint.pattern.cascade(parameters);
}
bool LineLayer::hasTransitions() const {
return paints.hasTransitions();
}
void LineLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.removeExpiredTransitions(parameters.now);
paints.calculateTransitioned(PropertyKey::LineOpacity, properties.opacity, parameters);
paints.calculateTransitioned(PropertyKey::LineColor, properties.color, parameters);
paints.calculateTransitioned(PropertyKey::LineTranslate, properties.translate, parameters);
paints.calculate(PropertyKey::LineTranslateAnchor, properties.translateAnchor, parameters);
paints.calculateTransitioned(PropertyKey::LineWidth, properties.width, parameters);
paints.calculateTransitioned(PropertyKey::LineGapWidth, properties.gap_width, parameters);
paints.calculateTransitioned(PropertyKey::LineBlur, properties.blur, parameters);
paints.calculate(PropertyKey::LineDashArray, properties.dash_array, parameters);
paints.calculate(PropertyKey::LineImage, properties.image, parameters);
bool LineLayer::recalculate(const StyleCalculationParameters& parameters) {
// for scaling dasharrays
StyleCalculationParameters dashArrayParams = parameters;
dashArrayParams.z = std::floor(dashArrayParams.z);
paints.calculate(PropertyKey::LineWidth, properties.dash_line_width, dashArrayParams);
paint.width.calculate(dashArrayParams);
paint.dashLineWidth = paint.width;
passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
bool hasTransitions = false;
hasTransitions |= paint.opacity.calculate(parameters);
hasTransitions |= paint.color.calculate(parameters);
hasTransitions |= paint.translate.calculate(parameters);
hasTransitions |= paint.translateAnchor.calculate(parameters);
hasTransitions |= paint.width.calculate(parameters);
hasTransitions |= paint.gapWidth.calculate(parameters);
hasTransitions |= paint.blur.calculate(parameters);
hasTransitions |= paint.dasharray.calculate(parameters);
hasTransitions |= paint.pattern.calculate(parameters);
passes = paint.isVisible() ? RenderPass::Translucent : RenderPass::None;
return hasTransitions;
}
std::unique_ptr<Bucket> LineLayer::createBucket(StyleBucketParameters& parameters) const {

View File

@@ -2,9 +2,8 @@
#define MBGL_LINE_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
@@ -16,6 +15,26 @@ public:
LayoutProperty<float> roundLimit = 1.0f;
};
class LinePaintProperties {
public:
PaintProperty<float> opacity = 1.0f;
PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
PaintProperty<float> width = 1;
PaintProperty<float> gapWidth = 0;
PaintProperty<float> blur = 0;
PaintProperty<std::vector<float>, Faded<std::vector<float>>> dasharray = { {} };
PaintProperty<std::string, Faded<std::string>> pattern = { "" };
// Special case
float dashLineWidth = 1;
bool isVisible() const {
return opacity > 0 && color.value[3] > 0 && width > 0;
}
};
class LineLayer : public StyleLayer {
public:
std::unique_ptr<StyleLayer> clone() const override;
@@ -24,16 +43,12 @@ public:
void parsePaints(const JSVal&) override;
void cascade(const StyleCascadeParameters&) override;
void recalculate(const StyleCalculationParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
bool hasTransitions() const override;
LineLayoutProperties layout;
PaintPropertiesMap paints;
LinePaintProperties properties;
LinePaintProperties paint;
};
}

View File

@@ -1,5 +1,4 @@
#include <mbgl/layer/raster_layer.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/renderer/bucket.hpp>
namespace mbgl {
@@ -7,48 +6,44 @@ namespace mbgl {
std::unique_ptr<StyleLayer> RasterLayer::clone() const {
std::unique_ptr<RasterLayer> result = std::make_unique<RasterLayer>();
result->copy(*this);
result->paints.paints = paints.paints;
result->paint = paint;
return std::move(result);
}
void RasterLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<float>>("raster-opacity", PropertyKey::RasterOpacity, paint, value);
parseProperty<PropertyTransition>("raster-opacity-transition", PropertyKey::RasterOpacity, paint, value);
parseProperty<Function<float>>("raster-hue-rotate", PropertyKey::RasterHueRotate, paint, value);
parseProperty<PropertyTransition>("raster-hue-rotate-transition", PropertyKey::RasterHueRotate, paint, value);
parseProperty<Function<float>>("raster-brightness-min", PropertyKey::RasterBrightnessLow, paint, value);
parseProperty<Function<float>>("raster-brightness-max", PropertyKey::RasterBrightnessHigh, paint, value);
parseProperty<PropertyTransition>("raster-brightness-transition", PropertyKey::RasterBrightness, paint, value);
parseProperty<Function<float>>("raster-saturation", PropertyKey::RasterSaturation, paint, value);
parseProperty<PropertyTransition>("raster-saturation-transition", PropertyKey::RasterSaturation, paint, value);
parseProperty<Function<float>>("raster-contrast", PropertyKey::RasterContrast, paint, value);
parseProperty<PropertyTransition>("raster-contrast-transition", PropertyKey::RasterContrast, paint, value);
parseProperty<Function<float>>("raster-fade-duration", PropertyKey::RasterFade, paint, value);
parseProperty<PropertyTransition>("raster-fade-duration-transition", PropertyKey::RasterFade, paint, value);
});
paint.opacity.parse("raster-opacity", layer);
paint.hueRotate.parse("raster-hue-rotate", layer);
paint.brightnessMin.parse("raster-brightness-min", layer);
paint.brightnessMax.parse("raster-brightness-max", layer);
paint.saturation.parse("raster-saturation", layer);
paint.contrast.parse("raster-contrast", layer);
paint.fadeDuration.parse("raster-fade-duration", layer);
}
void RasterLayer::cascade(const StyleCascadeParameters& parameters) {
paints.cascade(parameters);
paint.opacity.cascade(parameters);
paint.hueRotate.cascade(parameters);
paint.brightnessMin.cascade(parameters);
paint.brightnessMax.cascade(parameters);
paint.saturation.cascade(parameters);
paint.contrast.cascade(parameters);
paint.fadeDuration.cascade(parameters);
}
bool RasterLayer::hasTransitions() const {
return paints.hasTransitions();
}
bool RasterLayer::recalculate(const StyleCalculationParameters& parameters) {
bool hasTransitions = false;
void RasterLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.removeExpiredTransitions(parameters.now);
hasTransitions |= paint.opacity.calculate(parameters);
hasTransitions |= paint.hueRotate.calculate(parameters);
hasTransitions |= paint.brightnessMin.calculate(parameters);
hasTransitions |= paint.brightnessMax.calculate(parameters);
hasTransitions |= paint.saturation.calculate(parameters);
hasTransitions |= paint.contrast.calculate(parameters);
hasTransitions |= paint.fadeDuration.calculate(parameters);
paints.calculateTransitioned(PropertyKey::RasterOpacity, properties.opacity, parameters);
paints.calculateTransitioned(PropertyKey::RasterHueRotate, properties.hue_rotate, parameters);
paints.calculateTransitioned(PropertyKey::RasterBrightnessLow, properties.brightness[0], parameters);
paints.calculateTransitioned(PropertyKey::RasterBrightnessHigh, properties.brightness[1], parameters);
paints.calculateTransitioned(PropertyKey::RasterSaturation, properties.saturation, parameters);
paints.calculateTransitioned(PropertyKey::RasterContrast, properties.contrast, parameters);
paints.calculateTransitioned(PropertyKey::RasterFade, properties.fade, parameters);
passes = paint.opacity > 0 ? RenderPass::Translucent : RenderPass::None;
passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
return hasTransitions;
}
std::unique_ptr<Bucket> RasterLayer::createBucket(StyleBucketParameters&) const {

View File

@@ -2,11 +2,21 @@
#define MBGL_RASTER_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
class RasterPaintProperties {
public:
PaintProperty<float> opacity = 1.0f;
PaintProperty<float> hueRotate = 0.0f;
PaintProperty<float> brightnessMin = 0.0f;
PaintProperty<float> brightnessMax = 1.0f;
PaintProperty<float> saturation = 0.0f;
PaintProperty<float> contrast = 0.0f;
PaintProperty<float> fadeDuration = 0.0f;
};
class RasterLayer : public StyleLayer {
public:
std::unique_ptr<StyleLayer> clone() const override;
@@ -15,15 +25,11 @@ public:
void parsePaints(const JSVal&) override;
void cascade(const StyleCascadeParameters&) override;
void recalculate(const StyleCalculationParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
bool hasTransitions() const override;
PaintPropertiesMap paints;
RasterPaintProperties properties;
RasterPaintProperties paint;
};
}

View File

@@ -1,8 +1,6 @@
#include <mbgl/layer/symbol_layer.hpp>
#include <mbgl/renderer/symbol_bucket.hpp>
#include <mbgl/map/tile_id.hpp>
#include <mbgl/style/property_evaluator.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/style_bucket_parameters.hpp>
namespace mbgl {
@@ -11,7 +9,7 @@ std::unique_ptr<StyleLayer> SymbolLayer::clone() const {
std::unique_ptr<SymbolLayer> result = std::make_unique<SymbolLayer>();
result->copy(*this);
result->layout = layout;
result->paints.paints = paints.paints;
result->paint = paint;
return std::move(result);
}
@@ -52,71 +50,70 @@ void SymbolLayer::parseLayout(const JSVal& value) {
}
void SymbolLayer::parsePaints(const JSVal& layer) {
paints.parseEach(layer, [&] (ClassProperties& paint, const JSVal& value) {
parseProperty<Function<float>>("icon-opacity", PropertyKey::IconOpacity, paint, value);
parseProperty<PropertyTransition>("icon-opacity-transition", PropertyKey::IconOpacity, paint, value);
parseProperty<Function<Color>>("icon-color", PropertyKey::IconColor, paint, value);
parseProperty<PropertyTransition>("icon-color-transition", PropertyKey::IconColor, paint, value);
parseProperty<Function<Color>>("icon-halo-color", PropertyKey::IconHaloColor, paint, value);
parseProperty<PropertyTransition>("icon-halo-color-transition", PropertyKey::IconHaloColor, paint, value);
parseProperty<Function<float>>("icon-halo-width", PropertyKey::IconHaloWidth, paint, value);
parseProperty<PropertyTransition>("icon-halo-width-transition", PropertyKey::IconHaloWidth, paint, value);
parseProperty<Function<float>>("icon-halo-blur", PropertyKey::IconHaloBlur, paint, value);
parseProperty<PropertyTransition>("icon-halo-blur-transition", PropertyKey::IconHaloBlur, paint, value);
parseProperty<Function<std::array<float, 2>>>("icon-translate", PropertyKey::IconTranslate, paint, value);
parseProperty<PropertyTransition>("icon-translate-transition", PropertyKey::IconTranslate, paint, value);
parseProperty<Function<TranslateAnchorType>>("icon-translate-anchor", PropertyKey::IconTranslateAnchor, paint, value);
paint.icon.opacity.parse("icon-opacity", layer);
paint.icon.color.parse("icon-color", layer);
paint.icon.haloColor.parse("icon-halo-color", layer);
paint.icon.haloWidth.parse("icon-halo-width", layer);
paint.icon.haloBlur.parse("icon-halo-blur", layer);
paint.icon.translate.parse("icon-translate", layer);
paint.icon.translateAnchor.parse("icon-translate-anchor", layer);
parseProperty<Function<float>>("text-opacity", PropertyKey::TextOpacity, paint, value);
parseProperty<PropertyTransition>("text-opacity-transition", PropertyKey::TextOpacity, paint, value);
parseProperty<Function<Color>>("text-color", PropertyKey::TextColor, paint, value);
parseProperty<PropertyTransition>("text-color-transition", PropertyKey::TextColor, paint, value);
parseProperty<Function<Color>>("text-halo-color", PropertyKey::TextHaloColor, paint, value);
parseProperty<PropertyTransition>("text-halo-color-transition", PropertyKey::TextHaloColor, paint, value);
parseProperty<Function<float>>("text-halo-width", PropertyKey::TextHaloWidth, paint, value);
parseProperty<PropertyTransition>("text-halo-width-transition", PropertyKey::TextHaloWidth, paint, value);
parseProperty<Function<float>>("text-halo-blur", PropertyKey::TextHaloBlur, paint, value);
parseProperty<PropertyTransition>("text-halo-blur-transition", PropertyKey::TextHaloBlur, paint, value);
parseProperty<Function<std::array<float, 2>>>("text-translate", PropertyKey::TextTranslate, paint, value);
parseProperty<PropertyTransition>("text-translate-transition", PropertyKey::TextTranslate, paint, value);
parseProperty<Function<TranslateAnchorType>>("text-translate-anchor", PropertyKey::TextTranslateAnchor, paint, value);
});
paint.text.opacity.parse("text-opacity", layer);
paint.text.color.parse("text-color", layer);
paint.text.haloColor.parse("text-halo-color", layer);
paint.text.haloWidth.parse("text-halo-width", layer);
paint.text.haloBlur.parse("text-halo-blur", layer);
paint.text.translate.parse("text-translate", layer);
paint.text.translateAnchor.parse("text-translate-anchor", layer);
}
void SymbolLayer::cascade(const StyleCascadeParameters& parameters) {
paints.cascade(parameters);
paint.icon.opacity.cascade(parameters);
paint.icon.color.cascade(parameters);
paint.icon.haloColor.cascade(parameters);
paint.icon.haloWidth.cascade(parameters);
paint.icon.haloBlur.cascade(parameters);
paint.icon.translate.cascade(parameters);
paint.icon.translateAnchor.cascade(parameters);
paint.text.opacity.cascade(parameters);
paint.text.color.cascade(parameters);
paint.text.haloColor.cascade(parameters);
paint.text.haloWidth.cascade(parameters);
paint.text.haloBlur.cascade(parameters);
paint.text.translate.cascade(parameters);
paint.text.translateAnchor.cascade(parameters);
}
bool SymbolLayer::hasTransitions() const {
return paints.hasTransitions();
}
bool SymbolLayer::recalculate(const StyleCalculationParameters& parameters) {
bool hasTransitions = false;
void SymbolLayer::recalculate(const StyleCalculationParameters& parameters) {
paints.removeExpiredTransitions(parameters.now);
hasTransitions |= paint.icon.opacity.calculate(parameters);
hasTransitions |= paint.icon.color.calculate(parameters);
hasTransitions |= paint.icon.haloColor.calculate(parameters);
hasTransitions |= paint.icon.haloWidth.calculate(parameters);
hasTransitions |= paint.icon.haloBlur.calculate(parameters);
hasTransitions |= paint.icon.translate.calculate(parameters);
hasTransitions |= paint.icon.translateAnchor.calculate(parameters);
paints.calculateTransitioned(PropertyKey::IconOpacity, properties.icon.opacity, parameters);
paints.calculateTransitioned(PropertyKey::IconColor, properties.icon.color, parameters);
paints.calculateTransitioned(PropertyKey::IconHaloColor, properties.icon.halo_color, parameters);
paints.calculateTransitioned(PropertyKey::IconHaloWidth, properties.icon.halo_width, parameters);
paints.calculateTransitioned(PropertyKey::IconHaloBlur, properties.icon.halo_blur, parameters);
paints.calculateTransitioned(PropertyKey::IconTranslate, properties.icon.translate, parameters);
paints.calculate(PropertyKey::IconTranslateAnchor, properties.icon.translate_anchor, parameters);
paints.calculateTransitioned(PropertyKey::TextOpacity, properties.text.opacity, parameters);
paints.calculateTransitioned(PropertyKey::TextColor, properties.text.color, parameters);
paints.calculateTransitioned(PropertyKey::TextHaloColor, properties.text.halo_color, parameters);
paints.calculateTransitioned(PropertyKey::TextHaloWidth, properties.text.halo_width, parameters);
paints.calculateTransitioned(PropertyKey::TextHaloBlur, properties.text.halo_blur, parameters);
paints.calculateTransitioned(PropertyKey::TextTranslate, properties.text.translate, parameters);
paints.calculate(PropertyKey::TextTranslateAnchor, properties.text.translate_anchor, parameters);
hasTransitions |= paint.text.opacity.calculate(parameters);
hasTransitions |= paint.text.color.calculate(parameters);
hasTransitions |= paint.text.haloColor.calculate(parameters);
hasTransitions |= paint.text.haloWidth.calculate(parameters);
hasTransitions |= paint.text.haloBlur.calculate(parameters);
hasTransitions |= paint.text.translate.calculate(parameters);
hasTransitions |= paint.text.translateAnchor.calculate(parameters);
// text-size and icon-size are layout properties but they also need to be evaluated as paint properties:
layout.icon.size.calculate(parameters);
layout.text.size.calculate(parameters);
properties.icon.size = layout.icon.size;
properties.text.size = layout.text.size;
paint.icon.size = layout.icon.size;
paint.text.size = layout.text.size;
passes = properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
passes = (paint.icon.isVisible() || paint.text.isVisible())
? RenderPass::Translucent : RenderPass::None;
return hasTransitions;
}
std::unique_ptr<Bucket> SymbolLayer::createBucket(StyleBucketParameters& parameters) const {

View File

@@ -2,9 +2,8 @@
#define MBGL_SYMBOL_LAYER
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
namespace mbgl {
@@ -55,6 +54,32 @@ public:
float textMaxSize = 16.0f;
};
class SymbolPaintProperties {
public:
class PaintProperties {
public:
PaintProperties(float size_) : size(size_) {}
PaintProperty<float> opacity = 1.0f;
PaintProperty<Color> color = { {{ 0, 0, 0, 1 }} };
PaintProperty<Color> haloColor = { {{ 0, 0, 0, 0 }} };
PaintProperty<float> haloWidth = 0.0f;
PaintProperty<float> haloBlur = 0.0f;
PaintProperty<std::array<float, 2>> translate = { {{ 0, 0 }} };
PaintProperty<TranslateAnchorType> translateAnchor = TranslateAnchorType::Map;
// Special case
float size;
bool isVisible() const {
return opacity > 0 && (color.value[3] > 0 || haloColor.value[3] > 0) && size > 0;
}
};
PaintProperties icon { 1.0f };
PaintProperties text { 16.0f };
};
class SymbolLayer : public StyleLayer {
public:
std::unique_ptr<StyleLayer> clone() const override;
@@ -63,16 +88,12 @@ public:
void parsePaints(const JSVal&) override;
void cascade(const StyleCascadeParameters&) override;
void recalculate(const StyleCalculationParameters&) override;
bool recalculate(const StyleCalculationParameters&) override;
std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const override;
bool hasTransitions() const override;
SymbolLayoutProperties layout;
PaintPropertiesMap paints;
SymbolPaintProperties properties;
SymbolPaintProperties paint;
};
}

View File

@@ -282,8 +282,8 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
if (layer.visibility == VisibilityType::None) continue;
if (layer.type == StyleLayerType::Background) {
// This layer defines a background color/image.
auto& props = dynamic_cast<const BackgroundLayer&>(layer).properties;
if (props.image.from.empty()) {
auto& props = dynamic_cast<const BackgroundLayer&>(layer).paint;
if (props.pattern.value.from.empty()) {
// This is a solid background. We can use glClear().
background = props.color;
background[0] *= props.opacity;
@@ -352,14 +352,14 @@ std::vector<RenderItem> Painter::determineRenderOrder(const Style& style) {
void Painter::renderBackground(const BackgroundLayer& layer) {
// Note: This function is only called for textured background. Otherwise, the background color
// is created with glClear.
const BackgroundPaintProperties& properties = layer.properties;
const BackgroundPaintProperties& properties = layer.paint;
if (!properties.image.to.empty()) {
if (!properties.pattern.value.to.empty()) {
if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque))
return;
SpriteAtlasPosition imagePosA = spriteAtlas->getPosition(properties.image.from, true);
SpriteAtlasPosition imagePosB = spriteAtlas->getPosition(properties.image.to, true);
SpriteAtlasPosition imagePosA = spriteAtlas->getPosition(properties.pattern.value.from, true);
SpriteAtlasPosition imagePosB = spriteAtlas->getPosition(properties.pattern.value.to, true);
float zoomFraction = state.getZoomFraction();
config.program = patternShader->program;
@@ -368,7 +368,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
patternShader->u_pattern_br_a = imagePosA.br;
patternShader->u_pattern_tl_b = imagePosB.tl;
patternShader->u_pattern_br_b = imagePosB.br;
patternShader->u_mix = properties.image.t;
patternShader->u_mix = properties.pattern.value.t;
patternShader->u_opacity = properties.opacity;
LatLng latLng = state.getLatLng();
@@ -379,11 +379,11 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
mat3 matrixA;
matrix::identity(matrixA);
matrix::scale(matrixA, matrixA,
1.0f / (sizeA[0] * properties.image.fromScale),
1.0f / (sizeA[1] * properties.image.fromScale));
1.0f / (sizeA[0] * properties.pattern.value.fromScale),
1.0f / (sizeA[1] * properties.pattern.value.fromScale));
matrix::translate(matrixA, matrixA,
std::fmod(center.x * 512, sizeA[0] * properties.image.fromScale),
std::fmod(center.y * 512, sizeA[1] * properties.image.fromScale));
std::fmod(center.x * 512, sizeA[0] * properties.pattern.value.fromScale),
std::fmod(center.y * 512, sizeA[1] * properties.pattern.value.fromScale));
matrix::rotate(matrixA, matrixA, -state.getAngle());
matrix::scale(matrixA, matrixA,
scale * state.getWidth() / 2,
@@ -393,11 +393,11 @@ void Painter::renderBackground(const BackgroundLayer& layer) {
mat3 matrixB;
matrix::identity(matrixB);
matrix::scale(matrixB, matrixB,
1.0f / (sizeB[0] * properties.image.toScale),
1.0f / (sizeB[1] * properties.image.toScale));
1.0f / (sizeB[0] * properties.pattern.value.toScale),
1.0f / (sizeB[1] * properties.pattern.value.toScale));
matrix::translate(matrixB, matrixB,
std::fmod(center.x * 512, sizeB[0] * properties.image.toScale),
std::fmod(center.y * 512, sizeB[1] * properties.image.toScale));
std::fmod(center.x * 512, sizeB[0] * properties.pattern.value.toScale),
std::fmod(center.y * 512, sizeB[1] * properties.pattern.value.toScale));
matrix::rotate(matrixB, matrixB, -state.getAngle());
matrix::scale(matrixB, matrixB,
scale * state.getWidth() / 2,

View File

@@ -20,7 +20,7 @@ void Painter::renderCircle(CircleBucket& bucket,
config.stencilTest = GL_FALSE;
const CirclePaintProperties& properties = layer.properties;
const CirclePaintProperties& properties = layer.paint;
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
Color color = properties.color;
@@ -40,7 +40,7 @@ void Painter::renderCircle(CircleBucket& bucket,
circleShader->u_matrix = vtxMatrix;
circleShader->u_exmatrix = extrudeMatrix;
circleShader->u_color = color;
circleShader->u_blur = std::max(properties.blur, antialiasing);
circleShader->u_blur = std::max<float>(properties.blur, antialiasing);
circleShader->u_size = properties.radius;
bucket.drawCircles(*circleShader);

View File

@@ -12,16 +12,16 @@
using namespace mbgl;
void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileID& id, const mat4& matrix) {
const FillPaintProperties& properties = layer.properties;
const FillPaintProperties& properties = layer.paint;
mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor);
Color fill_color = properties.fill_color;
Color fill_color = properties.color;
fill_color[0] *= properties.opacity;
fill_color[1] *= properties.opacity;
fill_color[2] *= properties.opacity;
fill_color[3] *= properties.opacity;
Color stroke_color = properties.stroke_color;
Color stroke_color = properties.outlineColor;
if (stroke_color[3] < 0) {
stroke_color = fill_color;
} else {
@@ -31,7 +31,7 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
stroke_color[3] *= properties.opacity;
}
const bool pattern = !properties.image.from.empty();
const bool pattern = !properties.pattern.value.from.empty();
bool outline = properties.antialias && !pattern && stroke_color != fill_color;
bool fringeline = properties.antialias && !pattern && stroke_color == fill_color;
@@ -63,20 +63,20 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
// Image fill.
if (pass == RenderPass::Translucent) {
const SpriteAtlasPosition posA = spriteAtlas->getPosition(properties.image.from, true);
const SpriteAtlasPosition posB = spriteAtlas->getPosition(properties.image.to, true);
const SpriteAtlasPosition posA = spriteAtlas->getPosition(properties.pattern.value.from, true);
const SpriteAtlasPosition posB = spriteAtlas->getPosition(properties.pattern.value.to, true);
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z) / id.overscaling;
mat3 patternMatrixA;
matrix::identity(patternMatrixA);
matrix::scale(patternMatrixA, patternMatrixA,
1.0f / (posA.size[0] * factor * properties.image.fromScale),
1.0f / (posA.size[1] * factor * properties.image.fromScale));
1.0f / (posA.size[0] * factor * properties.pattern.value.fromScale),
1.0f / (posA.size[1] * factor * properties.pattern.value.fromScale));
mat3 patternMatrixB;
matrix::identity(patternMatrixB);
matrix::scale(patternMatrixB, patternMatrixB,
1.0f / (posB.size[0] * factor * properties.image.toScale),
1.0f / (posB.size[1] * factor * properties.image.toScale));
1.0f / (posB.size[0] * factor * properties.pattern.value.toScale),
1.0f / (posB.size[1] * factor * properties.pattern.value.toScale));
config.program = patternShader->program;
patternShader->u_matrix = vtxMatrix;
@@ -86,7 +86,7 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI
patternShader->u_pattern_br_b = posB.br;
patternShader->u_opacity = properties.opacity;
patternShader->u_image = 0;
patternShader->u_mix = properties.image.t;
patternShader->u_mix = properties.pattern.value.t;
patternShader->u_patternmatrix_a = patternMatrixA;
patternShader->u_patternmatrix_b = patternMatrixB;

View File

@@ -23,7 +23,7 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
config.depthTest = GL_TRUE;
config.depthMask = GL_FALSE;
const auto& properties = layer.properties;
const auto& properties = layer.paint;
const auto& layout = bucket.layout;
// the distance over which the line edge fades out.
@@ -36,8 +36,8 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
float offset = 0;
float shift = 0;
if (properties.gap_width != 0) {
inset = properties.gap_width / 2.0 + antialiasing * 0.5;
if (properties.gapWidth != 0) {
inset = properties.gapWidth / 2.0 + antialiasing * 0.5;
edgeWidth = properties.width;
// shift outer lines half a pixel towards the middle to eliminate the crack
@@ -69,7 +69,7 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
setDepthSublayer(0);
if (!properties.dash_array.from.empty()) {
if (!properties.dasharray.value.from.empty()) {
config.program = linesdfShader->program;
@@ -80,14 +80,14 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
linesdfShader->u_blur = blur;
linesdfShader->u_color = color;
LinePatternPos posA = lineAtlas->getDashPosition(properties.dash_array.from, layout.cap == CapType::Round);
LinePatternPos posB = lineAtlas->getDashPosition(properties.dash_array.to, layout.cap == CapType::Round);
LinePatternPos posA = lineAtlas->getDashPosition(properties.dasharray.value.from, layout.cap == CapType::Round);
LinePatternPos posB = lineAtlas->getDashPosition(properties.dasharray.value.to, layout.cap == CapType::Round);
lineAtlas->bind();
float patternratio = std::pow(2.0, std::floor(::log2(state.getScale())) - id.z) / 8.0 * id.overscaling;
float scaleXA = patternratio / posA.width / properties.dash_line_width / properties.dash_array.fromScale;
float scaleXA = patternratio / posA.width / properties.dashLineWidth / properties.dasharray.value.fromScale;
float scaleYA = -posA.height / 2.0;
float scaleXB = patternratio / posB.width / properties.dash_line_width / properties.dash_array.toScale;
float scaleXB = patternratio / posB.width / properties.dashLineWidth / properties.dasharray.value.toScale;
float scaleYB = -posB.height / 2.0;
linesdfShader->u_patternscale_a = {{ scaleXA, scaleYA }};
@@ -95,16 +95,16 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
linesdfShader->u_patternscale_b = {{ scaleXB, scaleYB }};
linesdfShader->u_tex_y_b = posB.y;
linesdfShader->u_image = 0;
linesdfShader->u_sdfgamma = lineAtlas->width / (properties.dash_line_width * std::min(posA.width, posB.width) * 256.0 * data.pixelRatio) / 2;
linesdfShader->u_mix = properties.dash_array.t;
linesdfShader->u_sdfgamma = lineAtlas->width / (properties.dashLineWidth * std::min(posA.width, posB.width) * 256.0 * data.pixelRatio) / 2;
linesdfShader->u_mix = properties.dasharray.value.t;
linesdfShader->u_extra = extra;
linesdfShader->u_antialiasingmatrix = antialiasingMatrix;
bucket.drawLineSDF(*linesdfShader);
} else if (!properties.image.from.empty()) {
SpriteAtlasPosition imagePosA = spriteAtlas->getPosition(properties.image.from, true);
SpriteAtlasPosition imagePosB = spriteAtlas->getPosition(properties.image.to, true);
} else if (!properties.pattern.value.from.empty()) {
SpriteAtlasPosition imagePosA = spriteAtlas->getPosition(properties.pattern.value.from, true);
SpriteAtlasPosition imagePosB = spriteAtlas->getPosition(properties.pattern.value.to, true);
float factor = 8.0 / std::pow(2, state.getIntegerZoom() - id.z) * id.overscaling;
@@ -116,13 +116,13 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI
linepatternShader->u_ratio = ratio;
linepatternShader->u_blur = blur;
linepatternShader->u_pattern_size_a = {{imagePosA.size[0] * factor * properties.image.fromScale, imagePosA.size[1]}};
linepatternShader->u_pattern_size_a = {{imagePosA.size[0] * factor * properties.pattern.value.fromScale, imagePosA.size[1]}};
linepatternShader->u_pattern_tl_a = imagePosA.tl;
linepatternShader->u_pattern_br_a = imagePosA.br;
linepatternShader->u_pattern_size_b = {{imagePosB.size[0] * factor * properties.image.toScale, imagePosB.size[1]}};
linepatternShader->u_pattern_size_b = {{imagePosB.size[0] * factor * properties.pattern.value.toScale, imagePosB.size[1]}};
linepatternShader->u_pattern_tl_b = imagePosB.tl;
linepatternShader->u_pattern_br_b = imagePosB.br;
linepatternShader->u_fade = properties.image.t;
linepatternShader->u_fade = properties.pattern.value.t;
linepatternShader->u_opacity = properties.opacity;
linepatternShader->u_extra = extra;
linepatternShader->u_antialiasingmatrix = antialiasingMatrix;

View File

@@ -9,18 +9,18 @@ using namespace mbgl;
void Painter::renderRaster(RasterBucket& bucket, const RasterLayer& layer, const TileID&, const mat4& matrix) {
if (pass != RenderPass::Translucent) return;
const RasterPaintProperties& properties = layer.properties;
const RasterPaintProperties& properties = layer.paint;
if (bucket.hasData()) {
config.program = rasterShader->program;
rasterShader->u_matrix = matrix;
rasterShader->u_buffer = 0;
rasterShader->u_opacity = properties.opacity;
rasterShader->u_brightness_low = properties.brightness[0];
rasterShader->u_brightness_high = properties.brightness[1];
rasterShader->u_brightness_low = properties.brightnessMin;
rasterShader->u_brightness_high = properties.brightnessMax;
rasterShader->u_saturation_factor = saturationFactor(properties.saturation);
rasterShader->u_contrast_factor = contrastFactor(properties.contrast);
rasterShader->u_spin_weights = spinWeights(properties.hue_rotate);
rasterShader->u_spin_weights = spinWeights(properties.hueRotate);
config.stencilOp.reset();
config.stencilTest = GL_TRUE;

View File

@@ -25,7 +25,7 @@ void Painter::renderSDF(SymbolBucket &bucket,
SDFShader& sdfShader,
void (SymbolBucket::*drawSDF)(SDFShader&))
{
mat4 vtxMatrix = translatedMatrix(matrix, styleProperties.translate, id, styleProperties.translate_anchor);
mat4 vtxMatrix = translatedMatrix(matrix, styleProperties.translate, id, styleProperties.translateAnchor);
bool skewed = (bucketProperties.rotationAlignment == RotationAlignmentType::Map);
mat4 exMatrix;
@@ -89,28 +89,28 @@ void Painter::renderSDF(SymbolBucket &bucket,
// We're drawing in the translucent pass which is bottom-to-top, so we need
// to draw the halo first.
if (styleProperties.halo_color[3] > 0.0f && styleProperties.halo_width > 0.0f) {
sdfShader.u_gamma = (styleProperties.halo_blur * blurOffset / fontScale / sdfPx + gamma) * gammaScale;
if (styleProperties.haloColor.value[3] > 0.0f && styleProperties.haloWidth > 0.0f) {
sdfShader.u_gamma = (styleProperties.haloBlur * blurOffset / fontScale / sdfPx + gamma) * gammaScale;
if (styleProperties.opacity < 1.0f) {
Color color = styleProperties.halo_color;
Color color = styleProperties.haloColor;
color[0] *= styleProperties.opacity;
color[1] *= styleProperties.opacity;
color[2] *= styleProperties.opacity;
color[3] *= styleProperties.opacity;
sdfShader.u_color = color;
} else {
sdfShader.u_color = styleProperties.halo_color;
sdfShader.u_color = styleProperties.haloColor;
}
sdfShader.u_buffer = (haloOffset - styleProperties.halo_width / fontScale) / sdfPx;
sdfShader.u_buffer = (haloOffset - styleProperties.haloWidth / fontScale) / sdfPx;
setDepthSublayer(0);
(bucket.*drawSDF)(sdfShader);
}
// Then, we draw the text/icon over the halo
if (styleProperties.color[3] > 0.0f) {
if (styleProperties.color.value[3] > 0.0f) {
sdfShader.u_gamma = gamma * gammaScale;
if (styleProperties.opacity < 1.0f) {
@@ -137,7 +137,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
return;
}
const auto& properties = layer.properties;
const auto& properties = layer.paint;
const auto& layout = bucket.layout;
config.depthMask = GL_FALSE;
@@ -206,7 +206,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const
*sdfIconShader,
&SymbolBucket::drawIcons);
} else {
mat4 vtxMatrix = translatedMatrix(matrix, properties.icon.translate, id, properties.icon.translate_anchor);
mat4 vtxMatrix = translatedMatrix(matrix, properties.icon.translate, id, properties.icon.translateAnchor);
bool skewed = layout.icon.rotationAlignment == RotationAlignmentType::Map;
mat4 exMatrix;

View File

@@ -1,52 +0,0 @@
#include <mbgl/style/applied_class_properties.hpp>
namespace mbgl {
AppliedClassPropertyValue::AppliedClassPropertyValue(ClassID class_id, const TimePoint& begin_, const TimePoint& end_, const PropertyValue &value_)
: name(class_id),
begin(begin_),
end(end_),
value(value_) {}
// Returns the ID of the most recent
ClassID AppliedClassPropertyValues::mostRecent() const {
return propertyValues.empty() ? ClassID::Fallback : propertyValues.back().name;
}
void AppliedClassPropertyValues::add(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value) {
propertyValues.emplace_back(class_id, begin, end, value);
}
bool AppliedClassPropertyValues::hasTransitions() const {
return propertyValues.size() > 1;
}
// Erase all items in the property list that are before a completed transition.
// Then, if the only remaining property is a Fallback value, remove it too.
void AppliedClassPropertyValues::cleanup(const TimePoint& now) {
// Iterate backwards, but without using the rbegin/rend interface since we need forward
// iterators to use .erase().
for (auto it = propertyValues.end(), begin = propertyValues.begin(); it != begin;) {
// If the property is finished, break iteration and delete all remaining items.
if ((--it)->end <= now) {
// Removes all items that precede the current iterator, but *not* the element currently
// pointed to by the iterator. This preserves the last completed transition as the
// first element in the property list.
propertyValues.erase(begin, it);
// Also erase the pivot element if it's a fallback value. This means we can remove the
// entire applied properties object as well, because we already have the fallback
// value set as the default.
if (it->name == ClassID::Fallback) {
propertyValues.erase(it);
}
break;
}
}
}
bool AppliedClassPropertyValues::empty() const {
return propertyValues.empty();
}
}

View File

@@ -1,39 +0,0 @@
#ifndef MBGL_STYLE_APPLIED_CLASS_PROPERTIES
#define MBGL_STYLE_APPLIED_CLASS_PROPERTIES
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/class_dictionary.hpp>
#include <mbgl/util/chrono.hpp>
#include <list>
namespace mbgl {
class AppliedClassPropertyValue {
public:
AppliedClassPropertyValue(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value);
public:
const ClassID name;
const TimePoint begin;
const TimePoint end;
const PropertyValue value;
};
class AppliedClassPropertyValues {
public:
std::list<AppliedClassPropertyValue> propertyValues;
public:
// Returns the ID of the most recent
ClassID mostRecent() const;
void add(ClassID class_id, const TimePoint& begin, const TimePoint& end, const PropertyValue &value);
void cleanup(const TimePoint& now);
bool hasTransitions() const;
bool empty() const;
};
}
#endif

View File

@@ -1,14 +0,0 @@
#include <mbgl/style/class_properties.hpp>
namespace mbgl {
PropertyTransition ClassProperties::getTransition(PropertyKey key) const {
auto it = transitions.find(key);
if (it == transitions.end()) {
return PropertyTransition();
} else {
return it->second;
}
}
}

View File

@@ -1,48 +0,0 @@
#ifndef MBGL_STYLE_CLASS_PROPERTIES
#define MBGL_STYLE_CLASS_PROPERTIES
#include <mbgl/style/property_key.hpp>
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/property_evaluator.hpp>
#include <mbgl/style/property_transition.hpp>
#include <map>
namespace mbgl {
class ClassProperties {
public:
inline void set(PropertyKey key, const PropertyValue &value) {
properties.emplace(key, value);
}
inline void set(PropertyKey key, const PropertyTransition &transition) {
transitions.emplace(key, transition);
}
PropertyTransition getTransition(PropertyKey key) const;
// Route-through iterable interface so that you can iterate on the object as is.
inline std::map<PropertyKey, PropertyValue>::const_iterator begin() const {
return properties.begin();
}
inline std::map<PropertyKey, PropertyValue>::const_iterator end() const {
return properties.end();
}
template <typename T>
void calculate(PropertyKey key, T& target, const float z) const {
auto it = properties.find(key);
if (it != properties.end()) {
target = mapbox::util::apply_visitor(PropertyEvaluator<T>(StyleCalculationParameters(z)), it->second);
}
}
public:
std::map<PropertyKey, PropertyValue> properties;
std::map<PropertyKey, PropertyTransition> transitions;
};
}
#endif

View File

@@ -29,8 +29,8 @@ public:
T evaluate(const StyleCalculationParameters&) const;
private:
const float base = 1;
const std::vector<std::pair<float, T>> stops;
float base = 1;
std::vector<std::pair<float, T>> stops;
};
// Partial specialization for cross-faded properties (*-pattern, line-dasharray).
@@ -50,7 +50,7 @@ public:
Faded<T> evaluate(const StyleCalculationParameters&) const;
private:
const std::vector<std::pair<float, T>> stops;
std::vector<std::pair<float, T>> stops;
};
}

View File

@@ -17,7 +17,7 @@ public:
void parse(const char * name, const JSVal& layout) {
if (layout.HasMember(name)) {
parsedValue = detail::parseProperty<Function<T>>(name, layout[name]);
parsedValue = parseProperty<Function<T>>(name, layout[name]);
}
}

View File

@@ -1,126 +0,0 @@
#include <mbgl/style/paint_properties_map.hpp>
#include <mbgl/style/property_transition.hpp>
#include <mbgl/style/property_fallback.hpp>
#include <mbgl/style/class_properties.hpp>
#include <mbgl/style/style_cascade_parameters.hpp>
namespace mbgl {
void PaintPropertiesMap::parseEach(const JSVal& layer, std::function<void (ClassProperties &, const JSVal &)> parsePaint) {
paints.clear();
rapidjson::Value::ConstMemberIterator itr = layer.MemberBegin();
for (; itr != layer.MemberEnd(); ++itr) {
const std::string name { itr->name.GetString(), itr->name.GetStringLength() };
if (name == "paint") {
parsePaint(paints[ClassID::Default], itr->value);
} else if (name.compare(0, 6, "paint.") == 0 && name.length() > 6) {
parsePaint(paints[ClassDictionary::Get().lookup(name.substr(6))], itr->value);
}
}
}
void PaintPropertiesMap::cascade(const StyleCascadeParameters& parameters) {
// Stores all keys that we have already added transitions for.
std::set<PropertyKey> alreadyApplied;
// We only apply the default style values if there are no classes set.
if (parameters.classes.empty()) {
cascadeClass(ClassID::Default, alreadyApplied, parameters);
return;
}
// Reverse iterate through all class names and apply them last to first.
for (auto it = parameters.classes.rbegin(); it != parameters.classes.rend(); ++it) {
// From here on, we're only dealing with IDs to avoid comparing strings all the time.
cascadeClass(ClassDictionary::Get().lookup(*it), alreadyApplied, parameters);
}
// As the last class, apply the default class.
cascadeClass(ClassID::Default, alreadyApplied, parameters);
// Make sure that we also transition to the fallback value for keys that aren't changed by
// any applied classes.
for (auto& propertyPair : appliedStyle) {
const PropertyKey key = propertyPair.first;
if (alreadyApplied.find(key) != alreadyApplied.end()) {
// This property has already been set by a previous class, so we don't need to
// transition to the fallback.
continue;
}
AppliedClassPropertyValues &appliedProperties = propertyPair.second;
// Make sure that we don't do double transitions to the fallback value.
if (appliedProperties.mostRecent() == ClassID::Fallback) {
continue;
}
// This property key hasn't been set by a previous class, so we need to add a transition
// to the fallback value for that key.
const TimePoint begin = parameters.now + *parameters.defaultTransition.delay;
const TimePoint end = begin + *parameters.defaultTransition.duration;
const PropertyValue &value = PropertyFallbackValue::Get(key);
appliedProperties.add(ClassID::Fallback, begin, end, value);
}
}
void PaintPropertiesMap::cascadeClass(const ClassID classID,
std::set<PropertyKey>& alreadyApplied,
const StyleCascadeParameters& parameters) {
auto styleIt = paints.find(classID);
if (styleIt == paints.end()) {
// There is no class in this layer with this class_name.
return;
}
// Loop through all the properties in this style, and add transitions to them, if they're
// not already the most recent transition.
const ClassProperties& classProperties = styleIt->second;
for (const auto& propertyPair : classProperties) {
PropertyKey key = propertyPair.first;
if (alreadyApplied.find(key) != alreadyApplied.end()) {
// This property has already been set by a previous class.
continue;
}
// Mark this property as written by a previous class, so that subsequent
// classes won't override this.
alreadyApplied.insert(key);
// If the most recent transition is not the one with the highest priority, create
// a transition.
AppliedClassPropertyValues &appliedProperties = appliedStyle[key];
if (appliedProperties.mostRecent() != classID) {
PropertyTransition transition = classProperties.getTransition(key);
Duration delay = transition.delay ? *transition.delay : *parameters.defaultTransition.delay;
Duration duration = transition.duration ? *transition.duration : *parameters.defaultTransition.duration;
const TimePoint begin = parameters.now + delay;
const TimePoint end = begin + duration;
const PropertyValue &value = propertyPair.second;
appliedProperties.add(classID, begin, end, value);
}
}
}
bool PaintPropertiesMap::hasTransitions() const {
for (const auto& pair : appliedStyle) {
if (pair.second.hasTransitions()) {
return true;
}
}
return hasPendingTransitions;
}
void PaintPropertiesMap::removeExpiredTransitions(const TimePoint& now) {
for (auto it = appliedStyle.begin(); it != appliedStyle.end();) {
AppliedClassPropertyValues& values = it->second;
values.cleanup(now);
// If the current properties object is empty, remove it from the map entirely.
values.empty() ? appliedStyle.erase(it++) : ++it;
}
// Clear the pending transitions flag upon each update.
hasPendingTransitions = false;
}
}

View File

@@ -1,95 +0,0 @@
#ifndef MBGL_PAINT_PROPERTIES_MAP
#define MBGL_PAINT_PROPERTIES_MAP
#include <mbgl/style/applied_class_properties.hpp>
#include <mbgl/style/property_evaluator.hpp>
#include <mbgl/style/class_dictionary.hpp>
#include <mbgl/style/property_key.hpp>
#include <mbgl/util/interpolate.hpp>
#include <rapidjson/document.h>
#include <map>
#include <set>
#include <functional>
namespace mbgl {
class ClassProperties;
class PropertyTransition;
class StyleCascadeParameters;
using JSVal = rapidjson::Value;
class PaintPropertiesMap {
public:
void cascade(const StyleCascadeParameters&);
bool hasTransitions() const;
void removeExpiredTransitions(const TimePoint& now);
// Call the function for each "paint" or "paint.*" object in the layer.
void parseEach(const JSVal& layer, std::function<void (ClassProperties&, const JSVal&)>);
template <typename T>
void calculate(PropertyKey key, T& target, const StyleCalculationParameters& parameters) {
auto it = appliedStyle.find(key);
if (it != appliedStyle.end()) {
AppliedClassPropertyValues &applied = it->second;
// Iterate through all properties that we need to apply in order.
const PropertyEvaluator<T> evaluator(parameters);
for (auto& property : applied.propertyValues) {
if (parameters.now >= property.begin) {
// We overwrite the current property with the new value.
target = mapbox::util::apply_visitor(evaluator, property.value);
} else {
// Do not apply this property because its transition hasn't begun yet.
}
}
}
}
template <typename T>
void calculateTransitioned(PropertyKey key, T& target, const StyleCalculationParameters& parameters) {
auto it = appliedStyle.find(key);
if (it != appliedStyle.end()) {
AppliedClassPropertyValues &applied = it->second;
// Iterate through all properties that we need to apply in order.
const PropertyEvaluator<T> evaluator(parameters);
for (auto& property : applied.propertyValues) {
if (parameters.now >= property.end) {
// We overwrite the current property with the new value.
target = mapbox::util::apply_visitor(evaluator, property.value);
} else if (parameters.now >= property.begin) {
// We overwrite the current property partially with the new value.
float progress = std::chrono::duration<float>(parameters.now - property.begin) / (property.end - property.begin);
target = util::interpolate(target, mapbox::util::apply_visitor(evaluator, property.value), progress);
hasPendingTransitions = true;
} else {
// Do not apply this property because its transition hasn't begun yet.
}
}
}
}
// Raw parsed paint class to property value map.
std::map<ClassID, ClassProperties> paints;
private:
// Applies all properties from a class, if they haven't been applied already.
void cascadeClass(const ClassID,
std::set<PropertyKey>&,
const StyleCascadeParameters&);
// For every property, stores a list of applied property values, with
// optional transition times.
std::map<PropertyKey, AppliedClassPropertyValues> appliedStyle;
// Stores whether there are pending transitions to be done on each update.
bool hasPendingTransitions = false;
};
};
#endif

View File

@@ -0,0 +1,152 @@
#ifndef MBGL_PAINT_PROPERTY
#define MBGL_PAINT_PROPERTY
#include <mbgl/style/class_dictionary.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/function.hpp>
#include <mbgl/style/property_transition.hpp>
#include <mbgl/style/style_cascade_parameters.hpp>
#include <mbgl/style/style_calculation_parameters.hpp>
#include <mbgl/util/interpolate.hpp>
#include <rapidjson/document.h>
#include <map>
namespace mbgl {
using JSVal = rapidjson::Value;
template <typename T, typename Result = T>
class PaintProperty {
public:
using Fn = Function<Result>;
PaintProperty(T fallbackValue_)
: fallbackValue(fallbackValue_),
value(fallbackValue_) {
values.emplace(ClassID::Fallback, Fn(fallbackValue));
}
PaintProperty(const PaintProperty& other)
: values(other.values),
transitions(other.transitions) {
}
void operator=(const PaintProperty& other) {
values = other.values;
transitions = other.transitions;
}
void parse(const char* name, const JSVal& layer) {
values.clear();
values.emplace(ClassID::Fallback, Fn(fallbackValue));
std::string transitionName = { name };
transitionName += "-transition";
for (auto it = layer.MemberBegin(); it != layer.MemberEnd(); ++it) {
const std::string paintName { it->name.GetString(), it->name.GetStringLength() };
if (paintName.compare(0, 5, "paint") != 0)
continue;
bool isClass = paintName.compare(0, 6, "paint.") == 0;
if (isClass && paintName.length() <= 6)
continue;
ClassID classID = isClass ? ClassDictionary::Get().lookup(paintName.substr(6)) : ClassID::Default;
if (it->value.HasMember(name)) {
auto v = parseProperty<Fn>(name, it->value[name]);
if (v) {
values.emplace(classID, *v);
}
}
if (it->value.HasMember(transitionName.c_str())) {
auto v = parseProperty<PropertyTransition>(name, it->value[transitionName.c_str()]);
if (v) {
transitions.emplace(classID, *v);
}
}
}
}
void cascade(const StyleCascadeParameters& parameters) {
Duration delay = *parameters.defaultTransition.delay;
Duration duration = *parameters.defaultTransition.duration;
for (auto classID : parameters.classes) {
if (values.find(classID) == values.end())
continue;
if (transitions.find(classID) != transitions.end()) {
const PropertyTransition& transition = transitions[classID];
if (transition.delay) delay = *transition.delay;
if (transition.duration) duration = *transition.duration;
}
cascaded = std::make_unique<CascadedValue>(std::move(cascaded),
parameters.now + delay,
parameters.now + delay + duration,
values.at(classID));
break;
}
assert(cascaded);
}
bool calculate(const StyleCalculationParameters& parameters) {
assert(cascaded);
value = cascaded->calculate(parameters);
return cascaded->prior.operator bool();
}
operator T() const { return value; }
T fallbackValue;
std::map<ClassID, Fn> values;
std::map<ClassID, PropertyTransition> transitions;
struct CascadedValue {
CascadedValue(std::unique_ptr<CascadedValue> prior_,
TimePoint begin_,
TimePoint end_,
Fn value_)
: prior(std::move(prior_)),
begin(begin_),
end(end_),
value(value_) {
}
Result calculate(const StyleCalculationParameters& parameters) {
Result final = value.evaluate(parameters);
if (!prior) {
// No prior value.
return final;
} else if (parameters.now >= end) {
// Transition from prior value is now complete.
prior.reset();
return final;
} else {
// Interpolate between recursively-calculated prior value and final.
float t = std::chrono::duration<float>(parameters.now - begin) / (end - begin);
return util::interpolate(prior->calculate(parameters), final, t);
}
}
std::unique_ptr<CascadedValue> prior;
TimePoint begin;
TimePoint end;
Fn value;
};
std::unique_ptr<CascadedValue> cascaded;
Result value;
};
}
#endif

View File

@@ -1,40 +0,0 @@
#ifndef MBGL_PROPERTY_EVALUATOR
#define MBGL_PROPERTY_EVALUATOR
#include <mbgl/style/zoom_history.hpp>
#include <mbgl/style/function.hpp>
#include <mbgl/style/style_calculation_parameters.hpp>
namespace mbgl {
struct ZoomHistory;
template <typename T>
class PropertyEvaluator {
public:
typedef T result_type;
PropertyEvaluator(const StyleCalculationParameters& parameters_)
: parameters(parameters_) {}
template <typename P, typename std::enable_if<std::is_convertible<P, T>::value, int>::type = 0>
T operator()(const P &value) const {
return value;
}
T operator()(const Function<T>& value) const {
return value.evaluate(parameters);
}
template <typename P, typename std::enable_if<!std::is_convertible<P, T>::value, int>::type = 0>
T operator()(const P &) const {
return T();
}
private:
StyleCalculationParameters parameters;
};
}
#endif

View File

@@ -1,59 +0,0 @@
#include <mbgl/style/property_fallback.hpp>
#include <mbgl/style/style_properties.hpp>
namespace mbgl {
const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
{ PropertyKey::FillAntialias, FillPaintProperties().antialias },
{ PropertyKey::FillOpacity, FillPaintProperties().opacity },
{ PropertyKey::FillColor, FillPaintProperties().fill_color },
// no FillOutlineColor on purpose.
{ PropertyKey::FillTranslate, FillPaintProperties().translate },
{ PropertyKey::FillTranslateAnchor, FillPaintProperties().translateAnchor },
{ PropertyKey::LineOpacity, LinePaintProperties().opacity },
{ PropertyKey::LineColor, LinePaintProperties().color },
{ PropertyKey::LineTranslate, LinePaintProperties().translate },
{ PropertyKey::LineTranslateAnchor, LinePaintProperties().translateAnchor },
{ PropertyKey::LineWidth, LinePaintProperties().width },
{ PropertyKey::LineGapWidth, LinePaintProperties().gap_width },
{ PropertyKey::LineBlur, LinePaintProperties().blur },
{ PropertyKey::CircleRadius, CirclePaintProperties().radius },
{ PropertyKey::CircleColor, CirclePaintProperties().color },
{ PropertyKey::CircleOpacity, CirclePaintProperties().opacity },
{ PropertyKey::CircleTranslate, CirclePaintProperties().translate },
{ PropertyKey::CircleTranslateAnchor, CirclePaintProperties().translateAnchor },
{ PropertyKey::CircleBlur, CirclePaintProperties().blur },
{ PropertyKey::IconOpacity, SymbolPaintProperties().icon.opacity },
{ PropertyKey::IconColor, SymbolPaintProperties().icon.color },
{ PropertyKey::IconHaloColor, SymbolPaintProperties().icon.halo_color },
{ PropertyKey::IconHaloWidth, SymbolPaintProperties().icon.halo_width },
{ PropertyKey::IconHaloBlur, SymbolPaintProperties().icon.halo_blur },
{ PropertyKey::IconTranslate, SymbolPaintProperties().icon.translate },
{ PropertyKey::IconTranslateAnchor, SymbolPaintProperties().icon.translate_anchor },
{ PropertyKey::TextOpacity, SymbolPaintProperties().text.opacity },
{ PropertyKey::TextColor, SymbolPaintProperties().text.color },
{ PropertyKey::TextHaloColor, SymbolPaintProperties().text.halo_color },
{ PropertyKey::TextHaloWidth, SymbolPaintProperties().text.halo_width },
{ PropertyKey::TextHaloBlur, SymbolPaintProperties().text.halo_blur },
{ PropertyKey::TextTranslate, SymbolPaintProperties().text.translate },
{ PropertyKey::TextTranslateAnchor, SymbolPaintProperties().text.translate_anchor },
{ PropertyKey::RasterOpacity, RasterPaintProperties().opacity },
{ PropertyKey::RasterHueRotate, RasterPaintProperties().hue_rotate },
{ PropertyKey::RasterBrightnessLow, RasterPaintProperties().brightness[0] },
{ PropertyKey::RasterBrightnessHigh, RasterPaintProperties().brightness[1] },
{ PropertyKey::RasterSaturation, RasterPaintProperties().saturation },
{ PropertyKey::RasterContrast, RasterPaintProperties().contrast },
{ PropertyKey::RasterFade, RasterPaintProperties().fade },
{ PropertyKey::BackgroundOpacity, BackgroundPaintProperties().opacity },
{ PropertyKey::BackgroundColor, BackgroundPaintProperties().color },
};
const PropertyValue PropertyFallbackValue::defaultProperty = false;
}

View File

@@ -1,29 +0,0 @@
#ifndef MBGL_STYLE_PROPERTY_FALLBACK
#define MBGL_STYLE_PROPERTY_FALLBACK
#include <mbgl/style/property_key.hpp>
#include <mbgl/style/property_value.hpp>
#include <map>
namespace mbgl {
class PropertyFallbackValue {
public:
static const PropertyValue &Get(PropertyKey key) {
auto it = properties.find(key);
if (it != properties.end()) {
return it->second;
} else {
return defaultProperty;
}
}
private:
static const std::map<PropertyKey, PropertyValue> properties;
static const PropertyValue defaultProperty;
};
}
#endif

View File

@@ -1,64 +0,0 @@
#ifndef MBGL_STYLE_PROPERTY_KEY
#define MBGL_STYLE_PROPERTY_KEY
namespace mbgl {
enum class PropertyKey {
FillAntialias,
FillOpacity,
FillColor,
FillOutlineColor,
FillTranslate, // for transitions only
FillTranslateAnchor,
FillImage,
LineOpacity,
LineColor,
LineTranslate, // for transitions only
LineTranslateAnchor,
LineWidth,
LineGapWidth,
LineBlur,
LineDashArray, // for transitions only
LineImage,
CircleRadius,
CircleColor,
CircleOpacity,
CircleTranslate,
CircleTranslateAnchor,
CircleBlur,
IconOpacity,
IconColor,
IconHaloColor,
IconHaloWidth,
IconHaloBlur,
IconTranslate,
IconTranslateAnchor,
TextOpacity,
TextColor,
TextHaloColor,
TextHaloWidth,
TextHaloBlur,
TextTranslate,
TextTranslateAnchor,
RasterOpacity,
RasterHueRotate,
RasterBrightness, // for transitions only
RasterBrightnessLow,
RasterBrightnessHigh,
RasterSaturation,
RasterContrast,
RasterFade,
BackgroundOpacity,
BackgroundColor,
BackgroundImage,
};
}
#endif

View File

@@ -1,11 +1,14 @@
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/property_transition.hpp>
#include <mbgl/style/function.hpp>
#include <mbgl/platform/log.hpp>
#include <csscolorparser/csscolorparser.hpp>
#include <vector>
namespace mbgl {
namespace detail {
template <>
optional<bool> parseProperty(const char* name, const JSVal& value) {
@@ -402,4 +405,3 @@ optional<Function<Faded<std::string>>> parseProperty(const char* name, const JSV
}
}
}

View File

@@ -1,11 +1,13 @@
#ifndef MBGL_PROPERTY_PARSING
#define MBGL_PROPERTY_PARSING
#include <mbgl/style/class_properties.hpp>
#include <mbgl/style/types.hpp>
#include <mapbox/optional.hpp>
#include <rapidjson/document.h>
#include <functional>
namespace mbgl {
using JSVal = rapidjson::Value;
@@ -13,25 +15,9 @@ using JSVal = rapidjson::Value;
template <typename T>
using optional = mapbox::util::optional<T>;
namespace detail {
template <typename T>
optional<T> parseProperty(const char* name, const JSVal&);
}
template <typename T>
void parseProperty(const char* name, PropertyKey key, ClassProperties& properties, const JSVal& value) {
if (!value.HasMember(name))
return;
const optional<T> res = detail::parseProperty<T>(name, value[name]);
if (res) {
properties.set(key, *res);
}
}
}
#endif

View File

@@ -1,36 +0,0 @@
#ifndef MBGL_STYLE_PROPERTY_VALUE
#define MBGL_STYLE_PROPERTY_VALUE
#include <mapbox/variant.hpp>
#include <mbgl/style/function.hpp>
#include <mbgl/style/types.hpp>
#include <vector>
#include <array>
namespace mbgl {
typedef mapbox::util::variant<
Function<std::string>,
Function<TranslateAnchorType>,
Function<RotateAnchorType>,
Function<CapType>,
Function<JoinType>,
VisibilityType,
Function<PlacementType>,
Function<RotationAlignmentType>,
Function<TextTransformType>,
Function<TextJustifyType>,
Function<TextAnchorType>,
Function<std::array<float, 2>>,
Function<bool>,
Function<float>,
Function<Color>,
Function<Faded<std::vector<float>>>,
Function<Faded<std::string>>
> PropertyValue;
}
#endif

View File

@@ -7,6 +7,7 @@
#include <mbgl/style/style_layer.hpp>
#include <mbgl/style/style_parser.hpp>
#include <mbgl/style/property_transition.hpp>
#include <mbgl/style/class_dictionary.hpp>
#include <mbgl/style/style_cascade_parameters.hpp>
#include <mbgl/style/style_calculation_parameters.hpp>
#include <mbgl/geometry/glyph_atlas.hpp>
@@ -121,7 +122,16 @@ void Style::update(const TransformState& transform,
}
void Style::cascade() {
StyleCascadeParameters parameters(data.getClasses(),
std::vector<ClassID> classes;
std::vector<std::string> classNames = data.getClasses();
for (auto it = classNames.rbegin(); it != classNames.rend(); it++) {
classes.push_back(ClassDictionary::Get().lookup(*it));
}
classes.push_back(ClassID::Default);
classes.push_back(ClassID::Fallback);
StyleCascadeParameters parameters(classes,
data.getAnimationTime(),
PropertyTransition { data.getDefaultTransitionDuration(),
data.getDefaultTransitionDelay() });
@@ -146,7 +156,7 @@ void Style::recalculate(float z) {
data.getDefaultFadeDuration());
for (const auto& layer : layers) {
layer->recalculate(parameters);
hasPendingTransitions |= layer->recalculate(parameters);
Source* source = getSource(layer->source);
if (!source) {
@@ -166,12 +176,7 @@ Source* Style::getSource(const std::string& id) const {
}
bool Style::hasTransitions() const {
for (const auto& layer : layers) {
if (layer->hasTransitions()) {
return true;
}
}
return false;
return hasPendingTransitions;
}
bool Style::isLoaded() const {

View File

@@ -110,6 +110,7 @@ private:
std::unique_ptr<uv::rwlock> mtx;
ZoomHistory zoomHistory;
bool hasPendingTransitions = false;
public:
Worker workers;

View File

@@ -2,6 +2,7 @@
#define STYLE_CASCADE_PARAMETERS
#include <mbgl/util/chrono.hpp>
#include <mbgl/style/types.hpp>
#include <vector>
@@ -11,14 +12,14 @@ class PropertyTransition;
class StyleCascadeParameters {
public:
StyleCascadeParameters(const std::vector<std::string>& classes_,
StyleCascadeParameters(const std::vector<ClassID>& classes_,
const TimePoint& now_,
const PropertyTransition& defaultTransition_)
: classes(classes_),
now(now_),
defaultTransition(defaultTransition_) {}
std::vector<std::string> classes;
std::vector<ClassID> classes;
TimePoint now;
PropertyTransition defaultTransition;
};

View File

@@ -8,7 +8,9 @@
#include <rapidjson/document.h>
#include <memory>
#include <string>
#include <limits>
namespace mbgl {
@@ -36,13 +38,11 @@ public:
virtual void cascade(const StyleCascadeParameters&) = 0;
// Fully evaluate cascaded paint properties based on a zoom level.
virtual void recalculate(const StyleCalculationParameters&) = 0;
// Returns true if any paint properties have active transitions.
virtual bool recalculate(const StyleCalculationParameters&) = 0;
virtual std::unique_ptr<Bucket> createBucket(StyleBucketParameters&) const = 0;
// Checks whether this layer has any active paint properties with transitions.
virtual bool hasTransitions() const = 0;
// Checks whether this layer needs to be rendered in the given render pass.
bool hasRenderPass(RenderPass) const;

View File

@@ -46,7 +46,8 @@ template<> inline TextJustifyType interpolate(const TextJustifyType a, const Tex
template<> inline TextTransformType interpolate(const TextTransformType a, const TextTransformType, const double) { return a; }
template<> inline RotationAlignmentType interpolate(const RotationAlignmentType a, const RotationAlignmentType, const double) { return a; }
template<> inline Faded<std::string> interpolate(const Faded<std::string>, const Faded<std::string> b, const double) { return b; }
template<> inline Faded<std::vector<float>> interpolate(const Faded<std::vector<float>>, const Faded<std::vector<float>> b, const double) { return b; }
}
}

View File

@@ -2,7 +2,6 @@
#include <mbgl/annotation/point_annotation.hpp>
#include <mbgl/annotation/shape_annotation.hpp>
#include <mbgl/style/style_properties.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/map/still_image.hpp>
#include <mbgl/platform/default/headless_display.hpp>
@@ -48,7 +47,7 @@ TEST(Annotations, LineAnnotation) {
AnnotationSegments segments = {{ {{ { 0, 0 }, { 45, 45 } }} }};
LinePaintProperties properties;
LineAnnotationProperties properties;
properties.color = {{ 255, 0, 0, 1 }};
properties.width = 5;
@@ -67,8 +66,8 @@ TEST(Annotations, FillAnnotation) {
AnnotationSegments segments = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
FillPaintProperties properties;
properties.fill_color = {{ 255, 0, 0, 1 }};
FillAnnotationProperties properties;
properties.color = {{ 255, 0, 0, 1 }};
map.addShapeAnnotation(ShapeAnnotation(segments, properties));
@@ -118,8 +117,8 @@ TEST(Annotations, NonImmediateAdd) {
AnnotationSegments segments = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
FillPaintProperties properties;
properties.fill_color = {{ 255, 0, 0, 1 }};
FillAnnotationProperties properties;
properties.color = {{ 255, 0, 0, 1 }};
map.addShapeAnnotation(ShapeAnnotation(segments, properties));
@@ -149,7 +148,7 @@ TEST(Annotations, RemoveShape) {
AnnotationSegments segments = {{ {{ { 0, 0 }, { 45, 45 } }} }};
LinePaintProperties properties;
LineAnnotationProperties properties;
properties.color = {{ 255, 0, 0, 1 }};
properties.width = 5;