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

Add the class FilterTargetSwitcher #5596

Conversation

shallawa
Copy link
Contributor

@shallawa shallawa commented Oct 20, 2022

5a02a23

Add the class FilterTargetSwitcher
https://bugs.webkit.org/show_bug.cgi?id=246822

Reviewed by Simon Fraser.

This class will manage applying a filter to a certain area of drawings with the
minimum changes in the existing code. All it needs is a set of callbacks in the
existing caller class. And the caller adds a line like this to the drawing
function:

        FilterTargetSwitcher targetSwitcher(*this, bounds);

The constructor of FilterTargetSwitcher will ask the client if there a filter to
apply or not. If there is a filter, it will switch the drawing to a temporary
ImageBuffer. The client has to make sure all the drawing code from now on will
use the context of this ImageBuffer. The destructor will apply the filter to the
temporary ImageBuffer and then composite filtered ImageBuffer back to the client
drawing context.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/filters/FilterTargetSwitcher.cpp: Added.
(WebCore::FilterTargetSwitcher::FilterTargetSwitcher):
(WebCore::FilterTargetSwitcher::~FilterTargetSwitcher):
(WebCore::FilterTargetSwitcher::drawingContext const):
(WebCore::FilterTargetSwitcher::outsets const):
* Source/WebCore/platform/graphics/filters/FilterTargetSwitcher.h: Added.

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

56c32d1

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

@shallawa shallawa self-assigned this Oct 20, 2022
@shallawa shallawa added Canvas Bugs related to the canvas element. WebKit Nightly Build labels Oct 20, 2022
@shallawa shallawa requested review from heycam and smfr October 20, 2022 19:43
@shallawa shallawa added the merge-queue Applied to send a pull request to merge-queue label Oct 20, 2022
https://bugs.webkit.org/show_bug.cgi?id=246822

Reviewed by Simon Fraser.

This class will manage applying a filter to a certain area of drawings with the
minimum changes in the existing code. All it needs is a set of callbacks in the
existing caller class. And the caller adds a line like this to the drawing
function:

	FilterTargetSwitcher targetSwitcher(*this, bounds);

The constructor of FilterTargetSwitcher will ask the client if there a filter to
apply or not. If there is a filter, it will switch the drawing to a temporary
ImageBuffer. The client has to make sure all the drawing code from now on will
use the context of this ImageBuffer. The destructor will apply the filter to the
temporary ImageBuffer and then composite filtered ImageBuffer back to the client
drawing context.

* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/graphics/filters/FilterTargetSwitcher.cpp: Added.
(WebCore::FilterTargetSwitcher::FilterTargetSwitcher):
(WebCore::FilterTargetSwitcher::~FilterTargetSwitcher):
(WebCore::FilterTargetSwitcher::drawingContext const):
(WebCore::FilterTargetSwitcher::outsets const):
* Source/WebCore/platform/graphics/filters/FilterTargetSwitcher.h: Added.

Canonical link: https://commits.webkit.org/255802@main
@webkit-commit-queue
Copy link
Collaborator

Committed 255802@main (5a02a23): https://commits.webkit.org/255802@main

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

@webkit-early-warning-system webkit-early-warning-system merged commit 5a02a23 into WebKit:main Oct 20, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 20, 2022
@shallawa shallawa deleted the eng/Add-the-class-FilterTargetSwitcher branch May 9, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Canvas Bugs related to the canvas element.
Projects
None yet
4 participants