Bug 233862

Summary: [CSS Color 5] Update color-mix() to support srgb-linear and alpha premultiplication
Product: WebKit Reporter: Sam Weinig <sam>
Component: CSSAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, esprehn+autocc, ews-watchlist, glenn, gyuyoung.kim, heycam, macpherson, menard, ryuan.choi, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Sam Weinig 2021-12-05 09:48:19 PST
Color interpolation has been updated to allow interpolation in the srgb-linear space and been clarified that mixing happens with alpha premultiplied colors.
Comment 1 Sam Weinig 2021-12-05 10:06:13 PST
Created attachment 445988 [details]
Patch
Comment 2 Cameron McCormack (:heycam) 2021-12-05 19:34:23 PST
Comment on attachment 445988 [details]
Patch

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

I didn't look at the test changes closely.

> Source/WebCore/platform/graphics/ColorInterpolation.h:282
> +        WebCore::ColorInterpolationColorSpace::SRGB,
> +        WebCore::ColorInterpolationColorSpace::XYZD50,

Missing SRGBLinear.

> Source/WebCore/platform/graphics/ColorNormalization.h:64
> +template<typename ComponentType> inline ComponentType normalizeHue(ComponentType hue)
> +{
> +    return std::fmod(std::fmod(hue, 360.0) + 360.0, 360.0);
> +}

Do we want to try to stick to floats and use fmodf when ComponentType is a float?
Comment 3 Sam Weinig 2021-12-06 05:47:51 PST
Created attachment 446034 [details]
Patch
Comment 4 Sam Weinig 2021-12-06 07:54:06 PST
Created attachment 446038 [details]
Patch
Comment 5 Sam Weinig 2021-12-06 07:55:50 PST
(In reply to Cameron McCormack (:heycam) from comment #2)
> Comment on attachment 445988 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=445988&action=review
> 
> I didn't look at the test changes closely.
> 
> > Source/WebCore/platform/graphics/ColorInterpolation.h:282
> > +        WebCore::ColorInterpolationColorSpace::SRGB,
> > +        WebCore::ColorInterpolationColorSpace::XYZD50,
> 
> Missing SRGBLinear.

Fixed.

> 
> > Source/WebCore/platform/graphics/ColorNormalization.h:64
> > +template<typename ComponentType> inline ComponentType normalizeHue(ComponentType hue)
> > +{
> > +    return std::fmod(std::fmod(hue, 360.0) + 360.0, 360.0);
> > +}
> 
> Do we want to try to stick to floats and use fmodf when ComponentType is a
> float?

This would subtly change the output of mixing to not be consistent with parsing (which uses doubles in normalization currently). We probably need to think about the use of doubles in the parsing code and decide where the appropriate point to cast down to float is and apply that holistically.

Thanks for the review.
Comment 6 EWS 2021-12-06 13:58:30 PST
Committed r286568 (?): <https://commits.webkit.org/r286568>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 446038 [details].
Comment 7 Radar WebKit Bug Importer 2021-12-06 13:59:21 PST
<rdar://problem/86122341>