-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] add a generic porter duff blend foreground shader. #41098
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| frag_color = IPBlendPlus(frag_info.color, dst_color); | ||
| } else { | ||
| frag_color = IPBlendModulate(frag_info.color, dst_color); | ||
| } |
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.
Rather than enumerating these on the GPU, most of these can be parameterized with 4 coefficients:
frag_color =
src * (frag_info.src_coeff + dst.a * frag_info.src_coeff_dst_alpha) +
dst * (frag_info.dst_coeff + src.a * frag_info.dst_coeff_src_alpha);And then the coefficients can be pulled from a LUT on the CPU without enumeration or hashing:
{src_coeff, src_coeff_dst_alpha, dst_coeff, dst_coeff_src_alpha}
{0, 0, 0, 0}, // Clear
{1, 0, 0, 0}, // Source
{0, 0, 1, 0}, // Destination
{1, 0, 1, -1}, // SourceOver
{1, -1, 1, 0}, // DestinationOver
{0, 1, 0, 0}, // SourceIn
{0, 0, 0, 1}, // DestinationIn
{1, -1, 0, 0}, // SourceOut
{0, 0, 1, -1}, // DestinationOut
{0, 1, 1, -1}, // SourceATop
{1, -1, 0, 1}, // DestinationATop
{1, -1, 1, -1}, // Xor
{1, 0, 1, 0}, // PlusI think we can also cover Modulate and Screen here by adding one more dst coefficient to multiply the source color in:
frag_color =
src * (frag_info.src_coeff + dst.a * frag_info.src_coeff_dst_alpha) +
dst * (frag_info.dst_coeff + src.a * frag_info.dst_coeff_src_alpha +
src * frag_info.dst_coeff_src_color);...and then the full table with all the blends becomes:
{src_coeff, src_coeff_dst_alpha, dst_coeff, dst_coeff_src_alpha, dst_coeff_src_color}
{0, 0, 0, 0, 0}, // Clear
{1, 0, 0, 0, 0}, // Source
{0, 0, 1, 0, 0}, // Destination
{1, 0, 1, -1, 0}, // SourceOver
{1, -1, 1, 0, 0}, // DestinationOver
{0, 1, 0, 0, 0}, // SourceIn
{0, 0, 0, 1, 0}, // DestinationIn
{1, -1, 0, 0, 0}, // SourceOut
{0, 0, 1, -1, 0}, // DestinationOut
{0, 1, 1, -1, 0}, // SourceATop
{1, -1, 0, 1, 0}, // DestinationATop
{1, -1, 1, -1, 0}, // Xor
{1, 0, 1, 0, 0}, // Plus
{0, 0, 0, 0, 1}, // Modulate
{0, 0, 1, 0, -1}, // Screen+cc @flar in case he has a moment to check my math :)
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.
Seems like a more technically sound approach, I'll make this change.
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.
|
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. |
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.
LGTM!
|
Golden file changes are available for triage from new commit, Click here to view. |
|
Goldens revealed that the check to convert the foreground blend back into a snapshot wasn't quite working correctly so I took it out. now we only apply the foreground if we can absorb opacity (which should generally be always) |
|
Golden file changes are available for triage from new commit, Click here to view. |
…124933) flutter/engine@feb476b...da0805a 2023-04-15 [email protected] Roll Skia from 2a4d95762651 to 2d0b05335104 (1 revision) (flutter/engine#41250) 2023-04-15 [email protected] [Impeller] add a generic porter duff blend foreground shader. (flutter/engine#41098) 2023-04-15 [email protected] Roll Fuchsia Linux SDK from Y_tD90hDX_jiubGbC... to hacWN-gQSoWudziIS... (flutter/engine#41248) 2023-04-15 [email protected] Roll Fuchsia Mac SDK from RFyPoDrXzIiy-E3wn... to gI2knJ4Rh0yoK4Syd... (flutter/engine#41249) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Y_tD90hDX_ji to hacWN-gQSoWu fuchsia/sdk/core/mac-amd64 from RFyPoDrXzIiy to gI2knJ4Rh0yo 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://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
…lutter#124933) flutter/engine@feb476b...da0805a 2023-04-15 [email protected] Roll Skia from 2a4d95762651 to 2d0b05335104 (1 revision) (flutter/engine#41250) 2023-04-15 [email protected] [Impeller] add a generic porter duff blend foreground shader. (flutter/engine#41098) 2023-04-15 [email protected] Roll Fuchsia Linux SDK from Y_tD90hDX_jiubGbC... to hacWN-gQSoWudziIS... (flutter/engine#41248) 2023-04-15 [email protected] Roll Fuchsia Mac SDK from RFyPoDrXzIiy-E3wn... to gI2knJ4Rh0yoK4Syd... (flutter/engine#41249) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Y_tD90hDX_ji to hacWN-gQSoWu fuchsia/sdk/core/mac-amd64 from RFyPoDrXzIiy to gI2knJ4Rh0yo 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://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


The pipeline blend component of flutter/flutter#124025 . This should also land alongside flutter/flutter#124640 which was necessary before we had completely optimized the image filters for texture inputs.
Fixes flutter/flutter#121650
Fixes flutter/flutter#124025