From 0cb00a6e89d83d4e16e6616f7af8819bd894b0da Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sun, 22 Sep 2024 09:10:54 +0530 Subject: BREAKING(webgpu/unstable): move `width` and `height` options to `UnsafeWindowSurface` constructor (#24200) Fixes https://github.com/denoland/deno/issues/23508 `width` and `height` are required to configure the wgpu surface because Deno is headless and depends on user to create a window. The options were non-standard extension of `GPUCanvasConfiguration#configure`. This PR adds a required options parameter with the `width` and `height` options to `Deno.UnsafeWindowSurface` constructor. ```typescript // Old, non-standard extension of GPUCanvasConfiguration const surface = new Deno.UnsafeWindowSurface("x11", displayHandle, windowHandle); const context = surface.getContext(); context.configure({ width: 600, height: 800, /* ... */ }); ``` ```typescript // New const surface = new Deno.UnsafeWindowSurface({ system: "x11", windowHandle, displayHandle, width: 600, height: 800, }); const context = surface.getContext(); context.configure({ /* ... */ }); ``` --- cli/tsc/dts/lib.deno.unstable.d.ts | 10 +++++++--- cli/tsc/dts/lib.deno_webgpu.d.ts | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'cli/tsc') diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 3a3bf037b..cafa539b5 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -28,9 +28,13 @@ declare namespace Deno { */ export class UnsafeWindowSurface { constructor( - system: "cocoa" | "win32" | "x11" | "wayland", - windowHandle: Deno.PointerValue, - displayHandle: Deno.PointerValue, + options: { + system: "cocoa" | "win32" | "x11" | "wayland"; + windowHandle: Deno.PointerValue; + displayHandle: Deno.PointerValue; + width: number; + height: number; + }, ); getContext(context: "webgpu"): GPUCanvasContext; present(): void; diff --git a/cli/tsc/dts/lib.deno_webgpu.d.ts b/cli/tsc/dts/lib.deno_webgpu.d.ts index 3a602d78a..e8d813823 100644 --- a/cli/tsc/dts/lib.deno_webgpu.d.ts +++ b/cli/tsc/dts/lib.deno_webgpu.d.ts @@ -1372,8 +1372,6 @@ declare interface GPUCanvasConfiguration { viewFormats?: GPUTextureFormat[]; colorSpace?: "srgb" | "display-p3"; alphaMode?: GPUCanvasAlphaMode; - width: number; - height: number; } /** @category GPU */ declare interface GPUCanvasContext { -- cgit v1.2.3