Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Apr 21, 2022

Removes usage of physical model layer and reverts back to paints and clips. The clips need not be composited. In addition this updates several tests that used Opacity or RenderOpacity to force compositing and instead switches those to use RepaintBoundary and RenderRepaintBoundary to make a future change to RenderOpacity easier to land

We expect this change should result in fewer layers in a given flutter application, with more complex operations rolled into those pictures. Thus for pictures which are raster cached, that raster caching should cache more operations.

This is a complimentary change to #101952, which makes scenarios where we must composite or where we perform animations with layers more efficient.

Partially reverts #29701
Partially fixes #91852

Will handle #102179 in a follow up (in addition to making the repaint compositing optional)

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 21, 2022
@jonahwilliams jonahwilliams marked this pull request as ready for review April 21, 2022 07:47
@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Apr 21, 2022
@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.

For more guidance, visit Writing a golden file test for package:flutter.

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

Changes reported for pull request #102274 at sha 27d0809

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Apr 21, 2022
@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

For more guidance, visit Writing a golden file test for package:flutter.

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

Changes reported for pull request #102274 at sha df9301f

@jonahwilliams jonahwilliams changed the title [framework] remove usage of physical model layer, fix opacity compositing [framework] remove usage of physical model layer Apr 25, 2022
@jonahwilliams jonahwilliams requested a review from dnfield April 25, 2022 19:29
final Rect offsetBounds = bounds.shift(offset);
final RRect offsetClipRRect = clipRRect.shift(offset);
if (needsCompositing) {
if (clipBehavior == Clip.none) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

right now the context asserts if I push clip.none, but I think I should remove that and just make it do the right thing here

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the idea there to avoid compositing a layer unnecessarily?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pushClip only conditionally composites, take a look at the implementation. Its why we pass in needsCompositing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait, this is the implementation lol. NVM. I added this change because otherwise the ClipRRectLayer would assert

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

Change LGTM.

Can we also add deprecation attributes to the PhysicalModelLayer?

We should also deprecate pushPhysicalShapeLayer in dart:ui.

final Rect offsetBounds = bounds.shift(offset);
final RRect offsetClipRRect = clipRRect.shift(offset);
if (needsCompositing) {
if (clipBehavior == Clip.none) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the idea there to avoid compositing a layer unnecessarily?

// The drawShadow call doesn't add the region of the shadow to the
// picture's bounds, so we draw a hardcoded amount of extra space to
// account for the maximum potential area of the shadow.
// TODO(jsimmons): remove this when Skia does it for us.
Copy link
Contributor

Choose a reason for hiding this comment

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

@flar fyi

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused. Where did this come from:

@jason-simmons

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This came from the revert of #29701 , but from there I'm not sure

Copy link
Contributor

Choose a reason for hiding this comment

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

I traced it back to #9654.

@jonahwilliams

This comment was marked as outdated.

final Rect offsetBounds = bounds.shift(offset);
final Path offsetClipPath = clipPath.shift(offset);
if (needsCompositing) {
if (clipBehavior == Clip.none) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: I believe this will allow us to clean up some other call-sides that currently re-implement this branch and don't call pushClipPath if the behavior is none (e.g. RenderClipOval)

Copy link
Member

Choose a reason for hiding this comment

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

Potentially the same for pushClipRRect.

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

Comment on lines 511 to 512
final Rect offsetBounds = bounds.shift(offset);
final Path offsetClipPath = clipPath.shift(offset);
Copy link
Member

Choose a reason for hiding this comment

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

This work is wasted if behaivor is none. Should we skip it in that case?

Copy link
Member

Choose a reason for hiding this comment

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

(same above)

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

Jonah Williams added 2 commits April 25, 2022 13:23
Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 27, 2022
@jonahwilliams jonahwilliams deleted the physical_model_layer branch April 27, 2022 19:39
@jonahwilliams
Copy link
Contributor Author

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 27, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 28, 2022
egramond pushed a commit to egramond/flutter that referenced this pull request May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate PhysicalModelLayer/PhysicalShapeLayer

6 participants