GPU: getPreferredCanvasFormat() メソッド
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
GPU
インターフェイスの getPreferredCanvasFormat()
メソッドは、現在のシステムにおける 8 ビット深度で通常のダイナミックレンジのコンテンツを表示する用の最適なキャンバステクスチャーの形式を返します。
これは、GPUCanvasContext.configure()
を呼び出す際に format
の値を現在のシステムで最適なものにするためによく用いられます。これは推奨される方法です。キャンバスコンテキストを設定する際に適した形式を用いないと、プラットフォームによっては、テクスチャーのコピーが増えるなどの追加のオーバーヘッドが発生する可能性があります。
構文
js
getPreferredCanvasFormat()
引数
なし
返値
キャンバステクスチャーの形式を表す文字列です。rgba8unorm
および bgra8unorm
を取りえます。
例外
なし
例
js
const canvas = document.querySelector("#gpuCanvas");
const context = canvas.getContext("webgpu");
context.configure({
device: device,
format: navigator.gpu.getPreferredCanvasFormat(),
alphaMode: "premultiplied",
});
仕様書
Specification |
---|
WebGPU # dom-gpu-getpreferredcanvasformat |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getPreferredCanvasFormat |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- In development. Supported in a pre-release version.
- In development. Supported in a pre-release version.
- No support
- No support
- Experimental. Expect behavior to change in the future.
- See implementation notes.
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.