HTMLCanvasElement: transferControlToOffscreen() メソッド
Baseline 2023Newly available
Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
HTMLCanvasElement.transferControlToOffscreen()
メソッドは、メインスレッドまたはワーカーの OffscreenCanvas
オブジェクトへ制御を委譲します。
構文
js
transferControlToOffscreen()
引数
なし。
返値
OffscreenCanvas
オブジェクト。
例
次の例は、メインスレッド上の OffscreenCanvas
オブジェクトに制御を移譲する方法です。
js
const htmlCanvas = document.createElement("canvas");
const offscreen = htmlCanvas.transferControlToOffscreen();
const gl = offscreen.getContext("webgl");
// Some drawing using the gl context…
次の例は、ワーカー上の OffscreenCanvas
オブジェクトに制御を移す方法を示しています。
js
const offscreen = document.querySelector("canvas").transferControlToOffscreen();
const worker = new Worker("myworkerurl.js");
worker.postMessage({ canvas: offscreen }, [offscreen]);
仕様書
Specification |
---|
HTML # dom-canvas-transfercontroltooffscreen-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
transferControlToOffscreen |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
- このメソッドを定義しているインターフェイス、
HTMLCanvasElement
OffscreenCanvas