Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 994527 of OffscreenCanvas

  • Revision slug: Web/API/OffscreenCanvas
  • Revision title: OffscreenCanvas
  • Revision id: 994527
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment TIL: This API does not yet work for Canvas 2D (bug 801176)

Revision Content

{{APIRef("Canvas API")}} {{SeeCompatTable}}

The OffscreenCanvas interface provides a canvas that can be rendered off screen. It is available in both, the window and in a worker context.

Note: This API is currently implemented for WebGL1 and WebGL2 contexts only. See {{bug(801176)}} for Canvas 2D API support from workers.

Constructors

{{domxref("OffscreenCanvas.OffscreenCanvas", "OffscreenCanvas()")}}
OffscreenCanvas constructor. Creates a new OffscreenCanvas object.

Properties

{{domxref("OffscreenCanvas.height")}}
The height of the offscreen canvas.
{{domxref("OffscreenCanvas.width")}}
The width of the offscreen canvas.

Methods

{{domxref("OffscreenCanvas.getContext()")}}
Returns a rendering context for the offscreen canvas.
{{domxref("OffscreenCanvas.toBlob()")}}
Creates a {{domxref("Blob")}} object representing the image contained in the canvas.
{{domxref("OffscreenCanvas.transferToImageBitmap()")}}
Creates an {{domxref("ImageBitmap")}} object from the most recently rendered image of the OffscreenCanvas.

Specifications

{{WhyNoSpecStart}} Currently drafted as a proposal: OffscreenCanvas.{{WhyNoSpecEnd}}

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatNo}} {{CompatGeckoDesktop(44)}} [1] {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatGeckoMobile(44)}} [1] {{CompatNo}} {{CompatNo}} {{CompatNo}}

[1] This feature is behind a feature preference setting. In about:config, set gfx.offscreencanvas.enabled to true.

See also

  • {{domxref("CanvasRenderingContext2D")}}

Revision Source

<div>{{APIRef("Canvas API")}} {{SeeCompatTable}}</div>

<p>The <strong><code>OffscreenCanvas</code></strong> interface provides a canvas that can be rendered off screen. It is available in both, the window and in a <a href="/en-US/docs/Web/API/Web_Workers_API">worker</a> context.</p>

<div class="note">
<p><strong>Note</strong>: This API is currently implemented for <a href="/en-US/docs/Web/API/WebGLRenderingContext">WebGL1</a> and <a href="/en-US/docs/Web/API/WebGL2RenderingContext">WebGL2</a> contexts only. See {{bug(801176)}} for <a href="/en-US/docs/Web/API/Canvas_API">Canvas 2D API</a> support from workers.</p>
</div>

<h2 id="Constructors">Constructors</h2>

<dl>
 <dt>{{domxref("OffscreenCanvas.OffscreenCanvas", "OffscreenCanvas()")}}</dt>
 <dd><code>OffscreenCanvas</code> constructor. Creates a new <code>OffscreenCanvas</code> object.</dd>
</dl>

<h2 id="Properties">Properties</h2>

<dl>
 <dt>{{domxref("OffscreenCanvas.height")}}</dt>
 <dd>The height of the offscreen canvas.</dd>
 <dt>{{domxref("OffscreenCanvas.width")}}</dt>
 <dd>The width of the offscreen canvas.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{domxref("OffscreenCanvas.getContext()")}}</dt>
 <dd>Returns a rendering context for the offscreen canvas.</dd>
</dl>

<dl>
 <dt>{{domxref("OffscreenCanvas.toBlob()")}}</dt>
 <dd>Creates a {{domxref("Blob")}} object representing the image contained in the canvas.</dd>
</dl>

<dl>
 <dt>{{domxref("OffscreenCanvas.transferToImageBitmap()")}}</dt>
 <dd>Creates an {{domxref("ImageBitmap")}} object from the most recently rendered image of the <code>OffscreenCanvas</code>.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<p>{{WhyNoSpecStart}} Currently drafted as a proposal: <a href="https://wiki.whatwg.org/wiki/OffscreenCanvas">OffscreenCanvas</a>.{{WhyNoSpecEnd}}</p>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoDesktop(44)}} [1]</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoMobile(44)}} [1]</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] This feature is behind a feature preference setting. In about:config, set <code>gfx.offscreencanvas.enabled</code> to <code>true</code>.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("CanvasRenderingContext2D")}}</li>
</ul>
Revert to this revision