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

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Mar 4, 2024

fixes flutter/flutter#144266

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.

@gaaclarke gaaclarke force-pushed the mask-blur-texture branch from ca123d4 to 4c75338 Compare March 5, 2024 23:53
@gaaclarke gaaclarke force-pushed the mask-blur-texture branch 2 times, most recently from 09bbeba to bd3a0c3 Compare March 6, 2024 00:47
@gaaclarke gaaclarke marked this pull request as ready for review March 6, 2024 00:48
@gaaclarke gaaclarke requested review from bdero and jonahwilliams March 6, 2024 00:48
bool needs_color_filter = paint.HasColorFilter();
if (needs_color_filter) {
auto color_filter = paint.GetColorFilter();
if (texture_contents->ApplyColorFilter(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will ever pass? This is for automagically filtering solid colors or gradients, things that exist on host memory.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, removed it.

}

std::shared_ptr<FilterContents> Paint::MaskBlurDescriptor::CreateMaskBlur(
std::shared_ptr<ColorSourceContents> color_source_contents,
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have a path for creating a mask blur from a color source contents. If we created a TiledTextureContents (which is a color source contents) instead of a TextureContents for drawImageRect calls with a mask blur descriptor, then could we pass it into this function and have it just work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, we have to essentially create a transparent halo around the texture to make the blending work correctly. That requires modifying texcoords. The path below doesn't know anything about that, just expanding geometry which would stretch the image.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, not a transparent halo, but sampling outside of the image based on whatever the sampler settings are.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, that's a bug in the existing path, then. And that same issue actually applies to all the ColorSource types (except for solid colors, of course).

One easy solution for that would be to amend the effect transform of the ColorSourceContents.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yea, that would explain some of the stretching I saw of gradients. I'll file an issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

absorb_opacity);
}

std::shared_ptr<FilterContents> Paint::MaskBlurDescriptor::CreateMaskBlur(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would defer to @bdero to review the mask blur implementation. Overall code looks reasonable to me.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@gaaclarke gaaclarke force-pushed the mask-blur-texture branch from 3c0163d to af8ce92 Compare March 8, 2024 01:47
@gaaclarke gaaclarke force-pushed the mask-blur-texture branch from af8ce92 to 3233ee2 Compare March 8, 2024 17:45
@gaaclarke
Copy link
Member Author

This should be generating goldens but hasn't yet. Let's see if it does this time around.

@bdero
Copy link
Member

bdero commented Mar 8, 2024

Mask blurring for all color sources (including textures) is already implemented if the user sets the color source and calls a path drawing command on Aiks (DrawPath, DrawRect, DrawCircle, etc.)

Not blocking this, but we'll need to fix the bugs in the generic color source path anyway. So later on I think we'll end up switching DrawImageRect to use TiledTextureContents (as @jonahwilliams suggested) in favor of copying and tweaking the existing flawed path (which I suspect has more behavioral flaws than just the UV mapping -- flaws that are being duplicated here).

@gaaclarke
Copy link
Member Author

gaaclarke commented Mar 8, 2024

we'll end up switching DrawImageRect to use TiledTextureContents (as @jonahwilliams suggested) in favor of copying and tweaking the existing flawed path

I tried working with TiledTextureContents and I wasn't seeing the mechanism to effectively edit the texcoords like I needed. It doesn't have any documentation, I think I'm missing some information. Can someone fill me in and/or fill out the TiledTextureContents documentation?

edit: I think you mention effect transform should affect the texcoords?

which I suspect has more behavioral flaws than just the UV mapping

Probably worth filing bugs if we find those so we can make sure we address them.

@jonahwilliams
Copy link
Contributor

This isn't the color source responsibility as much as the geometry responsibility. not that the geometry class has docs, but I'd start by looking at ComputeUVGeometryForRect to see how the UVS are computed

@gaaclarke
Copy link
Member Author

gaaclarke commented Mar 8, 2024

Ahh okay, so you're thinking something like contents->SetGeometry(contents->GetGeometry()->Scale(foo)->ScaleTexCoords(1/foo)). Makes sense.

@jonahwilliams
Copy link
Contributor

Yeah, by adjusting the geometry we should be able to adjust the size/texture coordinates for all color sources and solve this generically.

@bdero
Copy link
Member

bdero commented Mar 8, 2024

There's no need to modify any Geometry or Contents; everything that's needed to support the DrawImageRect use case with TiledTextureContents is already in place.

Just use the ColorSourceContents effect transform to:

  • Apply the source rectangle mapping done by DrawImageRect.
  • Fix the bug in the generic mask blur path by amending a source->destination rect transform to the existing ColorSourceContents effect transform when we perform the geometry border expansion.

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2024
@bdero
Copy link
Member

bdero commented Mar 8, 2024

Ahh okay, so you're thinking something like contents->SetGeometry(contents->GetGeometry()->Scale(foo)->ScaleTexCoords(1/foo)). Makes sense.

Note that the geometry change that happens for the mask blur is a border expansion, which is not a uniform scale-up centered around the UV space origin. So to fix the bug in the existing path, we need to apply the inverse of the border expansion to the UVs with a rect->rect mapping transform.

Yeah, by adjusting the geometry we should be able to adjust the size/texture coordinates for all color sources and solve this generically.

This can't work unless we also add support for applying this redundant geometry effect transform to all the color sources that don't use geometry->GetPositionUVBuffer. Strongly recommend just using the existing effect transform.

@gaaclarke
Copy link
Member Author

Ahh I was wondering if that would be a problem. Essentially that addresses the problem of what is the pivot used for the scale with the geometry approach if I'm understanding correctly.

@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 #51183 at sha 5c33bde

@gaaclarke gaaclarke merged commit 7541e90 into flutter:main Mar 8, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 9, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 9, 2024
…144862)

flutter/engine@953927e...7541e90

2024-03-08 [email protected] [Impeller] implement mask blur for textures (flutter/engine#51183)
2024-03-08 [email protected] Don't rely on dart binary on PATH in run_test.py (flutter/engine#51302)
2024-03-08 [email protected] Mark the Flutter Views as focusable by setting a tabindex value. (flutter/engine#50876)
2024-03-08 [email protected] Update the instructions for updating licenses. (flutter/engine#51297)
2024-03-08 [email protected] Optimize overlays in CanvasKit (flutter/engine#47317)
2024-03-08 [email protected] Roll Fuchsia Linux SDK from 5Ra_AjCji-uR1GaX7... to lAV5jgp4796siOZgI... (flutter/engine#51296)
2024-03-08 [email protected] [Impeller] Add the KHR prefix to existing swapchain utilities. (flutter/engine#51295)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from 5Ra_AjCji-uR to lAV5jgp4796s

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

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] mask blurs don't work for textures

3 participants