@@ -4,7 +4,6 @@
|
||||
namespace llmr {
|
||||
|
||||
enum class PropertyKey {
|
||||
FillEnabled,
|
||||
FillAntialias,
|
||||
FillOpacity,
|
||||
FillColor,
|
||||
@@ -15,7 +14,6 @@ enum class PropertyKey {
|
||||
FillTranslateAnchor,
|
||||
FillImage,
|
||||
|
||||
LineEnabled,
|
||||
LineOpacity,
|
||||
LineColor,
|
||||
LineTranslate, // for transitions only
|
||||
@@ -30,12 +28,10 @@ enum class PropertyKey {
|
||||
LineDashGap,
|
||||
LineImage,
|
||||
|
||||
IconEnabled,
|
||||
IconOpacity,
|
||||
IconRotate,
|
||||
IconRotateAnchor,
|
||||
|
||||
TextEnabled,
|
||||
TextOpacity,
|
||||
TextSize,
|
||||
TextColor,
|
||||
@@ -43,10 +39,8 @@ enum class PropertyKey {
|
||||
TextHaloWidth,
|
||||
TextHaloBlur,
|
||||
|
||||
CompositeEnabled,
|
||||
CompositeOpacity,
|
||||
|
||||
RasterEnabled,
|
||||
RasterOpacity,
|
||||
RasterSpin,
|
||||
RasterBrightnessLow,
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace llmr {
|
||||
|
||||
struct FillProperties {
|
||||
FillProperties() {}
|
||||
bool enabled = true;
|
||||
bool antialias = true;
|
||||
float opacity = 1.0f;
|
||||
Color fill_color = {{ 0, 0, 0, 1 }};
|
||||
@@ -24,13 +23,12 @@ struct FillProperties {
|
||||
std::string image;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return enabled && opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0);
|
||||
return opacity > 0 && (fill_color[3] > 0 || stroke_color[3] > 0);
|
||||
}
|
||||
};
|
||||
|
||||
struct LineProperties {
|
||||
inline LineProperties() {}
|
||||
bool enabled = true;
|
||||
float opacity = 1.0f;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
@@ -42,25 +40,23 @@ struct LineProperties {
|
||||
std::string image;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return enabled && opacity > 0 && color[3] > 0 && width > 0;
|
||||
return opacity > 0 && color[3] > 0 && width > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct IconProperties {
|
||||
inline IconProperties() {}
|
||||
bool enabled = true;
|
||||
float opacity = 1.0f;
|
||||
float rotate = 0.0f;
|
||||
RotateAnchorType rotate_anchor = RotateAnchorType::Default;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return enabled && opacity > 0;
|
||||
return opacity > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct TextProperties {
|
||||
inline TextProperties() {}
|
||||
bool enabled = true;
|
||||
float opacity = 1.0f;
|
||||
float size = 12.0f;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
@@ -69,23 +65,21 @@ struct TextProperties {
|
||||
float halo_blur = 1.0f;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return enabled && opacity > 0 && (color[3] > 0 || halo_color[3] > 0) && size > 0;
|
||||
return opacity > 0 && (color[3] > 0 || halo_color[3] > 0) && size > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct CompositeProperties {
|
||||
inline CompositeProperties() {}
|
||||
bool enabled = true;
|
||||
float opacity = 1.0f;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return enabled && opacity > 0;
|
||||
return opacity > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct RasterProperties {
|
||||
inline RasterProperties() {}
|
||||
bool enabled = true;
|
||||
float opacity = 1.0f;
|
||||
float spin = 0.0f;
|
||||
std::array<float, 2> brightness = {{ 0, 1 }};
|
||||
@@ -94,7 +88,7 @@ struct RasterProperties {
|
||||
float fade = 0.0f;
|
||||
|
||||
inline bool isVisible() const {
|
||||
return enabled && opacity > 0;
|
||||
return opacity > 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -150,7 +150,6 @@ void Painter::renderFill(FillBucket& bucket, std::shared_ptr<StyleLayer> layer_d
|
||||
if (!bucket.hasData()) return;
|
||||
|
||||
const FillProperties &properties = layer_desc->getProperties<FillProperties>();
|
||||
if (!properties.enabled) return;
|
||||
|
||||
if (layer_desc->rasterize && layer_desc->rasterize->isEnabled(id.z)) {
|
||||
if (pass == Translucent) {
|
||||
|
||||
@@ -14,7 +14,6 @@ void Painter::renderIcon(IconBucket& bucket, std::shared_ptr<StyleLayer> layer_d
|
||||
if (pass == Opaque) return;
|
||||
|
||||
const IconProperties &properties = layer_desc->getProperties<IconProperties>();
|
||||
if (!properties.enabled) return;
|
||||
|
||||
// TODO: when translating icon, are we doing this in the bucket already?
|
||||
// const mat4 &vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);
|
||||
|
||||
@@ -11,7 +11,6 @@ void Painter::renderLine(LineBucket& bucket, std::shared_ptr<StyleLayer> layer_d
|
||||
if (!bucket.hasData()) return;
|
||||
|
||||
const LineProperties &properties = layer_desc->getProperties<LineProperties>();
|
||||
if (!properties.enabled) return;
|
||||
|
||||
float width = properties.width;
|
||||
float offset = properties.offset / 2;
|
||||
|
||||
@@ -9,7 +9,6 @@ void Painter::renderRaster(RasterBucket& bucket, std::shared_ptr<StyleLayer> lay
|
||||
if (pass == Translucent) return;
|
||||
|
||||
const RasterProperties &properties = layer_desc->getProperties<RasterProperties>();
|
||||
if (!properties.enabled) return;
|
||||
|
||||
depthMask(false);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ void Painter::renderText(TextBucket& bucket, std::shared_ptr<StyleLayer> layer_d
|
||||
if (!bucket.hasData()) return;
|
||||
|
||||
const TextProperties &properties = layer_desc->getProperties<TextProperties>();
|
||||
if (!properties.enabled) return;
|
||||
|
||||
mat4 exMatrix;
|
||||
matrix::copy(exMatrix, projMatrix);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace llmr {
|
||||
|
||||
const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::FillEnabled, true },
|
||||
{ PropertyKey::FillAntialias, true },
|
||||
{ PropertyKey::FillOpacity, 1.0f },
|
||||
{ PropertyKey::FillColor, Color({{ 0, 0, 0, 1 }}) },
|
||||
@@ -11,7 +10,6 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::FillTranslateY, 0.0f },
|
||||
{ PropertyKey::FillTranslateAnchor, TranslateAnchorType::Map },
|
||||
|
||||
{ PropertyKey::LineEnabled, true },
|
||||
{ PropertyKey::LineOpacity, 1.0f },
|
||||
{ PropertyKey::LineColor, Color({{ 0, 0, 0, 1 }}) },
|
||||
{ PropertyKey::LineTranslateX, 0.0f },
|
||||
@@ -23,12 +21,10 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::LineDashLand, 1.0f },
|
||||
{ PropertyKey::LineDashGap, -1.0f },
|
||||
|
||||
{ PropertyKey::IconEnabled, true },
|
||||
{ PropertyKey::IconOpacity, 1.0f },
|
||||
{ PropertyKey::IconRotate, 0.0f },
|
||||
{ PropertyKey::IconRotateAnchor, RotateAnchorType::Viewport },
|
||||
|
||||
{ PropertyKey::TextEnabled, true },
|
||||
{ PropertyKey::TextOpacity, 1.0f },
|
||||
{ PropertyKey::TextSize, 16.0f },
|
||||
{ PropertyKey::TextColor, Color({{ 0, 0, 0, 1 }}) },
|
||||
@@ -36,10 +32,8 @@ const std::map<PropertyKey, PropertyValue> PropertyFallbackValue::properties = {
|
||||
{ PropertyKey::TextHaloWidth, 0.25f },
|
||||
{ PropertyKey::TextHaloBlur, 1.0f },
|
||||
|
||||
{ PropertyKey::CompositeEnabled, true },
|
||||
{ PropertyKey::CompositeOpacity, 1.0f },
|
||||
|
||||
{ PropertyKey::RasterEnabled, true },
|
||||
{ PropertyKey::RasterOpacity, 1.0f },
|
||||
{ PropertyKey::RasterSpin, 0.0f },
|
||||
{ PropertyKey::RasterBrightnessLow, 0.0f },
|
||||
|
||||
@@ -164,7 +164,6 @@ template <>
|
||||
void StyleLayer::applyStyleProperties<FillProperties>(const float z, const timestamp now) {
|
||||
properties.set<FillProperties>();
|
||||
FillProperties &fill = properties.get<FillProperties>();
|
||||
applyStyleProperty(PropertyKey::FillEnabled, fill.enabled, z, now);
|
||||
applyStyleProperty(PropertyKey::FillAntialias, fill.antialias, z, now);
|
||||
applyStyleProperty(PropertyKey::FillOpacity, fill.opacity, z, now);
|
||||
applyStyleProperty(PropertyKey::FillColor, fill.fill_color, z, now);
|
||||
@@ -179,7 +178,6 @@ template <>
|
||||
void StyleLayer::applyStyleProperties<LineProperties>(const float z, const timestamp now) {
|
||||
properties.set<LineProperties>();
|
||||
LineProperties &line = properties.get<LineProperties>();
|
||||
applyStyleProperty(PropertyKey::LineEnabled, line.enabled, z, now);
|
||||
applyStyleProperty(PropertyKey::LineOpacity, line.opacity, z, now);
|
||||
applyStyleProperty(PropertyKey::LineColor, line.color, z, now);
|
||||
applyStyleProperty(PropertyKey::LineTranslateX, line.translate[0], z, now);
|
||||
@@ -197,7 +195,6 @@ template <>
|
||||
void StyleLayer::applyStyleProperties<IconProperties>(const float z, const timestamp now) {
|
||||
properties.set<IconProperties>();
|
||||
IconProperties &icon = properties.get<IconProperties>();
|
||||
applyStyleProperty(PropertyKey::IconEnabled, icon.enabled, z, now);
|
||||
applyStyleProperty(PropertyKey::IconOpacity, icon.opacity, z, now);
|
||||
applyStyleProperty(PropertyKey::IconRotate, icon.rotate, z, now);
|
||||
applyStyleProperty(PropertyKey::IconRotateAnchor, icon.rotate_anchor, z, now);
|
||||
@@ -207,7 +204,6 @@ template <>
|
||||
void StyleLayer::applyStyleProperties<TextProperties>(const float z, const timestamp now) {
|
||||
properties.set<TextProperties>();
|
||||
TextProperties &text = properties.get<TextProperties>();
|
||||
applyStyleProperty(PropertyKey::TextEnabled, text.enabled, z, now);
|
||||
applyStyleProperty(PropertyKey::TextOpacity, text.opacity, z, now);
|
||||
applyStyleProperty(PropertyKey::TextSize, text.size, z, now);
|
||||
applyStyleProperty(PropertyKey::TextColor, text.color, z, now);
|
||||
@@ -220,7 +216,6 @@ template <>
|
||||
void StyleLayer::applyStyleProperties<CompositeProperties>(const float z, const timestamp now) {
|
||||
properties.set<CompositeProperties>();
|
||||
CompositeProperties &composite = properties.get<CompositeProperties>();
|
||||
applyStyleProperty(PropertyKey::CompositeEnabled, composite.enabled, z, now);
|
||||
applyStyleProperty(PropertyKey::CompositeOpacity, composite.opacity, z, now);
|
||||
}
|
||||
|
||||
@@ -228,7 +223,6 @@ template <>
|
||||
void StyleLayer::applyStyleProperties<RasterProperties>(const float z, const timestamp now) {
|
||||
properties.set<RasterProperties>();
|
||||
RasterProperties &raster = properties.get<RasterProperties>();
|
||||
applyStyleProperty(PropertyKey::RasterEnabled, raster.enabled, z, now);
|
||||
applyStyleProperty(PropertyKey::RasterOpacity, raster.opacity, z, now);
|
||||
applyStyleProperty(PropertyKey::RasterSpin, raster.spin, z, now);
|
||||
applyStyleProperty(PropertyKey::RasterBrightnessLow, raster.brightness[0], z, now);
|
||||
|
||||
@@ -600,8 +600,6 @@ void StyleParser::parseStyles(JSVal value, std::map<ClassID, ClassProperties> &s
|
||||
void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
using Key = PropertyKey;
|
||||
|
||||
parseOptionalProperty<Function<bool>>("fill-enabled", Key::FillEnabled, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-fill-enabled", Key::FillEnabled, klass, value);
|
||||
parseOptionalProperty<Function<bool>>("fill-antialias", Key::FillAntialias, klass, value);
|
||||
parseOptionalProperty<Function<float>>("fill-opacity", Key::FillOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-fill-opacity", Key::FillOpacity, klass, value);
|
||||
@@ -614,8 +612,6 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
parseOptionalProperty<TranslateAnchorType>("fill-translate-anchor", Key::FillTranslateAnchor, klass, value);
|
||||
parseOptionalProperty<std::string>("fill-image", Key::FillImage, klass, value);
|
||||
|
||||
parseOptionalProperty<Function<bool>>("line-enabled", Key::LineEnabled, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-line-enabled", Key::LineEnabled, klass, value);
|
||||
parseOptionalProperty<Function<float>>("line-opacity", Key::LineOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-line-opacity", Key::LineOpacity, klass, value);
|
||||
parseOptionalProperty<Function<Color>>("line-color", Key::LineColor, klass, value);
|
||||
@@ -633,15 +629,11 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
parseOptionalProperty<PropertyTransition>("transition-line-dasharray", Key::LineDashArray, klass, value);
|
||||
parseOptionalProperty<std::string>("line-image", Key::LineImage, klass, value);
|
||||
|
||||
parseOptionalProperty<Function<bool>>("icon-enabled", Key::IconEnabled, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-icon-enabled", Key::IconEnabled, klass, value);
|
||||
parseOptionalProperty<Function<float>>("icon-opacity", Key::IconOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-icon-opacity", Key::IconOpacity, klass, value);
|
||||
parseOptionalProperty<Function<float>>("icon-rotate", Key::IconRotate, klass, value);
|
||||
parseOptionalProperty<RotateAnchorType>("icon-rotate-anchor", Key::IconRotateAnchor, klass, value);
|
||||
|
||||
parseOptionalProperty<Function<bool>>("text-enabled", Key::TextEnabled, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-text-enabled", Key::TextEnabled, klass, value);
|
||||
parseOptionalProperty<Function<float>>("text-opacity", Key::TextOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-text-opacity", Key::TextOpacity, klass, value);
|
||||
parseOptionalProperty<Function<float>>("text-size", Key::TextSize, klass, value);
|
||||
@@ -655,13 +647,9 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
|
||||
parseOptionalProperty<Function<float>>("text-halo-blur", Key::TextHaloBlur, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-text-halo-blur", Key::TextHaloBlur, klass, value);
|
||||
|
||||
parseOptionalProperty<Function<bool>>("composite-enabled", Key::CompositeEnabled, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-composite-enabled", Key::CompositeEnabled, klass, value);
|
||||
parseOptionalProperty<Function<float>>("composite-opacity", Key::CompositeOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-composite-opacity", Key::CompositeOpacity, klass, value);
|
||||
|
||||
parseOptionalProperty<Function<bool>>("raster-enabled", Key::RasterEnabled, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-enabled", Key::RasterEnabled, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseOptionalProperty<PropertyTransition>("transition-raster-opacity", Key::RasterOpacity, klass, value);
|
||||
parseOptionalProperty<Function<float>>("raster-spin", Key::RasterSpin, klass, value);
|
||||
|
||||
Reference in New Issue
Block a user