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 Renderer - initial implementation #39072

Merged
merged 51 commits into from
Mar 2, 2023

Conversation

eyebrowsoffire
Copy link
Contributor

Implements a handful of renderer APIs, including paths, canvas, picture, paint.

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Jan 23, 2023
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@eyebrowsoffire eyebrowsoffire marked this pull request as draft January 23, 2023 19:35
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Jan 28, 2023
…e name.

Change-Id: I5e3644a904917a375486acd47830f311fe19a5ce
Tested: Running unit tests in this repo as well as running against coming web engine changes that use the @Native annotation: flutter/engine#39072
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279479
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Copy link
Contributor

@mdebbar mdebbar left a comment

Choose a reason for hiding this comment

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

LGTM! But someone else should take a look at the C++ files.

@@ -0,0 +1,63 @@
# Copyright 2019 The Flutter Authors. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it's orthogonal. It's a bit weird that some of our build files live in web_sdk at the root of the repo, while others live inside web_ui.

Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

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

LGTM with nits


@override
void saveLayer(ui.Rect? bounds, ui.Paint uiPaint) {
assert(uiPaint is SkwasmPaint);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: unnecessary since the next line will crash anyways if uiPaint is not a SkwasmPaint

SkwasmImage clone() => this;

@override
bool isCloneOf(ui.Image other) => other == this;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: change to identical(this, other). The way it's written now is potentially problematic if later on we add == operator to SkwasmImage in a way where == is not necessarily the same as being a clone

@@ -17,160 +18,182 @@ import '../../renderer.dart';
class SkwasmRenderer implements Renderer {
@override
ui.Path combinePaths(ui.PathOperation op, ui.Path path1, ui.Path path2) {
throw UnimplementedError('Not yet implemented');
assert(path1 is SkwasmPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: here and below, same issue as above re the assertions. since the as checks do the same thing

@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 1, 2023
Comment on lines 603 to 610
{
source = rebase_path("$root_out_dir/canvaskit_chromium/canvaskit.js")
destination = "flutter_web_sdk/canvaskit_chromium/canvaskit.js"
destination = "canvaskit/chromium/canvaskit.js"
},
{
source = rebase_path("$root_out_dir/canvaskit_chromium/canvaskit.wasm")
destination = "flutter_web_sdk/canvaskit_chromium/canvaskit.wasm"
destination = "canvaskit/chromium/canvaskit.wasm"
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for doing the chromium change as well! I guess I'm not gonna need my restructuring PR after all (#39796).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually though, the copy steps from that PR might still be pertinent. I don't have any copy steps here.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right. I still need out/wasm_release/canvaskit/chromium/... so that the flutter web server can find the locally built canvaskit(s) when --local-web-sdk is specified.

Although the PR will be smaller after your change.

@auto-submit auto-submit bot merged commit a749820 into flutter:main Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2023
]
} else {
ldflags += [
"-O1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use something higher for release builds?

}

inline SkRRect createRRect(const SkScalar* f) {
const SkScalar* twelveFloats = reinterpret_cast<const SkScalar*>(f);
Copy link
Contributor

Choose a reason for hiding this comment

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

This cast looks like an noop.

}

SKWASM_EXPORT void paint_destroy(SkPaint* paint) {
delete paint;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the ownership model for SkPaint? Is it safe to delete the object if it's been used in a picture?

chinmaygarde pushed a commit to chinmaygarde/flutter_engine that referenced this pull request Mar 3, 2023
Skwasm Renderer - initial implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
4 participants