RESOLVED FIXED 235496
Support interpolating colors with missing/none components via color-mix()
https://bugs.webkit.org/show_bug.cgi?id=235496
Summary Support interpolating colors with missing/none components via color-mix()
Sam Weinig
Reported 2022-01-23 10:44:18 PST
Support interpolating colors with missing/none components
Attachments
Patch (82.46 KB, patch)
2022-01-23 10:59 PST, Sam Weinig
no flags
Patch (81.75 KB, patch)
2022-01-23 11:01 PST, Sam Weinig
no flags
Patch (81.95 KB, patch)
2022-01-23 16:04 PST, Sam Weinig
no flags
Sam Weinig
Comment 1 2022-01-23 10:59:20 PST
EWS Watchlist
Comment 2 2022-01-23 11:01:32 PST
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Sam Weinig
Comment 3 2022-01-23 11:01:49 PST
Darin Adler
Comment 4 2022-01-23 11:55:55 PST
Comment on attachment 449757 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=449757&action=review > Source/WebCore/platform/graphics/ColorInterpolation.h:37 > +template<AlphaPremultiplication alphaPremultiplication, typename InterpolationMethodColorSpace> I suggest you omit the template argument name "alphaPremultiplication" here. Also, if you wanted to make the next line of code way shorter, maybe you could add ColorType as a third template argument with a default value of typename InterpolationMethodColorSpace::ColorType? No caller would ever specify that argument explicitly, so no actual code bloat, but it would make the argument list below easier to read. Not sure it would work. > Source/WebCore/platform/graphics/ColorInterpolation.h:47 > +// MARK: - Premultiplication agnostic interpolation helpers. I think a hyphen is needed in the phrase "premultiplication-agnostic". > Source/WebCore/platform/graphics/ColorInterpolation.h:65 > +float interpolateHue(InterpolationMethodColorSpace interpolationMethodColorSpace, float componentFromColor1, double color1Multiplier, float componentFromColor2, double color2Multiplier) Why is it that interpolateComponent does not account for NaN by default, but interpolateHue does, and so do many other functions below? Maybe interpolateComponent should be named interpolateComponetWithoutAccountingForNaN? > Source/WebCore/platform/graphics/ColorTypes.h:136 > template<typename ComponentType> > constexpr bool constexprIsNaN(ComponentType value) Probably should move this to MathExtras.h. It seems like roughly speaking this is in a family with clzConstexpr, ctzConstexpr, getLSBSetConstexpr, and getMSBSetConstexpr, in MathExtras.h, strcmpConstExpr, in SortedArrayMap.h, and isSortedConstExpr and allOfConstExpr in StdLibExtras.h. We have three naming schemes here, and some functions that are in the Extras headers, but others that are not.
Sam Weinig
Comment 5 2022-01-23 16:02:51 PST
(In reply to Darin Adler from comment #4) > Comment on attachment 449757 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=449757&action=review > > > Source/WebCore/platform/graphics/ColorInterpolation.h:37 > > +template<AlphaPremultiplication alphaPremultiplication, typename InterpolationMethodColorSpace> > > I suggest you omit the template argument name "alphaPremultiplication" here. Fixed. > > Also, if you wanted to make the next line of code way shorter, maybe you > could add ColorType as a third template argument with a default value of > typename InterpolationMethodColorSpace::ColorType? No caller would ever > specify that argument explicitly, so no actual code bloat, but it would make > the argument list below easier to read. Not sure it would work. > > > Source/WebCore/platform/graphics/ColorInterpolation.h:47 > > +// MARK: - Premultiplication agnostic interpolation helpers. > > I think a hyphen is needed in the phrase "premultiplication-agnostic". Fixed. > > > Source/WebCore/platform/graphics/ColorInterpolation.h:65 > > +float interpolateHue(InterpolationMethodColorSpace interpolationMethodColorSpace, float componentFromColor1, double color1Multiplier, float componentFromColor2, double color2Multiplier) > > Why is it that interpolateComponent does not account for NaN by default, but > interpolateHue does, and so do many other functions below? Maybe > interpolateComponent should be named > interpolateComponetWithoutAccountingForNaN? > > > Source/WebCore/platform/graphics/ColorTypes.h:136 > > template<typename ComponentType> > > constexpr bool constexprIsNaN(ComponentType value) > > Probably should move this to MathExtras.h. > > It seems like roughly speaking this is in a family with clzConstexpr, > ctzConstexpr, getLSBSetConstexpr, and getMSBSetConstexpr, in MathExtras.h, > strcmpConstExpr, in SortedArrayMap.h, and isSortedConstExpr and > allOfConstExpr in StdLibExtras.h. > > We have three naming schemes here, and some functions that are in the Extras > headers, but others that are not. I'll do this in a follow up. Do you have a preferred naming convention? I kind of prefer "Constexpr" over "ConstExpr" just because the name of the keyword is all the same case, but I don't feel strongly.
Sam Weinig
Comment 6 2022-01-23 16:04:02 PST
Darin Adler
Comment 7 2022-01-23 16:43:59 PST
(In reply to Sam Weinig from comment #5) > I'll do this in a follow up. Do you have a preferred naming convention? I > kind of prefer "Constexpr" over "ConstExpr" just because the name of the > keyword is all the same case, but I don't feel strongly. I thought it was a good choice that you put constexpr first in the name of your function because it could be recognizably the keyword since it's still all lowercase. Sadly there are other disadvantages to that approach; leaving "constexpr" unmolested requires capitalizing the function name, which won’t work well for "ctz". I slightly prefer ConstExpr; neither Constexpr nor ConstExpr looks right to me, but the latter looks more correct (admit this is wholly subjective).
Darin Adler
Comment 8 2022-01-23 16:44:49 PST
We also change the function name to our style, so is_sorted becomes isSorted. Can imagine it being is_sorted_constexpr, but this way lies madness?
Darin Adler
Comment 9 2022-01-23 16:46:24 PST
Hey, I’m also curious what your thoughts are on the other half of my comments, the ones you didn’t respond to: - third template argument - interpolateComponetWithoutAccountingForNaN Not insisting on anything, but would love to know what you think about those two.
EWS
Comment 10 2022-01-23 16:58:21 PST
Committed r288427 (246318@main): <https://commits.webkit.org/246318@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 449769 [details].
Radar WebKit Bug Importer
Comment 11 2022-01-23 17:16:57 PST
Darin Adler
Comment 12 2022-01-23 17:19:20 PST
Oh no, now I see you took my suggestion and used my name: interpolateComponetWithoutAccountingForNaN Typo, and all! I wrote componet!
Note You need to log in before you can comment on or make changes to this bug.