Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Implement data-driven styling for {text,icon}-{color,opacity,h…
Browse files Browse the repository at this point in the history
…alo-color,halo-blur,halo-width} (#7939)

* Add symbol dds attributes and adapt style code generation

* Update to mapbox-gl-js/master

* Refactor SymbolFeature as a subclass of GeometryTileFeature

Prepares for enabling DDS on symbol paint properties by allowing the
SymbolFeatures, which we keep around after constructing SymbolLayout,
to be used in evaluating data-driven paint properties later in the
layout process.

* Draft approach for splitting icon/text paint properties

The `Program` types are set up to bind GL attributes to each of the
data-driven paint properties specified in the `PaintProperties` type
provided.  Since `SymbolPaintProperties` specifies both `Text*` and
`Icon*` properties, the symbolIcon, symbolIconSDF, and symbolGlyph
programs each attempt to bind roughly double the number of attributes
that they actually need.

This change addresses this by:
- Adding the more specific `IconPaintProperties` and `TextPaintProperties` types, which are subsets of the full `SymbolPaintProperties`.
- The symbol layer continues to use its `SymbolPaintProperties paint` member to track layer property state, but it provides helpers that construct objects of each the specific `{Icon,Text}PaintProperties::Evaluated` type, for use by the painter.
- The three symbol programs instantiate `Program<>` using the appropriate `{Icon,Text}PaintProperties` type.

* check in generated style code

* Populate paint buffers for symbol DDS properties

* Address first round of review comments

* Refactor VectorTile{Layer,Feature} to explicitly share data

* Update submodule
  • Loading branch information
anandthakker authored Mar 1, 2017
1 parent c3ed1f5 commit f901e77
Show file tree
Hide file tree
Showing 31 changed files with 2,023 additions and 516 deletions.
60 changes: 30 additions & 30 deletions include/mbgl/style/layers/symbol_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,29 +169,29 @@ class SymbolLayer : public Layer {

// Paint properties

static PropertyValue<float> getDefaultIconOpacity();
PropertyValue<float> getIconOpacity(const optional<std::string>& klass = {}) const;
void setIconOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<float> getDefaultIconOpacity();
DataDrivenPropertyValue<float> getIconOpacity(const optional<std::string>& klass = {}) const;
void setIconOpacity(DataDrivenPropertyValue<float>, const optional<std::string>& klass = {});
void setIconOpacityTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<Color> getDefaultIconColor();
PropertyValue<Color> getIconColor(const optional<std::string>& klass = {}) const;
void setIconColor(PropertyValue<Color>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<Color> getDefaultIconColor();
DataDrivenPropertyValue<Color> getIconColor(const optional<std::string>& klass = {}) const;
void setIconColor(DataDrivenPropertyValue<Color>, const optional<std::string>& klass = {});
void setIconColorTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<Color> getDefaultIconHaloColor();
PropertyValue<Color> getIconHaloColor(const optional<std::string>& klass = {}) const;
void setIconHaloColor(PropertyValue<Color>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<Color> getDefaultIconHaloColor();
DataDrivenPropertyValue<Color> getIconHaloColor(const optional<std::string>& klass = {}) const;
void setIconHaloColor(DataDrivenPropertyValue<Color>, const optional<std::string>& klass = {});
void setIconHaloColorTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultIconHaloWidth();
PropertyValue<float> getIconHaloWidth(const optional<std::string>& klass = {}) const;
void setIconHaloWidth(PropertyValue<float>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<float> getDefaultIconHaloWidth();
DataDrivenPropertyValue<float> getIconHaloWidth(const optional<std::string>& klass = {}) const;
void setIconHaloWidth(DataDrivenPropertyValue<float>, const optional<std::string>& klass = {});
void setIconHaloWidthTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultIconHaloBlur();
PropertyValue<float> getIconHaloBlur(const optional<std::string>& klass = {}) const;
void setIconHaloBlur(PropertyValue<float>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<float> getDefaultIconHaloBlur();
DataDrivenPropertyValue<float> getIconHaloBlur(const optional<std::string>& klass = {}) const;
void setIconHaloBlur(DataDrivenPropertyValue<float>, const optional<std::string>& klass = {});
void setIconHaloBlurTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<std::array<float, 2>> getDefaultIconTranslate();
Expand All @@ -204,29 +204,29 @@ class SymbolLayer : public Layer {
void setIconTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});
void setIconTranslateAnchorTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultTextOpacity();
PropertyValue<float> getTextOpacity(const optional<std::string>& klass = {}) const;
void setTextOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<float> getDefaultTextOpacity();
DataDrivenPropertyValue<float> getTextOpacity(const optional<std::string>& klass = {}) const;
void setTextOpacity(DataDrivenPropertyValue<float>, const optional<std::string>& klass = {});
void setTextOpacityTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<Color> getDefaultTextColor();
PropertyValue<Color> getTextColor(const optional<std::string>& klass = {}) const;
void setTextColor(PropertyValue<Color>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<Color> getDefaultTextColor();
DataDrivenPropertyValue<Color> getTextColor(const optional<std::string>& klass = {}) const;
void setTextColor(DataDrivenPropertyValue<Color>, const optional<std::string>& klass = {});
void setTextColorTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<Color> getDefaultTextHaloColor();
PropertyValue<Color> getTextHaloColor(const optional<std::string>& klass = {}) const;
void setTextHaloColor(PropertyValue<Color>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<Color> getDefaultTextHaloColor();
DataDrivenPropertyValue<Color> getTextHaloColor(const optional<std::string>& klass = {}) const;
void setTextHaloColor(DataDrivenPropertyValue<Color>, const optional<std::string>& klass = {});
void setTextHaloColorTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultTextHaloWidth();
PropertyValue<float> getTextHaloWidth(const optional<std::string>& klass = {}) const;
void setTextHaloWidth(PropertyValue<float>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<float> getDefaultTextHaloWidth();
DataDrivenPropertyValue<float> getTextHaloWidth(const optional<std::string>& klass = {}) const;
void setTextHaloWidth(DataDrivenPropertyValue<float>, const optional<std::string>& klass = {});
void setTextHaloWidthTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<float> getDefaultTextHaloBlur();
PropertyValue<float> getTextHaloBlur(const optional<std::string>& klass = {}) const;
void setTextHaloBlur(PropertyValue<float>, const optional<std::string>& klass = {});
static DataDrivenPropertyValue<float> getDefaultTextHaloBlur();
DataDrivenPropertyValue<float> getTextHaloBlur(const optional<std::string>& klass = {}) const;
void setTextHaloBlur(DataDrivenPropertyValue<float>, const optional<std::string>& klass = {});
void setTextHaloBlurTransition(const TransitionOptions&, const optional<std::string>& klass = {});

static PropertyValue<std::array<float, 2>> getDefaultTextTranslate();
Expand Down
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 54 files
+13 −8 CONTRIBUTING.md
+0 −24 README.md
+6 −1 dist/mapbox-gl.css
+23 −0 docs/_posts/examples/3400-01-28-fullscreen.html
+1 −0 documentation.yml
+1 −0 src/index.js
+7 −8 src/source/rtl_text_plugin.js
+1 −1 src/source/source_cache.js
+8 −3 src/style/style.js
+1 −1 src/ui/camera.js
+88 −0 src/ui/control/fullscreen_control.js
+3 −3 src/ui/map.js
+31 −17 src/util/evented.js
+15 −0 src/util/lru_cache.js
+2 −2 test/README.md
+1 −0 test/integration/query-tests/options/filter-false/expected.json
+44 −0 test/integration/query-tests/options/filter-false/style.json
+15 −0 test/integration/query-tests/options/filter-true/expected.json
+44 −0 test/integration/query-tests/options/filter-true/style.json
+28 −0 test/integration/query-tests/options/layers-multiple/expected.json
+49 −0 test/integration/query-tests/options/layers-multiple/style.json
+15 −0 test/integration/query-tests/options/layers-one/expected.json
+49 −0 test/integration/query-tests/options/layers-one/style.json
+4 −2 test/integration/query-tests/regressions/mapbox-gl-js#3534/style.json
+1 −4 test/integration/render-tests/icon-color/property-function/style.json
+1 −4 test/integration/render-tests/icon-halo-blur/property-function/style.json
+1 −4 test/integration/render-tests/icon-halo-color/property-function/style.json
+1 −4 test/integration/render-tests/icon-halo-width/property-function/style.json
+1 −4 test/integration/render-tests/icon-opacity/property-function/style.json
+ test/integration/render-tests/icon-size/default/expected.png
+14 −34 test/integration/render-tests/icon-size/default/style.json
+ test/integration/render-tests/icon-size/function/expected.png
+19 −38 test/integration/render-tests/icon-size/function/style.json
+ test/integration/render-tests/icon-size/literal/expected.png
+14 −34 test/integration/render-tests/icon-size/literal/style.json
+2 −2 test/integration/render-tests/line-width/very-overscaled/style.json
+1 −4 test/integration/render-tests/text-color/property-function/style.json
+1 −4 test/integration/render-tests/text-halo-blur/property-function/style.json
+1 −4 test/integration/render-tests/text-halo-color/property-function/style.json
+1 −4 test/integration/render-tests/text-halo-width/property-function/style.json
+1 −4 test/integration/render-tests/text-opacity/property-function/style.json
+ test/integration/render-tests/text-size/default/expected.png
+15 −35 test/integration/render-tests/text-size/default/style.json
+ test/integration/render-tests/text-size/function/expected.png
+20 −39 test/integration/render-tests/text-size/function/style.json
+ test/integration/render-tests/text-size/literal/expected.png
+16 −36 test/integration/render-tests/text-size/literal/style.json
+1 −1 test/suite_implementation.js
+1 −1 test/unit/source/source_cache.test.js
+38 −0 test/unit/style/style.test.js
+35 −0 test/unit/ui/camera.test.js
+1 −1 test/unit/ui/map.test.js
+34 −0 test/unit/util/evented.test.js
+10 −0 test/unit/util/lru_cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ public static PropertyValue<Float> iconOpacity(Float value) {
/**
* The opacity at which the icon will be drawn.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @param <T> the function input type
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> iconOpacity(CameraFunction<Z, Float> function) {
public static <T> PropertyValue<Function<T, Float>> iconOpacity(Function<T, Float> function) {
return new PaintPropertyValue<>("icon-opacity", function);
}

Expand Down Expand Up @@ -486,11 +486,11 @@ public static PropertyValue<String> iconColor(String value) {
/**
* The color of the icon. This can only be used with sdf icons.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @param <T> the function input type
* @param function a wrapper function for String
* @return property wrapper around a String function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> iconColor(CameraFunction<Z, String> function) {
public static <T> PropertyValue<Function<T, String>> iconColor(Function<T, String> function) {
return new PaintPropertyValue<>("icon-color", function);
}

Expand Down Expand Up @@ -518,11 +518,11 @@ public static PropertyValue<String> iconHaloColor(String value) {
/**
* The color of the icon's halo. Icon halos can only be used with SDF icons.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @param <T> the function input type
* @param function a wrapper function for String
* @return property wrapper around a String function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> iconHaloColor(CameraFunction<Z, String> function) {
public static <T> PropertyValue<Function<T, String>> iconHaloColor(Function<T, String> function) {
return new PaintPropertyValue<>("icon-halo-color", function);
}

Expand All @@ -540,11 +540,11 @@ public static PropertyValue<Float> iconHaloWidth(Float value) {
/**
* Distance of halo to the icon outline.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @param <T> the function input type
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> iconHaloWidth(CameraFunction<Z, Float> function) {
public static <T> PropertyValue<Function<T, Float>> iconHaloWidth(Function<T, Float> function) {
return new PaintPropertyValue<>("icon-halo-width", function);
}

Expand All @@ -562,11 +562,11 @@ public static PropertyValue<Float> iconHaloBlur(Float value) {
/**
* Fade out the halo towards the outside.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @param <T> the function input type
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> iconHaloBlur(CameraFunction<Z, Float> function) {
public static <T> PropertyValue<Function<T, Float>> iconHaloBlur(Function<T, Float> function) {
return new PaintPropertyValue<>("icon-halo-blur", function);
}

Expand Down Expand Up @@ -628,11 +628,11 @@ public static PropertyValue<Float> textOpacity(Float value) {
/**
* The opacity at which the text will be drawn.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @param <T> the function input type
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> textOpacity(CameraFunction<Z, Float> function) {
public static <T> PropertyValue<Function<T, Float>> textOpacity(Function<T, Float> function) {
return new PaintPropertyValue<>("text-opacity", function);
}

Expand Down Expand Up @@ -660,11 +660,11 @@ public static PropertyValue<String> textColor(String value) {
/**
* The color with which the text will be drawn.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @param <T> the function input type
* @param function a wrapper function for String
* @return property wrapper around a String function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textColor(CameraFunction<Z, String> function) {
public static <T> PropertyValue<Function<T, String>> textColor(Function<T, String> function) {
return new PaintPropertyValue<>("text-color", function);
}

Expand Down Expand Up @@ -692,11 +692,11 @@ public static PropertyValue<String> textHaloColor(String value) {
/**
* The color of the text's halo, which helps it stand out from backgrounds.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for String
* @param <T> the function input type
* @param function a wrapper function for String
* @return property wrapper around a String function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textHaloColor(CameraFunction<Z, String> function) {
public static <T> PropertyValue<Function<T, String>> textHaloColor(Function<T, String> function) {
return new PaintPropertyValue<>("text-halo-color", function);
}

Expand All @@ -714,11 +714,11 @@ public static PropertyValue<Float> textHaloWidth(Float value) {
/**
* Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @param <T> the function input type
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> textHaloWidth(CameraFunction<Z, Float> function) {
public static <T> PropertyValue<Function<T, Float>> textHaloWidth(Function<T, Float> function) {
return new PaintPropertyValue<>("text-halo-width", function);
}

Expand All @@ -736,11 +736,11 @@ public static PropertyValue<Float> textHaloBlur(Float value) {
/**
* The halo's fadeout distance towards the outside.
*
* @param <Z> the zoom parameter type
* @param function a wrapper {@link CameraFunction} for Float
* @param <T> the function input type
* @param function a wrapper function for Float
* @return property wrapper around a Float function
*/
public static <Z extends Number> PropertyValue<CameraFunction<Z, Float>> textHaloBlur(CameraFunction<Z, Float> function) {
public static <T> PropertyValue<Function<T, Float>> textHaloBlur(Function<T, Float> function) {
return new PaintPropertyValue<>("text-halo-blur", function);
}

Expand Down Expand Up @@ -1742,7 +1742,7 @@ public static <Z extends Number> PropertyValue<CameraFunction<Z, String>> textRo
}

/**
* Value to use for a text label. Feature properties are specified using tokens like {field_name}. (Token replacement is only supported for literal `textField` values--not for property functions.)
* Value to use for a text label. Feature properties are specified using tokens like {field_name}. (Token replacement is only supported for literal {@link PropertyFactory#textField} values--not for property functions.)
*
* @param value a String value
* @return property wrapper around String
Expand All @@ -1754,7 +1754,7 @@ public static PropertyValue<String> textField(String value) {


/**
* Value to use for a text label. Feature properties are specified using tokens like {field_name}. (Token replacement is only supported for literal `textField` values--not for property functions.)
* Value to use for a text label. Feature properties are specified using tokens like {field_name}. (Token replacement is only supported for literal {@link PropertyFactory#textField} values--not for property functions.)
*
* @param <T> the function input type
* @param function a wrapper function for String
Expand Down
Loading

0 comments on commit f901e77

Please sign in to comment.