-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] implement mask blur for textures #51183
Conversation
ca123d4 to
4c75338
Compare
09bbeba to
bd3a0c3
Compare
impeller/aiks/canvas.cc
Outdated
| bool needs_color_filter = paint.HasColorFilter(); | ||
| if (needs_color_filter) { | ||
| auto color_filter = paint.GetColorFilter(); | ||
| if (texture_contents->ApplyColorFilter( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e620d09 to
0fee14e
Compare
| absorb_opacity); | ||
| } | ||
|
|
||
| std::shared_ptr<FilterContents> Paint::MaskBlurDescriptor::CreateMaskBlur( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
3c0163d to
af8ce92
Compare
af8ce92 to
3233ee2
Compare
|
This should be generating goldens but hasn't yet. Let's see if it does this time around. |
|
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). |
I tried working with edit: I think you mention effect transform should affect the texcoords?
Probably worth filing bugs if we find those so we can make sure we address them. |
|
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 |
|
Ahh okay, so you're thinking something like |
|
Yeah, by adjusting the geometry we should be able to adjust the size/texture coordinates for all color sources and solve this generically. |
|
There's no need to modify any Just use the
|
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.
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 |
|
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. |
|
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. |
…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
fixes flutter/flutter#144266
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.