Skip to content

Commit 220a831

Browse files
authored
Move fuchsia/scenic integration behind #define (flutter#19003)
Additionally create "_next" permutations for all of the test binaries on Fuchsia, in order to test both code-paths. Using the #define follow-up CLs can also create a flutter_runner_next binary that does not contain any legacy integration code. BUG: 53847
1 parent de68a7f commit 220a831

Some content is hidden

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

51 files changed

+582
-249
lines changed

BUILD.gn

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ config("config") {
125125
}
126126
}
127127

128+
# This "fuchsia_legacy" configuration includes old, non-embedder API sources and
129+
# defines the LEGACY_FUCHSIA_EMBEDDER symbol. This config and its associated
130+
# template are both transitional and will be removed after the embedder API
131+
# transition is complete.
132+
#
133+
# See `source_set_maybe_fuchsia_legacy` in //flutter/common/config.gni
134+
#
135+
# TODO(fxb/54041): Remove when no longer neccesary.
136+
config("fuchsia_legacy") {
137+
if (is_fuchsia) {
138+
defines = [ "LEGACY_FUCHSIA_EMBEDDER" ]
139+
}
140+
}
141+
128142
config("export_dynamic_symbols") {
129143
if (is_linux || is_fuchsia) {
130144
inputs = [
@@ -151,9 +165,12 @@ if (is_fuchsia) {
151165

152166
deps = [
153167
"//flutter/flow:flow_tests",
168+
"//flutter/flow:flow_tests_next",
154169
"//flutter/fml:fml_tests",
155170
"//flutter/runtime:runtime_tests",
171+
"//flutter/runtime:runtime_tests_next",
156172
"//flutter/shell/common:shell_tests",
173+
"//flutter/shell/common:shell_tests_next",
157174
"//flutter/shell/platform/fuchsia/flutter:flutter_runner_scenic_tests",
158175
"//flutter/shell/platform/fuchsia/flutter:flutter_runner_tests",
159176
]

common/config.gni

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,119 @@ if (is_ios || is_mac) {
7676
]
7777
flutter_cflags_objcc = flutter_cflags_objc
7878
}
79+
80+
# This template creates a `source_set` in both standard and "fuchsia_legacy"
81+
# configurations.
82+
#
83+
# The "fuchsia_legacy" configuration includes old, non-embedder API sources and
84+
# defines the LEGACY_FUCHSIA_EMBEDDER symbol. This template and the config
85+
# are both transitional and will be removed after the embedder API transition
86+
# is complete.
87+
# TODO(fxb/54041): Remove when no longer neccesary.
88+
#
89+
# `sources`, `defines`, `public_configs`, `configs`, `public_deps`, `deps` work
90+
# as they do in a normal `source_set`.
91+
#
92+
# `legacy_deps` is the list of dependencies which should be mutated by
93+
# appending '_fuchsia_legacy' when creating the 2 `source_set`'s. The template adds
94+
# `legacy_deps` to `public_deps`, whether it mutates them or not.
95+
template("source_set_maybe_fuchsia_legacy") {
96+
public_deps_non_legacy = []
97+
deps_non_legacy = []
98+
if (defined(invoker.public_deps)) {
99+
public_deps_non_legacy += invoker.public_deps
100+
}
101+
if (defined(invoker.deps)) {
102+
deps_non_legacy += invoker.deps
103+
}
104+
if (defined(invoker.public_deps_legacy_and_next)) {
105+
foreach(legacy_dep, invoker.public_deps_legacy_and_next) {
106+
public_deps_non_legacy += [ legacy_dep ]
107+
}
108+
}
109+
if (defined(invoker.deps_legacy_and_next)) {
110+
foreach(legacy_dep, invoker.deps_legacy_and_next) {
111+
deps_non_legacy += [ legacy_dep ]
112+
}
113+
}
114+
115+
source_set(target_name) {
116+
forward_variables_from(invoker,
117+
[
118+
"testonly",
119+
"sources",
120+
"defines",
121+
"public_configs",
122+
"configs",
123+
])
124+
public_deps = public_deps_non_legacy
125+
deps = deps_non_legacy
126+
}
127+
128+
if (is_fuchsia) {
129+
legagcy_suffix = "_fuchsia_legacy"
130+
131+
sources_legacy = []
132+
if (defined(invoker.sources_legacy)) {
133+
sources_legacy += invoker.sources_legacy
134+
}
135+
if (defined(invoker.sources)) {
136+
sources_legacy += invoker.sources
137+
}
138+
139+
public_configs_legacy = [ "//flutter:fuchsia_legacy" ]
140+
if (defined(invoker.public_configs)) {
141+
public_configs_legacy += invoker.public_configs
142+
}
143+
144+
public_deps_legacy = []
145+
deps_legacy = []
146+
if (defined(invoker.public_deps)) {
147+
public_deps_legacy += invoker.public_deps
148+
}
149+
if (defined(invoker.deps)) {
150+
deps_legacy += invoker.deps
151+
}
152+
if (defined(invoker.public_deps_legacy)) {
153+
public_deps_legacy += invoker.public_deps_legacy
154+
}
155+
if (defined(invoker.deps_legacy)) {
156+
deps_legacy += invoker.deps_legacy
157+
}
158+
if (defined(invoker.public_deps_legacy_and_next)) {
159+
foreach(legacy_dep, invoker.public_deps_legacy_and_next) {
160+
public_deps_legacy += [ legacy_dep + legagcy_suffix ]
161+
}
162+
}
163+
if (defined(invoker.deps_legacy_and_next)) {
164+
foreach(legacy_dep, invoker.deps_legacy_and_next) {
165+
deps_legacy += [ legacy_dep + legagcy_suffix ]
166+
}
167+
}
168+
169+
source_set(target_name + legagcy_suffix) {
170+
forward_variables_from(invoker,
171+
[
172+
"testonly",
173+
"defines",
174+
"configs",
175+
])
176+
sources = sources_legacy
177+
178+
public_configs = public_configs_legacy
179+
180+
public_deps = public_deps_legacy
181+
deps = deps_legacy
182+
}
183+
} else {
184+
if (defined(invoker.sources_legacy)) {
185+
not_needed(invoker, [ "sources_legacy" ])
186+
}
187+
if (defined(invoker.public_deps_legacy)) {
188+
not_needed(invoker, [ "public_deps_legacy" ])
189+
}
190+
if (defined(invoker.deps_legacy)) {
191+
not_needed(invoker, [ "deps_legacy" ])
192+
}
193+
}
194+
}

flow/BUILD.gn

Lines changed: 87 additions & 30 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+
public_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_common") {
130130
testonly = true
131131

132132
sources = [
@@ -161,14 +161,8 @@ executable("flow_unittests") {
161161
"texture_unittests.cc",
162162
]
163163

164-
if (is_fuchsia) {
165-
sources += [ "layers/fuchsia_layer_unittests.cc" ]
166-
}
167-
168164
deps = [
169-
":flow",
170165
":flow_fixtures",
171-
":flow_testing",
172166
"//flutter/fml",
173167
"//flutter/testing:skia",
174168
"//flutter/testing:testing_lib",
@@ -177,8 +171,38 @@ executable("flow_unittests") {
177171
"//third_party/skia",
178172
]
179173

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

@@ -215,4 +239,37 @@ if (is_fuchsia) {
215239
},
216240
]
217241
}
242+
243+
fuchsia_archive("flow_tests_next") {
244+
testonly = true
245+
246+
deps = [
247+
":flow_unittests_next",
248+
]
249+
250+
binary = "flow_unittests_next"
251+
252+
libraries = common_libs
253+
254+
meta_dir = "//flutter/testing/fuchsia/meta"
255+
cmx_file = "$meta_dir/fuchsia_test.cmx"
256+
257+
resources = [
258+
{
259+
path = rebase_path(
260+
"//flutter/testing/resources/performance_overlay_gold_60fps.png")
261+
dest = "flutter/testing/resources/performance_overlay_gold_60fps.png"
262+
},
263+
{
264+
path = rebase_path(
265+
"//flutter/testing/resources/performance_overlay_gold_90fps.png")
266+
dest = "flutter/testing/resources/performance_overlay_gold_90fps.png"
267+
},
268+
{
269+
path = rebase_path(
270+
"//flutter/testing/resources/performance_overlay_gold_120fps.png")
271+
dest = "flutter/testing/resources/performance_overlay_gold_120fps.png"
272+
},
273+
]
274+
}
218275
}

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
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
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
2727

2828
private:
2929
SkPath clip_path_;

0 commit comments

Comments
 (0)