Skip to content

Commit e733df9

Browse files
committed
[css-color-4] Gamut mapping applies to unorm8 canvas as well as displays #10112
1 parent b73134b commit e733df9

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

‎css-color-4/Overview.bs‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6167,14 +6167,42 @@ Deviations from Perceptual Uniformity: Hue Curvature</h4>
61676167
<h3 id="css-gamut-mapping" algorithm="to CSS gamut map">
61686168
CSS Gamut Mapping to an RGB Destination</h3>
61696169

6170-
<wpt title="Actual values of color are not exposed to script, making this hard to test in an automated manner."></wpt>
6170+
<wpt title="Actual values of color are not exposed to script, making this hard to test in an automated manner. A choice of three algorithms also makes this harder to test"></wpt>
61716171

61726172
The three <dfn export>CSS gamut mapping algorithms</dfn>
61736173
apply to
61746174
Standard Dynamic Range (SDR) CSS colors
6175-
which are out of gamut
6176-
of an RGB display
6177-
and thus require to be <dfn export>css gamut mapped</dfn>.
6175+
which are out of gamut of:
6176+
6177+
<ul>
6178+
<li>an RGB display (which cannot represent out of gamut values in the frame buffer)</li>
6179+
<li>a canvas, with <a href="https://html.spec.whatwg.org/multipage/canvas.html#dom-canvascolortype-unorm8">unorm8</a>
6180+
backing store (thus, unable to store out of gamut values)</li>
6181+
</ul>
6182+
6183+
They thus require to be <dfn export>css gamut mapped</dfn>.
6184+
6185+
<div class="example" id="ex-p3-oog-display">
6186+
For example, given a Display P3 screen,
6187+
attempting to display the color color(display-p3 1.1 0.4 0.2)
6188+
will trigger gamut mapping,
6189+
because the red coordinate is outside the range 0 to 1;
6190+
gamut mapping will produce a similar, but lower chroma,
6191+
color, such as <span class="swatch" style="--color: #ff764f"></span>&nbsp;color(display-p3 1 0.473 0.314).
6192+
</div>
6193+
6194+
<div class="example" id="ex-p3-oog-canvas">
6195+
For example, given a 2d context
6196+
with colorSpace set to "display-p3"
6197+
and colorType set to "unorm8";
6198+
attempting to paint the color oklch(76% 0.27 60)
6199+
will trigger gamut mapping,
6200+
because once converted to Display P3,
6201+
the value color(display-p3 1.062 0.4954 -0.3115)
6202+
has a red coordinate greater than 1 and a negative blue coordinate.
6203+
Gamut mapping will produce a similar, but lower chroma,
6204+
color, such as <span class="swatch" style="--color: #ff8900"></span>&nbsp;color(display-p3 1 0.546 0).
6205+
</div>
61786206

61796207
Implementations my choose any of the three algorithms
61806208
based on their quality and runtime efficiency tradeoffs,

0 commit comments

Comments
 (0)
Sponsor
SponsoredKunjungi sekarang
Promo