Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 44093cc

Browse files
committed
Move fuchsia/scenic integration behind #define
Using the #define one can create a new flutter_runner_next executable that does not contain any legacy integration code. BUG:
1 parent a960e72 commit 44093cc

Some content is hidden

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

44 files changed

+285
-161
lines changed

BUILD.gn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ config("config") {
123123
}
124124
}
125125

126+
config("fuchsia_legacy") {
127+
if (is_fuchsia) {
128+
defines = [ "LEGACY_FUCHSIA_EMBEDDER" ]
129+
}
130+
}
131+
126132
config("export_dynamic_symbols") {
127133
if (is_linux || is_fuchsia) {
128134
inputs = [

common/config.gni

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,89 @@ if (is_ios || is_mac) {
7676
]
7777
flutter_cflags_objcc = flutter_cflags_objc
7878
}
79+
80+
# This template allows creating a `source_set` in both standard and "fuchsia_legacy" configurations.
81+
#
82+
# The "fuchsia_legacy" configuration includes old, non-embedder API sources and defines the LEGACY_FUCHSIA_EMBEDDER symbol.
83+
#
84+
# `sources`, `defines`, `public_configs`, `configs`, `public_deps`, `deps` work
85+
# as they do in a normal `source_set`.
86+
#
87+
# `legacy_deps` is the list of dependencies which should be mutated by
88+
# appending '_fuchsia_legacy' when creating the 2 `source_set`'s. The template adds
89+
# `legacy_deps` to `public_deps`, whether it mutates them or not.
90+
template("source_set_maybe_fuchsia_legacy") {
91+
pub_deps = []
92+
if (defined(invoker.public_deps)) {
93+
pub_deps += invoker.public_deps
94+
}
95+
if (defined(invoker.deps_legacy_and_next)) {
96+
foreach(legacy_dep, invoker.deps_legacy_and_next) {
97+
pub_deps += [ legacy_dep ]
98+
}
99+
}
100+
101+
source_set(target_name) {
102+
forward_variables_from(invoker,
103+
[
104+
"testonly",
105+
"sources",
106+
"defines",
107+
"public_configs",
108+
"configs",
109+
"deps",
110+
])
111+
public_deps = pub_deps
112+
}
113+
114+
if (is_fuchsia) {
115+
legagcy_suffix = "_fuchsia_legacy"
116+
sources_legacy = []
117+
if (defined(invoker.sources_legacy)) {
118+
sources_legacy = invoker.sources_legacy
119+
}
120+
if (defined(invoker.sources)) {
121+
sources_legacy += invoker.sources
122+
}
123+
124+
public_configs_legacy = [ "//flutter:fuchsia_legacy" ]
125+
if (defined(invoker.public_configs)) {
126+
public_configs_legacy += invoker.public_configs
127+
}
128+
129+
public_deps_legacy = []
130+
if (defined(invoker.deps_legacy)) {
131+
public_deps_legacy = invoker.deps_legacy
132+
}
133+
if (defined(invoker.public_deps)) {
134+
public_deps_legacy += invoker.public_deps
135+
}
136+
if (defined(invoker.deps_legacy_and_next)) {
137+
foreach(legacy_dep, invoker.deps_legacy_and_next) {
138+
public_deps_legacy += [ legacy_dep + legagcy_suffix ]
139+
}
140+
}
141+
142+
source_set(target_name + legagcy_suffix) {
143+
forward_variables_from(invoker,
144+
[
145+
"testonly",
146+
"defines",
147+
"configs",
148+
"deps",
149+
])
150+
sources = sources_legacy
151+
152+
public_configs = public_configs_legacy
153+
154+
public_deps = public_deps_legacy
155+
}
156+
} else {
157+
if (defined(invoker.sources_legacy)) {
158+
not_needed(invoker, [ "sources_legacy" ])
159+
}
160+
if (defined(invoker.deps_legacy)) {
161+
not_needed(invoker, [ "deps_legacy" ])
162+
}
163+
}
164+
}

flow/BUILD.gn

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
import("//flutter/common/config.gni")
6+
import("//flutter/testing/testing.gni")
57
if (is_fuchsia) {
68
import("//build/fuchsia/sdk.gni")
79
import("//flutter/tools/fuchsia/fuchsia_archive.gni")
810
}
9-
import("//flutter/testing/testing.gni")
1011

11-
source_set("flow") {
12+
source_set_maybe_fuchsia_legacy("flow") {
1213
sources = [
1314
"compositor_context.cc",
1415
"compositor_context.h",
@@ -74,37 +75,33 @@ source_set("flow") {
7475

7576
public_configs = [ "//flutter:config" ]
7677

77-
public_deps = []
78-
7978
deps = [
8079
"//flutter/common",
8180
"//flutter/fml",
8281
"//third_party/skia",
8382
]
8483

85-
if (is_fuchsia) {
86-
sources += [
87-
"layers/child_scene_layer.cc",
88-
"layers/child_scene_layer.h",
89-
"scene_update_context.cc",
90-
"scene_update_context.h",
91-
"view_holder.cc",
92-
"view_holder.h",
93-
]
84+
sources_legacy = [
85+
"layers/child_scene_layer.cc",
86+
"layers/child_scene_layer.h",
87+
"scene_update_context.cc",
88+
"scene_update_context.h",
89+
"view_holder.cc",
90+
"view_holder.h",
91+
]
9492

95-
public_deps += [
96-
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
97-
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
98-
"$fuchsia_sdk_root/pkg:scenic_cpp",
99-
]
100-
}
93+
deps_legacy = [
94+
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
95+
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
96+
"$fuchsia_sdk_root/pkg:scenic_cpp",
97+
]
10198
}
10299

103100
test_fixtures("flow_fixtures") {
104101
fixtures = []
105102
}
106103

107-
source_set("flow_testing") {
104+
source_set_maybe_fuchsia_legacy("flow_testing") {
108105
testonly = true
109106

110107
sources = [
@@ -113,20 +110,23 @@ source_set("flow_testing") {
113110
"testing/layer_test.h",
114111
"testing/mock_layer.cc",
115112
"testing/mock_layer.h",
113+
"testing/mock_raster_cache.cc",
114+
"testing/mock_raster_cache.h",
116115
"testing/mock_texture.cc",
117116
"testing/mock_texture.h",
118117
"testing/skia_gpu_object_layer_test.cc",
119118
"testing/skia_gpu_object_layer_test.h",
120119
]
121120

122121
public_deps = [
123-
":flow",
124122
"//flutter/testing:skia",
125123
"//third_party/googletest:gtest",
126124
]
125+
126+
deps_legacy_and_next = [ ":flow" ]
127127
}
128128

129-
executable("flow_unittests") {
129+
source_set_maybe_fuchsia_legacy("flow_unittests_srcs") {
130130
testonly = true
131131

132132
sources = [
@@ -160,10 +160,6 @@ executable("flow_unittests") {
160160
"texture_unittests.cc",
161161
]
162162

163-
if (is_fuchsia) {
164-
sources += [ "layers/fuchsia_layer_unittests.cc" ]
165-
}
166-
167163
deps = [
168164
":flow",
169165
":flow_fixtures",
@@ -176,8 +172,35 @@ executable("flow_unittests") {
176172
"//third_party/skia",
177173
]
178174

179-
if (is_fuchsia) {
180-
deps += [ "//build/fuchsia/pkg:sys_cpp_testing" ]
175+
sources_legacy = [ "layers/fuchsia_layer_unittests.cc" ]
176+
177+
deps_legacy = [ "//build/fuchsia/pkg:sys_cpp_testing" ]
178+
179+
deps_legacy_and_next = [ ":flow" ]
180+
}
181+
182+
if (is_fuchsia) {
183+
executable("flow_unittests") {
184+
testonly = true
185+
186+
deps = [
187+
":flow_unittests_srcs_fuchsia_legacy",
188+
]
189+
}
190+
executable("flow_unittests_next") {
191+
testonly = true
192+
193+
deps = [
194+
":flow_unittests_srcs",
195+
]
196+
}
197+
} else {
198+
executable("flow_unittests") {
199+
testonly = true
200+
201+
deps = [
202+
":flow_unittests_srcs",
203+
]
181204
}
182205
}
183206

flow/compositor_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "flutter/fml/macros.h"
1616
#include "flutter/fml/raster_thread_merger.h"
1717
#include "third_party/skia/include/core/SkCanvas.h"
18-
#include "third_party/skia/include/core/SkPictureRecorder.h"
18+
#include "third_party/skia/include/gpu/GrContext.h"
1919

2020
namespace flutter {
2121

flow/layers/clip_path_layer.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
#include "flutter/flow/layers/clip_path_layer.h"
66

7-
#if defined(OS_FUCHSIA)
7+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
88

99
#include "lib/ui/scenic/cpp/commands.h"
1010

11-
#endif // defined(OS_FUCHSIA)
11+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
1212

1313
namespace flutter {
1414

@@ -40,7 +40,7 @@ void ClipPathLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
4040
context->cull_rect = previous_cull_rect;
4141
}
4242

43-
#if defined(OS_FUCHSIA)
43+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
4444

4545
void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
4646
TRACE_EVENT0("flutter", "ClipPathLayer::UpdateScene");
@@ -51,7 +51,7 @@ void ClipPathLayer::UpdateScene(SceneUpdateContext& context) {
5151
UpdateSceneChildren(context);
5252
}
5353

54-
#endif // defined(OS_FUCHSIA)
54+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
5555

5656
void ClipPathLayer::Paint(PaintContext& context) const {
5757
TRACE_EVENT0("flutter", "ClipPathLayer::Paint");

flow/layers/clip_path_layer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class ClipPathLayer : public ContainerLayer {
2121
return clip_behavior_ == Clip::antiAliasWithSaveLayer;
2222
}
2323

24-
#if defined(OS_FUCHSIA)
24+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
2525
void UpdateScene(SceneUpdateContext& context) override;
26-
#endif // defined(OS_FUCHSIA)
26+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
2727

2828
private:
2929
SkPath clip_path_;

flow/layers/clip_rect_layer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void ClipRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
3333
context->cull_rect = previous_cull_rect;
3434
}
3535

36-
#if defined(OS_FUCHSIA)
36+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
3737

3838
void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
3939
TRACE_EVENT0("flutter", "ClipRectLayer::UpdateScene");
@@ -44,7 +44,7 @@ void ClipRectLayer::UpdateScene(SceneUpdateContext& context) {
4444
UpdateSceneChildren(context);
4545
}
4646

47-
#endif // defined(OS_FUCHSIA)
47+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
4848

4949
void ClipRectLayer::Paint(PaintContext& context) const {
5050
TRACE_EVENT0("flutter", "ClipRectLayer::Paint");

flow/layers/clip_rect_layer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class ClipRectLayer : public ContainerLayer {
2020
return clip_behavior_ == Clip::antiAliasWithSaveLayer;
2121
}
2222

23-
#if defined(OS_FUCHSIA)
23+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
2424
void UpdateScene(SceneUpdateContext& context) override;
25-
#endif // defined(OS_FUCHSIA)
25+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
2626

2727
private:
2828
SkRect clip_rect_;

flow/layers/clip_rrect_layer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void ClipRRectLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
3434
context->cull_rect = previous_cull_rect;
3535
}
3636

37-
#if defined(OS_FUCHSIA)
37+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
3838

3939
void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) {
4040
TRACE_EVENT0("flutter", "ClipRRectLayer::UpdateScene");
@@ -45,7 +45,7 @@ void ClipRRectLayer::UpdateScene(SceneUpdateContext& context) {
4545
UpdateSceneChildren(context);
4646
}
4747

48-
#endif // defined(OS_FUCHSIA)
48+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
4949

5050
void ClipRRectLayer::Paint(PaintContext& context) const {
5151
TRACE_EVENT0("flutter", "ClipRRectLayer::Paint");

flow/layers/clip_rrect_layer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class ClipRRectLayer : public ContainerLayer {
2121
return clip_behavior_ == Clip::antiAliasWithSaveLayer;
2222
}
2323

24-
#if defined(OS_FUCHSIA)
24+
#if defined(LEGACY_FUCHSIA_EMBEDDER)
2525
void UpdateScene(SceneUpdateContext& context) override;
26-
#endif // defined(OS_FUCHSIA)
26+
#endif // defined(LEGACY_FUCHSIA_EMBEDDER)
2727

2828
private:
2929
SkRRect clip_rrect_;

0 commit comments

Comments
 (0)