GPU: Methode getPreferredCanvasFormat()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.
Sicherer Kontext: Diese Funktion ist nur in sicheren Kontexten (HTTPS) in einigen oder allen unterstützenden Browsern verfügbar.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die getPreferredCanvasFormat()
-Methode der GPU
-Schnittstelle gibt das optimale Texturformat für Canvas zur Anzeige von Inhalten mit 8-Bit-Tiefe im Standard-Dynamikumfang auf dem aktuellen System zurück.
Dies wird häufig verwendet, um einem Aufruf von GPUCanvasContext.configure()
den optimalen format
-Wert für das aktuelle System bereitzustellen. Dies wird empfohlen – wenn Sie das bevorzugte Format beim Konfigurieren des Canvas-Kontexts nicht verwenden, kann je nach Plattform zusätzlicher Overhead entstehen, wie z. B. zusätzliche Texturkopien.
Syntax
getPreferredCanvasFormat()
Parameter
Keine.
Rückgabewert
Ein String, der ein Texturformat für das Canvas angibt. Der Wert kann rgba8unorm
oder bgra8unorm
sein.
Ausnahmen
Keine.
Beispiele
const canvas = document.querySelector("#gpuCanvas");
const context = canvas.getContext("webgpu");
context.configure({
device: device,
format: navigator.gpu.getPreferredCanvasFormat(),
alphaMode: "premultiplied",
});
Spezifikationen
Specification |
---|
WebGPU # dom-gpu-getpreferredcanvasformat |
Browser-Kompatibilität
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.
Siehe auch
- Die WebGPU API