Open Bug 1626624 Opened 4 years ago Updated 2 months ago

Support Wide Gamut Color in CSS with Display-P3

Categories

(Core :: Graphics, enhancement)

enhancement

Tracking

()

Tracking Status
firefox76 --- affected

People

(Reporter: alex.fdm, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

(Keywords: parity-chrome, parity-safari)

CSS Color Module Level 4 introduced syntax to use Display-P3 color space on the web:
color: color(display-p3 1 0.5 0)

This is already implemented in WebKit:
https://webkit.org/blog/10042/wide-gamut-color-in-css-with-display-p3/

I have already linked a bug for media-query support, but a separate bug for the Inspector is probably needed to.

Severity: normal → S3

Do we have support for wide-gamut color ranges on the gfx side even, or do we just convert to sRGB for rendering anyway?

Currently we convert images to the display profile and CSS colors remain uncorrected. On macOS we always use sRGB as the display profile and the OS will convert our combined sRGB content to the display profile for us.

It seems like it would be a reasonable start to convert wide gamut colors to sRGB.

If we end up converting colors into sRGB for rendering to screen and they are outside of sRGB gamut, we need to map them according to the spec here: https://drafts.csswg.org/css-color-4/#css-gamut-mapping

Blocks: 1815186
Depends on: 1823363
Duplicate of this bug: 1830268

1830268 is now resolved, shouldn't this issue be closed too?

Why? Bug 1830268 has been closed as a duplicate of this bug.

It may be worth revisiting the priority and severity here now that Figma supports this, as it is also an interop2022/2023 item.

Flags: needinfo?(emilio)

My understanding is that the CSS part of this seems basically done. The remaining bits seem actually layout/rendering, where for non-sRGB colors:

  • For sRGB displays we need to map to the sRGB gamut.
  • For non-sRGB displays we ideally carry the colors all the way across the pipeline.

Tiaan is my understanding correct? If so, should this move to either layout / graphics? I think this is worth doing sooner rather than later tho.

Flags: needinfo?(emilio) → needinfo?(tlouw)

Yes we have the colors now in different color spaces and can convert to a device color space for rendering, but right now the rendering back ends (webrender, cairo at least) doesn't seem to support anything other than sRGB, so this work should move there.

Flags: needinfo?(tlouw)
Component: CSS Parsing and Computation → Graphics
No longer blocks: css-color-4
No longer duplicate of this bug: 1830268

I tried enabling the following in about:config but its not working for me:

gfx.color_management.display_profile = /System/Library/ColorSync/Profiles/Display P3.icc
gfx.color_management.mode = 1
gfx.color_management.native_srgb = false

I should be more specific, when I go to this page I don't see a different in the P3 and non-P3 colors but do on Chrome and Safari: https://codepen.io/hashtag_dino/pen/gEvJQa

(In reply to GolDonMomotaro from comment #13)

I should be more specific, when I go to this page I don't see a different in the P3 and non-P3 colors but do on Chrome and Safari: https://codepen.io/hashtag_dino/pen/gEvJQa

Yeah, more things need to be hooked up for that to work

Like what?

ToDeviceColor needs support for displayP3 colors:
https://searchfox.org/mozilla-central/rev/8461ad1fc943ac560414322b66de5929ef10f706/gfx/thebes/gfxUtils.cpp#1783 and then the style system needs to be hooked up to use the displayP3 ToDeviceColor variant

You need to log in before you can comment on or make changes to this bug.