Bug 215896

Summary: CSS invert() and opacity() filter implementations should use linear transfer functions for clarity and simplicity
Product: WebKit Reporter: frankhome61
Component: CSSAssignee: frankhome61
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, darin, dino, esprehn+autocc, ews-watchlist, glenn, kondapallykalyan, mmaxfield, pdr, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description frankhome61 2020-08-27 11:32:07 PDT
In WebKit's implementation of CSS filters invert() and opacity(), FEComponentTransfer is used and the transfer function is surprisingly to table, instead of linear. Looking at the CSS spec, https://drafts.fxtf.org/filter-effects/#invertEquivalent
invert() and opacity() is implemented using "table" with just 2 values, which is equivalent to using a linear function. I propose to change the implementation of invert() and opacity() to use linear transfer function as well for simplicity and clarity.
Comment 1 Radar WebKit Bug Importer 2020-08-27 11:32:37 PDT
<rdar://problem/67887069>
Comment 2 frankhome61 2020-08-27 11:45:35 PDT
Created attachment 407421 [details]
Patch
Comment 3 Darin Adler 2020-08-27 17:50:28 PDT
Comment on attachment 407421 [details]
Patch

Does this have any effect on performance?
Comment 4 frankhome61 2020-08-27 18:06:35 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 407421 [details]
> Patch
> 
> Does this have any effect on performance?

No, not that I know of. By looking at the code, FEComponentTransfer eventually converts linear, discrete table transfer functions to a hash map that maps each R,G,B values to a new value by applying the transfer function. So I don't expect this patch to cause any performance hit at all
Comment 5 EWS 2020-08-27 18:24:21 PDT
Committed r266266: <https://trac.webkit.org/changeset/266266>

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