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

Conversation

@ferhatb
Copy link
Contributor

@ferhatb ferhatb commented Jan 21, 2021

PhysicalShape shadows failed for non rect/oval shapes since the physical shape adds an svg clip path to render background. This PR adds an SVG asset behind inner clip area to render shadow of physical shape separately.

Related issues:
flutter/flutter#65498
flutter/flutter#66334
flutter/flutter#57527

Tests updated in golden_compositing_test.dart

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.
  • The reviewer has submitted any presubmit flakes in this PR using the [engine presubmit flakes form] before re-triggering the failure.

If you need help, consider asking for advice on the #hackers-new channel on [Discord].

@ferhatb ferhatb requested a review from yjbanov January 21, 2021 17:41
/// contents against same path for shadow to work since box-shadow doesn't
/// take clip-path into account.
///
/// Webkit has a bug when applying clip-path on an element that has
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a link to the WebKit bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added link.

/// we size the inner container to cover full pathBounds instead of sizing
/// to clipping rect bounds (which is the case for elevation == 0.0 where
/// we shift outer/inner clip area instead to position clip-path).
final String svgClipPath = elevation == 0.0 ?
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the ? should go on the next line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

offsetY: 0.0,
scaleX: 1.0 / pathBounds.right,
scaleY: 1.0 / pathBounds.bottom);
/// If apply is called multiple times (without update) , remove prior
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove space before the comma

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

DomRenderer.setElementStyle(
rootElement!, 'clip-path', 'url(#svgClip$_clipIdCounter)');
DomRenderer.setElementStyle(
rootElement!, '-webkit-clip-path', 'url(#svgClip$_clipIdCounter)');
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting style properties has been showing up in our profiles. Can we set either clip-path or -webkit-clip-path depending on the browserEngine, but not both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Moved clip-path code into DomRenderer


final ui.Rect pathBounds2 = path.getBounds();
_svgElement = _pathToSvgElement(
path, SurfacePaintData()..color = color, '${pathBounds2.right}', '${pathBounds2.bottom}');
Copy link
Contributor

Choose a reason for hiding this comment

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

Does _applyColor need to be revised now that this function also uses the color field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

_applyColor();
}
if (oldSurface.elevation != elevation ||
if (oldSurface.path != path || oldSurface.elevation != elevation ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a test that covers the update codepath? We frequently get bugs that only manifest when the DOM nodes are updated from a previous state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

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

lgtm

@chinmaygarde chinmaygarde added the platform-web Code specifically for the web engine label Jan 21, 2021
@ferhatb ferhatb merged commit a242dd8 into flutter:master Jan 22, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 23, 2021
zanderso pushed a commit to flutter/flutter that referenced this pull request Jan 25, 2021
* 004d8ad Roll Skia from cc6961b9ac5e to 6a272434c2b2 (3 revisions) (flutter/engine#23864)

* 7c2da3b reland of flutter/engine#23634 (flutter/engine#23865)

* a4f02b7 Share Android surface GrDirectContext (flutter/engine#23798)

* 31ef1dd Roll Skia from 6a272434c2b2 to bfc9be0f773f (2 revisions) (flutter/engine#23867)

* 6dec57f Remove workarounds now that type promotion accounts for local boolean variables. (flutter/engine#23862)

* a787229 Roll Skia from bfc9be0f773f to 3193ff271628 (5 revisions) (flutter/engine#23872)

* a242dd8 [web] Fix shadows for arbitrary paths on PhysicalShape (flutter/engine#23830)

* 05b4bec Started using Dart_CreateInGroup when using spawn on a release build (flutter/engine#23782)
@ferhatb ferhatb deleted the elevation branch February 11, 2021 17:41
hjfreyer pushed a commit to hjfreyer/engine that referenced this pull request Mar 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants