Bug 246822

Summary: Add the class FilterTargetSwitcher
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: CanvasAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 198416    

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.