Skip to content

Commit 97f6e4f

Browse files
committed
incorporate texElementImage2D feedback
1 parent 948dc72 commit 97f6e4f

2 files changed

Lines changed: 42 additions & 116 deletions

File tree

specs/latest/2.0/index.html

Lines changed: 31 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ <h3>Types</h3>
266266
<pre class="idl">
267267
typedef long long GLint64;
268268
typedef unsigned long long GLuint64;
269+
270+
dictionary WebGLCopyElementImageConfig {
271+
GLfloat sx = 0;
272+
GLfloat sy = 0;
273+
GLfloat swidth;
274+
GLfloat sheight;
275+
GLsizei width;
276+
GLsizei height;
277+
};
269278
</pre>
270279

271280
<!-- ======================================================================================================= -->
@@ -935,6 +944,9 @@ <h3><a name="WEBGLRENDERINGCONTEXT">The WebGL context</a></h3>
935944
optional unsigned long long srcOffset = 0,
936945
optional GLuint srcLengthOverride = 0);
937946

947+
undefined texElementImage2D(GLenum target, GLenum internalformat, (Element or ElementImage) element,
948+
optional WebGLCopyElementImageConfig config = {}); // May throw DOMException
949+
938950
undefined uniform1fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
939951
optional GLuint srcLength = 0);
940952
undefined uniform2fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
@@ -2212,116 +2224,28 @@ <h4>Texture objects</h4>
22122224
</dd>
22132225

22142226
<dt class="idl-code">
2215-
[throws] undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLenum format, GLenum type, Element element);
2216-
</dt>
2217-
<dd>
2218-
<p>Renders the given element to the currently bound WebGLTexture.</p>
2219-
<p>The width and height of the texture are derived from the CSS borderbox of the element at the time of rendering. Add links to whatwg.</p>
2220-
<p>TBD: define state of rendering + security. These will be more links to whatwg</p><p></p>
2221-
<p>If this function is called with an <code>HTMLElement</code> that is not a direct descendant of the <a href="#context-canvas">canvas</a> of the current context, generates an <code>INVALID_OPERATION</code> error.</p>
2222-
<p>If a WebGLBuffer is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
2223-
<p>The combination of <em>internalformat</em>, <em>format</em>, and <em>type</em> must be listed in the following table:</p>
2224-
<table id="TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE_2">
2225-
<tr><th>Internal Format</th><th>Format</th><th>Type</th></tr>
2226-
<tr><td>RGB</td><td>RGB</td><td>UNSIGNED_BYTE</td></tr>
2227-
<tr><td>RGBA</td><td>RGBA</td><td>UNSIGNED_BYTE</td></tr>
2228-
<tr><td>RGB16F</td><td>RGB</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2229-
<tr><td>RGB32F</td><td>RGB</td><td>FLOAT</td></tr>
2230-
<tr><td>RGBA16F</td><td>RGBA</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2231-
<tr><td>RGBA32F</td><td>RGBA</td><td>FLOAT</td></tr>
2232-
</table>
2233-
<p>
2234-
If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met,
2235-
generates an <code>INVALID_OPERATION</code> error.
2236-
</p>
2237-
</dd>
2238-
2239-
<dt class="idl-code">
2240-
[throws] undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, Element element);
2241-
</dt>
2242-
<dd>
2243-
<p>Renders the given element to the currently bound WebGLTexture.</p>
2244-
<p>The width and height of the texture are set by the passed in width and height.</p>
2245-
<p>TBD: define state of rendering + security. These will be more links to whatwg</p><p></p>
2246-
<p>If this function is called with an <code>HTMLElement</code> that is not a direct descendant of the <a href="#context-canvas">canvas</a> of the current context, generates an <code>INVALID_OPERATION</code> error.</p>
2247-
<p>If a WebGLBuffer is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
2248-
<p>The combination of <em>internalformat</em>, <em>format</em>, and <em>type</em> must be listed in the following table:</p>
2249-
<table id="TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE_2">
2250-
<tr><th>Internal Format</th><th>Format</th><th>Type</th></tr>
2251-
<tr><td>RGB</td><td>RGB</td><td>UNSIGNED_BYTE</td></tr>
2252-
<tr><td>RGBA</td><td>RGBA</td><td>UNSIGNED_BYTE</td></tr>
2253-
<tr><td>RGB16F</td><td>RGB</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2254-
<tr><td>RGB32F</td><td>RGB</td><td>FLOAT</td></tr>
2255-
<tr><td>RGBA16F</td><td>RGBA</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2256-
<tr><td>RGBA32F</td><td>RGBA</td><td>FLOAT</td></tr>
2257-
</table>
2258-
<p>
2259-
If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met,
2260-
generates an <code>INVALID_OPERATION</code> error.
2261-
</p>
2262-
</dd>
2263-
2264-
<dt class="idl-code">
2265-
[throws] undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLfloat sx, GLfloat sy, GLfloat swidth, GLfloat sheight, GLenum format, GLenum type, Element element)
2266-
</dt>
2267-
<dd>
2268-
<p>Renders the given element to the currently bound WebGLTexture.</p>
2269-
<p>sx, sy, swidth and sheight define a rectangular slice of the element's borderbox. This slice determines the size of the generated texture.</p>
2270-
<p>TBD: define state of rendering + security. These will be more links to whatwg</p><p></p>
2271-
<p>If this function is called with an <code>HTMLElement</code> that is not a direct descendant of the <a href="#context-canvas">canvas</a> of the current context, generates an <code>INVALID_OPERATION</code> error.</p>
2272-
<p>If a WebGLBuffer is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
2273-
<p>The combination of <em>internalformat</em>, <em>format</em>, and <em>type</em> must be listed in the following table:</p>
2274-
<table id="TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE_2">
2275-
<tr><th>Internal Format</th><th>Format</th><th>Type</th></tr>
2276-
<tr><td>RGB</td><td>RGB</td><td>UNSIGNED_BYTE</td></tr>
2277-
<tr><td>RGBA</td><td>RGBA</td><td>UNSIGNED_BYTE</td></tr>
2278-
<tr><td>RGB16F</td><td>RGB</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2279-
<tr><td>RGB32F</td><td>RGB</td><td>FLOAT</td></tr>
2280-
<tr><td>RGBA16F</td><td>RGBA</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2281-
<tr><td>RGBA32F</td><td>RGBA</td><td>FLOAT</td></tr>
2282-
</table>
2283-
<p>
2284-
If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met,
2285-
generates an <code>INVALID_OPERATION</code> error.
2286-
</p>
2287-
</dd>
2288-
2289-
<dt class="idl-code">
2290-
[throws] undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLfloat sx, GLfloat sy, GLfloat swidth, GLfloat sheight, GLsizei width, GLsizei height, GLenum format, GLenum type, Element element)
2227+
[throws] undefined texElementImage2D(GLenum target, GLenum internalformat, (Element or ElementImage) element,
2228+
optional WebGLCopyElementImageConfig config = {});
22912229
</dt>
22922230
<dd>
2293-
<p>Renders the given element to the currently bound WebGLTexture.</p>
2294-
<p>sx, sy, swidth and sheight define a rectangular slice of the element's when its size is set to the width and height. This slice determines the size of the generated texture.</p>
2295-
<p>TBD: define state of rendering + security. These will be more links to whatwg</p><p></p>
2296-
<p>If this function is called with an <code>HTMLElement</code> that is not a direct descendant of the <a href="#context-canvas">canvas</a> of the current context, generates an <code>INVALID_OPERATION</code> error.</p>
2297-
<p>If a WebGLBuffer is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
2298-
<p>The combination of <em>internalformat</em>, <em>format</em>, and <em>type</em> must be listed in the following table:</p>
2299-
<table id="TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE_2">
2300-
<tr><th>Internal Format</th><th>Format</th><th>Type</th></tr>
2301-
<tr><td>RGB</td><td>RGB</td><td>UNSIGNED_BYTE</td></tr>
2302-
<tr><td>RGBA</td><td>RGBA</td><td>UNSIGNED_BYTE</td></tr>
2303-
<tr><td>RGB16F</td><td>RGB</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2304-
<tr><td>RGB32F</td><td>RGB</td><td>FLOAT</td></tr>
2305-
<tr><td>RGBA16F</td><td>RGBA</td><td>HALF_FLOAT<br>FLOAT</td></tr>
2306-
<tr><td>RGBA32F</td><td>RGBA</td><td>FLOAT</td></tr>
2231+
<p>Renders <code>element</code> to the currently bound <code>WebGLTexture</code> at level zero.</p>
2232+
<p>The <code>element</code> argument identifies an <a href="https://whatpr.org/html/11588/canvas.html#concept-canvas-element-image-snapshots">element image snapshot</a>, as defined by HTML. The HTML algorithms define how element image snapshots are created, updated, retrieved, and filtered for security- or privacy-sensitive information. If <code>element</code> is an <code>Element</code>, the source rendering is the snapshot from the most recent <code>paint</code> event for the <a href="#context-canvas">canvas</a> of the current context. If <code>element</code> is an <code>ElementImage</code>, the source rendering is that captured snapshot.</p>
2233+
<p>If this function is called with an <code>Element</code> that is not a direct child of the <a href="#context-canvas">canvas</a> of the current context in the most recent rendering update, generates an <code>INVALID_OPERATION</code> error.</p>
2234+
<p>If <code>target</code> is not <code>TEXTURE_2D</code>, generates an <code>INVALID_ENUM</code> error.</p>
2235+
<p>If no <code>WebGLTexture</code> is bound to <code>target</code>, generates an <code>INVALID_OPERATION</code> error.</p>
2236+
<p>If a <code>WebGLBuffer</code> is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
2237+
<p><code>config.sx</code> and <code>config.sy</code> are in CSS pixels and default to 0. <code>config.swidth</code> and <code>config.sheight</code> are in CSS pixels and default to the source's natural width minus <code>config.sx</code> and natural height minus <code>config.sy</code>, respectively. Together, these members define the source rectangle of the element image snapshot to render.</p>
2238+
<p><code>config.width</code> and <code>config.height</code> are in texels and define the generated texture size. If omitted, each dimension defaults to the source rectangle size scaled by the inverse of the canvas-grid-to-CSS scaling factor used to produce the element image snapshot.</p>
2239+
<p>The <code>internalformat</code> argument must be one of the values in the following table. Each value has an implied source format of <code>RGBA</code> and the listed implied source type:</p>
2240+
<table>
2241+
<tr><th>Internal Format</th><th>Implied Source Type</th></tr>
2242+
<tr><td>RGBA8</td><td>UNSIGNED_BYTE</td></tr>
2243+
<tr><td>SRGB8_ALPHA8</td><td>UNSIGNED_BYTE</td></tr>
2244+
<tr><td>RGBA16F</td><td>HALF_FLOAT</td></tr>
2245+
<tr><td>RGBA32F</td><td>FLOAT</td></tr>
23072246
</table>
2308-
<p>
2309-
If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met,
2310-
generates an <code>INVALID_OPERATION</code> error.
2311-
</p>
2312-
</dd>
2313-
2314-
<dt class="idl-code">
2315-
[throws] undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
2316-
GLenum format, GLenum type, Element element);
2317-
</dt>
2318-
<dd>
2319-
<p>Renders the given element to the currently bound WebGLTexture.</p>
2320-
<p>The texture is resized to <code>width</code> and <code>height</code>>. Add links to whatwg.</p>
2321-
<p>TBD: define state of rendering + security. These will be more links to whatwg</p><p></p>
2322-
<p>If this function is called with an <code>HTMLElement</code> that is not a direct descendant of the <a href="#context-canvas">canvas</a> of the current context, generates an <code>INVALID_OPERATION</code> error.</p>
2323-
<p>If a WebGLBuffer is bound to the <code>PIXEL_UNPACK_BUFFER</code> target, generates an <code>INVALID_OPERATION</code> error.</p>
2324-
<p>See <a href="../1.0/index.html#TEXTURE_TYPES_FORMATS_FROM_DOM_ELEMENTS_TABLE_2">texElementImage2D</a> for the interpretation of the <em>internalformat</em>, <em>format</em> and <em>type</em> arguments, and notes on the <code>UNPACK_PREMULTIPLY_ALPHA_WEBGL</code> pixel storage parameter. </p>
2247+
<p>If <code>internalformat</code> is not listed in the table above, generates an <code>INVALID_ENUM</code> error.</p>
2248+
<p>If any supplied numeric member of <code>config</code> is negative, or if the computed source rectangle width, source rectangle height, texture width, or texture height is not positive, generates an <code>INVALID_VALUE</code> error.</p>
23252249
<p>
23262250
If <a href="#PIXEL_STORE_PARAM_CONSTRAINTS">pixel store parameter constraints</a> are not met,
23272251
generates an <code>INVALID_OPERATION</code> error.

specs/latest/2.0/webgl2.idl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
typedef long long GLint64;
2828
typedef unsigned long long GLuint64;
2929

30+
dictionary WebGLCopyElementImageConfig {
31+
GLfloat sx = 0;
32+
GLfloat sy = 0;
33+
GLfloat swidth;
34+
GLfloat sheight;
35+
GLsizei width;
36+
GLsizei height;
37+
};
38+
3039

3140
[Exposed=(Window,Worker)]
3241
interface WebGLQuery : WebGLObject {
@@ -558,15 +567,8 @@ interface mixin WebGL2RenderingContextOverloads
558567
optional unsigned long long srcOffset = 0,
559568
optional GLuint srcLengthOverride = 0);
560569

561-
undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLenum format, GLenum type,
562-
Element element);
563-
undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
564-
GLenum format, GLenum type, Element element);
565-
undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLfloat sx, GLfloat sy,
566-
GLfloat swidth, GLfloat sheight, GLenum format, GLenum type, Element element);
567-
undefined texElementImage2D(GLenum target, GLint level, GLint internalformat, GLfloat sx, GLfloat sy,
568-
GLfloat swidth, GLfloat sheight, GLsizei width, GLsizei height, GLenum format,
569-
GLenum type, Element element);
570+
undefined texElementImage2D(GLenum target, GLenum internalformat, (Element or ElementImage) element,
571+
optional WebGLCopyElementImageConfig config = {}); // May throw DOMException
570572

571573
undefined uniform1fv(WebGLUniformLocation? location, Float32List data, optional unsigned long long srcOffset = 0,
572574
optional GLuint srcLength = 0);

0 commit comments

Comments
 (0)