@@ -65366,12 +65366,15 @@ typedef (<span>HTMLOrSVGImageElement</span> or
65366
65366
65367
65367
enum <dfn enum>PredefinedColorSpace</dfn> { "<span data-x="dom-PredefinedColorSpace-srgb">srgb</span>", "<span data-x="dom-PredefinedColorSpace-display-p3">display-p3</span>" };
65368
65368
65369
+ enum <dfn enum>CanvasColorType</dfn> { "<span data-x="dom-CanvasColorType-unorm8">unorm8</span>", "<span data-x="dom-CanvasColorType-float16">float16</span>" };
65370
+
65369
65371
enum <dfn enum>CanvasFillRule</dfn> { "<span data-x="dom-context-2d-fillRule-nonzero">nonzero</span>", "<span data-x="dom-context-2d-fillRule-evenodd">evenodd</span>" };
65370
65372
65371
65373
dictionary <dfn dictionary>CanvasRenderingContext2DSettings</dfn> {
65372
65374
boolean <span data-x="dom-CanvasRenderingContext2DSettings-alpha">alpha</span> = true;
65373
65375
boolean <span data-x="dom-CanvasRenderingContext2DSettings-desynchronized">desynchronized</span> = false;
65374
65376
<span>PredefinedColorSpace</span> <span data-x="dom-CanvasRenderingContext2DSettings-colorSpace">colorSpace</span> = "<span data-x="dom-PredefinedColorSpace-srgb">srgb</span>";
65377
+ <span>CanvasColorType</span> <span data-x="dom-CanvasRenderingContext2DSettings-colorType">colorType</span> = "<span data-x="dom-CanvasColorType-unorm8">unorm8</span>";
65375
65378
boolean <span data-x="dom-CanvasRenderingContext2DSettings-willReadFrequently">willReadFrequently</span> = false;
65376
65379
};
65377
65380
@@ -65820,6 +65823,19 @@ context.fillRect(100,0,50,50); // only this square remains</code></pre>
65820
65823
65821
65824
<hr>
65822
65825
65826
+ <p>The <code>CanvasColorType</code> enumeration is used to specify the <span
65827
+ data-x="concept-canvas-color-type">color type</span> of the canvas's backing store.</p>
65828
+
65829
+ <p>The "<dfn enum-value for="CanvasColorType"><code
65830
+ data-x="dom-CanvasColorType-unorm8">unorm8</code></dfn>" value indicates that the type
65831
+ for all color channels is 8-bit unsigned normalized.</p>
65832
+
65833
+ <p>The "<dfn enum-value for="CanvasColorType"><code
65834
+ data-x="dom-CanvasColorType-float16">float16</code></dfn>" value indicates that the type
65835
+ for all color channels is 16-bit floating point.</p>
65836
+
65837
+ <hr>
65838
+
65823
65839
<p>The <code>CanvasFillRule</code> enumeration is used to select the <dfn>fill rule</dfn>
65824
65840
algorithm by which to determine if a point is inside or outside a path.</p>
65825
65841
@@ -65962,6 +65978,12 @@ context.fillRect(100,0,50,50); // only this square remains</code></pre>
65962
65978
data-x="concept-canvas-color-space">color space</span> indicates the color space for the
65963
65979
<span>output bitmap</span>.</p>
65964
65980
65981
+ <p>The <code>CanvasSettings</code> object also has a <dfn
65982
+ data-x="concept-canvas-color-type">color type</dfn> setting of type
65983
+ <code>CanvasColorType</code>. The <code>CanvasSettings</code> object's <span
65984
+ data-x="concept-canvas-color-type">color type</span> indicates the data type of the
65985
+ color and alpha components of the pixels of the <span>output bitmap</span>.</p>
65986
+
65965
65987
<p>To <dfn data-x="canvas-setting-init-bitmap">initialize a <code>CanvasSettings</code> output
65966
65988
bitmap</dfn>, given a <code>CanvasSettings</code> <var>context</var> and a
65967
65989
<code>CanvasRenderingContext2DSettings</code> <var>settings</var>:</p>
@@ -65980,6 +66002,10 @@ context.fillRect(100,0,50,50); // only this square remains</code></pre>
65980
66002
<var>settings</var>["<dfn dict-member for="CanvasRenderingContext2DSettings"><code
65981
66003
data-x="dom-CanvasRenderingContext2DSettings-colorSpace">colorSpace</code></dfn>"].</p></li>
65982
66004
66005
+ <li><p>Set <var>context</var>'s <span data-x="concept-canvas-color-type">color type</span> to
66006
+ <var>settings</var>["<dfn dict-member for="CanvasRenderingContext2DSettings"><code
66007
+ data-x="dom-CanvasRenderingContext2DSettings-colorType">colorType</code></dfn>"].</p></li>
66008
+
65983
66009
<li><p>Set <var>context</var>'s <span data-x="concept-canvas-will-read-frequently">will read
65984
66010
frequently</span> to <var>settings</var>["<dfn dict-member
65985
66011
for="CanvasRenderingContext2DSettings"><code
@@ -71832,6 +71858,16 @@ interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
71832
71858
data-x="dom-canvas-toBlob">toBlob()</code> method to the canvas, given the appropriate dimensions,
71833
71859
has no visible effect beyond, at most, clipping colors of the canvas to a more narrow gamut.</p>
71834
71860
71861
+ <p>For image types that support multiple bit depths, the serialized image must use the bit depth
71862
+ that best preserves content of the underlying bitmap.</p>
71863
+
71864
+ <p class="example">For example, when serializing a 2D context that has
71865
+ <span data-x="concept-canvas-color-type">color type</span> of
71866
+ <span data-x="dom-CanvasColorType-float16">float16</span> to <var>type</var>
71867
+ "<code>image/png</code>", the resulting image would have 16 bits per sample.
71868
+ This serialization will still lose significant detail (all values less than 0.5/65535
71869
+ would be clamped to 0, and all values greater than 1 would be clamped to 1).</p>
71870
+
71835
71871
<p>If <var>type</var> is an image format that supports variable quality (such as
71836
71872
"<code>image/jpeg</code>"), <var>quality</var> is given, and <var>type</var> is not
71837
71873
"<code>image/png</code>", then, if <var>quality</var> <span data-x="js-Number">is a Number</span>
@@ -71971,9 +72007,9 @@ interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
71971
72007
<p>As certain colors can only be represented under premultiplied alpha (for instance, additive
71972
72008
colors), and others can only be represented under non-premultiplied alpha (for instance,
71973
72009
"invisible" colors which hold certain red, green, and blue values even with no opacity); and
71974
- division and multiplication on 8-bit integers (which is how canvas's colors are currently stored)
71975
- entails a loss of precision, converting between premultiplied and non-premultiplied alpha is a
71976
- lossy operation on colors that are not fully opaque.</p>
72010
+ division and multiplication using finite precision entails a loss of accuracy, converting between
72011
+ premultiplied and non-premultiplied alpha is a lossy operation on colors that are not fully
72012
+ opaque.</p>
71977
72013
71978
72014
<p>A <code>CanvasRenderingContext2D</code>'s <span>output bitmap</span> and an
71979
72015
<code>OffscreenCanvasRenderingContext2D</code>'s <span>output bitmap</span> must use premultiplied
0 commit comments