Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Skia] Implement support for shadows that ignore transforms #25178

Conversation

GeorgesStavracas
Copy link
Contributor

@GeorgesStavracas GeorgesStavracas commented Feb 27, 2024

caf3994

[Skia] Implement support for shadows that ignore transforms
https://bugs.webkit.org/show_bug.cgi?id=270175

Reviewed by Carlos Garcia Campos and Nikolas Zimmermann.

When creating the drop shadow filter, if state.shadowsIgnoreTransforms()
is true, render the drop shadow with trasformed coordinates and blur
radius, by adjusting them against the CTM inverse.

This is enough to make various canvas tests happy. Some of them are still
failing with off-by-one colors, and it's not clear why.

* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::createDropShadowFilterIfNeeded const):

Canonical link: https://commits.webkit.org/275492@main

e124da8

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac   πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2   πŸ§ͺ gtk-wk2
  πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ api-gtk
  πŸ›  tv-sim
  πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge   πŸ›  watch-sim

@GeorgesStavracas GeorgesStavracas self-assigned this Feb 27, 2024
@GeorgesStavracas GeorgesStavracas added the Layout and Rendering For bugs with layout and rendering of Web pages. label Feb 27, 2024
@GeorgesStavracas GeorgesStavracas force-pushed the eng/Skia-Implement-support-for-untransformed-shadows branch from a63db86 to bc9d51d Compare February 28, 2024 20:55
@GeorgesStavracas GeorgesStavracas added WPE WebKit WebKit WPE component and removed Layout and Rendering For bugs with layout and rendering of Web pages. labels Feb 28, 2024
Copy link
Contributor

@nikolaszimmermann nikolaszimmermann left a comment

Choose a reason for hiding this comment

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

r=me with comments


// Ignoring the CTM is practically equal as applying the inverse of
// the CTM when post-processing the drop shadow.
if (const std::optional<SkMatrix>& inverse = ctm.inverse()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for converting directly to SkMatrix? IMHO AffineTransform is more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because the methods mapHomogeneousPoints and mapRadius only exist in SkMatrix, unless I've missed something?

// the CTM when post-processing the drop shadow.
if (const std::optional<SkMatrix>& inverse = ctm.inverse()) {
SkPoint3 p = SkPoint3::Make(offset.width(), offset.height(), 0);
inverse->mapHomogeneousPoints(&p, &p, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense! You need to transform all lengths to be in identity space - as you intent to remove the CTM.

@GeorgesStavracas GeorgesStavracas force-pushed the eng/Skia-Implement-support-for-untransformed-shadows branch from bc9d51d to e124da8 Compare February 29, 2024 13:52
@carlosgcampos carlosgcampos added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 29, 2024
https://bugs.webkit.org/show_bug.cgi?id=270175

Reviewed by Carlos Garcia Campos and Nikolas Zimmermann.

When creating the drop shadow filter, if state.shadowsIgnoreTransforms()
is true, render the drop shadow with trasformed coordinates and blur
radius, by adjusting them against the CTM inverse.

This is enough to make various canvas tests happy. Some of them are still
failing with off-by-one colors, and it's not clear why.

* Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp:
(WebCore::GraphicsContextSkia::createDropShadowFilterIfNeeded const):

Canonical link: https://commits.webkit.org/275492@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Skia-Implement-support-for-untransformed-shadows branch from e124da8 to caf3994 Compare February 29, 2024 14:00
@webkit-commit-queue
Copy link
Collaborator

Committed 275492@main (caf3994): https://commits.webkit.org/275492@main

Reviewed commits have been landed. Closing PR #25178 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit caf3994 into WebKit:main Feb 29, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 29, 2024
@GeorgesStavracas GeorgesStavracas deleted the eng/Skia-Implement-support-for-untransformed-shadows branch February 29, 2024 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WPE WebKit WebKit WPE component
Projects
None yet
5 participants