Bug 233862 - [CSS Color 5] Update color-mix() to support srgb-linear and alpha premultiplication
Summary: [CSS Color 5] Update color-mix() to support srgb-linear and alpha premultipli...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-12-05 09:48 PST by Sam Weinig
Modified: 2021-12-06 13:59 PST (History)
11 users (show)

See Also:


Attachments
Patch (116.96 KB, patch)
2021-12-05 10:06 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (117.08 KB, patch)
2021-12-06 05:47 PST, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (117.02 KB, patch)
2021-12-06 07:54 PST, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>