-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] implements blur styles inner and outer #51018
Conversation
This reverts commit 21b28ce.
| return static_cast<int>(std::round(radius * scalar)); | ||
| } | ||
|
|
||
| class GeometryExtractor : public TypedContentsVisitor<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.
This approach feels really fragile. We should have the geometry when we construct the mask blur, right?
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.
Yea, in our current implementation we do. There is also a bug in our current implementation where it seems to only work for ColorSourceContents, which isn't what we want.
It isn't as fragile as it seems since the compiler is supporting it. If another subclass of ColorSourceContents is introduced, the visitor will have a compile error were you just implement the standard Visitor pattern and it will work.
The way this could break is if we introduce a new Contents that has a geometry that isn't a ColorSourceContents. But this way is probably more robust to that change than relying on having a ColorSourceContents when we create the blur.
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.
Also, passing in the geometry as part of the filterinput and as a separate parameter can create the opportunity for them to differ which would be a logical error.
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.
This just seems like way too much code to support mask blurs, which are only supported in relatively limited configrations. For example, we don't need to worry about mask blurs on arbitrary filers, its always going to be on a paint for a draw call, which means we should always have the geometry.
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 don't need to worry about mask blurs on arbitrary filers
What's enforcing that? Why doesn't our API enforce that? I worry that trying to ignore what the API allows creates oversights like with what happened with mask blur filters on textures. That's the downside to doing it the other way.
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.
Tests enforce it, same as it ever was!
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.
@bdero I chatted with jonah and what we decided to do is just reduce the scope of the Visitor so that it only goes as far as ColorSourceContents. That's all I need to implement what I want and cuts down a lot of the code. If we need an more expansive visitor in the future we can implement that similarly to what I've done here.
I wish I understood the wizardry that std::variant uses to implement their visitor since it would resolve this 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.
I think you might also be able to simplify the visitor further too, if you're limiting the scope to just the work needed to land this change. In that case, you don't even need to know what you are visiting, just whether or not it has a geometry you can use.
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.
Okay @jonahwilliams, please take a look, I removed all the subclasses of ColorSourceContents and FilterContents. I don't need to know anything below that to implement what we need.
|
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. |
|
I added outer too since I'm waiting on reviews and it wasn't a big change. |
|
Golden file changes are available for triage from new commit, Click here to view. |
| virtual void SetRenderingMode(Entity::RenderingMode rendering_mode); | ||
|
|
||
| // |Contents| | ||
| void Visit(ContentsVisitor* visitor) override { visitor->Visit(this); } |
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.
Do we need overrides on all of the filter subtypes still?
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. Thanks, I missed some of them. I think I have them all now.
|
Golden file changes are available for triage from new commit, Click here to view. |
|
@jonahwilliams @bdero ready for review |
| Scalar sigma_y, | ||
| Entity::TileMode tile_mode, | ||
| BlurStyle blur_style, | ||
| const std::shared_ptr<Geometry>& geometry); |
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.
uber-nit: I might call this something like "mask_geometry", to clarify that it is the geometry for the mask and not the destination geometry/rect of the filter.
impeller/aiks/paint.cc
Outdated
| return FilterContents::MakeGaussianBlur( | ||
| FilterInput::Make(color_source_contents), sigma, sigma, style, | ||
| Entity::TileMode::kDecal); | ||
| Entity::TileMode::kDecal, color_source_contents->GetGeometry()); |
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.
Also need to set the geometry for the FilterContents::MakeGaussianBlur a few lines below.
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.
It seems unnecessary to make the tests pass. Could I hit that with a gradient?
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.
Yeah, setting any ColorSource other than solid color should trigger it.
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'm adding it, but it doesn't render correctly. I'll have to do a followup to add that and address the rendering bug.
TEST_P(AiksTest, GaussianBlurStyleInnerGradient) {
Canvas canvas;
canvas.Scale(GetContentScale());
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
Paint paint;
paint.color = Color::Green();
paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
.style = FilterContents::BlurStyle::kInner,
.sigma = Sigma(30),
};
std::vector<Color> colors = {Color{0.0, 0.7, 0.8, 1.0},
Color{0.0, 0.8, 0.7, 1.0}};
std::vector<Scalar> stops = {0.0, 1.0};
paint.color_source =
ColorSource::MakeLinearGradient({0, 0}, {200, 200}, std::move(colors),
std::move(stops), Entity::TileMode::kRepeat, {});
canvas.DrawPath(PathBuilder()
.MoveTo({200, 200})
.LineTo({300, 400})
.LineTo({100, 400})
.Close()
.TakePath(),
paint);
// Draw another thing to make sure the clip area is reset.
Paint red;
red.color = Color::Red();
canvas.DrawRect(Rect::MakeXYWH(0, 0, 200, 200), red);
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
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.
issue filed: flutter/flutter#144449
| Entity::TileMode tile_mode) { | ||
| FilterContents::BlurStyle blur_style, | ||
| Entity::TileMode tile_mode, | ||
| const std::shared_ptr<Geometry>& geometry) { |
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.
optional, but you could re-arrange the params so that blur_style (mask_blur_style?) and mask_geometry happen last and default them to normal/nullptr - here and in the ctor.
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
jonahwilliams
left a comment
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 with nits
bdero
left a comment
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.
|
Filed an issue since it doesnt' render correctly: flutter/flutter#144449 |
|
Golden file changes are available for triage from new commit, Click here to view. |
|
auto label is removed for flutter/engine/51018, due to - The status or check suite Mac mac_clang_tidy has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…144558) flutter/engine@a312091...0d8588b 2024-03-04 [email protected] [Impeller] implements blur styles inner and outer (flutter/engine#51018) 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],[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
issue: flutter/flutter#134178
This doesn't yet do textures since there is a bug in rendering mask blurs with textures.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.