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

Add drawingBufferColorSpace/unpackColorSpace attributes to WebGLRenderingContextBase. #3292

Merged
merged 6 commits into from
May 7, 2022
Merged
49 changes: 39 additions & 10 deletions specs/latest/1.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>
[Exposed=Worker] readonly attribute OffscreenCanvas canvas;
readonly attribute GLsizei drawingBufferWidth;
readonly attribute GLsizei drawingBufferHeight;
attribute PredefinedColorSpace colorSpace = "srgb";

[WebGLHandlesContextLoss] WebGLContextAttributes? getContextAttributes();
[WebGLHandlesContextLoss] boolean isContextLost();
Expand Down Expand Up @@ -1979,6 +1980,20 @@ <h4>Attributes</h4>
The actual height of the drawing buffer. May be different from the
<code>height</code> attribute of the <code>HTMLCanvasElement</code> if
the implementation is unable to satisfy the requested width or height.
<dt>
<code class=attribute-name>
<a id="DOM-WebGLRenderingContext-colorSpace">
colorSpace
</a>
</code>
of type <code><a href="https://html.spec.whatwg.org/multipage/canvas.html#predefinedcolorspace">PredefinedColorSpace</a></code>
<a href="#refsPREDEFINEDCOLORSPACE">(specification)</a>
<dd>
The color space in which the drawing buffer's contents are assumed to
have been produced. Changing this attribute affects the on-screen display
of the rendering context, but does not change the drawing buffer's
kainino0x marked this conversation as resolved.
Show resolved Hide resolved
contents. This attribute also affects how <code>TexImageSource</code>
kenrussell marked this conversation as resolved.
Show resolved Hide resolved
sources are uploaded to textures.
kenrussell marked this conversation as resolved.
Show resolved Hide resolved
</dl>

<!-- ======================================================================================================= -->
Expand Down Expand Up @@ -2653,10 +2668,23 @@ <h4>Texture objects</h4>
The width and height of the texture are set as specified in section
<a href="#TEXTURE_UPLOAD_SIZE">Texture Upload Width and Height</a>.<br><br>

The source image data is conceptually first converted to the data type and format
specified by the <em>format</em> and <em>type</em> arguments, and then transferred to
the WebGL implementation. Format conversion is performed according to the following table.
If a packed pixel format is specified which would imply loss of bits of precision from the
First, the source image data is conceptually converted to the color space
specified by the <a href="#DOM-WebGLRenderingContext-colorSpace">colorSpace</a>
attribute, except in the following situations:

<ul>
<li> the source image data is an <code>HTMLImageElement</code>, and
the <code>UNPACK_COLORSPACE_CONVERSION_WEBGL</code> pixel storage
parameter is set to <code>NONE</code>. </li>
<li> the source image data is an <code>ImageBitmap</code>, in which case
kenrussell marked this conversation as resolved.
Show resolved Hide resolved
all color space conversions were assumed to have occurred
during <code>ImageBitmap</code> construction. </li>
</ul>

Next, the source image data is converted to the data type and format specified by
the <em>format</em> and <em>type</em> arguments, and then transferred to the WebGL
implementation. Format conversion is performed according to the following table. If a
packed pixel format is specified which would imply loss of bits of precision from the
image data, this loss of precision must occur. <br><br>

<table class="foo">
Expand Down Expand Up @@ -2799,12 +2827,8 @@ <h4>Texture objects</h4>
<a href="#TEXTURE_UPLOAD_SIZE">Texture Upload Width and Height</a>.<br><br>

See <a href="#TEXIMAGE2D_HTML">texImage2D</a> for the interpretation of
the <em>format</em> and <em>type</em> arguments, and notes on
the <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> pixel storage parameter. <br><br>

See <a href="#PIXEL_STORAGE_PARAMETERS">Pixel Storage Parameters</a> for WebGL-specific
pixel storage parameters that affect the behavior of this function when it is called
with any argument type other than <code>ImageBitmap</code>. <br><br>
the <em>format</em> and <em>type</em> arguments, handling of WebGL-specific pixel
storage parameters, and potential color space transformations of the input. <br><br>

The first pixel transferred from the source to the WebGL implementation corresponds
to the upper left corner of the source. This behavior is modified by the
Expand Down Expand Up @@ -4555,6 +4579,11 @@ <h2>References</h2>
<dd>(Non-normative) <cite><a href="https://w3c.github.io/webcodecs/">WebCodecs API</a></cite>,
C. Cunningham, P. Adenot, B. Aboba. W3C.
</dd>
<dt id="refsPREDEFINEDCOLORSPACE">[PREDEFINEDCOLORSPACE]</dt>
<dd><cite><a href="https://html.spec.whatwg.org/multipage/canvas.html#predefinedcolorspace">
HTML Living Standard - The PredefinedColorSpace enum</a></cite>,
WHATWG.
</dd>
</dl>

<!-- ======================================================================================================= -->
Expand Down