Re: [csswg-drafts] [css-color-4] Disagreements over gamut mapping (#7610)

> good point, it's also worth testing somewhere where luminance is in SDR range. I think `color(srgb 1.05 0 0)` is such an example, which STP renders as `color(display-p3 0.9639 0.2133 0.1489)`. I'm not sure what to conclude from this, except that it's not merely clamping to RGB red, as Safari stable did.

It's not clamping to sRGB Red, it is clamping in the Display P3 color space. It isn't doing any fancy gamut mapping, just simple clipping in Display P3, as most new Macs have Display P3 monitors. Safari, due to its "color management" then works in Display P3. I guess this is new behavior between stable and STP. That's all that happening.

```python
>>> Color('color(srgb 1.05 0 0)').convert('display-p3').clip()
color(display-p3 0.96358 0.21239 0.14773 / 1)
```

As far as I can tell, Safari doesn't do anything but simple clipping currently. On Display P3 systems, it will clip to the Display P3 color space, and on sRGB systems, it will clip to sRGB. We can see this by using `color(srgb 2 0 0)`.

```python
>>> Color('color(srgb 2 0 0)').convert('display-p3').clip()
color(display-p3 1 0.44226 0.32203 / 1)
```

If it was doing gamut mapping as described in the CSS spec, the results would probably be white as the color would be beyond the luminance of Display P3. The CSS spec currently recommends gamut mapping in Oklch, so if we look at the slice of Oklch in which gamut mapping would occur, limiting the gamut to Display P3, we can see why it would go to white.

![gamut-p3](https://user-images.githubusercontent.com/1055125/185141317-5ccc05ad-7d28-4354-b92b-6e2363dfd7fb.png)

```python
>>> Color('color(srgb 2 0 0)').convert('display-p3').fit(method='oklch-chroma')
color(display-p3 1 1 1 / 1)
```



-- 
GitHub Notification of comment by facelessuser
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7610#issuecomment-1217987125 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 17 August 2022 13:07:17 UTC