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

[core] Images in labels #15937

Merged
merged 16 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions include/mbgl/style/expression/format_expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ namespace style {
namespace expression {

struct FormatExpressionSection {
FormatExpressionSection(std::unique_ptr<Expression> text_,
optional<std::unique_ptr<Expression>> fontScale_,
optional<std::unique_ptr<Expression>> textFont_,
optional<std::unique_ptr<Expression>> textColor_);

std::shared_ptr<Expression> text;
explicit FormatExpressionSection(std::unique_ptr<Expression> content_);

void setTextSectionOptions(optional<std::unique_ptr<Expression>> fontScale_,
optional<std::unique_ptr<Expression>> textFont_,
optional<std::unique_ptr<Expression>> textColor_);

// Content can be expression that evaluates to String or Image.
std::shared_ptr<Expression> content;

// Text related section options.
optional<std::shared_ptr<Expression>> fontScale;
optional<std::shared_ptr<Expression>> textFont;
optional<std::shared_ptr<Expression>> textColor;
Expand Down
27 changes: 14 additions & 13 deletions include/mbgl/style/expression/formatted.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <mbgl/style/conversion.hpp>
#include <mbgl/style/expression/image.hpp>
#include <mbgl/util/color.hpp>
#include <mbgl/util/font_stack.hpp>
#include <mbgl/util/optional.hpp>
Expand All @@ -17,17 +18,19 @@ extern const char* const kFormattedSectionTextFont;
extern const char* const kFormattedSectionTextColor;

struct FormattedSection {
FormattedSection(std::string text_,
optional<double> fontScale_,
optional<FontStack> fontStack_,
optional<Color> textColor_)
: text(std::move(text_))
, fontScale(std::move(fontScale_))
, fontStack(std::move(fontStack_))
, textColor(std::move(textColor_))
{}
explicit FormattedSection(std::string text_,
optional<double> fontScale_,
optional<FontStack> fontStack_,
optional<Color> textColor_)
: text(std::move(text_)),
fontScale(std::move(fontScale_)),
fontStack(std::move(fontStack_)),
textColor(std::move(textColor_)) {}

explicit FormattedSection(Image image_) : image(std::move(image_)) {}
tmpsantos marked this conversation as resolved.
Show resolved Hide resolved

std::string text;
optional<Image> image;
optional<double> fontScale;
optional<FontStack> fontStack;
optional<Color> textColor;
Expand All @@ -50,10 +53,8 @@ class Formatted {
std::string toString() const;
mbgl::Value toObject() const;

bool empty() const {
return sections.empty() || sections.at(0).text.empty();
}

bool empty() const;

std::vector<FormattedSection> sections;
};

Expand Down
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 93 files
+27 −2 .eslintrc
+19 −0 bench/benchmarks/layers.js
+1 −1 bench/styles/benchmarks.js
+5 −4 bench/versions/benchmarks.js
+1 −1 build/generate-style-code.js
+6 −2 build/rollup_plugins.js
+50 −14 debug/animate.html
+38 −0 debug/is-safari.html
+3 −1 package.json
+23 −12 src/data/bucket/symbol_bucket.js
+3 −1 src/data/feature_position_map.js
+13 −11 src/data/program_configuration.js
+5 −0 src/index.js
+42 −10 src/render/draw_symbol.js
+1 −1 src/render/glyph_atlas.js
+13 −12 src/render/image_atlas.js
+2 −1 src/render/program/program_uniforms.js
+69 −1 src/render/program/symbol_program.js
+3 −0 src/shaders/shaders.js
+4 −5 src/shaders/symbol_icon.vertex.glsl
+4 −6 src/shaders/symbol_sdf.vertex.glsl
+68 −0 src/shaders/symbol_text_and_icon.fragment.glsl
+116 −0 src/shaders/symbol_text_and_icon.vertex.glsl
+1 −1 src/style-spec/expression/definitions/coercion.js
+64 −44 src/style-spec/expression/definitions/format.js
+16 −2 src/style-spec/expression/types/formatted.js
+1 −1 src/style-spec/reference/v8.json
+3 −3 src/style-spec/validate_mapbox_api_supported.js
+102 −86 src/symbol/quads.js
+262 −86 src/symbol/shaping.js
+45 −36 src/symbol/symbol_layout.js
+1 −1 src/symbol/symbol_size.js
+5 −1 src/ui/control/fullscreen_control.js
+11 −6 src/ui/control/geolocate_control.js
+1 −1 src/ui/control/logo_control.js
+15 −7 src/ui/control/navigation_control.js
+7 −11 src/ui/control/scale_control.js
+20 −0 src/ui/default_locale.js
+7 −2 src/ui/hash.js
+15 −2 src/ui/map.js
+14 −5 src/util/actor.js
+12 −0 src/util/debug.js
+30 −7 src/util/tile_request_cache.js
+24 −0 src/util/util.js
+1 −1 src/util/web_worker_transfer.js
+122 −47 test/expected/text-shaping-default.json
+275 −0 test/expected/text-shaping-images-horizontal.json
+160 −0 test/expected/text-shaping-images-vertical.json
+240 −90 test/expected/text-shaping-linebreak.json
+240 −90 test/expected/text-shaping-newline.json
+242 −88 test/expected/text-shaping-newlines-in-middle.json
+53 −20 test/expected/text-shaping-null.json
+122 −47 test/expected/text-shaping-spacing.json
+335 −124 test/expected/text-shaping-zero-width-space.json
+386 −193 test/fixtures/fontstack-glyphs.json
+4 −0 test/integration/expression-tests/format/basic/test.json
+3 −0 test/integration/expression-tests/format/coercion/test.json
+2 −0 test/integration/expression-tests/format/data-driven-font/test.json
+54 −0 test/integration/expression-tests/format/image-sections/test.json
+3 −0 test/integration/expression-tests/format/implicit-coerce/test.json
+3 −0 test/integration/expression-tests/format/implicit-omit/test.json
+3 −0 test/integration/expression-tests/format/implicit/test.json
+ test/integration/render-tests/line-dasharray/round/segments/expected.png
+85 −0 test/integration/render-tests/line-dasharray/round/segments/style.json
+ test/integration/render-tests/line-dasharray/round/zero-gap-width/expected.png
+85 −0 test/integration/render-tests/line-dasharray/round/zero-gap-width/style.json
+ test/integration/render-tests/text-field/formatted-arabic/expected.png
+ test/integration/render-tests/text-field/formatted-images-constant-size/expected.png
+59 −0 test/integration/render-tests/text-field/formatted-images-constant-size/style.json
+ test/integration/render-tests/text-field/formatted-images-line/expected.png
+82 −0 test/integration/render-tests/text-field/formatted-images-line/style.json
+ test/integration/render-tests/text-field/formatted-images-multiline/expected.png
+75 −0 test/integration/render-tests/text-field/formatted-images-multiline/style.json
+ test/integration/render-tests/text-field/formatted-images-variable-anchors-justification/expected.png
+103 −0 test/integration/render-tests/text-field/formatted-images-variable-anchors-justification/style.json
+ test/integration/render-tests/text-field/formatted-images-vertical/expected.png
+46 −0 test/integration/render-tests/text-field/formatted-images-vertical/style.json
+ test/integration/render-tests/text-field/formatted-images-zoom-dependent-size/expected.png
+69 −0 test/integration/render-tests/text-field/formatted-images-zoom-dependent-size/style.json
+ test/integration/render-tests/text-field/formatted-images/expected.png
+64 −0 test/integration/render-tests/text-field/formatted-images/style.json
+ test/integration/render-tests/text-field/formatted-text-color/expected.png
+ test/integration/render-tests/text-field/formatted/expected.png
+2 −2 test/unit/style-spec/fixture/non-mapbox-references.output-api-supported.json
+1 −1 test/unit/style-spec/fixture/root-properties.output-api-supported.json
+2 −2 test/unit/style-spec/fixture/sources.output-api-supported.json
+63 −1 test/unit/style-spec/fixture/text-field-format.input.json
+12 −8 test/unit/style-spec/fixture/text-field-format.output-api-supported.json
+12 −8 test/unit/style-spec/fixture/text-field-format.output.json
+10 −5 test/unit/symbol/quads.test.js
+74 −15 test/unit/symbol/shaping.test.js
+2 −1 test/unit/util/tile_request_cache.test.js
+123 −7 yarn.lock
6 changes: 3 additions & 3 deletions metrics/tests/binary-size/linux-clang8/metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
[
"mbgl-glfw",
"/src/workspace/next-linux-clang8-release/bin/mbgl-glfw",
6225032
6290568
],
[
"mbgl-offline",
"/src/workspace/next-linux-clang8-release/bin/mbgl-offline",
5532376
5597912
],
[
"mbgl-render",
"/src/workspace/next-linux-clang8-release/bin/mbgl-render",
6151096
6220728
]
]
}
2 changes: 1 addition & 1 deletion metrics/tests/binary-size/linux-gcc8/metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[
"mbgl-offline",
"/src/workspace/next-linux-gcc8-release/bin/mbgl-offline",
6357224
6422760
],
[
"mbgl-render",
Expand Down
2 changes: 2 additions & 0 deletions next/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ add_library(
${MBGL_ROOT}/src/mbgl/programs/gl/symbol_icon.cpp
${MBGL_ROOT}/src/mbgl/programs/gl/symbol_sdf_icon.cpp
${MBGL_ROOT}/src/mbgl/programs/gl/symbol_sdf_text.cpp
${MBGL_ROOT}/src/mbgl/programs/gl/symbol_text_and_icon.cpp
${MBGL_ROOT}/src/mbgl/programs/heatmap_program.cpp
${MBGL_ROOT}/src/mbgl/programs/heatmap_program.hpp
${MBGL_ROOT}/src/mbgl/programs/heatmap_texture_program.cpp
Expand All @@ -466,6 +467,7 @@ add_library(
${MBGL_ROOT}/src/mbgl/programs/symbol_program.hpp
${MBGL_ROOT}/src/mbgl/programs/symbol_sdf_icon_program.hpp
${MBGL_ROOT}/src/mbgl/programs/symbol_sdf_text_program.hpp
${MBGL_ROOT}/src/mbgl/programs/symbol_text_and_icon_program.hpp
${MBGL_ROOT}/src/mbgl/programs/textures.hpp
${MBGL_ROOT}/src/mbgl/programs/uniforms.hpp
${MBGL_ROOT}/src/mbgl/renderer/backend_scope.cpp
Expand Down
1 change: 1 addition & 0 deletions next/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ add_library(
${MBGL_ROOT}/test/style/style_parser.test.cpp
${MBGL_ROOT}/test/text/bidi.test.cpp
${MBGL_ROOT}/test/text/cross_tile_symbol_index.test.cpp
${MBGL_ROOT}/test/text/formatted.test.cpp
${MBGL_ROOT}/test/text/glyph_manager.test.cpp
${MBGL_ROOT}/test/text/glyph_pbf.test.cpp
${MBGL_ROOT}/test/text/language_tag.test.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
0,
0
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
2,
4,
9,
1,
[
36864,
36864
],
[
202,
202
],
[
704,
704
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
0,
0
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
2,
4,
9,
1,
[
36864,
36864
],
[
202,
202
],
[
704,
704
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
3,
161976
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
2,
4,
13,
1,
[
24580,
24580
],
[
190,
190
],
[
1856,
1856
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
3,
120865
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
3,
4,
11,
1,
[
28318,
28318
],
[
190,
190
],
[
1424,
1424
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
3,
120865
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
2,
6,
13,
1,
[
44921,
44921
],
[
310,
310
],
[
3136,
3136
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
3,
161976
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
1,
4,
9,
1,
[
24580,
24580
],
[
2290,
2290
],
[
24256,
24256
]
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": [
[
"probeNetwork - default - end",
4,
255564
],
[
"probeNetwork - default - start",
0,
0
]
],
"gfx": [
[
"probeGFX - default - end",
1,
4,
9,
1,
[
35756,
35756
],
[
310,
310
],
[
3136,
3136
]
]
]
}
Loading