From b2beeda50bbd48fecad957d194dd5b40c72eb9c7 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 21 Apr 2016 13:05:10 -0700 Subject: [core] Adopt a strict naming convention for style properties This will allow code to be generated from the style specification. --- src/mbgl/annotation/annotation_manager.cpp | 4 +- src/mbgl/annotation/shape_annotation_impl.cpp | 14 +- src/mbgl/layer/background_layer.cpp | 20 +-- src/mbgl/layer/background_layer.hpp | 6 +- src/mbgl/layer/circle_layer.cpp | 36 ++-- src/mbgl/layer/circle_layer.hpp | 14 +- src/mbgl/layer/fill_layer.cpp | 46 ++--- src/mbgl/layer/fill_layer.hpp | 14 +- src/mbgl/layer/line_layer.cpp | 80 ++++----- src/mbgl/layer/line_layer.hpp | 30 ++-- src/mbgl/layer/raster_layer.cpp | 44 ++--- src/mbgl/layer/raster_layer.hpp | 14 +- src/mbgl/layer/symbol_layer.cpp | 249 +++++++++++++------------- src/mbgl/layer/symbol_layer.hpp | 118 ++++++------ src/mbgl/renderer/line_bucket.cpp | 10 +- src/mbgl/renderer/painter.hpp | 19 +- src/mbgl/renderer/painter_background.cpp | 30 ++-- src/mbgl/renderer/painter_circle.cpp | 18 +- src/mbgl/renderer/painter_fill.cpp | 44 ++--- src/mbgl/renderer/painter_line.cpp | 54 +++--- src/mbgl/renderer/painter_raster.cpp | 12 +- src/mbgl/renderer/painter_symbol.cpp | 119 +++++++----- src/mbgl/renderer/symbol_bucket.cpp | 96 +++++----- src/mbgl/style/style.cpp | 12 +- src/mbgl/style/style_parser.cpp | 2 +- src/mbgl/text/quads.cpp | 6 +- src/mbgl/text/shaping.cpp | 4 +- 27 files changed, 571 insertions(+), 544 deletions(-) (limited to 'src') diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 5f5feb456a..13675bf2ba 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -116,8 +116,8 @@ void AnnotationManager::updateStyle(Style& style) { layer->id = PointLayerID; layer->source = SourceID; layer->sourceLayer = PointLayerID; - layer->layout.icon.image = std::string("{sprite}"); - layer->layout.icon.allowOverlap = true; + layer->layout.iconImage = std::string("{sprite}"); + layer->layout.iconAllowOverlap = true; layer->spriteAtlas = &spriteAtlas; style.addLayer(std::move(layer)); diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index 380a5b7746..e0e2eb51b2 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -31,12 +31,12 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { type = geojsonvt::ProjectedFeatureType::LineString; std::unique_ptr layer = std::make_unique(); - layer->layout.join = LineJoinType::Round; + layer->layout.lineJoin = LineJoinType::Round; const LineAnnotationProperties& properties = shape.properties.get(); - layer->paint.opacity = properties.opacity; - layer->paint.width = properties.width; - layer->paint.color = properties.color; + layer->paint.lineOpacity = properties.opacity; + layer->paint.lineWidth = properties.width; + layer->paint.lineColor = properties.color; layer->id = layerID; layer->source = AnnotationManager::SourceID; @@ -50,9 +50,9 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { std::unique_ptr layer = std::make_unique(); const FillAnnotationProperties& properties = shape.properties.get(); - layer->paint.opacity = properties.opacity; - layer->paint.color = properties.color; - layer->paint.outlineColor = properties.outlineColor; + layer->paint.fillOpacity = properties.opacity; + layer->paint.fillColor = properties.color; + layer->paint.fillOutlineColor = properties.outlineColor; layer->id = layerID; layer->source = AnnotationManager::SourceID; diff --git a/src/mbgl/layer/background_layer.cpp b/src/mbgl/layer/background_layer.cpp index 25fbe620e5..e2879f786e 100644 --- a/src/mbgl/layer/background_layer.cpp +++ b/src/mbgl/layer/background_layer.cpp @@ -8,25 +8,25 @@ std::unique_ptr BackgroundLayer::clone() const { } void BackgroundLayer::parsePaints(const JSValue& layer) { - paint.opacity.parse("background-opacity", layer); - paint.color.parse("background-color", layer); - paint.pattern.parse("background-pattern", layer); + paint.backgroundOpacity.parse("background-opacity", layer); + paint.backgroundColor.parse("background-color", layer); + paint.backgroundPattern.parse("background-pattern", layer); } void BackgroundLayer::cascade(const StyleCascadeParameters& parameters) { - paint.opacity.cascade(parameters); - paint.color.cascade(parameters); - paint.pattern.cascade(parameters); + paint.backgroundOpacity.cascade(parameters); + paint.backgroundColor.cascade(parameters); + paint.backgroundPattern.cascade(parameters); } bool BackgroundLayer::recalculate(const StyleCalculationParameters& parameters) { bool hasTransitions = false; - hasTransitions |= paint.opacity.calculate(parameters); - hasTransitions |= paint.color.calculate(parameters); - hasTransitions |= paint.pattern.calculate(parameters); + hasTransitions |= paint.backgroundOpacity.calculate(parameters); + hasTransitions |= paint.backgroundColor.calculate(parameters); + hasTransitions |= paint.backgroundPattern.calculate(parameters); - passes = paint.opacity > 0 ? RenderPass::Translucent : RenderPass::None; + passes = paint.backgroundOpacity > 0 ? RenderPass::Translucent : RenderPass::None; return hasTransitions; } diff --git a/src/mbgl/layer/background_layer.hpp b/src/mbgl/layer/background_layer.hpp index 118bb19053..786dd0732f 100644 --- a/src/mbgl/layer/background_layer.hpp +++ b/src/mbgl/layer/background_layer.hpp @@ -8,9 +8,9 @@ namespace mbgl { class BackgroundPaintProperties { public: - PaintProperty opacity { 1.0f }; - PaintProperty color { {{ 0, 0, 0, 1 }} }; - PaintProperty> pattern { "" }; + PaintProperty backgroundOpacity { 1.0f }; + PaintProperty backgroundColor { {{ 0, 0, 0, 1 }} }; + PaintProperty> backgroundPattern { "" }; }; class BackgroundLayer : public StyleLayer { diff --git a/src/mbgl/layer/circle_layer.cpp b/src/mbgl/layer/circle_layer.cpp index b668847f55..bd70e1649e 100644 --- a/src/mbgl/layer/circle_layer.cpp +++ b/src/mbgl/layer/circle_layer.cpp @@ -10,32 +10,32 @@ std::unique_ptr CircleLayer::clone() const { } void CircleLayer::parsePaints(const JSValue& layer) { - 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); + paint.circleRadius.parse("circle-radius", layer); + paint.circleColor.parse("circle-color", layer); + paint.circleOpacity.parse("circle-opacity", layer); + paint.circleTranslate.parse("circle-translate", layer); + paint.circleTranslateAnchor.parse("circle-translate-anchor", layer); + paint.circleBlur.parse("circle-blur", layer); } void CircleLayer::cascade(const StyleCascadeParameters& 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); + paint.circleRadius.cascade(parameters); + paint.circleColor.cascade(parameters); + paint.circleOpacity.cascade(parameters); + paint.circleTranslate.cascade(parameters); + paint.circleTranslateAnchor.cascade(parameters); + paint.circleBlur.cascade(parameters); } bool CircleLayer::recalculate(const StyleCalculationParameters& parameters) { bool hasTransitions = false; - 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); + hasTransitions |= paint.circleRadius.calculate(parameters); + hasTransitions |= paint.circleColor.calculate(parameters); + hasTransitions |= paint.circleOpacity.calculate(parameters); + hasTransitions |= paint.circleTranslate.calculate(parameters); + hasTransitions |= paint.circleTranslateAnchor.calculate(parameters); + hasTransitions |= paint.circleBlur.calculate(parameters); passes = paint.isVisible() ? RenderPass::Translucent : RenderPass::None; diff --git a/src/mbgl/layer/circle_layer.hpp b/src/mbgl/layer/circle_layer.hpp index 036bf79991..2eda3e783a 100644 --- a/src/mbgl/layer/circle_layer.hpp +++ b/src/mbgl/layer/circle_layer.hpp @@ -8,15 +8,15 @@ namespace mbgl { class CirclePaintProperties { public: - PaintProperty radius { 5.0f }; - PaintProperty color { {{ 0, 0, 0, 1 }} }; - PaintProperty opacity { 1.0f }; - PaintProperty> translate { {{ 0, 0 }} }; - PaintProperty translateAnchor { TranslateAnchorType::Map }; - PaintProperty blur { 0 }; + PaintProperty circleRadius { 5.0f }; + PaintProperty circleColor { {{ 0, 0, 0, 1 }} }; + PaintProperty circleOpacity { 1.0f }; + PaintProperty> circleTranslate { {{ 0, 0 }} }; + PaintProperty circleTranslateAnchor { TranslateAnchorType::Map }; + PaintProperty circleBlur { 0 }; bool isVisible() const { - return radius > 0 && color.value[3] > 0 && opacity > 0; + return circleRadius > 0 && circleColor.value[3] > 0 && circleOpacity > 0; } }; diff --git a/src/mbgl/layer/fill_layer.cpp b/src/mbgl/layer/fill_layer.cpp index 739a6fd20c..0ba83e7fe4 100644 --- a/src/mbgl/layer/fill_layer.cpp +++ b/src/mbgl/layer/fill_layer.cpp @@ -10,43 +10,43 @@ std::unique_ptr FillLayer::clone() const { } void FillLayer::parsePaints(const JSValue& layer) { - 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); + paint.fillAntialias.parse("fill-antialias", layer); + paint.fillOpacity.parse("fill-opacity", layer); + paint.fillColor.parse("fill-color", layer); + paint.fillOutlineColor.parse("fill-outline-color", layer); + paint.fillTranslate.parse("fill-translate", layer); + paint.fillTranslateAnchor.parse("fill-translate-anchor", layer); + paint.fillPattern.parse("fill-pattern", layer); } void FillLayer::cascade(const StyleCascadeParameters& 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); + paint.fillAntialias.cascade(parameters); + paint.fillOpacity.cascade(parameters); + paint.fillColor.cascade(parameters); + paint.fillOutlineColor.cascade(parameters); + paint.fillTranslate.cascade(parameters); + paint.fillTranslateAnchor.cascade(parameters); + paint.fillPattern.cascade(parameters); } bool FillLayer::recalculate(const StyleCalculationParameters& parameters) { bool hasTransitions = false; - 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); + hasTransitions |= paint.fillAntialias.calculate(parameters); + hasTransitions |= paint.fillOpacity.calculate(parameters); + hasTransitions |= paint.fillColor.calculate(parameters); + hasTransitions |= paint.fillOutlineColor.calculate(parameters); + hasTransitions |= paint.fillTranslate.calculate(parameters); + hasTransitions |= paint.fillTranslateAnchor.calculate(parameters); + hasTransitions |= paint.fillPattern.calculate(parameters); passes = RenderPass::None; - if (paint.antialias) { + if (paint.fillAntialias) { passes |= RenderPass::Translucent; } - if (!paint.pattern.value.from.empty() || (paint.color.value[3] * paint.opacity) < 1.0f) { + if (!paint.fillPattern.value.from.empty() || (paint.fillColor.value[3] * paint.fillOpacity) < 1.0f) { passes |= RenderPass::Translucent; } else { passes |= RenderPass::Opaque; diff --git a/src/mbgl/layer/fill_layer.hpp b/src/mbgl/layer/fill_layer.hpp index 3b1c5a84fe..3a6f1fbf19 100644 --- a/src/mbgl/layer/fill_layer.hpp +++ b/src/mbgl/layer/fill_layer.hpp @@ -8,13 +8,13 @@ namespace mbgl { class FillPaintProperties { public: - PaintProperty antialias { true }; - PaintProperty opacity { 1.0f }; - PaintProperty color { {{ 0, 0, 0, 1 }} }; - PaintProperty outlineColor { {{ 0, 0, 0, -1 }} }; - PaintProperty> translate { {{ 0, 0 }} }; - PaintProperty translateAnchor { TranslateAnchorType::Map }; - PaintProperty> pattern { "" }; + PaintProperty fillAntialias { true }; + PaintProperty fillOpacity { 1.0f }; + PaintProperty fillColor { {{ 0, 0, 0, 1 }} }; + PaintProperty fillOutlineColor { {{ 0, 0, 0, -1 }} }; + PaintProperty> fillTranslate { {{ 0, 0 }} }; + PaintProperty fillTranslateAnchor { TranslateAnchorType::Map }; + PaintProperty> fillPattern { "" }; }; class FillLayer : public StyleLayer { diff --git a/src/mbgl/layer/line_layer.cpp b/src/mbgl/layer/line_layer.cpp index c3576a9ee2..83994edf6c 100644 --- a/src/mbgl/layer/line_layer.cpp +++ b/src/mbgl/layer/line_layer.cpp @@ -11,57 +11,57 @@ std::unique_ptr LineLayer::clone() const { } void LineLayer::parseLayout(const JSValue& value) { - layout.cap.parse("line-cap", value); - layout.join.parse("line-join", value); - layout.miterLimit.parse("line-miter-limit", value); - layout.roundLimit.parse("line-round-limit", value); + layout.lineCap.parse("line-cap", value); + layout.lineJoin.parse("line-join", value); + layout.lineMiterLimit.parse("line-miter-limit", value); + layout.lineRoundLimit.parse("line-round-limit", value); } void LineLayer::parsePaints(const JSValue& layer) { - 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.offset.parse("line-offset", layer); - paint.blur.parse("line-blur", layer); - paint.dasharray.parse("line-dasharray", layer); - paint.pattern.parse("line-pattern", layer); + paint.lineOpacity.parse("line-opacity", layer); + paint.lineColor.parse("line-color", layer); + paint.lineTranslate.parse("line-translate", layer); + paint.lineTranslateAnchor.parse("line-translate-anchor", layer); + paint.lineWidth.parse("line-width", layer); + paint.lineGapWidth.parse("line-gap-width", layer); + paint.lineOffset.parse("line-offset", layer); + paint.lineBlur.parse("line-blur", layer); + paint.lineDasharray.parse("line-dasharray", layer); + paint.linePattern.parse("line-pattern", layer); } void LineLayer::cascade(const StyleCascadeParameters& 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.offset.cascade(parameters); - paint.blur.cascade(parameters); - paint.dasharray.cascade(parameters); - paint.pattern.cascade(parameters); + paint.lineOpacity.cascade(parameters); + paint.lineColor.cascade(parameters); + paint.lineTranslate.cascade(parameters); + paint.lineTranslateAnchor.cascade(parameters); + paint.lineWidth.cascade(parameters); + paint.lineGapWidth.cascade(parameters); + paint.lineOffset.cascade(parameters); + paint.lineBlur.cascade(parameters); + paint.lineDasharray.cascade(parameters); + paint.linePattern.cascade(parameters); } bool LineLayer::recalculate(const StyleCalculationParameters& parameters) { // for scaling dasharrays StyleCalculationParameters dashArrayParams = parameters; dashArrayParams.z = std::floor(dashArrayParams.z); - paint.width.calculate(dashArrayParams); - paint.dashLineWidth = paint.width; + paint.lineWidth.calculate(dashArrayParams); + paint.dashLineWidth = paint.lineWidth; 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.offset.calculate(parameters); - hasTransitions |= paint.blur.calculate(parameters); - hasTransitions |= paint.dasharray.calculate(parameters); - hasTransitions |= paint.pattern.calculate(parameters); + hasTransitions |= paint.lineOpacity.calculate(parameters); + hasTransitions |= paint.lineColor.calculate(parameters); + hasTransitions |= paint.lineTranslate.calculate(parameters); + hasTransitions |= paint.lineTranslateAnchor.calculate(parameters); + hasTransitions |= paint.lineWidth.calculate(parameters); + hasTransitions |= paint.lineGapWidth.calculate(parameters); + hasTransitions |= paint.lineOffset.calculate(parameters); + hasTransitions |= paint.lineBlur.calculate(parameters); + hasTransitions |= paint.lineDasharray.calculate(parameters); + hasTransitions |= paint.linePattern.calculate(parameters); passes = paint.isVisible() ? RenderPass::Translucent : RenderPass::None; @@ -74,10 +74,10 @@ std::unique_ptr LineLayer::createBucket(StyleBucketParameters& parameter bucket->layout = layout; StyleCalculationParameters p(parameters.tileID.z); - bucket->layout.cap.calculate(p); - bucket->layout.join.calculate(p); - bucket->layout.miterLimit.calculate(p); - bucket->layout.roundLimit.calculate(p); + bucket->layout.lineCap.calculate(p); + bucket->layout.lineJoin.calculate(p); + bucket->layout.lineMiterLimit.calculate(p); + bucket->layout.lineRoundLimit.calculate(p); parameters.eachFilteredFeature(filter, [&] (const auto& feature) { bucket->addGeometry(getGeometries(feature)); diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp index f7f5abdbfc..fba8050774 100644 --- a/src/mbgl/layer/line_layer.hpp +++ b/src/mbgl/layer/line_layer.hpp @@ -9,30 +9,30 @@ namespace mbgl { class LineLayoutProperties { public: - LayoutProperty cap { LineCapType::Butt }; - LayoutProperty join { LineJoinType::Miter }; - LayoutProperty miterLimit { 2.0f }; - LayoutProperty roundLimit { 1.0f }; + LayoutProperty lineCap { LineCapType::Butt }; + LayoutProperty lineJoin { LineJoinType::Miter }; + LayoutProperty lineMiterLimit { 2.0f }; + LayoutProperty lineRoundLimit { 1.0f }; }; class LinePaintProperties { public: - PaintProperty opacity { 1.0f }; - PaintProperty color { {{ 0, 0, 0, 1 }} }; - PaintProperty> translate { {{ 0, 0 }} }; - PaintProperty translateAnchor { TranslateAnchorType::Map }; - PaintProperty width { 1 }; - PaintProperty gapWidth { 0 }; - PaintProperty blur { 0 }; - PaintProperty offset { 0 }; - PaintProperty, Faded>> dasharray { {} }; - PaintProperty> pattern { "" }; + PaintProperty lineOpacity { 1.0f }; + PaintProperty lineColor { {{ 0, 0, 0, 1 }} }; + PaintProperty> lineTranslate { {{ 0, 0 }} }; + PaintProperty lineTranslateAnchor { TranslateAnchorType::Map }; + PaintProperty lineWidth { 1 }; + PaintProperty lineGapWidth { 0 }; + PaintProperty lineBlur { 0 }; + PaintProperty lineOffset { 0 }; + PaintProperty, Faded>> lineDasharray { {} }; + PaintProperty> linePattern { "" }; // Special case float dashLineWidth = 1; bool isVisible() const { - return opacity > 0 && color.value[3] > 0 && width > 0; + return lineOpacity > 0 && lineColor.value[3] > 0 && lineWidth > 0; } }; diff --git a/src/mbgl/layer/raster_layer.cpp b/src/mbgl/layer/raster_layer.cpp index 401097073d..fa41609039 100644 --- a/src/mbgl/layer/raster_layer.cpp +++ b/src/mbgl/layer/raster_layer.cpp @@ -8,37 +8,37 @@ std::unique_ptr RasterLayer::clone() const { } void RasterLayer::parsePaints(const JSValue& layer) { - 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); + paint.rasterOpacity.parse("raster-opacity", layer); + paint.rasterHueRotate.parse("raster-hue-rotate", layer); + paint.rasterBrightnessMin.parse("raster-brightness-min", layer); + paint.rasterBrightnessMax.parse("raster-brightness-max", layer); + paint.rasterSaturation.parse("raster-saturation", layer); + paint.rasterContrast.parse("raster-contrast", layer); + paint.rasterFadeDuration.parse("raster-fade-duration", layer); } void RasterLayer::cascade(const StyleCascadeParameters& 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); + paint.rasterOpacity.cascade(parameters); + paint.rasterHueRotate.cascade(parameters); + paint.rasterBrightnessMin.cascade(parameters); + paint.rasterBrightnessMax.cascade(parameters); + paint.rasterSaturation.cascade(parameters); + paint.rasterContrast.cascade(parameters); + paint.rasterFadeDuration.cascade(parameters); } bool RasterLayer::recalculate(const StyleCalculationParameters& parameters) { bool hasTransitions = false; - 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); + hasTransitions |= paint.rasterOpacity.calculate(parameters); + hasTransitions |= paint.rasterHueRotate.calculate(parameters); + hasTransitions |= paint.rasterBrightnessMin.calculate(parameters); + hasTransitions |= paint.rasterBrightnessMax.calculate(parameters); + hasTransitions |= paint.rasterSaturation.calculate(parameters); + hasTransitions |= paint.rasterContrast.calculate(parameters); + hasTransitions |= paint.rasterFadeDuration.calculate(parameters); - passes = paint.opacity > 0 ? RenderPass::Translucent : RenderPass::None; + passes = paint.rasterOpacity > 0 ? RenderPass::Translucent : RenderPass::None; return hasTransitions; } diff --git a/src/mbgl/layer/raster_layer.hpp b/src/mbgl/layer/raster_layer.hpp index 52c0f0a7ae..1acf8f5685 100644 --- a/src/mbgl/layer/raster_layer.hpp +++ b/src/mbgl/layer/raster_layer.hpp @@ -8,13 +8,13 @@ namespace mbgl { class RasterPaintProperties { public: - PaintProperty opacity { 1.0f }; - PaintProperty hueRotate { 0.0f }; - PaintProperty brightnessMin { 0.0f }; - PaintProperty brightnessMax { 1.0f }; - PaintProperty saturation { 0.0f }; - PaintProperty contrast { 0.0f }; - PaintProperty fadeDuration { 0.0f }; + PaintProperty rasterOpacity { 1.0f }; + PaintProperty rasterHueRotate { 0.0f }; + PaintProperty rasterBrightnessMin { 0.0f }; + PaintProperty rasterBrightnessMax { 1.0f }; + PaintProperty rasterSaturation { 0.0f }; + PaintProperty rasterContrast { 0.0f }; + PaintProperty rasterFadeDuration { 0.0f }; }; class RasterLayer : public StyleLayer { diff --git a/src/mbgl/layer/symbol_layer.cpp b/src/mbgl/layer/symbol_layer.cpp index 477d28b6e0..6b02fc6d2b 100644 --- a/src/mbgl/layer/symbol_layer.cpp +++ b/src/mbgl/layer/symbol_layer.cpp @@ -10,104 +10,103 @@ std::unique_ptr SymbolLayer::clone() const { } void SymbolLayer::parseLayout(const JSValue& value) { - layout.placement.parse("symbol-placement", value); - layout.spacing.parse("symbol-spacing", value); - layout.avoidEdges.parse("symbol-avoid-edges", value); - - layout.icon.allowOverlap.parse("icon-allow-overlap", value); - layout.icon.ignorePlacement.parse("icon-ignore-placement", value); - layout.icon.optional.parse("icon-optional", value); - layout.icon.rotationAlignment.parse("icon-rotation-alignment", value); - layout.icon.size.parse("icon-size", value); - layout.icon.image.parse("icon-image", value); - layout.icon.rotate.parse("icon-rotate", value); - layout.icon.padding.parse("icon-padding", value); - layout.icon.keepUpright.parse("icon-keep-upright", value); - layout.icon.offset.parse("icon-offset", value); - - layout.text.rotationAlignment.parse("text-rotation-alignment", value); - layout.text.field.parse("text-field", value); - layout.text.font.parse("text-font", value); - layout.text.size.parse("text-size", value); - layout.text.maxWidth.parse("text-max-width", value); - layout.text.lineHeight.parse("text-line-height", value); - layout.text.letterSpacing.parse("text-letter-spacing", value); - layout.text.justify.parse("text-justify", value); - layout.text.anchor.parse("text-anchor", value); - layout.text.maxAngle.parse("text-max-angle", value); - layout.text.rotate.parse("text-rotate", value); - layout.text.padding.parse("text-padding", value); - layout.text.keepUpright.parse("text-keep-upright", value); - layout.text.transform.parse("text-transform", value); - layout.text.offset.parse("text-offset", value); - layout.text.allowOverlap.parse("text-allow-overlap", value); - layout.text.ignorePlacement.parse("text-ignore-placement", value); - layout.text.optional.parse("text-optional", value); + layout.symbolPlacement.parse("symbol-placement", value); + layout.symbolSpacing.parse("symbol-spacing", value); + layout.symbolAvoidEdges.parse("symbol-avoid-edges", value); + + layout.iconAllowOverlap.parse("icon-allow-overlap", value); + layout.iconIgnorePlacement.parse("icon-ignore-placement", value); + layout.iconOptional.parse("icon-optional", value); + layout.iconRotationAlignment.parse("icon-rotation-alignment", value); + layout.iconSize.parse("icon-size", value); + layout.iconImage.parse("icon-image", value); + layout.iconRotate.parse("icon-rotate", value); + layout.iconPadding.parse("icon-padding", value); + layout.iconKeepUpright.parse("icon-keep-upright", value); + layout.iconOffset.parse("icon-offset", value); + + layout.textRotationAlignment.parse("text-rotation-alignment", value); + layout.textField.parse("text-field", value); + layout.textFont.parse("text-font", value); + layout.textSize.parse("text-size", value); + layout.textMaxWidth.parse("text-max-width", value); + layout.textLineHeight.parse("text-line-height", value); + layout.textLetterSpacing.parse("text-letter-spacing", value); + layout.textJustify.parse("text-justify", value); + layout.textAnchor.parse("text-anchor", value); + layout.textMaxAngle.parse("text-max-angle", value); + layout.textRotate.parse("text-rotate", value); + layout.textPadding.parse("text-padding", value); + layout.textKeepUpright.parse("text-keep-upright", value); + layout.textTransform.parse("text-transform", value); + layout.textOffset.parse("text-offset", value); + layout.textAllowOverlap.parse("text-allow-overlap", value); + layout.textIgnorePlacement.parse("text-ignore-placement", value); + layout.textOptional.parse("text-optional", value); } void SymbolLayer::parsePaints(const JSValue& layer) { - 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); - - 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); + paint.iconOpacity.parse("icon-opacity", layer); + paint.iconColor.parse("icon-color", layer); + paint.iconHaloColor.parse("icon-halo-color", layer); + paint.iconHaloWidth.parse("icon-halo-width", layer); + paint.iconHaloBlur.parse("icon-halo-blur", layer); + paint.iconTranslate.parse("icon-translate", layer); + paint.iconTranslateAnchor.parse("icon-translate-anchor", layer); + + paint.textOpacity.parse("text-opacity", layer); + paint.textColor.parse("text-color", layer); + paint.textHaloColor.parse("text-halo-color", layer); + paint.textHaloWidth.parse("text-halo-width", layer); + paint.textHaloBlur.parse("text-halo-blur", layer); + paint.textTranslate.parse("text-translate", layer); + paint.textTranslateAnchor.parse("text-translate-anchor", layer); } void SymbolLayer::cascade(const StyleCascadeParameters& 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); + paint.iconOpacity.cascade(parameters); + paint.iconColor.cascade(parameters); + paint.iconHaloColor.cascade(parameters); + paint.iconHaloWidth.cascade(parameters); + paint.iconHaloBlur.cascade(parameters); + paint.iconTranslate.cascade(parameters); + paint.iconTranslateAnchor.cascade(parameters); + + paint.textOpacity.cascade(parameters); + paint.textColor.cascade(parameters); + paint.textHaloColor.cascade(parameters); + paint.textHaloWidth.cascade(parameters); + paint.textHaloBlur.cascade(parameters); + paint.textTranslate.cascade(parameters); + paint.textTranslateAnchor.cascade(parameters); } bool SymbolLayer::recalculate(const StyleCalculationParameters& parameters) { bool hasTransitions = false; - 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); - - 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); + hasTransitions |= paint.iconOpacity.calculate(parameters); + hasTransitions |= paint.iconColor.calculate(parameters); + hasTransitions |= paint.iconHaloColor.calculate(parameters); + hasTransitions |= paint.iconHaloWidth.calculate(parameters); + hasTransitions |= paint.iconHaloBlur.calculate(parameters); + hasTransitions |= paint.iconTranslate.calculate(parameters); + hasTransitions |= paint.iconTranslateAnchor.calculate(parameters); + + hasTransitions |= paint.textOpacity.calculate(parameters); + hasTransitions |= paint.textColor.calculate(parameters); + hasTransitions |= paint.textHaloColor.calculate(parameters); + hasTransitions |= paint.textHaloWidth.calculate(parameters); + hasTransitions |= paint.textHaloBlur.calculate(parameters); + hasTransitions |= paint.textTranslate.calculate(parameters); + hasTransitions |= paint.textTranslateAnchor.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); - paint.icon.size = layout.icon.size; - paint.text.size = layout.text.size; + layout.iconSize.calculate(parameters); + layout.textSize.calculate(parameters); + paint.iconSize = layout.iconSize; + paint.textSize = layout.textSize; - passes = (paint.icon.isVisible() || paint.text.isVisible()) - ? RenderPass::Translucent : RenderPass::None; + passes = paint.isVisible() ? RenderPass::Translucent : RenderPass::None; return hasTransitions; } @@ -120,48 +119,48 @@ std::unique_ptr SymbolLayer::createBucket(StyleBucketParameters& paramet bucket->layout = layout; StyleCalculationParameters p(parameters.tileID.z); - bucket->layout.placement.calculate(p); - if (bucket->layout.placement.value == SymbolPlacementType::Line) { - bucket->layout.icon.rotationAlignment.value = RotationAlignmentType::Map; - bucket->layout.text.rotationAlignment.value = RotationAlignmentType::Map; + bucket->layout.symbolPlacement.calculate(p); + if (bucket->layout.symbolPlacement.value == SymbolPlacementType::Line) { + bucket->layout.iconRotationAlignment.value = RotationAlignmentType::Map; + bucket->layout.textRotationAlignment.value = RotationAlignmentType::Map; }; - bucket->layout.spacing.calculate(p); - bucket->layout.avoidEdges.calculate(p); - - bucket->layout.icon.allowOverlap.calculate(p); - bucket->layout.icon.ignorePlacement.calculate(p); - bucket->layout.icon.optional.calculate(p); - bucket->layout.icon.rotationAlignment.calculate(p); - bucket->layout.icon.image.calculate(p); - bucket->layout.icon.padding.calculate(p); - bucket->layout.icon.rotate.calculate(p); - bucket->layout.icon.keepUpright.calculate(p); - bucket->layout.icon.offset.calculate(p); - - bucket->layout.text.rotationAlignment.calculate(p); - bucket->layout.text.field.calculate(p); - bucket->layout.text.font.calculate(p); - bucket->layout.text.maxWidth.calculate(p); - bucket->layout.text.lineHeight.calculate(p); - bucket->layout.text.letterSpacing.calculate(p); - bucket->layout.text.maxAngle.calculate(p); - bucket->layout.text.rotate.calculate(p); - bucket->layout.text.padding.calculate(p); - bucket->layout.text.ignorePlacement.calculate(p); - bucket->layout.text.optional.calculate(p); - bucket->layout.text.justify.calculate(p); - bucket->layout.text.anchor.calculate(p); - bucket->layout.text.keepUpright.calculate(p); - bucket->layout.text.transform.calculate(p); - bucket->layout.text.offset.calculate(p); - bucket->layout.text.allowOverlap.calculate(p); - - bucket->layout.icon.size.calculate(StyleCalculationParameters(18)); - bucket->layout.text.size.calculate(StyleCalculationParameters(18)); - bucket->layout.iconMaxSize = bucket->layout.icon.size; - bucket->layout.textMaxSize = bucket->layout.text.size; - bucket->layout.icon.size.calculate(StyleCalculationParameters(p.z + 1)); - bucket->layout.text.size.calculate(StyleCalculationParameters(p.z + 1)); + bucket->layout.symbolSpacing.calculate(p); + bucket->layout.symbolAvoidEdges.calculate(p); + + bucket->layout.iconAllowOverlap.calculate(p); + bucket->layout.iconIgnorePlacement.calculate(p); + bucket->layout.iconOptional.calculate(p); + bucket->layout.iconRotationAlignment.calculate(p); + bucket->layout.iconImage.calculate(p); + bucket->layout.iconPadding.calculate(p); + bucket->layout.iconRotate.calculate(p); + bucket->layout.iconKeepUpright.calculate(p); + bucket->layout.iconOffset.calculate(p); + + bucket->layout.textRotationAlignment.calculate(p); + bucket->layout.textField.calculate(p); + bucket->layout.textFont.calculate(p); + bucket->layout.textMaxWidth.calculate(p); + bucket->layout.textLineHeight.calculate(p); + bucket->layout.textLetterSpacing.calculate(p); + bucket->layout.textMaxAngle.calculate(p); + bucket->layout.textRotate.calculate(p); + bucket->layout.textPadding.calculate(p); + bucket->layout.textIgnorePlacement.calculate(p); + bucket->layout.textOptional.calculate(p); + bucket->layout.textJustify.calculate(p); + bucket->layout.textAnchor.calculate(p); + bucket->layout.textKeepUpright.calculate(p); + bucket->layout.textTransform.calculate(p); + bucket->layout.textOffset.calculate(p); + bucket->layout.textAllowOverlap.calculate(p); + + bucket->layout.iconSize.calculate(StyleCalculationParameters(18)); + bucket->layout.textSize.calculate(StyleCalculationParameters(18)); + bucket->layout.iconMaxSize = bucket->layout.iconSize; + bucket->layout.textMaxSize = bucket->layout.textSize; + bucket->layout.iconSize.calculate(StyleCalculationParameters(p.z + 1)); + bucket->layout.textSize.calculate(StyleCalculationParameters(p.z + 1)); bucket->parseFeatures(parameters.layer, filter); diff --git a/src/mbgl/layer/symbol_layer.hpp b/src/mbgl/layer/symbol_layer.hpp index 75759e2a19..95d71bb3cb 100644 --- a/src/mbgl/layer/symbol_layer.hpp +++ b/src/mbgl/layer/symbol_layer.hpp @@ -11,45 +11,39 @@ class SpriteAtlas; class SymbolLayoutProperties { public: - LayoutProperty placement { SymbolPlacementType::Point }; - LayoutProperty spacing { 250.0f }; - LayoutProperty avoidEdges { false }; - - class IconProperties { - public: - LayoutProperty allowOverlap { false }; - LayoutProperty ignorePlacement { false }; - LayoutProperty optional { false }; - LayoutProperty rotationAlignment { RotationAlignmentType::Viewport }; - LayoutProperty size { 1.0f }; - LayoutProperty image { "" }; - LayoutProperty rotate { 0.0f }; - LayoutProperty padding { 2.0f }; - LayoutProperty keepUpright { false }; - LayoutProperty> offset { {{ 0, 0 }} }; - } icon; - - class TextProperties { - public: - LayoutProperty rotationAlignment { RotationAlignmentType::Viewport }; - LayoutProperty field { "" }; - LayoutProperty font { "Open Sans Regular, Arial Unicode MS Regular" }; - LayoutProperty size { 16.0f }; - LayoutProperty maxWidth { 15.0f /* em */ }; - LayoutProperty lineHeight { 1.2f /* em */ }; - LayoutProperty letterSpacing { 0.0f /* em */ }; - LayoutProperty justify { TextJustifyType::Center }; - LayoutProperty anchor { TextAnchorType::Center }; - LayoutProperty maxAngle { 45.0f /* degrees */ }; - LayoutProperty rotate { 0.0f }; - LayoutProperty padding { 2.0f }; - LayoutProperty keepUpright { true }; - LayoutProperty transform { TextTransformType::None }; - LayoutProperty> offset { {{ 0, 0 }} }; - LayoutProperty allowOverlap { false }; - LayoutProperty ignorePlacement { false }; - LayoutProperty optional { false }; - } text; + LayoutProperty symbolPlacement { SymbolPlacementType::Point }; + LayoutProperty symbolSpacing { 250.0f }; + LayoutProperty symbolAvoidEdges { false }; + + LayoutProperty iconAllowOverlap { false }; + LayoutProperty iconIgnorePlacement { false }; + LayoutProperty iconOptional { false }; + LayoutProperty iconRotationAlignment { RotationAlignmentType::Viewport }; + LayoutProperty iconSize { 1.0f }; + LayoutProperty iconImage { "" }; + LayoutProperty iconRotate { 0.0f }; + LayoutProperty iconPadding { 2.0f }; + LayoutProperty iconKeepUpright { false }; + LayoutProperty> iconOffset { {{ 0, 0 }} }; + + LayoutProperty textRotationAlignment { RotationAlignmentType::Viewport }; + LayoutProperty textField { "" }; + LayoutProperty textFont { "Open Sans Regular, Arial Unicode MS Regular" }; + LayoutProperty textSize { 16.0f }; + LayoutProperty textMaxWidth { 15.0f /* em */ }; + LayoutProperty textLineHeight { 1.2f /* em */ }; + LayoutProperty textLetterSpacing { 0.0f /* em */ }; + LayoutProperty textJustify { TextJustifyType::Center }; + LayoutProperty textAnchor { TextAnchorType::Center }; + LayoutProperty textMaxAngle { 45.0f /* degrees */ }; + LayoutProperty textRotate { 0.0f }; + LayoutProperty textPadding { 2.0f }; + LayoutProperty textKeepUpright { true }; + LayoutProperty textTransform { TextTransformType::None }; + LayoutProperty> textOffset { {{ 0, 0 }} }; + LayoutProperty textAllowOverlap { false }; + LayoutProperty textIgnorePlacement { false }; + LayoutProperty textOptional { false }; // Special case. float iconMaxSize = 1.0f; @@ -58,28 +52,30 @@ public: class SymbolPaintProperties { public: - class PaintProperties { - public: - PaintProperties(float size_) : size(size_) {} - - PaintProperty opacity { 1.0f }; - PaintProperty color { {{ 0, 0, 0, 1 }} }; - PaintProperty haloColor { {{ 0, 0, 0, 0 }} }; - PaintProperty haloWidth { 0.0f }; - PaintProperty haloBlur { 0.0f }; - PaintProperty> translate { {{ 0, 0 }} }; - PaintProperty 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 }; + PaintProperty iconOpacity { 1.0f }; + PaintProperty iconColor { {{ 0, 0, 0, 1 }} }; + PaintProperty iconHaloColor { {{ 0, 0, 0, 0 }} }; + PaintProperty iconHaloWidth { 0.0f }; + PaintProperty iconHaloBlur { 0.0f }; + PaintProperty> iconTranslate { {{ 0, 0 }} }; + PaintProperty iconTranslateAnchor { TranslateAnchorType::Map }; + + PaintProperty textOpacity { 1.0f }; + PaintProperty textColor { {{ 0, 0, 0, 1 }} }; + PaintProperty textHaloColor { {{ 0, 0, 0, 0 }} }; + PaintProperty textHaloWidth { 0.0f }; + PaintProperty textHaloBlur { 0.0f }; + PaintProperty> textTranslate { {{ 0, 0 }} }; + PaintProperty textTranslateAnchor { TranslateAnchorType::Map }; + + // Special case + float iconSize = 1.0f; + float textSize = 16.0f; + + bool isVisible() const { + return (iconOpacity > 0 && (iconColor.value[3] > 0 || iconHaloColor.value[3] > 0) && iconSize > 0) + || (textOpacity > 0 && (textColor.value[3] > 0 || textHaloColor.value[3] > 0) && textSize > 0); + } }; class SymbolLayer : public StyleLayer { diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 3d8ef69003..0819524b96 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -67,7 +67,7 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { return; } - const float miterLimit = layout.join == LineJoinType::Bevel ? 1.05f : float(layout.miterLimit); + const float miterLimit = layout.lineJoin == LineJoinType::Bevel ? 1.05f : float(layout.lineMiterLimit); const double sharpCornerOffset = SHARP_CORNER_OFFSET * (float(util::EXTENT) / (util::tileSize * overscaling)); @@ -80,8 +80,8 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { return; } - const LineCapType beginCap = layout.cap; - const LineCapType endCap = closed ? LineCapType::Butt : LineCapType(layout.cap); + const LineCapType beginCap = layout.lineCap; + const LineCapType endCap = closed ? LineCapType::Butt : LineCapType(layout.lineCap); double distance = 0; bool startOfLine = true; @@ -172,12 +172,12 @@ void LineBucket::addGeometry(const GeometryCoordinates& vertices) { // The join if a middle vertex, otherwise the cap const bool middleVertex = prevVertex && nextVertex; - LineJoinType currentJoin = layout.join; + LineJoinType currentJoin = layout.lineJoin; const LineCapType currentCap = nextVertex ? beginCap : endCap; if (middleVertex) { if (currentJoin == LineJoinType::Round) { - if (miterLength < layout.roundLimit) { + if (miterLength < layout.lineRoundLimit) { currentJoin = LineJoinType::Miter; } else if (miterLength <= 2) { currentJoin = LineJoinType::FakeRound; diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index d411f8821c..5dc87f9c9f 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -124,16 +124,27 @@ private: void setClipping(const ClipID&); - template void renderSDF(SymbolBucket &bucket, const TileID &id, const mat4 &matrixSymbol, - const BucketProperties& bucketProperties, - const StyleProperties& styleProperties, float scaleDivisor, std::array texsize, SDFShader& sdfShader, - void (SymbolBucket::*drawSDF)(SDFShader&, gl::GLObjectStore&)); + void (SymbolBucket::*drawSDF)(SDFShader&, gl::GLObjectStore&), + + // Layout + RotationAlignmentType rotationAlignment, + float layoutSize, + + // Paint + float opacity, + Color color, + Color haloColor, + float haloWidth, + float haloBlur, + std::array translate, + TranslateAnchorType translateAnchor, + float paintSize); void setDepthSublayer(int n); diff --git a/src/mbgl/renderer/painter_background.cpp b/src/mbgl/renderer/painter_background.cpp index 6105fd4e73..dddc755542 100644 --- a/src/mbgl/renderer/painter_background.cpp +++ b/src/mbgl/renderer/painter_background.cpp @@ -14,13 +14,13 @@ void Painter::renderBackground(const BackgroundLayer& layer) { // glClear rather than this method. const BackgroundPaintProperties& properties = layer.paint; - const bool isPatterned = !properties.pattern.value.to.empty();// && false; + const bool isPatterned = !properties.backgroundPattern.value.to.empty();// && false; optional imagePosA; optional imagePosB; if (isPatterned) { - imagePosA = spriteAtlas->getPosition(properties.pattern.value.from, true); - imagePosB = spriteAtlas->getPosition(properties.pattern.value.to, true); + imagePosA = spriteAtlas->getPosition(properties.backgroundPattern.value.from, true); + imagePosB = spriteAtlas->getPosition(properties.backgroundPattern.value.to, true); if (!imagePosA || !imagePosB) return; @@ -31,18 +31,18 @@ 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.pattern.value.t; - patternShader->u_opacity = properties.opacity; + patternShader->u_mix = properties.backgroundPattern.value.t; + patternShader->u_opacity = properties.backgroundOpacity; spriteAtlas->bind(true, glObjectStore); backgroundPatternArray.bind(*patternShader, tileStencilBuffer, BUFFER_OFFSET(0), glObjectStore); } else { - Color color = properties.color; - color[0] *= properties.opacity; - color[1] *= properties.opacity; - color[2] *= properties.opacity; - color[3] *= properties.opacity; + Color color = properties.backgroundColor; + color[0] *= properties.backgroundOpacity; + color[1] *= properties.backgroundOpacity; + color[2] *= properties.backgroundOpacity; + color[3] *= properties.backgroundOpacity; config.program = plainShader->getID(); plainShader->u_color = color; @@ -66,12 +66,12 @@ void Painter::renderBackground(const BackgroundLayer& layer) { patternShader->u_matrix = vtxMatrix; std::array imageSizeScaledA = {{ - (int)((*imagePosA).size[0] * properties.pattern.value.fromScale), - (int)((*imagePosA).size[1] * properties.pattern.value.fromScale) + (int)((*imagePosA).size[0] * properties.backgroundPattern.value.fromScale), + (int)((*imagePosA).size[1] * properties.backgroundPattern.value.fromScale) }}; std::array imageSizeScaledB = {{ - (int)((*imagePosB).size[0] * properties.pattern.value.toScale), - (int)((*imagePosB).size[1] * properties.pattern.value.toScale) + (int)((*imagePosB).size[0] * properties.backgroundPattern.value.toScale), + (int)((*imagePosB).size[1] * properties.backgroundPattern.value.toScale) }}; patternShader->u_patternscale_a = {{ @@ -95,7 +95,7 @@ void Painter::renderBackground(const BackgroundLayer& layer) { } else { plainShader->u_matrix = vtxMatrix; - Color color = properties.color; + Color color = properties.backgroundColor; plainShader->u_color = color; } diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp index 9e795dec1a..8e601ea7ee 100644 --- a/src/mbgl/renderer/painter_circle.cpp +++ b/src/mbgl/renderer/painter_circle.cpp @@ -23,27 +23,27 @@ void Painter::renderCircle(CircleBucket& bucket, setDepthSublayer(0); const CirclePaintProperties& properties = layer.paint; - mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, properties.circleTranslate, id, properties.circleTranslateAnchor); - Color color = properties.color; - color[0] *= properties.opacity; - color[1] *= properties.opacity; - color[2] *= properties.opacity; - color[3] *= properties.opacity; + Color color = properties.circleColor; + color[0] *= properties.circleOpacity; + color[1] *= properties.circleOpacity; + color[2] *= properties.circleOpacity; + color[3] *= properties.circleOpacity; // Antialiasing factor: this is a minimum blur distance that serves as // a faux-antialiasing for the circle. since blur is a ratio of the circle's // size and the intent is to keep the blur at roughly 1px, the two // are inversely related. - float antialiasing = 1 / frame.pixelRatio / properties.radius; + float antialiasing = 1 / frame.pixelRatio / properties.circleRadius; config.program = circleShader->getID(); circleShader->u_matrix = vtxMatrix; circleShader->u_exmatrix = extrudeMatrix; circleShader->u_color = color; - circleShader->u_blur = std::max(properties.blur, antialiasing); - circleShader->u_size = properties.radius; + circleShader->u_blur = std::max(properties.circleBlur, antialiasing); + circleShader->u_size = properties.circleRadius; bucket.drawCircles(*circleShader, glObjectStore); } diff --git a/src/mbgl/renderer/painter_fill.cpp b/src/mbgl/renderer/painter_fill.cpp index 5bc0c1d9d4..0452b532ac 100644 --- a/src/mbgl/renderer/painter_fill.cpp +++ b/src/mbgl/renderer/painter_fill.cpp @@ -11,28 +11,28 @@ using namespace mbgl; void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileID& id, const mat4& matrix) { const FillPaintProperties& properties = layer.paint; - mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, properties.fillTranslate, id, properties.fillTranslateAnchor); - 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 fill_color = properties.fillColor; + fill_color[0] *= properties.fillOpacity; + fill_color[1] *= properties.fillOpacity; + fill_color[2] *= properties.fillOpacity; + fill_color[3] *= properties.fillOpacity; - Color stroke_color = properties.outlineColor; + Color stroke_color = properties.fillOutlineColor; if (stroke_color[3] < 0) { stroke_color = fill_color; } else { - stroke_color[0] *= properties.opacity; - stroke_color[1] *= properties.opacity; - stroke_color[2] *= properties.opacity; - stroke_color[3] *= properties.opacity; + stroke_color[0] *= properties.fillOpacity; + stroke_color[1] *= properties.fillOpacity; + stroke_color[2] *= properties.fillOpacity; + stroke_color[3] *= properties.fillOpacity; } - const bool pattern = !properties.pattern.value.from.empty(); + const bool pattern = !properties.fillPattern.value.from.empty(); - bool outline = properties.antialias && !pattern && stroke_color != fill_color; - bool fringeline = properties.antialias && !pattern && stroke_color == fill_color; + bool outline = properties.fillAntialias && !pattern && stroke_color != fill_color; + bool fringeline = properties.fillAntialias && !pattern && stroke_color == fill_color; config.stencilOp.reset(); config.stencilTest = GL_TRUE; @@ -59,8 +59,8 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI } if (pattern) { - optional posA = spriteAtlas->getPosition(properties.pattern.value.from, true); - optional posB = spriteAtlas->getPosition(properties.pattern.value.to, true); + optional posA = spriteAtlas->getPosition(properties.fillPattern.value.from, true); + optional posB = spriteAtlas->getPosition(properties.fillPattern.value.to, true); // Image fill. if (pass == RenderPass::Translucent && posA && posB) { @@ -71,17 +71,17 @@ void Painter::renderFill(FillBucket& bucket, const FillLayer& layer, const TileI patternShader->u_pattern_br_a = (*posA).br; patternShader->u_pattern_tl_b = (*posB).tl; patternShader->u_pattern_br_b = (*posB).br; - patternShader->u_opacity = properties.opacity; + patternShader->u_opacity = properties.fillOpacity; patternShader->u_image = 0; - patternShader->u_mix = properties.pattern.value.t; + patternShader->u_mix = properties.fillPattern.value.t; std::array imageSizeScaledA = {{ - (int)((*posA).size[0] * properties.pattern.value.fromScale), - (int)((*posA).size[1] * properties.pattern.value.fromScale) + (int)((*posA).size[0] * properties.fillPattern.value.fromScale), + (int)((*posA).size[1] * properties.fillPattern.value.fromScale) }}; std::array imageSizeScaledB = {{ - (int)((*posB).size[0] * properties.pattern.value.toScale), - (int)((*posB).size[1] * properties.pattern.value.toScale) + (int)((*posB).size[0] * properties.fillPattern.value.toScale), + (int)((*posB).size[1] * properties.fillPattern.value.toScale) }}; patternShader->u_patternscale_a = {{ diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp index 1ea5e932e0..1345ba5ea0 100644 --- a/src/mbgl/renderer/painter_line.cpp +++ b/src/mbgl/renderer/painter_line.cpp @@ -28,15 +28,15 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI // Retina devices need a smaller distance to avoid aliasing. float antialiasing = 1.0 / frame.pixelRatio; - float blur = properties.blur + antialiasing; - float edgeWidth = properties.width / 2.0; + float blur = properties.lineBlur + antialiasing; + float edgeWidth = properties.lineWidth / 2.0; float inset = -1; float offset = 0; float shift = 0; - if (properties.gapWidth != 0) { - inset = properties.gapWidth / 2.0 + antialiasing * 0.5; - edgeWidth = properties.width; + if (properties.lineGapWidth != 0) { + inset = properties.lineGapWidth / 2.0 + antialiasing * 0.5; + edgeWidth = properties.lineWidth; // shift outer lines half a pixel towards the middle to eliminate the crack offset = inset - antialiasing / 2.0; @@ -44,11 +44,11 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI float outset = offset + edgeWidth + antialiasing / 2.0 + shift; - Color color = properties.color; - color[0] *= properties.opacity; - color[1] *= properties.opacity; - color[2] *= properties.opacity; - color[3] *= properties.opacity; + Color color = properties.lineColor; + color[0] *= properties.lineOpacity; + color[1] *= properties.lineOpacity; + color[2] *= properties.lineOpacity; + color[3] *= properties.lineOpacity; const float ratio = 1.0 / id.pixelsToTileUnits(1.0, state.getZoom()); @@ -63,11 +63,11 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI float x = state.getHeight() / 2.0f * std::tan(state.getPitch()); float extra = (topedgelength + x) / topedgelength - 1; - mat4 vtxMatrix = translatedMatrix(matrix, properties.translate, id, properties.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, properties.lineTranslate, id, properties.lineTranslateAnchor); setDepthSublayer(0); - if (!properties.dasharray.value.from.empty()) { + if (!properties.lineDasharray.value.from.empty()) { config.program = linesdfShader->getID(); @@ -78,11 +78,11 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI linesdfShader->u_blur = blur; linesdfShader->u_color = color; - LinePatternPos posA = lineAtlas->getDashPosition(properties.dasharray.value.from, layout.cap == LineCapType::Round, glObjectStore); - LinePatternPos posB = lineAtlas->getDashPosition(properties.dasharray.value.to, layout.cap == LineCapType::Round, glObjectStore); + LinePatternPos posA = lineAtlas->getDashPosition(properties.lineDasharray.value.from, layout.lineCap == LineCapType::Round, glObjectStore); + LinePatternPos posB = lineAtlas->getDashPosition(properties.lineDasharray.value.to, layout.lineCap == LineCapType::Round, glObjectStore); - const float widthA = posA.width * properties.dasharray.value.fromScale * properties.dashLineWidth; - const float widthB = posB.width * properties.dasharray.value.toScale * properties.dashLineWidth; + const float widthA = posA.width * properties.lineDasharray.value.fromScale * properties.dashLineWidth; + const float widthB = posB.width * properties.lineDasharray.value.toScale * properties.dashLineWidth; float scaleXA = 1.0 / id.pixelsToTileUnits(widthA, state.getIntegerZoom()); float scaleYA = -posA.height / 2.0; @@ -94,9 +94,9 @@ 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_sdfgamma = lineAtlas->width / (std::min(widthA, widthB) * 256.0 * frame.pixelRatio) / 2; - linesdfShader->u_mix = properties.dasharray.value.t; + linesdfShader->u_mix = properties.lineDasharray.value.t; linesdfShader->u_extra = extra; - linesdfShader->u_offset = -properties.offset; + linesdfShader->u_offset = -properties.lineOffset; linesdfShader->u_antialiasingmatrix = antialiasingMatrix; linesdfShader->u_image = 0; @@ -105,9 +105,9 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI bucket.drawLineSDF(*linesdfShader, glObjectStore); - } else if (!properties.pattern.value.from.empty()) { - optional imagePosA = spriteAtlas->getPosition(properties.pattern.value.from, true); - optional imagePosB = spriteAtlas->getPosition(properties.pattern.value.to, true); + } else if (!properties.linePattern.value.from.empty()) { + optional imagePosA = spriteAtlas->getPosition(properties.linePattern.value.from, true); + optional imagePosB = spriteAtlas->getPosition(properties.linePattern.value.to, true); if (!imagePosA || !imagePosB) return; @@ -121,23 +121,23 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI linepatternShader->u_blur = blur; linepatternShader->u_pattern_size_a = {{ - id.pixelsToTileUnits((*imagePosA).size[0] * properties.pattern.value.fromScale, state.getIntegerZoom()), + id.pixelsToTileUnits((*imagePosA).size[0] * properties.linePattern.value.fromScale, state.getIntegerZoom()), (*imagePosA).size[1] }}; linepatternShader->u_pattern_tl_a = (*imagePosA).tl; linepatternShader->u_pattern_br_a = (*imagePosA).br; linepatternShader->u_pattern_size_b = {{ - id.pixelsToTileUnits((*imagePosB).size[0] * properties.pattern.value.toScale, state.getIntegerZoom()), + id.pixelsToTileUnits((*imagePosB).size[0] * properties.linePattern.value.toScale, state.getIntegerZoom()), (*imagePosB).size[1] }}; linepatternShader->u_pattern_tl_b = (*imagePosB).tl; linepatternShader->u_pattern_br_b = (*imagePosB).br; - linepatternShader->u_fade = properties.pattern.value.t; - linepatternShader->u_opacity = properties.opacity; + linepatternShader->u_fade = properties.linePattern.value.t; + linepatternShader->u_opacity = properties.lineOpacity; linepatternShader->u_extra = extra; - linepatternShader->u_offset = -properties.offset; + linepatternShader->u_offset = -properties.lineOffset; linepatternShader->u_antialiasingmatrix = antialiasingMatrix; linepatternShader->u_image = 0; @@ -155,7 +155,7 @@ void Painter::renderLine(LineBucket& bucket, const LineLayer& layer, const TileI lineShader->u_ratio = ratio; lineShader->u_blur = blur; lineShader->u_extra = extra; - lineShader->u_offset = -properties.offset; + lineShader->u_offset = -properties.lineOffset; lineShader->u_antialiasingmatrix = antialiasingMatrix; lineShader->u_color = color; diff --git a/src/mbgl/renderer/painter_raster.cpp b/src/mbgl/renderer/painter_raster.cpp index c86d1a4c58..39e0b5f195 100644 --- a/src/mbgl/renderer/painter_raster.cpp +++ b/src/mbgl/renderer/painter_raster.cpp @@ -15,12 +15,12 @@ void Painter::renderRaster(RasterBucket& bucket, const RasterLayer& layer, const config.program = rasterShader->getID(); rasterShader->u_matrix = matrix; rasterShader->u_buffer = 0; - rasterShader->u_opacity = properties.opacity; - 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.hueRotate); + rasterShader->u_opacity = properties.rasterOpacity; + rasterShader->u_brightness_low = properties.rasterBrightnessMin; + rasterShader->u_brightness_high = properties.rasterBrightnessMax; + rasterShader->u_saturation_factor = saturationFactor(properties.rasterSaturation); + rasterShader->u_contrast_factor = contrastFactor(properties.rasterContrast); + rasterShader->u_spin_weights = spinWeights(properties.rasterHueRotate); config.stencilTest = GL_FALSE; diff --git a/src/mbgl/renderer/painter_symbol.cpp b/src/mbgl/renderer/painter_symbol.cpp index bd245b0032..3e4367506a 100644 --- a/src/mbgl/renderer/painter_symbol.cpp +++ b/src/mbgl/renderer/painter_symbol.cpp @@ -13,20 +13,31 @@ using namespace mbgl; -template void Painter::renderSDF(SymbolBucket &bucket, const TileID &id, const mat4 &matrix, - const BucketProperties& bucketProperties, - const StyleProperties& styleProperties, float sdfFontSize, std::array texsize, SDFShader& sdfShader, - void (SymbolBucket::*drawSDF)(SDFShader&, gl::GLObjectStore&)) + void (SymbolBucket::*drawSDF)(SDFShader&, gl::GLObjectStore&), + + // Layout + RotationAlignmentType rotationAlignment, + float layoutSize, + + // Paint + float opacity, + Color color, + Color haloColor, + float haloWidth, + float haloBlur, + std::array translate, + TranslateAnchorType translateAnchor, + float paintSize) { - mat4 vtxMatrix = translatedMatrix(matrix, styleProperties.translate, id, styleProperties.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, translate, id, translateAnchor); - bool skewed = (bucketProperties.rotationAlignment == RotationAlignmentType::Map); + bool skewed = rotationAlignment == RotationAlignmentType::Map; mat4 exMatrix; float s; float gammaScale; @@ -44,7 +55,7 @@ void Painter::renderSDF(SymbolBucket &bucket, matrix::scale(exMatrix, exMatrix, s, s, 1); // If layerStyle.size > bucket.info.fontSize then labels may collide - float fontSize = styleProperties.size; + float fontSize = paintSize; float fontScale = fontSize / sdfFontSize; matrix::scale(exMatrix, exMatrix, fontScale, fontScale, 1.0f); @@ -56,7 +67,7 @@ void Painter::renderSDF(SymbolBucket &bucket, sdfShader.u_texture = 0; // adjust min/max zooms for variable font sies - float zoomAdjust = std::log(fontSize / bucketProperties.size) / std::log(2); + float zoomAdjust = std::log(fontSize / layoutSize) / std::log(2); sdfShader.u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level @@ -83,41 +94,35 @@ 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.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.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.haloColor; + if (haloColor[3] > 0.0f && haloWidth > 0.0f) { + sdfShader.u_gamma = (haloBlur * blurOffset / fontScale / sdfPx + gamma) * gammaScale; + + if (opacity < 1.0f) { + haloColor[0] *= opacity; + haloColor[1] *= opacity; + haloColor[2] *= opacity; + haloColor[3] *= opacity; } - sdfShader.u_buffer = (haloOffset - styleProperties.haloWidth / fontScale) / sdfPx; + sdfShader.u_color = haloColor; + sdfShader.u_buffer = (haloOffset - haloWidth / fontScale) / sdfPx; setDepthSublayer(0); (bucket.*drawSDF)(sdfShader, glObjectStore); } // Then, we draw the text/icon over the halo - if (styleProperties.color.value[3] > 0.0f) { + if (color[3] > 0.0f) { sdfShader.u_gamma = gamma * gammaScale; - if (styleProperties.opacity < 1.0f) { - Color color = styleProperties.color; - 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.color; + if (opacity < 1.0f) { + color[0] *= opacity; + color[1] *= opacity; + color[2] *= opacity; + color[3] *= opacity; } + sdfShader.u_color = color; sdfShader.u_buffer = (256.0f - 64.0f) / 256.0f; setDepthSublayer(1); @@ -131,14 +136,14 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const return; } - const auto& properties = layer.paint; + const auto& paint = layer.paint; const auto& layout = bucket.layout; config.depthMask = GL_FALSE; // TODO remove the `true ||` when #1673 is implemented - const bool drawAcrossEdges = (frame.mapMode == MapMode::Continuous) && (true || !(layout.text.allowOverlap || layout.icon.allowOverlap || - layout.text.ignorePlacement || layout.icon.ignorePlacement)); + const bool drawAcrossEdges = (frame.mapMode == MapMode::Continuous) && (true || !(layout.textAllowOverlap || layout.iconAllowOverlap || + layout.textIgnorePlacement || layout.iconIgnorePlacement)); // Disable the stencil test so that labels aren't clipped to tile boundaries. // @@ -153,7 +158,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const } if (bucket.hasIconData()) { - if (layout.icon.rotationAlignment == RotationAlignmentType::Map) { + if (layout.iconRotationAlignment == RotationAlignmentType::Map) { config.depthFunc.reset(); config.depthTest = GL_TRUE; } else { @@ -163,16 +168,16 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const bool sdf = bucket.sdfIcons; const float angleOffset = - layout.icon.rotationAlignment == RotationAlignmentType::Map + layout.iconRotationAlignment == RotationAlignmentType::Map ? state.getAngle() : 0; - const float fontSize = properties.icon.size; + const float fontSize = paint.iconSize; const float fontScale = fontSize / 1.0f; SpriteAtlas* activeSpriteAtlas = layer.spriteAtlas; const bool iconScaled = fontScale != 1 || frame.pixelRatio != activeSpriteAtlas->getPixelRatio() || bucket.iconsNeedLinear; - const bool iconTransformed = layout.icon.rotationAlignment == RotationAlignmentType::Map || angleOffset != 0 || state.getPitch() != 0; + const bool iconTransformed = layout.iconRotationAlignment == RotationAlignmentType::Map || angleOffset != 0 || state.getPitch() != 0; config.activeTexture = GL_TEXTURE0; activeSpriteAtlas->bind(sdf || state.isChanging() || iconScaled || iconTransformed, glObjectStore); @@ -180,16 +185,24 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const renderSDF(bucket, id, matrix, - layout.icon, - properties.icon, 1.0f, {{ float(activeSpriteAtlas->getWidth()) / 4.0f, float(activeSpriteAtlas->getHeight()) / 4.0f }}, *sdfIconShader, - &SymbolBucket::drawIcons); + &SymbolBucket::drawIcons, + layout.iconRotationAlignment, + layout.iconSize, + paint.iconOpacity, + paint.iconColor, + paint.iconHaloColor, + paint.iconHaloWidth, + paint.iconHaloBlur, + paint.iconTranslate, + paint.iconTranslateAnchor, + paint.iconSize); } else { - mat4 vtxMatrix = translatedMatrix(matrix, properties.icon.translate, id, properties.icon.translateAnchor); + mat4 vtxMatrix = translatedMatrix(matrix, paint.iconTranslate, id, paint.iconTranslateAnchor); - bool skewed = layout.icon.rotationAlignment == RotationAlignmentType::Map; + bool skewed = layout.iconRotationAlignment == RotationAlignmentType::Map; mat4 exMatrix; float s; @@ -220,14 +233,14 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const iconShader->u_texture = 0; // adjust min/max zooms for variable font sies - float zoomAdjust = std::log(fontSize / layout.icon.size) / std::log(2); + float zoomAdjust = std::log(fontSize / layout.iconSize) / std::log(2); iconShader->u_zoom = (state.getZoom() - zoomAdjust) * 10; // current zoom level iconShader->u_fadedist = 0 * 10; iconShader->u_minfadezoom = state.getZoom() * 10; iconShader->u_maxfadezoom = state.getZoom() * 10; iconShader->u_fadezoom = state.getZoom() * 10; - iconShader->u_opacity = properties.icon.opacity; + iconShader->u_opacity = paint.iconOpacity; setDepthSublayer(0); bucket.drawIcons(*iconShader, glObjectStore); @@ -235,7 +248,7 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const } if (bucket.hasTextData()) { - if (layout.text.rotationAlignment == RotationAlignmentType::Map) { + if (layout.textRotationAlignment == RotationAlignmentType::Map) { config.depthFunc.reset(); config.depthTest = GL_TRUE; } else { @@ -248,12 +261,20 @@ void Painter::renderSymbol(SymbolBucket& bucket, const SymbolLayer& layer, const renderSDF(bucket, id, matrix, - layout.text, - properties.text, 24.0f, {{ float(glyphAtlas->width) / 4, float(glyphAtlas->height) / 4 }}, *sdfGlyphShader, - &SymbolBucket::drawGlyphs); + &SymbolBucket::drawGlyphs, + layout.textRotationAlignment, + layout.textSize, + paint.textOpacity, + paint.textColor, + paint.textHaloColor, + paint.textHaloWidth, + paint.textHaloBlur, + paint.textTranslate, + paint.textTranslateAnchor, + paint.textSize); } if (bucket.hasCollisionBoxData()) { diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index 1bc38fe066..a52a8ba8ad 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -101,8 +101,8 @@ bool SymbolBucket::needsClipping() const { void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, const FilterExpression& filter) { - const bool has_text = !layout.text.field.value.empty() && !layout.text.font.value.empty(); - const bool has_icon = !layout.icon.image.value.empty(); + const bool has_text = !layout.textField.value.empty() && !layout.textFont.value.empty(); + const bool has_icon = !layout.iconImage.value.empty(); if (!has_text && !has_icon) { return; @@ -125,11 +125,11 @@ void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, }; if (has_text) { - std::string u8string = util::replaceTokens(layout.text.field, getValue); + std::string u8string = util::replaceTokens(layout.textField, getValue); - if (layout.text.transform == TextTransformType::Uppercase) { + if (layout.textTransform == TextTransformType::Uppercase) { u8string = platform::uppercase(u8string); - } else if (layout.text.transform == TextTransformType::Lowercase) { + } else if (layout.textTransform == TextTransformType::Lowercase) { u8string = platform::lowercase(u8string); } @@ -144,7 +144,7 @@ void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, } if (has_icon) { - ft.sprite = util::replaceTokens(layout.icon.image, getValue); + ft.sprite = util::replaceTokens(layout.iconImage, getValue); } if (ft.label.length() || ft.sprite.length()) { @@ -163,17 +163,17 @@ void SymbolBucket::parseFeatures(const GeometryTileLayer& layer, } } - if (layout.placement == SymbolPlacementType::Line) { + if (layout.symbolPlacement == SymbolPlacementType::Line) { util::mergeLines(features); } } bool SymbolBucket::needsDependencies(GlyphStore& glyphStore, SpriteStore& spriteStore) { - if (!layout.text.field.value.empty() && !layout.text.font.value.empty() && !glyphStore.hasGlyphRanges(layout.text.font, ranges)) { + if (!layout.textField.value.empty() && !layout.textFont.value.empty() && !glyphStore.hasGlyphRanges(layout.textFont, ranges)) { return true; } - if (!layout.icon.image.value.empty() && !spriteStore.isLoaded()) { + if (!layout.iconImage.value.empty() && !spriteStore.isLoaded()) { return true; } @@ -187,7 +187,7 @@ void SymbolBucket::addFeatures(uintptr_t tileUID, float horizontalAlign = 0.5; float verticalAlign = 0.5; - switch (layout.text.anchor) { + switch (layout.textAnchor) { case TextAnchorType::Top: case TextAnchorType::Bottom: case TextAnchorType::Center: @@ -204,7 +204,7 @@ void SymbolBucket::addFeatures(uintptr_t tileUID, break; } - switch (layout.text.anchor) { + switch (layout.textAnchor) { case TextAnchorType::Left: case TextAnchorType::Right: case TextAnchorType::Center: @@ -221,11 +221,11 @@ void SymbolBucket::addFeatures(uintptr_t tileUID, break; } - const float justify = layout.text.justify == TextJustifyType::Right ? 1 : - layout.text.justify == TextJustifyType::Left ? 0 : + const float justify = layout.textJustify == TextJustifyType::Right ? 1 : + layout.textJustify == TextJustifyType::Left ? 0 : 0.5; - auto fontStack = glyphStore.getFontStack(layout.text.font); + auto fontStack = glyphStore.getFontStack(layout.textFont); for (const auto& feature : features) { if (feature.geometry.empty()) continue; @@ -238,18 +238,18 @@ void SymbolBucket::addFeatures(uintptr_t tileUID, if (feature.label.length()) { shapedText = fontStack->getShaping( /* string */ feature.label, - /* maxWidth: ems */ layout.placement != SymbolPlacementType::Line ? - layout.text.maxWidth * 24 : 0, - /* lineHeight: ems */ layout.text.lineHeight * 24, + /* maxWidth: ems */ layout.symbolPlacement != SymbolPlacementType::Line ? + layout.textMaxWidth * 24 : 0, + /* lineHeight: ems */ layout.textLineHeight * 24, /* horizontalAlign */ horizontalAlign, /* verticalAlign */ verticalAlign, /* justify */ justify, - /* spacing: ems */ layout.text.letterSpacing * 24, - /* translate */ vec2(layout.text.offset.value[0], layout.text.offset.value[1])); + /* spacing: ems */ layout.textLetterSpacing * 24, + /* translate */ vec2(layout.textOffset.value[0], layout.textOffset.value[1])); // Add the glyphs we need for this label to the glyph atlas. if (shapedText) { - glyphAtlas.addGlyphs(tileUID, feature.label, layout.text.font, **fontStack, face); + glyphAtlas.addGlyphs(tileUID, feature.label, layout.textFont, **fontStack, face); } } @@ -284,24 +284,24 @@ void SymbolBucket::addFeature(const GeometryCollection &lines, const float minScale = 0.5f; const float glyphSize = 24.0f; - const float fontScale = layout.text.size / glyphSize; + const float fontScale = layout.textSize / glyphSize; const float textBoxScale = tilePixelRatio * fontScale; const float textMaxBoxScale = tilePixelRatio * layout.textMaxSize / glyphSize; - const float iconBoxScale = tilePixelRatio * layout.icon.size; - const float symbolSpacing = tilePixelRatio * layout.spacing; - const bool avoidEdges = layout.avoidEdges && layout.placement != SymbolPlacementType::Line; - const float textPadding = layout.text.padding * tilePixelRatio; - const float iconPadding = layout.icon.padding * tilePixelRatio; - const float textMaxAngle = layout.text.maxAngle * util::DEG2RAD; + const float iconBoxScale = tilePixelRatio * layout.iconSize; + const float symbolSpacing = tilePixelRatio * layout.symbolSpacing; + const bool avoidEdges = layout.symbolAvoidEdges && layout.symbolPlacement != SymbolPlacementType::Line; + const float textPadding = layout.textPadding * tilePixelRatio; + const float iconPadding = layout.iconPadding * tilePixelRatio; + const float textMaxAngle = layout.textMaxAngle * util::DEG2RAD; const bool textAlongLine = - layout.text.rotationAlignment == RotationAlignmentType::Map && - layout.placement == SymbolPlacementType::Line; + layout.textRotationAlignment == RotationAlignmentType::Map && + layout.symbolPlacement == SymbolPlacementType::Line; const bool iconAlongLine = - layout.icon.rotationAlignment == RotationAlignmentType::Map && - layout.placement == SymbolPlacementType::Line; - const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap || - layout.text.ignorePlacement || layout.icon.ignorePlacement; - const bool isLine = layout.placement == SymbolPlacementType::Line; + layout.iconRotationAlignment == RotationAlignmentType::Map && + layout.symbolPlacement == SymbolPlacementType::Line; + const bool mayOverlap = layout.textAllowOverlap || layout.iconAllowOverlap || + layout.textIgnorePlacement || layout.iconIgnorePlacement; + const bool isLine = layout.symbolPlacement == SymbolPlacementType::Line; const float textRepeatDistance = symbolSpacing / 2; auto& clippedLines = isLine ? @@ -372,14 +372,14 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { // create the bufers used for rendering. const bool textAlongLine = - layout.text.rotationAlignment == RotationAlignmentType::Map && - layout.placement == SymbolPlacementType::Line; + layout.textRotationAlignment == RotationAlignmentType::Map && + layout.symbolPlacement == SymbolPlacementType::Line; const bool iconAlongLine = - layout.icon.rotationAlignment == RotationAlignmentType::Map && - layout.placement == SymbolPlacementType::Line; + layout.iconRotationAlignment == RotationAlignmentType::Map && + layout.symbolPlacement == SymbolPlacementType::Line; - const bool mayOverlap = layout.text.allowOverlap || layout.icon.allowOverlap || - layout.text.ignorePlacement || layout.icon.ignorePlacement; + const bool mayOverlap = layout.textAllowOverlap || layout.iconAllowOverlap || + layout.textIgnorePlacement || layout.iconIgnorePlacement; // Sort symbols by their y position on the canvas so that they lower symbols // are drawn on top of higher symbols. @@ -403,18 +403,18 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { const bool hasText = symbolInstance.hasText; const bool hasIcon = symbolInstance.hasIcon; - const bool iconWithoutText = layout.text.optional || !hasText; - const bool textWithoutIcon = layout.icon.optional || !hasIcon; + const bool iconWithoutText = layout.textOptional || !hasText; + const bool textWithoutIcon = layout.iconOptional || !hasIcon; // Calculate the scales at which the text and icon can be placed without collision. float glyphScale = hasText ? collisionTile.placeFeature(symbolInstance.textCollisionFeature, - layout.text.allowOverlap, layout.avoidEdges) : + layout.textAllowOverlap, layout.symbolAvoidEdges) : collisionTile.minScale; float iconScale = hasIcon ? collisionTile.placeFeature(symbolInstance.iconCollisionFeature, - layout.icon.allowOverlap, layout.avoidEdges) : + layout.iconAllowOverlap, layout.symbolAvoidEdges) : collisionTile.minScale; @@ -432,24 +432,24 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) { // Insert final placement into collision tree and add glyphs/icons to buffers if (hasText) { - if (!layout.text.ignorePlacement) { + if (!layout.textIgnorePlacement) { collisionTile.insertFeature(symbolInstance.textCollisionFeature, glyphScale); } if (glyphScale < collisionTile.maxScale) { addSymbols( renderDataInProgress->text, symbolInstance.glyphQuads, glyphScale, - layout.text.keepUpright, textAlongLine, collisionTile.config.angle); + layout.textKeepUpright, textAlongLine, collisionTile.config.angle); } } if (hasIcon) { - if (!layout.icon.ignorePlacement) { + if (!layout.iconIgnorePlacement) { collisionTile.insertFeature(symbolInstance.iconCollisionFeature, iconScale); } if (iconScale < collisionTile.maxScale) { addSymbols( renderDataInProgress->icon, symbolInstance.iconQuads, iconScale, - layout.icon.keepUpright, iconAlongLine, collisionTile.config.angle); + layout.iconKeepUpright, iconAlongLine, collisionTile.config.angle); } } } diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 010f0aeafd..a480ef8d97 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -256,13 +256,13 @@ RenderData Style::getRenderData() const { continue; if (const BackgroundLayer* background = layer->as()) { - if (layer.get() == layers[0].get() && background->paint.pattern.value.from.empty()) { + if (layer.get() == layers[0].get() && background->paint.backgroundPattern.value.from.empty()) { // This is a solid background. We can use glClear(). - result.backgroundColor = background->paint.color; - result.backgroundColor[0] *= background->paint.opacity; - result.backgroundColor[1] *= background->paint.opacity; - result.backgroundColor[2] *= background->paint.opacity; - result.backgroundColor[3] *= background->paint.opacity; + result.backgroundColor = background->paint.backgroundColor; + result.backgroundColor[0] *= background->paint.backgroundOpacity; + result.backgroundColor[1] *= background->paint.backgroundOpacity; + result.backgroundColor[2] *= background->paint.backgroundOpacity; + result.backgroundColor[3] *= background->paint.backgroundOpacity; } else { // This is a textured background, or not the bottommost layer. We need to render it with a quad. result.order.emplace_back(*layer); diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index cea0a95a22..e312dee3b3 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -497,7 +497,7 @@ std::vector StyleParser::fontStacks() const { for (const auto& layer : layers) { if (layer->is()) { - LayoutProperty property = layer->as()->layout.text.font; + LayoutProperty property = layer->as()->layout.textFont; if (property.parsedValue) { for (const auto& stop : property.parsedValue->getStops()) { result.insert(stop.second); diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index 2117538232..2b5db023c0 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -28,7 +28,7 @@ SymbolQuads getIconQuads(Anchor& anchor, const PositionedIcon& shapedIcon, vec2 bl{left, bottom}; - float angle = layout.icon.rotate * util::DEG2RAD; + float angle = layout.iconRotate * util::DEG2RAD; if (alongLine) { assert(static_cast(anchor.segment) < line.size()); const GeometryCoordinate &prev= line[anchor.segment]; @@ -136,8 +136,8 @@ SymbolQuads getGlyphQuads(Anchor& anchor, const Shaping& shapedText, const float boxScale, const GeometryCoordinates& line, const SymbolLayoutProperties& layout, const bool alongLine, const GlyphPositions& face) { - const float textRotate = layout.text.rotate * util::DEG2RAD; - const bool keepUpright = layout.text.keepUpright; + const float textRotate = layout.textRotate * util::DEG2RAD; + const bool keepUpright = layout.textKeepUpright; SymbolQuads quads; diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 342a27a66f..9ad3c3e71d 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -4,8 +4,8 @@ namespace mbgl { PositionedIcon shapeIcon(const SpriteAtlasElement& image, const SymbolLayoutProperties& layout) { - float dx = layout.icon.offset.value[0]; - float dy = layout.icon.offset.value[1]; + float dx = layout.iconOffset.value[0]; + float dy = layout.iconOffset.value[1]; float x1 = dx - image.spriteImage->getWidth() / 2.0f; float x2 = x1 + image.spriteImage->getWidth(); float y1 = dy - image.spriteImage->getHeight() / 2.0f; -- cgit v1.2.1