Skip to content

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Oct 24, 2025

fixes #170973

This changes the math for drawing RuntimeEffect's so that it works with ImageFilter.compose. Without this patch the ComposePaintRuntimeInner would draw a cropped image.

Pre-launch Checklist

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

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Oct 24, 2025
@gaaclarke gaaclarke changed the title Runtime effect compose Fixed RuntimeEffect interaction with ImageFilter.compose Oct 24, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new unit tests for composing image filters with runtime effects in the Impeller rendering engine. It also modifies the RuntimeEffectFilterContents class to correctly handle the snapshot origin when rendering the filter. The changes include adding a new shader file and updating the build configuration. The review focuses on correctness and potential areas for improvement in the new tests and the origin handling logic.

@gaaclarke

This comment was marked as outdated.

@flutter-dashboard

This comment was marked as outdated.

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Oct 24, 2025
@gaaclarke

This comment was marked as outdated.

@gaaclarke

This comment was marked as outdated.

@gaaclarke gaaclarke marked this pull request as draft October 24, 2025 22:42
@gaaclarke
Copy link
Member Author

okay all tests in the issue are fixed now

@gaaclarke
Copy link
Member Author

/gemini review

@gaaclarke gaaclarke marked this pull request as ready for review October 24, 2025 23:36
@gaaclarke gaaclarke changed the title Fixed RuntimeEffect interaction with ImageFilter.compose Fixed RuntimeEffect with ImageFilter.compose Oct 24, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue where RuntimeEffect would produce a cropped image when combined with ImageFilter.compose. The fix involves adjusting the transformation logic in RuntimeEffectFilterContents to correctly account for the origin of input snapshots. The changes are supported by new unit tests for both blur filters and runtime effects used with ImageFilter.compose.

My review includes suggestions to fix unbalanced Restore calls in the new tests, remove incorrect [[maybe_unused]] attributes, and a minor stylistic improvement for better code clarity. Overall, the changes are logical and well-tested.

sub_entity.SetBlendMode(entity.GetBlendMode());
sub_entity.SetTransform(input_snapshot->transform);
sub_entity.SetTransform(input_snapshot->transform *
Matrix::MakeTranslation(-1.0f * snapshot_origin));
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and to use the idiomatic operator, you can apply the unary minus operator directly to snapshot_origin.

Suggested change
Matrix::MakeTranslation(-1.0f * snapshot_origin));
Matrix::MakeTranslation(-snapshot_origin));

ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

TEST_P(AiksTest, ComposePaintBlurOuter) {
Copy link
Member Author

Choose a reason for hiding this comment

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

These were just backfill from the bug report to verify the problem was unique to runtimeeffect.

Size size = Size(input_snapshot->texture->GetSize());
memcpy(uniforms_->data(), &size, sizeof(Size));

Point snapshot_origin = input_coverage.GetOrigin();
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't work when the snapshot->transform is not just translations. That sufficient for fixing the linked issue. For different transforms there is a separate issue #170820

I attempted to use the snapshot->transform here and it wasn't enough to resolve that issue. There is more required.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good and this should address most cases.

@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 #177510 at sha b9d1ca3

@gaaclarke
Copy link
Member Author

If you look at the goldens there are 2 issues:

  1. opengles images are drawn upside down
  2. the goldens are drawn at the wrong scale (which was resolved a long time ago for other tests)

Those weren't problems weren't introduced in this PR. Since there was not existing test for this I plan on filing issues for those problems instead of addressing them here so I can focus on #170820

Size size = Size(input_snapshot->texture->GetSize());
memcpy(uniforms_->data(), &size, sizeof(Size));

Point snapshot_origin = input_coverage.GetOrigin();
Copy link
Member

Choose a reason for hiding this comment

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

Sounds good and this should address most cases.

@chinmaygarde
Copy link
Member

chinmaygarde commented Oct 27, 2025

@gaaclarke About the OpenGL ES images being drawn upside down, we just saw a report of this issue in triage that I think is the same #177317

Unrelated to this of course.

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2025
@gaaclarke
Copy link
Member Author

About the OpenGL ES images being drawn upside down, we just saw a report of this issue in triage that I think is the same #177317

@chinmaygarde it might be. I think this upside down opengles issue may be a case where it needs to be addressed N times in the renderer so it might be unique to this situation.

@gaaclarke
Copy link
Member Author

Filed those 2 follow up issues:

@auto-submit auto-submit bot added this pull request to the merge queue Oct 27, 2025
Merged via the queue into flutter:master with commit 4fd6606 Oct 27, 2025
185 of 186 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 28, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 28, 2025
flutter/flutter@4c91098...7cf0dc1

2025-10-28 [email protected] Roll Skia from 602bbd4af8f9 to e4d3d8f31aef (4 revisions) (flutter/flutter#177647)
2025-10-28 [email protected] Fix AppBar Semantics namesRoute for mismatched platforms (flutter/flutter#176694)
2025-10-28 [email protected] Fix Popup menu Semantics label for mismatched platforms (flutter/flutter#177049)
2025-10-28 [email protected] Roll Skia from 8b2d056701df to 602bbd4af8f9 (1 revision) (flutter/flutter#177628)
2025-10-28 [email protected] Roll Skia from 5723f87f8530 to 8b2d056701df (3 revisions) (flutter/flutter#177626)
2025-10-27 [email protected] Roll Skia from 170c11f1ddc5 to 5723f87f8530 (6 revisions) (flutter/flutter#177618)
2025-10-27 [email protected] Enhance DropdownMenuEntry's labelWidget docs (flutter/flutter#177160)
2025-10-27 [email protected] Regenerated lockfiles for New Template Values (flutter/flutter#177617)
2025-10-27 [email protected] Correct editable text and placeholder position in baseline aligned stack (flutter/flutter#177342)
2025-10-27 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4 to 5 in the all-github-actions group (flutter/flutter#177620)
2025-10-27 [email protected] add gn flag to optimize builds for size (flutter/flutter#176835)
2025-10-27 [email protected] disable metal for crosscompile from mac to linux (flutter/flutter#176639)
2025-10-27 [email protected] [DDM] enable host builds in the merge queue (flutter/flutter#177446)
2025-10-27 [email protected] Disable vulkan X11 support when building for minimal linux (flutter/flutter#176697)
2025-10-27 [email protected] Roll Skia from 77348c40d101 to 170c11f1ddc5 (6 revisions) (flutter/flutter#177602)
2025-10-27 [email protected] Set the font weight variation axis based on the text style's FontWeight (flutter/flutter#175771)
2025-10-27 [email protected] Fixed `RuntimeEffect` with `ImageFilter.compose` (flutter/flutter#177510)
2025-10-27 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clean before building when framework headers change (#177512)" (flutter/flutter#177610)
2025-10-27 [email protected] [skia] Disable legacy png encoding/decoding in skp (flutter/flutter#177462)
2025-10-27 [email protected] Clean before building when framework headers change (flutter/flutter#177512)
2025-10-27 [email protected] Roll dartdoc to 9.0.0 (flutter/flutter#177590)
2025-10-27 [email protected] Fix typo in comment about `manifestFile` in `DeepLinkJsonFromManifestTaskHelper.kt‎` (flutter/flutter#177538)
2025-10-27 [email protected] Fix RoundedSuperellipse crashes for tiny corners (flutter/flutter#177070)
2025-10-27 [email protected] Roll Packages from 53d6138 to bbf96a0 (7 revisions) (flutter/flutter#177588)
2025-10-27 [email protected] Fix missing list indicators in CHANGELOG.md (flutter/flutter#177484)
2025-10-27 [email protected] [ Tool ] Add `Stream.transformWithCallSite` to provide more useful stack traces (flutter/flutter#177470)
2025-10-27 [email protected] Roll Skia from 06243224ecf0 to 77348c40d101 (1 revision) (flutter/flutter#177585)
2025-10-27 [email protected] Add guided error for precompiled cache error (flutter/flutter#177327)
2025-10-27 [email protected] Roll Fuchsia Linux SDK from tKrvmvTOQITL81oOC... to ir6J2isKAYa1jNLyJ... (flutter/flutter#177578)
2025-10-27 [email protected] Roll Skia from 784ed1787bd6 to 06243224ecf0 (1 revision) (flutter/flutter#177575)
2025-10-27 [email protected] Roll Skia from de52b3a7585a to 784ed1787bd6 (5 revisions) (flutter/flutter#177571)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
flutter-zl pushed a commit that referenced this pull request Oct 31, 2025
fixes #170973

This changes the math for drawing RuntimeEffect's so that it works with
`ImageFilter.compose`. Without this patch the `ComposePaintRuntimeInner`
would draw a cropped image.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
fixes flutter#170973

This changes the math for drawing RuntimeEffect's so that it works with
`ImageFilter.compose`. Without this patch the `ComposePaintRuntimeInner`
would draw a cropped image.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels. will affect goldens Changes to golden files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] ImageFilter.compose doesn't work with ImageFilter.shader in all cases

2 participants