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

[Impeller] Make conical gradient work as expected #42567

Merged
merged 3 commits into from
Jun 6, 2023

Conversation

ColdPaleLight
Copy link
Member

@ColdPaleLight ColdPaleLight commented Jun 5, 2023

fix flutter/flutter#128012

In many instances (flutter/flutter#128012 (comment)), the current implementation of conical gradient in impeller produces incorrect results. This pull request proposes to migrate the conical gradient algorithm from skia to impeller.

Please see https://github.com/google/skia/blob/ddf987d2ab3314ee0e80ac1ae7dbffb44a87d394/src/sksl/sksl_graphite_frag.sksl#L541-L666

Test result
FGcZZRCQZJ

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@ColdPaleLight ColdPaleLight changed the title [][Impeller] Make conical gradient work as expected [WIP][Impeller] Make conical gradient work as expected Jun 5, 2023
@ColdPaleLight ColdPaleLight self-assigned this Jun 5, 2023
@ColdPaleLight ColdPaleLight requested review from gaaclarke and bdero and removed request for gaaclarke June 5, 2023 15:56
@ColdPaleLight ColdPaleLight changed the title [WIP][Impeller] Make conical gradient work as expected [Impeller] Make conical gradient work as expected Jun 5, 2023
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

Nice find! The graphite code is so much easier to migrate. I spent so much time reading the math papers (which I swear are wrong) and reading through the skia code.

The code looks good. Just needs a comment linking the source of the code also I need confirmation that it's fine to opt out of IsOpaque since we could implement it if we want.

/// circles defined by (c0, r0) and (c1, r1). The returned vec2 encapsulates 't'
/// as its x component and validity status as its y component, with positive y
/// indicating a valid result.
vec2 IPComputeConicalT(vec2 c0, float r0, vec2 c1, float r1, vec2 pos) {
Copy link
Member

Choose a reason for hiding this comment

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

You should add a comment that points to the graphite implementation. If there are upstream bugfixes we'll want to know where to grab them.

@@ -51,18 +51,6 @@ void ConicalGradientContents::SetFocus(std::optional<Point> focus,
focus_radius_ = radius;
}

bool ConicalGradientContents::IsOpaque() const {
Copy link
Member

Choose a reason for hiding this comment

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

Was this removed for the cases where the gradient doesn't occupy the full square? That wasn't the crux of the reported issue, right? I'm not sure if it's worth detecting those scenarios for IsOpaque.

Copy link
Member

Choose a reason for hiding this comment

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

@bdero are you fine with us opting out of IsOpaque? I think we could calculate this by expanding on what we previously had if it's worth it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this is just used to optimize the blend mode for HSR and prevent unnecessary overdraw, so it's safe to just remove for now if it's wrong.

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #42567 at sha 552cf7c

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

LGTM modulo comment linking skia code.

@gaaclarke gaaclarke added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Jun 5, 2023
@ColdPaleLight ColdPaleLight added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 6, 2023
@auto-submit auto-submit bot merged commit 445db0d into flutter:main Jun 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 6, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jun 6, 2023
…128341)

flutter/engine@722aad8...b6d37f8

2023-06-06 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from tCxDcZ3yi0rnKGVHt... to atrYtfHWi2cmV9B_C... (flutter/engine#42589)
2023-06-06 zhangzhijian.123@bytedance.com [Impeller] Make conical gradient work as expected (flutter/engine#42567)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from tCxDcZ3yi0rn to atrYtfHWi2cm

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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 e: impeller will affect goldens
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Impeller] Gradient rendering error
3 participants