[Impeller] Fix issue about saveLayer ignoring opacity of paint with advanced blend mode#41972
Conversation
…dvanced blend mode
| ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); | ||
| } | ||
|
|
||
| TEST_P(DisplayListTest, SaveLayerWithOpacityAndAdvancedBlendMode) { |
There was a problem hiding this comment.
If you make this an Aiks unittest I believe we can get a golden test image out of it so it gets verified on CI.
There was a problem hiding this comment.
actually, that would only show an issue if it were an arm64 mac. Still, might be good to do.
There was a problem hiding this comment.
If you make this an Aiks unittest I believe we can get a golden test image out of it so it gets verified on CI.
Sounds good, done.
d65f8c6 to
7e4abc5
Compare
|
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. |
|
@jonahwilliams I moved the test from dl_unittests to aiks_unittests, and verified locally that there are no issues, but the bot added the label "will affect goldens" to this PR, I don't know how to fix it, would you mind teaching me how to do it? Thanks |
|
Golden file changes are available for triage from new commit, Click here to view. |
|
Are you able to log into the Skia gold instance and click approve for the new screen shots? |
|
I'll do it for now, If we don't have instructions we should write some up |
|
It looks like blend_filter_contents.cc doesn't have a path to accept the src snapshot opacity. |
|
I'm able to fix the rest of the backends with the following patch: diff --git a/impeller/entity/contents/filters/blend_filter_contents.cc b/impeller/entity/contents/filters/blend_filter_contents.cc
index 015197dd15..47d0c40911 100644
--- a/impeller/entity/contents/filters/blend_filter_contents.cc
+++ b/impeller/entity/contents/filters/blend_filter_contents.cc
@@ -148,6 +148,7 @@ static std::optional<Entity> AdvancedBlend(
auto src_sampler = renderer.GetContext()->GetSamplerLibrary()->GetSampler(
src_sampler_descriptor);
blend_info.color_factor = 0;
+ blend_info.src_input_alpha = src_snapshot->opacity;
FS::BindTextureSamplerSrc(cmd, src_snapshot->texture, src_sampler);
frame_info.src_y_coord_scale = src_snapshot->texture->GetYCoordScale();
}
diff --git a/impeller/entity/shaders/blending/advanced_blend.glsl b/impeller/entity/shaders/blending/advanced_blend.glsl
index cb8aaa7d1d..d60e9237e1 100644
--- a/impeller/entity/shaders/blending/advanced_blend.glsl
+++ b/impeller/entity/shaders/blending/advanced_blend.glsl
@@ -9,6 +9,7 @@
uniform BlendInfo {
float16_t dst_input_alpha;
+ float16_t src_input_alpha;
float16_t color_factor;
f16vec4 color; // This color input is expected to be unpremultiplied.
}
@@ -40,10 +41,11 @@ void main() {
f16vec4 dst = IPHalfUnpremultiply(dst_sample);
f16vec4 src = blend_info.color_factor > 0.0hf
? blend_info.color
- : IPHalfUnpremultiply(Sample(
- texture_sampler_src, // sampler
- v_src_texture_coords // texture coordinates
- ));
+ : IPHalfUnpremultiply(
+ Sample(texture_sampler_src, // sampler
+ v_src_texture_coords // texture coordinates
+ ) *
+ blend_info.src_input_alpha);
f16vec4 blended = f16vec4(Blend(dst.rgb, src.rgb), 1.0hf) * dst.a;I think this is reasonable? Tagging @dnfield / @bdero to confirm |
|
Patch LGTM. |
|
Golden file changes are available for triage from new commit, Click here to view. |
|
@jonahwilliams Thanks for your patch! I added the patch to this PR. Now still need to approve new screenshots on skia gold, since I don't have access, would you mind approving it? |
bdero
left a comment
There was a problem hiding this comment.
I approved the goldens. LGTM, thanks!
…t with advanced blend mode (flutter-team-archive/engine#41972)
…t with advanced blend mode (flutter-team-archive/engine#41972)
flutter-team-archive/engine@c4d4b40...d7a5de6 2023-05-16 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JCoP2Fekj3MBIqskE... to N4LwCRxg0oIevhQ_O... (flutter-team-archive/engine#42070) 2023-05-16 zhangzhijian.123@bytedance.com [Impeller] Fix issue about saveLayer ignoring opacity of paint with advanced blend mode (flutter-team-archive/engine#41972) 2023-05-16 ychris@google.com [ios_platform_view] Only remove platform views from flutter view in reset. (flutter-team-archive/engine#41709) 2023-05-16 godofredoc@google.com Add drone_dimensions as top level target property. (flutter-team-archive/engine#42064) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JCoP2Fekj3MB to N4LwCRxg0oIe 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 rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
|
Can we cherry-pick this into stable please? The request template is here. |
…th advanced blend mode flutter-team-archive#41972
…6919) flutter-team-archive/engine@c4d4b40...d7a5de6 2023-05-16 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from JCoP2Fekj3MBIqskE... to N4LwCRxg0oIevhQ_O... (flutter-team-archive/engine#42070) 2023-05-16 zhangzhijian.123@bytedance.com [Impeller] Fix issue about saveLayer ignoring opacity of paint with advanced blend mode (flutter-team-archive/engine#41972) 2023-05-16 ychris@google.com [ios_platform_view] Only remove platform views from flutter view in reset. (flutter-team-archive/engine#41709) 2023-05-16 godofredoc@google.com Add drone_dimensions as top level target property. (flutter-team-archive/engine#42064) Also rolling transitive DEPS: fuchsia/sdk/core/mac-amd64 from JCoP2Fekj3MB to N4LwCRxg0oIe 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 rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

fix flutter/flutter#126532
without patch

with patch

Pre-launch Checklist
///).