Bug 246822 - Add the class FilterTargetSwitcher
Summary: Add the class FilterTargetSwitcher
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks: 198416
  Show dependency treegraph
 
Reported: 2022-10-20 12:22 PDT by Said Abou-Hallawa
Modified: 2022-10-20 14:29 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2022-10-20 12:22:08 PDT
This 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 can either add this line of code to the drawing function:

FilterTargetSwitcher targetSwitcher(*this, bounds);

Or a line like this one if calculating the bounds is expensive:

FilterTargetSwitcher targetSwitcher(*this, []() {
    return path.fastBoundingRect();
});

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 to the client drawing context.
Comment 1 Radar WebKit Bug Importer 2022-10-20 12:30:34 PDT
<rdar://problem/101394417>
Comment 2 Said Abou-Hallawa 2022-10-20 12:31:42 PDT
Pull request: https://github.com/WebKit/WebKit/pull/5596
Comment 3 EWS 2022-10-20 14:29:12 PDT
Committed 255802@main (5a02a23fcd77): <https://commits.webkit.org/255802@main>

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