Bug 232705

Summary: [GPU Process] [Filters 17/23] Make FilterEffect calculate the primitive subregion only when needed
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: Layout and RenderingAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, bfulgham, changseok, dino, eric.carlson, esprehn+autocc, ews-watchlist, fmalita, fred.wang, glenn, gyuyoung.kim, heycam, hta, jer.noble, kondapallykalyan, macpherson, menard, pdr, philipj, ryuan.choi, schenney, sergio, simon.fraser, tommyw, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 231253    
Attachments:
Description Flags
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch for review
none
Patch
none
Patch
none
Patch
none
Patch none

Description Said Abou-Hallawa 2021-11-04 02:40:13 PDT
FilterEffect should be able to calculate and hold only two rectangles:

1) primitiveSubRegion which is defined here https://www.w3.org/TR/filter-effects-1/#FilterPrimitiveSubRegion
2) imageRect which is the rectangle of the result FilterImage.

And to simplify the calculation we can keep these two rectangles as FloatRects and they will be in filter coordinates. But

1) Only when drawing to a FilterImage, we should convert from filter coordinates to absolute coordinates. 
2) And when getting pixels from or putting pixels in a FilterImage, we will convert the FloatRect to a IntRect.

And since the plan is to remove the result FilterImage from the FilterEffect, we are going to keep these rectangles in FilterImage. The conversion from filter coordinates to absolute coordinates will happen through the Filter class.
Comment 1 Said Abou-Hallawa 2021-11-04 03:04:15 PDT
Created attachment 443290 [details]
Patch
Comment 2 Said Abou-Hallawa 2021-11-07 02:16:19 PST
Created attachment 443503 [details]
Patch
Comment 3 Said Abou-Hallawa 2021-11-07 02:20:46 PST
Created attachment 443504 [details]
Patch
Comment 4 Said Abou-Hallawa 2021-11-07 02:58:14 PST
Created attachment 443505 [details]
Patch
Comment 5 Said Abou-Hallawa 2021-11-07 11:58:14 PST
Created attachment 443516 [details]
Patch
Comment 6 Said Abou-Hallawa 2021-11-07 12:17:53 PST
Created attachment 443517 [details]
Patch
Comment 7 Said Abou-Hallawa 2021-11-08 20:37:34 PST
Created attachment 443652 [details]
Patch for review
Comment 8 Radar WebKit Bug Importer 2021-11-11 01:41:20 PST
<rdar://problem/85290142>
Comment 9 Said Abou-Hallawa 2021-12-04 01:49:41 PST
Created attachment 445965 [details]
Patch
Comment 10 Said Abou-Hallawa 2021-12-06 11:02:09 PST
Created attachment 446055 [details]
Patch
Comment 11 Said Abou-Hallawa 2021-12-06 11:03:36 PST
Created attachment 446057 [details]
Patch
Comment 12 Said Abou-Hallawa 2021-12-06 13:19:35 PST
Created attachment 446074 [details]
Patch
Comment 13 Cameron McCormack (:heycam) 2021-12-06 15:35:26 PST
Comment on attachment 446074 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446074&action=review

> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:52
> +        for (auto& input : inputs)
> +            primitiveSubregion.unite(input->primitiveSubregion());

I guess we're guaranteed that input's primitive subregion has already been calculated at this point, because of the ordering of the filter effects in the overall expression?
Comment 14 Said Abou-Hallawa 2021-12-06 15:50:45 PST
Comment on attachment 446074 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=446074&action=review

>> Source/WebCore/platform/graphics/filters/FilterEffect.cpp:52
>> +            primitiveSubregion.unite(input->primitiveSubregion());
> 
> I guess we're guaranteed that input's primitive subregion has already been calculated at this point, because of the ordering of the filter effects in the overall expression?

Yes this correct. In SVGFilter we apply the effects from the SVGFilterExpression which is the post-fix notation of the filter. For CSSFilter we apply the effects from left to right since every effect is the input to the next effect.
Comment 15 EWS 2021-12-06 16:37:04 PST
Committed r286578 (?): <https://commits.webkit.org/r286578>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446074 [details].