Skip to content

Commit d3172a0

Browse files
authored
[Impeller] Add STB text backend. (flutter#44887)
Pull the STB text backend into the engine from impeller-cmake.
1 parent a42ddc1 commit d3172a0

53 files changed

Lines changed: 1253 additions & 223 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DEPS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ vars = {
214214
"upstream_sqlite": "https://github.com/sqlite/sqlite.git",
215215
"upstream_sse": "https://github.com/dart-lang/sse.git",
216216
"upstream_stack_trace": "https://github.com/dart-lang/stack_trace.git",
217+
"upstream_stb": "https://github.com/nothings/stb.git",
217218
"upstream_stream_channel": "https://github.com/dart-lang/stream_channel.git",
218219
"upstream_string_scanner": "https://github.com/dart-lang/string_scanner.git",
219220
"upstream_SwiftShader": "https://swiftshader.googlesource.com/SwiftShader.git",
@@ -257,7 +258,7 @@ allowed_hosts = [
257258
]
258259

259260
deps = {
260-
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'a067408d923ccf80742571bb7a71705499f5779e',
261+
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'f91786b0f7ed84f4d55fef7707b68bea180281f5',
261262

262263
# Fuchsia compatibility
263264
#
@@ -681,6 +682,9 @@ deps = {
681682
'src/third_party/json':
682683
Var('github_git') + '/nlohmann/json.git' + '@' + '17d9eacd248f58b73f4d1be518ef649fe2295642',
683684

685+
'src/third_party/stb':
686+
Var('github_git') + '/nothings/stb.git' + '@' + '5736b15f7ea0ffb08dd38af21067c314d6a3aae9',
687+
684688
'src/third_party/gradle': {
685689
'packages': [
686690
{

ci/licenses_golden/excluded_files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,7 @@
28912891
../../../third_party/sqlite/Makefile
28922892
../../../third_party/sqlite/README.md
28932893
../../../third_party/sqlite/VERSION
2894+
../../../third_party/stb
28942895
../../../third_party/swiftshader
28952896
../../../third_party/tinygltf
28962897
../../../third_party/vulkan-deps/.git

ci/licenses_golden/licenses_flutter

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,12 +1701,22 @@ ORIGIN: ../../../flutter/impeller/toolkit/egl/surface.cc + ../../../flutter/LICE
17011701
ORIGIN: ../../../flutter/impeller/toolkit/egl/surface.h + ../../../flutter/LICENSE
17021702
ORIGIN: ../../../flutter/impeller/toolkit/gles/gles.h + ../../../flutter/LICENSE
17031703
ORIGIN: ../../../flutter/impeller/toolkit/gles/texture.h + ../../../flutter/LICENSE
1704+
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/glyph_atlas_context_skia.cc + ../../../flutter/LICENSE
1705+
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/glyph_atlas_context_skia.h + ../../../flutter/LICENSE
17041706
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.cc + ../../../flutter/LICENSE
17051707
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.h + ../../../flutter/LICENSE
1706-
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_render_context_skia.cc + ../../../flutter/LICENSE
1707-
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_render_context_skia.h + ../../../flutter/LICENSE
17081708
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/typeface_skia.cc + ../../../flutter/LICENSE
17091709
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/typeface_skia.h + ../../../flutter/LICENSE
1710+
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/typographer_context_skia.cc + ../../../flutter/LICENSE
1711+
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/typographer_context_skia.h + ../../../flutter/LICENSE
1712+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/glyph_atlas_context_stb.cc + ../../../flutter/LICENSE
1713+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/glyph_atlas_context_stb.h + ../../../flutter/LICENSE
1714+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/text_frame_stb.cc + ../../../flutter/LICENSE
1715+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/text_frame_stb.h + ../../../flutter/LICENSE
1716+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/typeface_stb.cc + ../../../flutter/LICENSE
1717+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/typeface_stb.h + ../../../flutter/LICENSE
1718+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/typographer_context_stb.cc + ../../../flutter/LICENSE
1719+
ORIGIN: ../../../flutter/impeller/typographer/backends/stb/typographer_context_stb.h + ../../../flutter/LICENSE
17101720
ORIGIN: ../../../flutter/impeller/typographer/font.cc + ../../../flutter/LICENSE
17111721
ORIGIN: ../../../flutter/impeller/typographer/font.h + ../../../flutter/LICENSE
17121722
ORIGIN: ../../../flutter/impeller/typographer/font_glyph_pair.cc + ../../../flutter/LICENSE
@@ -1721,12 +1731,12 @@ ORIGIN: ../../../flutter/impeller/typographer/rectangle_packer.cc + ../../../flu
17211731
ORIGIN: ../../../flutter/impeller/typographer/rectangle_packer.h + ../../../flutter/LICENSE
17221732
ORIGIN: ../../../flutter/impeller/typographer/text_frame.cc + ../../../flutter/LICENSE
17231733
ORIGIN: ../../../flutter/impeller/typographer/text_frame.h + ../../../flutter/LICENSE
1724-
ORIGIN: ../../../flutter/impeller/typographer/text_render_context.cc + ../../../flutter/LICENSE
1725-
ORIGIN: ../../../flutter/impeller/typographer/text_render_context.h + ../../../flutter/LICENSE
17261734
ORIGIN: ../../../flutter/impeller/typographer/text_run.cc + ../../../flutter/LICENSE
17271735
ORIGIN: ../../../flutter/impeller/typographer/text_run.h + ../../../flutter/LICENSE
17281736
ORIGIN: ../../../flutter/impeller/typographer/typeface.cc + ../../../flutter/LICENSE
17291737
ORIGIN: ../../../flutter/impeller/typographer/typeface.h + ../../../flutter/LICENSE
1738+
ORIGIN: ../../../flutter/impeller/typographer/typographer_context.cc + ../../../flutter/LICENSE
1739+
ORIGIN: ../../../flutter/impeller/typographer/typographer_context.h + ../../../flutter/LICENSE
17301740
ORIGIN: ../../../flutter/lib/gpu/context.cc + ../../../flutter/LICENSE
17311741
ORIGIN: ../../../flutter/lib/gpu/context.h + ../../../flutter/LICENSE
17321742
ORIGIN: ../../../flutter/lib/gpu/export.cc + ../../../flutter/LICENSE
@@ -4432,12 +4442,22 @@ FILE: ../../../flutter/impeller/toolkit/gles/gles.h
44324442
FILE: ../../../flutter/impeller/toolkit/gles/texture.cc
44334443
FILE: ../../../flutter/impeller/toolkit/gles/texture.h
44344444
FILE: ../../../flutter/impeller/tools/malioc.json
4445+
FILE: ../../../flutter/impeller/typographer/backends/skia/glyph_atlas_context_skia.cc
4446+
FILE: ../../../flutter/impeller/typographer/backends/skia/glyph_atlas_context_skia.h
44354447
FILE: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.cc
44364448
FILE: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.h
4437-
FILE: ../../../flutter/impeller/typographer/backends/skia/text_render_context_skia.cc
4438-
FILE: ../../../flutter/impeller/typographer/backends/skia/text_render_context_skia.h
44394449
FILE: ../../../flutter/impeller/typographer/backends/skia/typeface_skia.cc
44404450
FILE: ../../../flutter/impeller/typographer/backends/skia/typeface_skia.h
4451+
FILE: ../../../flutter/impeller/typographer/backends/skia/typographer_context_skia.cc
4452+
FILE: ../../../flutter/impeller/typographer/backends/skia/typographer_context_skia.h
4453+
FILE: ../../../flutter/impeller/typographer/backends/stb/glyph_atlas_context_stb.cc
4454+
FILE: ../../../flutter/impeller/typographer/backends/stb/glyph_atlas_context_stb.h
4455+
FILE: ../../../flutter/impeller/typographer/backends/stb/text_frame_stb.cc
4456+
FILE: ../../../flutter/impeller/typographer/backends/stb/text_frame_stb.h
4457+
FILE: ../../../flutter/impeller/typographer/backends/stb/typeface_stb.cc
4458+
FILE: ../../../flutter/impeller/typographer/backends/stb/typeface_stb.h
4459+
FILE: ../../../flutter/impeller/typographer/backends/stb/typographer_context_stb.cc
4460+
FILE: ../../../flutter/impeller/typographer/backends/stb/typographer_context_stb.h
44414461
FILE: ../../../flutter/impeller/typographer/font.cc
44424462
FILE: ../../../flutter/impeller/typographer/font.h
44434463
FILE: ../../../flutter/impeller/typographer/font_glyph_pair.cc
@@ -4452,12 +4472,12 @@ FILE: ../../../flutter/impeller/typographer/rectangle_packer.cc
44524472
FILE: ../../../flutter/impeller/typographer/rectangle_packer.h
44534473
FILE: ../../../flutter/impeller/typographer/text_frame.cc
44544474
FILE: ../../../flutter/impeller/typographer/text_frame.h
4455-
FILE: ../../../flutter/impeller/typographer/text_render_context.cc
4456-
FILE: ../../../flutter/impeller/typographer/text_render_context.h
44574475
FILE: ../../../flutter/impeller/typographer/text_run.cc
44584476
FILE: ../../../flutter/impeller/typographer/text_run.h
44594477
FILE: ../../../flutter/impeller/typographer/typeface.cc
44604478
FILE: ../../../flutter/impeller/typographer/typeface.h
4479+
FILE: ../../../flutter/impeller/typographer/typographer_context.cc
4480+
FILE: ../../../flutter/impeller/typographer/typographer_context.h
44614481
FILE: ../../../flutter/lib/gpu/context.cc
44624482
FILE: ../../../flutter/lib/gpu/context.h
44634483
FILE: ../../../flutter/lib/gpu/export.cc

ci/licenses_golden/tool_signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: d8b5e1bcc7593e590ac227d01043c4a8
1+
Signature: 996bda987bb421e5aecf9238c247c296
22

impeller/BUILD.gn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ group("impeller") {
6262
"image:image_skia_backend",
6363
"renderer",
6464
"renderer/backend",
65-
"typographer",
65+
"typographer/backends/skia:typographer_skia_backend",
6666
]
6767
}
6868
}

impeller/aiks/BUILD.gn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ impeller_component("aiks") {
3737

3838
impeller_component("aiks_playground") {
3939
testonly = true
40+
4041
sources = [
4142
"aiks_playground.cc",
4243
"aiks_playground.h",
@@ -45,10 +46,14 @@ impeller_component("aiks_playground") {
4546
":aiks",
4647
"../playground:playground_test",
4748
]
49+
public_deps = [
50+
"//flutter/impeller/typographer/backends/skia:typographer_skia_backend",
51+
]
4852
}
4953

5054
impeller_component("aiks_unittests") {
5155
testonly = true
56+
5257
sources = [
5358
"aiks_unittests.cc",
5459
"canvas_unittests.cc",
@@ -62,6 +67,7 @@ impeller_component("aiks_unittests") {
6267
"//flutter/impeller/geometry:geometry_asserts",
6368
"//flutter/impeller/golden_tests:golden_playground_test",
6469
"//flutter/impeller/playground:playground_test",
70+
"//flutter/impeller/typographer/backends/stb:typographer_stb_backend",
6571
"//flutter/testing:testing_lib",
6672
]
6773
}
@@ -86,6 +92,7 @@ impeller_component("aiks_unittests_golden") {
8692
"//flutter/impeller/geometry:geometry_asserts",
8793
"//flutter/impeller/golden_tests:golden_playground_test",
8894
"//flutter/impeller/playground:playground_test",
95+
"//flutter/impeller/typographer/backends/stb:typographer_stb_backend",
8996
"//flutter/testing:testing_lib",
9097
]
9198
}

impeller/aiks/aiks_context.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
#include "impeller/aiks/aiks_context.h"
66

77
#include "impeller/aiks/picture.h"
8-
#include "impeller/typographer/text_render_context.h"
8+
#include "impeller/typographer/typographer_context.h"
99

1010
namespace impeller {
1111

12-
AiksContext::AiksContext(std::shared_ptr<Context> context,
13-
std::shared_ptr<TextRenderContext> text_render_context)
12+
AiksContext::AiksContext(
13+
std::shared_ptr<Context> context,
14+
std::shared_ptr<TypographerContext> typographer_context)
1415
: context_(std::move(context)) {
1516
if (!context_ || !context_->IsValid()) {
1617
return;
1718
}
1819

1920
content_context_ = std::make_unique<ContentContext>(
20-
context_, std::move(text_render_context));
21+
context_, std::move(typographer_context));
2122
if (!content_context_->IsValid()) {
2223
return;
2324
}

impeller/aiks/aiks_context.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "impeller/entity/contents/content_context.h"
1111
#include "impeller/renderer/context.h"
1212
#include "impeller/renderer/render_target.h"
13-
#include "impeller/typographer/text_render_context.h"
13+
#include "impeller/typographer/typographer_context.h"
1414

1515
namespace impeller {
1616

@@ -24,12 +24,12 @@ class AiksContext {
2424
/// @param context The Impeller context that Aiks should use for
2525
/// allocating resources and executing device
2626
/// commands. Required.
27-
/// @param text_render_context The text backend to use for rendering text. If
27+
/// @param typographer_context The text backend to use for rendering text. If
2828
/// `nullptr` is supplied, then attempting to draw
2929
/// text with Aiks will result in validation
3030
/// errors.
3131
AiksContext(std::shared_ptr<Context> context,
32-
std::shared_ptr<TextRenderContext> text_render_context);
32+
std::shared_ptr<TypographerContext> typographer_context);
3333

3434
~AiksContext();
3535

impeller/aiks/aiks_playground.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
#include <memory>
88

99
#include "impeller/aiks/aiks_context.h"
10-
#include "impeller/typographer/backends/skia/text_render_context_skia.h"
11-
#include "impeller/typographer/text_render_context.h"
10+
#include "impeller/typographer/backends/skia/typographer_context_skia.h"
11+
#include "impeller/typographer/typographer_context.h"
1212
#include "third_party/imgui/imgui.h"
1313

1414
namespace impeller {
1515

1616
AiksPlayground::AiksPlayground()
17-
: text_render_context_(TextRenderContextSkia::Make()) {}
17+
: typographer_context_(TypographerContextSkia::Make()) {}
1818

1919
AiksPlayground::~AiksPlayground() = default;
2020

21-
void AiksPlayground::SetTextRenderContext(
22-
std::shared_ptr<TextRenderContext> text_render_context) {
23-
text_render_context_ = std::move(text_render_context);
21+
void AiksPlayground::SetTypographerContext(
22+
std::shared_ptr<TypographerContext> typographer_context) {
23+
typographer_context_ = std::move(typographer_context);
2424
}
2525

2626
bool AiksPlayground::OpenPlaygroundHere(const Picture& picture) {
@@ -35,7 +35,7 @@ bool AiksPlayground::OpenPlaygroundHere(AiksPlaygroundCallback callback) {
3535
return true;
3636
}
3737

38-
AiksContext renderer(GetContext(), text_render_context_);
38+
AiksContext renderer(GetContext(), typographer_context_);
3939

4040
if (!renderer.IsValid()) {
4141
return false;

impeller/aiks/aiks_playground.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "impeller/aiks/aiks_context.h"
99
#include "impeller/aiks/picture.h"
1010
#include "impeller/playground/playground_test.h"
11-
#include "impeller/typographer/text_render_context.h"
11+
#include "impeller/typographer/typographer_context.h"
1212

1313
namespace impeller {
1414

@@ -21,15 +21,15 @@ class AiksPlayground : public PlaygroundTest {
2121

2222
~AiksPlayground();
2323

24-
void SetTextRenderContext(
25-
std::shared_ptr<TextRenderContext> text_render_context);
24+
void SetTypographerContext(
25+
std::shared_ptr<TypographerContext> typographer_context);
2626

2727
bool OpenPlaygroundHere(const Picture& picture);
2828

2929
bool OpenPlaygroundHere(AiksPlaygroundCallback callback);
3030

3131
private:
32-
std::shared_ptr<TextRenderContext> text_render_context_;
32+
std::shared_ptr<TypographerContext> typographer_context_;
3333

3434
FML_DISALLOW_COPY_AND_ASSIGN(AiksPlayground);
3535
};

0 commit comments

Comments
 (0)