Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds wide-gamut support #3882

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -59318,6 +59318,17 @@ dictionary <dfn>AssignedNodesOptions</dfn> {
<dd w-nodev>
<pre><code class="idl" data-x="">typedef (<span>CanvasRenderingContext2D</span> or <span>ImageBitmapRenderingContext</span> or <span>WebGLRenderingContext</span>) <dfn>RenderingContext</dfn>;

enum <dfn>CanvasPixelFormat</dfn> {
"8-8-8-8", // default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume you're using this pattern (which looks kinda odd to me, and doesn't match the structure of the other option) instead of something like int8 because we want to be open to things like 10-10-10-2 or whatever in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly.

"float16",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No trailing comma

};

dictionary <dfn>ImageEncodeOptions</dfn> {
DOMString <span data-x="image-encode-options-type">type</span> = "image/png";
unrestricted double <span data-x="image-encode-options-quality">quality</span> = 1.0;
CanvasPixelFormat <span data-x="image-encode-options-pixelformat">pixelFormat</span> = "8-8-8-8";
};

[Exposed=Window,
<span>HTMLConstructor</span>]
interface <dfn>HTMLCanvasElement</dfn> : <span>HTMLElement</span> {
Expand Down Expand Up @@ -59817,6 +59828,7 @@ enum <dfn>CanvasFillRule</dfn> { "<span data-x="dom-context-2d-fillRule-nonzero"

dictionary <dfn>CanvasRenderingContext2DSettings</dfn> {
boolean <span data-x="dom-CanvasRenderingContext2DSettings-alpha">alpha</span> = true;
<span>CanvasPixelFormat</span> <span data-x="dom-CanvasRenderingContext2DSettings-pixelFormat">pixelFormat</span> = "8-8-8-8";
};

enum <dfn>ImageSmoothingQuality</dfn> { "<span data-x="dom-context-2d-imageSmoothingQuality-low">low</span>", "<span data-x="dom-context-2d-imageSmoothingQuality-medium">medium</span>", "<span data-x="dom-context-2d-imageSmoothingQuality-high">high</span>" };
Expand Down Expand Up @@ -60080,6 +60092,15 @@ interface <dfn>Path2D</dfn> {

</dd>

<dt><var>context</var> = <var>canvas</var> . <code data-x="dom-canvas-getContext">getContext</code>('2d' [, { [ <code data-x="dom-CanvasRenderingContext2DSettings-pixelFormat">pixelFormat</code>: "float16" ] } ] )</dt>

<dd>

<p>Returns a <code>CanvasRenderingContext2D</code> object backed by a 16-bit
float backing.</p>

</dd>

<dt><var>context</var> . <code subdfn data-x="dom-context-2d-canvas">canvas</code></dt>

<dd>
Expand Down Expand Up @@ -60183,6 +60204,16 @@ interface <dfn>Path2D</dfn> {
<dd>If false, then set <var>context</var>'s <span data-x="concept-canvas-alpha">alpha</span>
flag to false.</dd>
</dl>

<dl>
<dt><dfn><code data-x="dom-CanvasRenderingContext2DSettings-pixelFormat">pixelFormat</code></dfn></dt>
<dd>Decides the backing storage for the <code data-x="dom-context-2d-canvas">canvas</code>'s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a description, but doesn't make any statements requiring the user agent to do anything. Some questions:

  • What does this impact, observably? Does it change the numeric values returned from any canvas or pixel-reading APIs?
  • Is "backing storage" the same as the CanvasRenderingContext2D's output bitmap?
  • What does "optional" mean? Does it mean fall back to 8-8-8, or throw an exception, or...?
  • Where is this information stored? What parts of the spec later use it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fserb looks like this is waiting for you to address change requests from @domenic

context. Support for "8-8-8-8" is mandatory. All other formats are optional. When using "8-8-8-8",
one byte is used for each color channel and 1 byte used for alpha. When using float
formats, values outside of [0, 1] range can be used to represent colors outside of the color

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires the transfer function to be fully specified outside [0,1].

Could I have a pointer to where that is defined?

gamut, depending on the capabilities of the device and output display.</dd>
</dl>

</li>

<li><p>Return <var>context</var>.</p></li>
Expand Down Expand Up @@ -65041,11 +65072,6 @@ dictionary <dfn>ImageBitmapRenderingContextSettings</dfn> {
<pre><code class="idl" data-x="">typedef (<span>OffscreenCanvasRenderingContext2D</span> or
<span>WebGLRenderingContext</span>) <dfn>OffscreenRenderingContext</dfn>;

dictionary <dfn>ImageEncodeOptions</dfn> {
DOMString <span data-x="image-encode-options-type">type</span> = "image/png";
unrestricted double <span data-x="image-encode-options-quality">quality</span> = 1.0;
};

enum <dfn>OffscreenRenderingContextId</dfn> { "<span data-x="offscreen-context-type-2d">2d</span>", "<span data-x="offscreen-context-type-webgl">webgl</span>" };

[<span data-x="dom-OffscreenCanvas">Constructor</span>([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height), Exposed=(Window,Worker), <span>Transferable</span>]
Expand Down Expand Up @@ -65352,8 +65378,9 @@ interface <dfn>OffscreenCanvas</dfn> : <span>EventTarget</span> {

<ol>
<li><p>Let <var>file</var> be <span data-x="a serialization of the bitmap as a file">a
serialization of <var>bitmap</var> as a file</span>, with <var>options</var>'s <dfn><code
data-x="image-encode-options-type">type</code></dfn> and <dfn><code
serialization of the <code>Canvas</code>'s bitmap as a file</span>, with <var>options</var>'s
<dfn><code data-x="image-encode-options-type">type</code></dfn>, <dfn><code
data-x="image-encode-options-pixelformat">pixelFormat</code></dfn> and <dfn><code
data-x="image-encode-options-quality">quality</code></dfn>.</p></li>

<li>
Expand Down