Skip to content

Commit

Permalink
Remove OffscreenCanvas contexts' commit() method
Browse files Browse the repository at this point in the history
This goes beyond #3872 and removes the OffscreenCanvas contexts' commit(), method which has been superseded by requestAnimationFrame() since #3677 and is thus not strictly necessary anymore and might conflict with this new model.

Closes #3872.
  • Loading branch information
Kaiido committed Apr 18, 2024
1 parent c42d28e commit 95cb883
Showing 1 changed file with 18 additions and 66 deletions.
84 changes: 18 additions & 66 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -64034,8 +64034,7 @@ callback <dfn callback>BlobCallback</dfn> = undefined (<span>Blob</span>? blob);
<p>When its <span data-x="concept-canvas-context-mode">canvas context mode</span> is <span
data-x="concept-canvas-placeholder">placeholder</span>, a <code>canvas</code> element has no
rendering context. It serves as a placeholder for an <code>OffscreenCanvas</code> object, and
the content of the <code>canvas</code> element is updated by calling the <code
data-x="offscreencontext-commit">commit()</code> method of the <code>OffscreenCanvas</code>
the content of the <code>canvas</code> element is updated by the <code>OffscreenCanvas</code>
object's rendering context.</p>

<p>When a <code>canvas</code> element represents <span>embedded content</span>, it provides a
Expand Down Expand Up @@ -64329,13 +64328,13 @@ callback <dfn callback>BlobCallback</dfn> = undefined (<span>Blob</span>? blob);
<dt><code data-x=""><var>canvas</var>.<span subdfn data-x="dom-canvas-transferControlToOffscreen">transferControlToOffscreen</span>()</code></dt>

<dd>
<p>Returns a newly created <code>OffscreenCanvas</code> object that uses the <code>canvas</code>
element as a placeholder. Once the <code>canvas</code> element has become a placeholder for an
<code>OffscreenCanvas</code> object, its natural size can no longer be changed, and it cannot
have a rendering context. The content of the placeholder canvas is updated by calling the <code
data-x="offscreencontext-commit">commit()</code> method of the <code>OffscreenCanvas</code>
object's rendering context.
</p>
<p>Returns a newly created <code>OffscreenCanvas</code> object that uses the
<code>canvas</code> element as a placeholder. Once the <code>canvas</code> element has become a
placeholder for an <code>OffscreenCanvas</code> object, its natural size can no longer be
changed, and it cannot have a rendering context. The content of the placeholder canvas is
updated on the <code>OffscreenCanvas</code>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span>update the rendering</span>
steps.</p>
</dd>
</dl>

Expand Down Expand Up @@ -70323,14 +70322,10 @@ interface <dfn interface>OffscreenCanvas</dfn> : <span>EventTarget</span> {
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</dfn>, which is
typically in the DOM, whose embedded content is provided by the <code>OffscreenCanvas</code>
object. The bitmap of the <code>OffscreenCanvas</code> object is pushed to the <span
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span> by calling the
<dfn><code data-x="offscreencontext-commit">commit()</code></dfn> method of the
<code>OffscreenCanvas</code> object's rendering context. All rendering context types that can be
created by an <code>OffscreenCanvas</code> object must implement a <code
data-x="offscreencontext-commit">commit()</code> method. The exact behavior of the commit method
(e.g. whether it copies or transfers bitmaps) may vary, as defined by the rendering contexts'
respective specifications. Only the <span data-x="OffscreenCanvasRenderingContext2D">2D context
for offscreen canvases</span> is defined in this specification.</p>
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span> as part of
the <code>OffscreenCanvas</code>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span>update the rendering</span>
steps.</p>

<dl class="domintro">
<dt><code data-x=""><var>offscreenCanvas</var> = new <span subdfn data-x="dom-OffscreenCanvas">OffscreenCanvas</span>(<var>width</var>,
Expand Down Expand Up @@ -70621,9 +70616,9 @@ interface <dfn interface>OffscreenCanvas</dfn> : <span>EventTarget</span> {
<p class="note">If an <code>OffscreenCanvas</code> object whose dimensions were changed has
a <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span>, then
the <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span>'s
<span data-x="natural dimensions">natural size</span> will only be updated via the <code
data-x="offscreencontext-commit">commit()</code> method of the <code>OffscreenCanvas</code>
object's rendering context.</p>
<span data-x="natural dimensions">natural size</span> will only be updated during the
<code>OffscreenCanvas</code>'s <span>relevant agent</span>'s <span
data-x="concept-agent-event-loop">event loop</span>'s <span>update the rendering</span> steps.</p>

<dl class="domintro">
<dt><code data-x=""><var>promise</var> = <var>offscreenCanvas</var>.<span subdfn data-x="dom-OffscreenCanvas-convertToBlob">convertToBlob</span>([<var>options</var>])</code></dt>
Expand Down Expand Up @@ -70759,7 +70754,6 @@ interface <dfn interface>OffscreenCanvas</dfn> : <span>EventTarget</span> {

<pre><code class="idl">[Exposed=(Window,Worker)]
interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
undefined <span data-x="offscreencontext2d-commit">commit</span>();
readonly attribute <span>OffscreenCanvas</span> <span data-x="offscreencontext2d-canvas">canvas</span>;
};

Expand Down Expand Up @@ -70789,9 +70783,6 @@ interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
features;</p></li>
<li><p>its <code data-x="offscreencontext2d-canvas">canvas</code> attribute refers to an
<code>OffscreenCanvas</code> object rather than a <code>canvas</code> element;</p></li>
<li><p>it has a <code data-x="offscreencontext2d-commit">commit()</code> method for pushing the
rendered image to the context's <code>OffscreenCanvas</code> object's <span
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span>.</p></li>
</ul>

<p>An <code>OffscreenCanvasRenderingContext2D</code> object has a <dfn
Expand Down Expand Up @@ -70822,16 +70813,6 @@ interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
from which the <code>OffscreenCanvasRenderingContext2D</code> object was created.

<dl class="domintro">
<dt><code data-x=""><var>offscreenCanvasRenderingContext2D</var>.<span subdfn data-x="offscreencontext2d-commit">commit</span>()</code></dt>

<dd>
<p>Copies the rendering context's <span data-x="offscreencontext2d-bitmap">bitmap</span> to the
bitmap of the <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code>
element</span> of the <span>associated <code>OffscreenCanvas</code> object</span>. The copy
operation is synchronous. Calling this method is not needed for the transfer, since it happens
automatically during the <span>event loop</span> execution.</p>
</dd>

<dt><code data-x=""><var>offscreenCanvas</var> = <var>offscreenCanvasRenderingContext2D</var>.<span subdfn data-x="offscreencontext2d-canvas">canvas</span></code></dt>

<dd><p>Returns the <span>associated <code>OffscreenCanvas</code> object</span>.</p></dd>
Expand Down Expand Up @@ -70879,43 +70860,14 @@ interface <dfn interface>OffscreenCanvasRenderingContext2D</dfn> {
<li><p>Return <var>context</var>.</p></li>
</ol>

<p>The <dfn><code data-x="offscreencontext2d-commit">commit()</code></dfn> method, when invoked,
must run the following steps:</p>

<ol>
<li><p>If this <code>OffscreenCanvasRenderingContext2D</code>'s <span>associated
<code>OffscreenCanvas</code> object</span> does not have a <span
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span>, then
return.</p></li>

<li><p>Let <var>image</var> be a copy of this <code>OffscreenCanvasRenderingContext2D</code>'s
<span data-x="offscreencontext2d-bitmap">bitmap</span>, including the value of its <span
data-x="offscreencontext2d-origin-clean">origin-clean</span> flag.</p></li>

<li>
<p><span>Queue an element task</span> on the <span>DOM manipulation task source</span> given
the <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span>
to set the <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code>
element</span>'s <span>output bitmap</span> to be a reference to <var>image</var>.</p>

<p class="note">If <var>image</var> has different dimensions than the bitmap previously
referenced as the <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code>
element</span>'s <span>output bitmap</span>, then this task will result in a change in
the <span data-x="offscreencanvas-placeholder">placeholder <code>canvas</code>
element</span>'s <span data-x="natural dimensions">natural size</span>, which can affect
document layout.</p>
</li>
</ol>

<p class="note">Implementations are encouraged to short-circuit the graphics update steps of
the <span>window event loop</span> for the purposes of updating the contents of a <span
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span> to the
display. This could mean, for example, that the <code
data-x="offscreencontext2d-commit">commit()</code> method can copy the bitmap contents directly
to a graphics buffer that is mapped to the physical display location of the <span
display. This could mean, for example, that the bitmap contents are copied directly to a graphics
buffer that is mapped to the physical display location of the <span
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span>. This or
similar short-circuiting approaches can significantly reduce display latency, especially in cases
where the <code data-x="offscreencontext2d-commit">commit()</code> method is invoked from a
where the <code>OffscreenCanvas</code> is updated from a
<span>worker event loop</span> and the <span>window event loop</span> of the <span
data-x="offscreencanvas-placeholder">placeholder <code>canvas</code> element</span> is busy.
However, such shortcuts cannot have any script-observable side-effects. This means that the
Expand Down

0 comments on commit 95cb883

Please sign in to comment.