Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skwasm scene #40330

Merged
merged 46 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
cfccaa7
WIP add screenshot goldens to ui_tests
harryterkelsen Feb 15, 2023
294cff9
Started implementing skwasm scene stuff.
eyebrowsoffire Mar 13, 2023
6dc5144
Scene builder mostly coded up.
eyebrowsoffire Mar 14, 2023
13816e4
Stuff.
eyebrowsoffire Mar 15, 2023
ab7e937
Running into TFA issues.
eyebrowsoffire Mar 15, 2023
6184bec
More scene changes.
eyebrowsoffire Mar 21, 2023
fd915b3
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 21, 2023
aade26b
We drawing now.
eyebrowsoffire Mar 22, 2023
d49f73d
Copy stuff, but skwasm.worker.js doesn't copy yet.
eyebrowsoffire Mar 22, 2023
c473192
Add a few flags.
eyebrowsoffire Mar 23, 2023
bbd206b
Bundle skwasm.
eyebrowsoffire Mar 23, 2023
b651d65
Use newer buildroot.
eyebrowsoffire Mar 23, 2023
6fbb8d0
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 23, 2023
4796b64
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 29, 2023
d79c143
Use the normal toolchain so we get LTO.
eyebrowsoffire Mar 29, 2023
8350e48
Merge remote-tracking branch 'hterkelsen/ui-golden-tests' into skwasm…
eyebrowsoffire Mar 29, 2023
d8bfb0f
Analyzer cleanup and Kevin's comments.
eyebrowsoffire Mar 29, 2023
f7a22db
Update license golden.
eyebrowsoffire Mar 29, 2023
ad64278
Some fixes for goldens, although skwasm renderer has async issues.
eyebrowsoffire Mar 29, 2023
17a8e6c
Some async stuff.
eyebrowsoffire Mar 29, 2023
c89584c
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 29, 2023
d446202
Fixed cull rect calculation.
eyebrowsoffire Mar 30, 2023
4ca5636
Update licenses and fix an analyzer issue.
eyebrowsoffire Mar 30, 2023
4f85df1
Wrote unit tests that cover the remainder of what skwasm has implemen…
eyebrowsoffire Mar 31, 2023
a722c25
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 31, 2023
b4f98fc
Update README
eyebrowsoffire Mar 31, 2023
a5d798d
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 31, 2023
1cb3514
Wait one frame after rendering to ensure the screenshot captures prop…
eyebrowsoffire Mar 31, 2023
6cb0f12
Use switch expression.
eyebrowsoffire Mar 31, 2023
32299b2
Merge branch 'main' into skwasm_scene
eyebrowsoffire Mar 31, 2023
c2ca50c
Tweak build parameters for skwasm.
eyebrowsoffire Mar 31, 2023
64d5728
Update lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart
eyebrowsoffire Apr 4, 2023
a239266
Address some comments from Mouad.
eyebrowsoffire Apr 4, 2023
3d90da0
Merge branch 'main' into skwasm_scene
eyebrowsoffire Apr 4, 2023
da3be30
Fix formatting.
eyebrowsoffire Apr 4, 2023
e0892d6
Change name of variable for clarity.
eyebrowsoffire Apr 4, 2023
07f6f75
Fix async semantics of skwasm surface.
eyebrowsoffire Apr 4, 2023
0d94512
Reinstate old transformRect algorithm.
eyebrowsoffire Apr 4, 2023
cd56076
Merge branch 'main' into skwasm_scene
eyebrowsoffire Apr 4, 2023
85674bc
Shift cullRect by offset when using opacity layer.
eyebrowsoffire Apr 5, 2023
457059f
Renderer.renderScene should return FutureOr.
eyebrowsoffire Apr 5, 2023
a0dbca2
Merge branch 'main' into skwasm_scene
eyebrowsoffire Apr 5, 2023
a6f8d1e
Merge branch 'main' into skwasm_scene
eyebrowsoffire Apr 6, 2023
26a54c0
Get rid of duplicate `skwasm_group` definitino from merge.
eyebrowsoffire Apr 6, 2023
6a41070
Merge branch 'main' into skwasm_scene
eyebrowsoffire Apr 6, 2023
2d52b90
Merge branch 'main' into skwasm_scene
eyebrowsoffire Apr 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1986,12 +1986,15 @@ ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/services/serialization.dart +
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/shadow.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/canvas.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/image.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/layers.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paint.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/path.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/path_metrics.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/picture.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/js_functions.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_canvas.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_geometry.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_memory.dart + ../../../flutter/LICENSE
Expand All @@ -2001,6 +2004,7 @@ ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_pa
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_picture.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_surface.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/renderer.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/scene_builder.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/vertices.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart + ../../../flutter/LICENSE
Expand Down Expand Up @@ -4565,12 +4569,15 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/services/serialization.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/shadow.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/canvas.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/font_collection.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/image.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/layers.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paint.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/path.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/path_metrics.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/picture.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/js_functions.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_canvas.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_geometry.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_memory.dart
Expand All @@ -4580,6 +4587,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_path
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_picture.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/raw/raw_surface.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/renderer.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/scene_builder.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/surface.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/vertices.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_stub.dart
Expand Down
18 changes: 13 additions & 5 deletions lib/web_ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ all web engine targets are built. Common targets are as follows:
The output of these steps is used in unit tests, and can be used with the flutter
command via the `--local-web-sdk=wasm_release` command.

The `build` command also accepts either the `--profile` or `--debug` flags, which
can be used to change the build profile of the artifacts.

##### Examples
Builds all web engine targets, then runs a Flutter app using it:
```
Expand All @@ -54,14 +57,19 @@ information on how test suites are structured, see the test configuration

By default, `felt test` compiles and runs all suites that are compatible with the
host system. Some useful flags supported by this command:
* `--compile` will only perform compilation of these suites without running them.
* `--run` will only run the tests and not compile them, and assume they have been
compiled in a previous run of the tool.
* Action flags which say what parts of the test pipeline to perform. More of one
of these can be specified to run multiple actions. If none are specified, then
*all* of these actions are performed
* `--compile` performs compilation of the test bundles.
* `--run` runs the unit tests
* `--copy-artifacts` will copy build artifacts needed for the tests to run.
* The `--profile` or `--debug` flags can be specified to copy over artifacts
from the profile or debug build folders instead of release.
* `--list` will list all the test suites and test bundles and exit without
compiling or running anything.
* `--verbose` will output some extra information that may be useful for debugging.
* `--debug` will open a browser window and pause the tests before starting so that
breakpoints can be set before starting the test suites.
* `--debug-browser` will open a browser window and pause the tests before starting
so that breakpoints can be set before starting the test suites.

Several other flags can be passed that filter which test suites should be run:
* `--browser` runs only the test suites that test on the browsers passed. Valid
Expand Down
32 changes: 8 additions & 24 deletions lib/web_ui/dev/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import 'environment.dart';
import 'pipeline.dart';
import 'utils.dart';

enum RuntimeMode {
profile,
release,
}

const Map<String, String> targetAliases = <String, String>{
'sdk': 'flutter/web_sdk',
'web_sdk': 'flutter/web_sdk',
Expand Down Expand Up @@ -45,6 +40,12 @@ class BuildCommand extends Command<bool> with ArgUtils<bool> {
'output will be located at "out/wasm_profile".\nThis only applies to '
'the wasm build. The host build is always built in release mode.',
);
argParser.addFlag(
kevmoo marked this conversation as resolved.
Show resolved Hide resolved
'debug',
help: 'Build in debug mode instead of release mode. In this mode, the '
'output will be located at "out/wasm_debug".\nThis only applies to '
'the wasm build. The host build is always built in release mode.',
);
}

@override
Expand All @@ -57,9 +58,6 @@ class BuildCommand extends Command<bool> with ArgUtils<bool> {

bool get host => boolArg('host');

RuntimeMode get runtimeMode =>
boolArg('profile') ? RuntimeMode.profile : RuntimeMode.release;

eyebrowsoffire marked this conversation as resolved.
Show resolved Hide resolved
List<String> get targets => argResults?.rest ?? <String>[];

@override
Expand Down Expand Up @@ -112,15 +110,6 @@ class GnPipelineStep extends ProcessStep {
@override
bool get isSafeToInterrupt => false;

String get runtimeModeFlag {
switch (runtimeMode) {
case RuntimeMode.profile:
return 'profile';
case RuntimeMode.release:
return 'release';
}
}

List<String> get _gnArgs {
if (host) {
return <String>[
Expand All @@ -130,7 +119,7 @@ class GnPipelineStep extends ProcessStep {
} else {
return <String>[
'--web',
'--runtime-mode=$runtimeModeFlag',
'--runtime-mode=${runtimeMode.name}',
];
}
}
Expand Down Expand Up @@ -169,12 +158,7 @@ class NinjaPipelineStep extends ProcessStep {
if (host) {
return environment.hostDebugUnoptDir.path;
}
switch (runtimeMode) {
case RuntimeMode.profile:
return environment.wasmProfileOutDir.path;
case RuntimeMode.release:
return environment.wasmReleaseOutDir.path;
}
return getBuildDirectoryForRuntimeMode(runtimeMode).path;
}

@override
Expand Down
7 changes: 7 additions & 0 deletions lib/web_ui/dev/environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Environment {
io.Directory(pathlib.join(outDir.path, 'wasm_release'));
final io.Directory wasmProfileOutDir =
io.Directory(pathlib.join(outDir.path, 'wasm_profile'));
final io.Directory wasmDebugOutDir =
io.Directory(pathlib.join(outDir.path, 'wasm_debug'));
final io.Directory hostDebugUnoptDir =
io.Directory(pathlib.join(outDir.path, 'host_debug_unopt'));
final io.Directory dartSdkDir = dartExecutable.parent.parent;
Expand All @@ -57,6 +59,7 @@ class Environment {
outDir: outDir,
wasmReleaseOutDir: wasmReleaseOutDir,
wasmProfileOutDir: wasmProfileOutDir,
wasmDebugOutDir: wasmDebugOutDir,
hostDebugUnoptDir: hostDebugUnoptDir,
dartSdkDir: dartSdkDir,
);
Expand All @@ -71,6 +74,7 @@ class Environment {
required this.outDir,
required this.wasmReleaseOutDir,
required this.wasmProfileOutDir,
required this.wasmDebugOutDir,
required this.hostDebugUnoptDir,
required this.dartSdkDir,
});
Expand Down Expand Up @@ -103,6 +107,9 @@ class Environment {
/// The output directory for the wasm_profile build.
final io.Directory wasmProfileOutDir;

/// The output directory for the wasm_debug build.
final io.Directory wasmDebugOutDir;

/// The output directory for the host_debug_unopt build.
final io.Directory hostDebugUnoptDir;

Expand Down
8 changes: 3 additions & 5 deletions lib/web_ui/dev/steps/copy_artifacts_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import '../pipeline.dart';
import '../utils.dart';

class CopyArtifactsStep implements PipelineStep {
CopyArtifactsStep(this.artifactDeps, { required this.isProfile });
CopyArtifactsStep(this.artifactDeps, { required this.runtimeMode });

final ArtifactDependencies artifactDeps;
final bool isProfile;
final RuntimeMode runtimeMode;

@override
String get description => 'copy_artifacts';
Expand Down Expand Up @@ -167,9 +167,7 @@ class CopyArtifactsStep implements PipelineStep {
}
}

String get outBuildPath => isProfile
? environment.wasmProfileOutDir.path
: environment.wasmReleaseOutDir.path;
String get outBuildPath => getBuildDirectoryForRuntimeMode(runtimeMode).path;

Future<void> copySkwasm() async {
final io.Directory targetDir = io.Directory(pathlib.join(
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/dev/steps/run_suite_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import '../utils.dart';
/// them from another bot.
class RunSuiteStep implements PipelineStep {
RunSuiteStep(this.suite, {
required this.isDebug,
required this.isDebugBrowser,
required this.isVerbose,
required this.doUpdateScreenshotGoldens,
required this.requireSkiaGold,
Expand All @@ -39,7 +39,7 @@ class RunSuiteStep implements PipelineStep {

final TestSuite suite;
final Set<FilePath>? testFiles;
final bool isDebug;
final bool isDebugBrowser;
final bool isVerbose;
final bool doUpdateScreenshotGoldens;
final String? overridePathToCanvasKit;
Expand Down Expand Up @@ -76,7 +76,7 @@ class RunSuiteStep implements PipelineStep {
...<String>['-r', 'compact'],
// Disable concurrency. Running with concurrency proved to be flaky.
'--concurrency=1',
if (isDebug) '--pause-after-load',
if (isDebugBrowser) '--pause-after-load',
'--platform=${browserEnvironment.packageTestRuntime.identifier}',
'--precompiled=$bundleBuildPath',
'--configuration=$configurationFilePath',
Expand Down Expand Up @@ -167,7 +167,7 @@ class RunSuiteStep implements PipelineStep {
final Renderer renderer = suite.testBundle.compileConfig.renderer;
final CanvasKitVariant? variant = suite.runConfig.variant;
final SkiaGoldClient skiaClient = SkiaGoldClient(
environment.webUiSkiaGoldDirectory,
getSkiaGoldDirectoryForSuite(suite),
dimensions: <String, String> {
'Browser': suite.runConfig.browser.name,
if (isWasm) 'Wasm': 'true',
Expand Down
1 change: 1 addition & 0 deletions lib/web_ui/dev/test_dart2wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ window.onload = async function () {
document.body.appendChild(skwasmScript);
skwasmScript.addEventListener('load', async () => {
const skwasmInstance = await skwasm();
window._flutter_skwasmInstance = skwasmInstance;
resolve({
"skwasm": skwasmInstance.asm,
"ffi": {
Expand Down
1 change: 1 addition & 0 deletions lib/web_ui/dev/test_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ class BrowserPlatform extends PlatformPlugin {
screenshot,
doUpdateScreenshotGoldens,
filename,
getSkiaGoldDirectoryForSuite(suite),
skiaClient,
isCanvaskitTest: isCanvaskitTest,
verbose: isVerbose,
Expand Down
13 changes: 9 additions & 4 deletions lib/web_ui/dev/test_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
TestCommand() {
argParser
..addFlag(
'debug',
'debug-browser',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flutter tool calls this --start-paused which I think is a more self-explanatory name and keeps names consistent across repos/tools.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is probably a better name. One detail is that this option also causes us to run in a window instead of headless, but that probably is fine to just leave implied.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's how it works in the flutter tool too.

help: 'Pauses the browser before running a test, giving you an '
'opportunity to add breakpoints or inspect loaded code before '
'running the code.',
Expand Down Expand Up @@ -80,6 +80,11 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
help:
'Use artifacts from the profile build instead of release.'
)
..addFlag(
'debug',
help:
'Use artifacts from the debug build instead of release.'
)
..addFlag(
'require-skia-gold',
help:
Expand Down Expand Up @@ -152,7 +157,7 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
///
/// In this mode the browser pauses before running the test to allow
/// you set breakpoints or inspect the code.
bool get isDebug => boolArg('debug');
bool get isDebugBrowser => boolArg('debug-browser');

bool get isVerbose => boolArg('verbose');

Expand Down Expand Up @@ -364,7 +369,7 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
final Set<FilePath>? testFiles = targetFiles.isEmpty ? null : Set<FilePath>.from(targetFiles);
final Pipeline testPipeline = Pipeline(steps: <PipelineStep>[
if (isWatchMode) ClearTerminalScreenStep(),
if (shouldCopyArtifacts) CopyArtifactsStep(artifacts, isProfile: boolArg('profile')),
if (shouldCopyArtifacts) CopyArtifactsStep(artifacts, runtimeMode: runtimeMode),
if (shouldCompile)
for (final TestBundle bundle in bundles)
CompileBundleStep(
Expand All @@ -376,7 +381,7 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
for (final TestSuite suite in filteredSuites)
RunSuiteStep(
suite,
isDebug: isDebug,
isDebugBrowser: isDebugBrowser,
isVerbose: isVerbose,
doUpdateScreenshotGoldens: doUpdateScreenshotGoldens,
requireSkiaGold: requireSkiaGold,
Expand Down
37 changes: 37 additions & 0 deletions lib/web_ui/dev/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import 'environment.dart';
import 'exceptions.dart';
import 'felt_config.dart';

enum RuntimeMode {
debug,
profile,
release,
}

class FilePath {
FilePath.fromCwd(String relativePath)
: _absolutePath = path.absolute(relativePath);
Expand Down Expand Up @@ -328,8 +334,30 @@ mixin ArgUtils<T> on Command<T> {

/// Extracts a string argument from [argResults].
String stringArg(String name) => argResults![name] as String;

RuntimeMode get runtimeMode {
final bool isProfile = boolArg('profile');
final bool isDebug = boolArg('debug');
if (isProfile && isDebug) {
throw ToolExit('Cannot specify both --profile and --debug at the same time.');
}
if (isProfile) {
return RuntimeMode.profile;
} else if (isDebug) {
return RuntimeMode.debug;
} else {
return RuntimeMode.release;
}
}
}

io.Directory getBuildDirectoryForRuntimeMode(RuntimeMode runtimeMode) =>
switch (runtimeMode) {
kevmoo marked this conversation as resolved.
Show resolved Hide resolved
RuntimeMode.debug => environment.wasmDebugOutDir,
RuntimeMode.profile => environment.wasmProfileOutDir,
RuntimeMode.release => environment.wasmReleaseOutDir,
};

/// There might be proccesses started during the tests.
///
/// Use this list to store those Processes, for cleaning up before shutdown.
Expand Down Expand Up @@ -390,6 +418,15 @@ io.Directory getBundleBuildDirectory(TestBundle bundle) {
);
}

io.Directory getSkiaGoldDirectoryForSuite(TestSuite suite) {
return io.Directory(
path.join(
environment.webUiSkiaGoldDirectory.path,
suite.name,
)
);
}

extension AnsiColors on String {
static bool shouldEscape = io.stdout.hasTerminal && io.stdout.supportsAnsiEscapes;

Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/canvaskit/renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class CanvasKitRenderer implements Renderer {
CkParagraphBuilder(style);

@override
void renderScene(ui.Scene scene) {
Future<void> renderScene(ui.Scene scene) async {
// "Build finish" and "raster start" happen back-to-back because we
// render on the same thread, so there's no overhead from hopping to
// another thread.
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/html/renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class HtmlRenderer implements Renderer {
CanvasParagraphBuilder(style as EngineParagraphStyle);

@override
void renderScene(ui.Scene scene) {
Future<void> renderScene(ui.Scene scene) async {
_viewEmbedder.addSceneToSceneHost((scene as SurfaceScene).webOnlyRootElement);
frameTimingsOnRasterFinish();
}
Expand Down