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

[canvaskit] Clip before applying ColorFilter so it doesn't filter beyond child bounds #52704

Merged
merged 3 commits into from
May 10, 2024

Conversation

harryterkelsen
Copy link
Contributor

@harryterkelsen harryterkelsen commented May 9, 2024

When a ColorFilter affects transparent black, it will expand its bounds to the entire screen, even if the saveLayer call is bounded. This applies a clip before applying the ColorFilter so the filter is bounded to just the child drawings.

Also fixes bug with ColorFilter being used as an ImageFilter.

Before:
canvaskit_colorfilter_bounds_before

After:
canvaskit_colorfilter_bounds_after

Fixes flutter/flutter#88866
Fixes flutter/flutter#144015

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 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.

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

@harryterkelsen harryterkelsen requested a review from yjbanov May 9, 2024 21:34
@github-actions github-actions bot added the platform-web Code specifically for the web engine label May 9, 2024
@@ -409,12 +411,23 @@ class ImageFilterEngineLayer extends ContainerLayer
childMatrix.translate(_offset.dx, _offset.dy);
prerollContext.mutatorsStack
.pushTransform(Matrix4.translationValues(_offset.dx, _offset.dy, 0.0));
final CkManagedSkImageFilterConvertible convertible;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be a field that's populated in the constructor and reused by both preroll and paint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only used in preroll. In paint we use the filter directly

@harryterkelsen harryterkelsen merged commit ba8e0d3 into flutter:main May 10, 2024
26 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 10, 2024
@zanderso
Copy link
Member

This change had SkiaGold diffs in two tests on the roll to the framework. https://flutter-gold.skia.org/search?crs=github&issue=148147&patchsets=8&positive=true&untriaged=false They looked correct, and I accepted them.

auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 10, 2024
…148147)

flutter/engine@d4f705c...ba8e0d3

2024-05-10 [email protected] [canvaskit] Clip before applying ColorFilter so it doesn't filter beyond child bounds (flutter/engine#52704)
2024-05-10 [email protected] Migrate FlutterView, FlutterPlatformViews, FlutterOverlayView to ARC (flutter/engine#52535)
2024-05-10 [email protected] Infer `--rbe` based on the existence of `//flutter/build/rbe` (flutter/engine#52700)
2024-05-10 [email protected] [Impeller] Disable AHB swapchain. (flutter/engine#52713)
2024-05-10 [email protected] Roll Skia from c7cd1e9690d1 to 11d892ce49b6 (25 revisions) (flutter/engine#52712)
2024-05-10 [email protected] [Impeller] Document how to do basic rendering in Impeller. (flutter/engine#52703)
2024-05-10 [email protected] [impeller] adds experimental canvas docstring (flutter/engine#52710)
2024-05-10 [email protected] Roll third_party/freetype2 from 3bea27612 to af4c2d86d (2 revisions) (flutter/engine#52689)

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 [email protected],[email protected] 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://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-web Code specifically for the web engine
Projects
None yet
3 participants