Skip to content

Commit bfd2e96

Browse files
authored
Add GPUCanvasContext (#2404)
Co-authored-by: saschanaz <saschanaz@users.noreply.github.com>
1 parent 7d725b7 commit bfd2e96

17 files changed

+964
-23
lines changed

baselines/dom.generated.d.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,19 @@ interface FullscreenOptions {
805805
navigationUI?: FullscreenNavigationUI;
806806
}
807807

808+
interface GPUCanvasConfiguration {
809+
alphaMode?: GPUCanvasAlphaMode;
810+
colorSpace?: PredefinedColorSpace;
811+
format: GPUTextureFormat;
812+
toneMapping?: GPUCanvasToneMapping;
813+
usage?: GPUTextureUsageFlags;
814+
viewFormats?: GPUTextureFormat[];
815+
}
816+
817+
interface GPUCanvasToneMapping {
818+
mode?: GPUCanvasToneMappingMode;
819+
}
820+
808821
interface GPUColorDict {
809822
a: number;
810823
b: number;
@@ -15003,6 +15016,50 @@ declare var GPUBuffer: {
1500315016
new(): GPUBuffer;
1500415017
};
1500515018

15019+
/**
15020+
* The **`GPUCanvasContext`** interface of the WebGPU API represents the WebGPU rendering context of a <canvas> element, returned via an HTMLCanvasElement.getContext() call with a contextType of "webgpu".
15021+
* Available only in secure contexts.
15022+
*
15023+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext)
15024+
*/
15025+
interface GPUCanvasContext {
15026+
/**
15027+
* The **`canvas`** read-only property of the GPUCanvasContext interface returns a reference to the canvas that the context was created from.
15028+
*
15029+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/canvas)
15030+
*/
15031+
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
15032+
/**
15033+
* The **`configure()`** method of the GPUCanvasContext interface configures the context to use for rendering with a given GPUDevice. When called the canvas will initially be cleared to transparent black.
15034+
*
15035+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/configure)
15036+
*/
15037+
configure(configuration: GPUCanvasConfiguration): void;
15038+
/**
15039+
* The **`getConfiguration()`** method of the GPUCanvasContext interface returns the current configuration set for the context.
15040+
*
15041+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getConfiguration)
15042+
*/
15043+
getConfiguration(): GPUCanvasConfiguration | null;
15044+
/**
15045+
* The **`getCurrentTexture()`** method of the GPUCanvasContext interface returns the next GPUTexture to be composited to the document by the canvas context.
15046+
*
15047+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getCurrentTexture)
15048+
*/
15049+
getCurrentTexture(): GPUTexture;
15050+
/**
15051+
* The **`unconfigure()`** method of the GPUCanvasContext interface removes any previously-set context configuration, and destroys any textures returned via getCurrentTexture() while the canvas context was configured.
15052+
*
15053+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/unconfigure)
15054+
*/
15055+
unconfigure(): void;
15056+
}
15057+
15058+
declare var GPUCanvasContext: {
15059+
prototype: GPUCanvasContext;
15060+
new(): GPUCanvasContext;
15061+
};
15062+
1500615063
/**
1500715064
* The **`GPUCommandBuffer`** interface of the WebGPU API represents a pre-recorded list of GPU commands that can be submitted to a GPUQueue for execution.
1500815065
* Available only in secure contexts.
@@ -43648,7 +43705,7 @@ type MediaProvider = MediaStream | MediaSource | Blob;
4364843705
type MessageEventSource = WindowProxy | MessagePort | ServiceWorker;
4364943706
type MutationRecordType = "attributes" | "characterData" | "childList";
4365043707
type NamedCurve = string;
43651-
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
43708+
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext | GPUCanvasContext;
4365243709
type OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull | null;
4365343710
type OnErrorEventHandler = OnErrorEventHandlerNonNull | null;
4365443711
type OptionalPostfixToken<T extends string> = ` ${T}` | "";
@@ -43660,7 +43717,7 @@ type RTCRtpSenderTransform = RTCRtpScriptTransform;
4366043717
type ReadableStreamController<T> = ReadableStreamDefaultController<T> | ReadableByteStreamController;
4366143718
type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>;
4366243719
type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
43663-
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
43720+
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext | GPUCanvasContext;
4366443721
type ReportList = Report[];
4366543722
type RequestInfo = Request | string;
4366643723
type SanitizerAttribute = string | SanitizerAttributeNamespace;
@@ -43741,6 +43798,8 @@ type FontFaceLoadStatus = "error" | "loaded" | "loading" | "unloaded";
4374143798
type FontFaceSetLoadStatus = "loaded" | "loading";
4374243799
type FullscreenNavigationUI = "auto" | "hide" | "show";
4374343800
type GPUBufferMapState = "mapped" | "pending" | "unmapped";
43801+
type GPUCanvasAlphaMode = "opaque" | "premultiplied";
43802+
type GPUCanvasToneMappingMode = "extended" | "standard";
4374443803
type GPUCompilationMessageType = "error" | "info" | "warning";
4374543804
type GPUDeviceLostReason = "destroyed" | "unknown";
4374643805
type GPUIndexFormat = "uint16" | "uint32";

baselines/serviceworker.generated.d.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ interface FontFaceSetLoadEventInit extends EventInit {
272272
fontfaces?: FontFace[];
273273
}
274274

275+
interface GPUCanvasConfiguration {
276+
alphaMode?: GPUCanvasAlphaMode;
277+
colorSpace?: PredefinedColorSpace;
278+
format: GPUTextureFormat;
279+
toneMapping?: GPUCanvasToneMapping;
280+
usage?: GPUTextureUsageFlags;
281+
viewFormats?: GPUTextureFormat[];
282+
}
283+
284+
interface GPUCanvasToneMapping {
285+
mode?: GPUCanvasToneMappingMode;
286+
}
287+
275288
interface GPUColorDict {
276289
a: number;
277290
b: number;
@@ -4446,6 +4459,50 @@ declare var GPUBuffer: {
44464459
new(): GPUBuffer;
44474460
};
44484461

4462+
/**
4463+
* The **`GPUCanvasContext`** interface of the WebGPU API represents the WebGPU rendering context of a <canvas> element, returned via an HTMLCanvasElement.getContext() call with a contextType of "webgpu".
4464+
* Available only in secure contexts.
4465+
*
4466+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext)
4467+
*/
4468+
interface GPUCanvasContext {
4469+
/**
4470+
* The **`canvas`** read-only property of the GPUCanvasContext interface returns a reference to the canvas that the context was created from.
4471+
*
4472+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/canvas)
4473+
*/
4474+
readonly canvas: OffscreenCanvas;
4475+
/**
4476+
* The **`configure()`** method of the GPUCanvasContext interface configures the context to use for rendering with a given GPUDevice. When called the canvas will initially be cleared to transparent black.
4477+
*
4478+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/configure)
4479+
*/
4480+
configure(configuration: GPUCanvasConfiguration): void;
4481+
/**
4482+
* The **`getConfiguration()`** method of the GPUCanvasContext interface returns the current configuration set for the context.
4483+
*
4484+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getConfiguration)
4485+
*/
4486+
getConfiguration(): GPUCanvasConfiguration | null;
4487+
/**
4488+
* The **`getCurrentTexture()`** method of the GPUCanvasContext interface returns the next GPUTexture to be composited to the document by the canvas context.
4489+
*
4490+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getCurrentTexture)
4491+
*/
4492+
getCurrentTexture(): GPUTexture;
4493+
/**
4494+
* The **`unconfigure()`** method of the GPUCanvasContext interface removes any previously-set context configuration, and destroys any textures returned via getCurrentTexture() while the canvas context was configured.
4495+
*
4496+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/unconfigure)
4497+
*/
4498+
unconfigure(): void;
4499+
}
4500+
4501+
declare var GPUCanvasContext: {
4502+
prototype: GPUCanvasContext;
4503+
new(): GPUCanvasContext;
4504+
};
4505+
44494506
/**
44504507
* The **`GPUCommandBuffer`** interface of the WebGPU API represents a pre-recorded list of GPU commands that can be submitted to a GPUQueue for execution.
44514508
* Available only in secure contexts.
@@ -12839,7 +12896,7 @@ type ImageDataArray = Uint8ClampedArray<ArrayBuffer>;
1283912896
type Int32List = Int32Array<ArrayBufferLike> | GLint[];
1284012897
type MessageEventSource = MessagePort | ServiceWorker;
1284112898
type NamedCurve = string;
12842-
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
12899+
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext | GPUCanvasContext;
1284312900
type OnErrorEventHandler = OnErrorEventHandlerNonNull | null;
1284412901
type PerformanceEntryList = PerformanceEntry[];
1284512902
type PushMessageDataInit = BufferSource | string;
@@ -12880,6 +12937,8 @@ type FontFaceLoadStatus = "error" | "loaded" | "loading" | "unloaded";
1288012937
type FontFaceSetLoadStatus = "loaded" | "loading";
1288112938
type FrameType = "auxiliary" | "nested" | "none" | "top-level";
1288212939
type GPUBufferMapState = "mapped" | "pending" | "unmapped";
12940+
type GPUCanvasAlphaMode = "opaque" | "premultiplied";
12941+
type GPUCanvasToneMappingMode = "extended" | "standard";
1288312942
type GPUCompilationMessageType = "error" | "info" | "warning";
1288412943
type GPUDeviceLostReason = "destroyed" | "unknown";
1288512944
type GPUIndexFormat = "uint16" | "uint32";

baselines/sharedworker.generated.d.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,19 @@ interface FontFaceSetLoadEventInit extends EventInit {
216216
fontfaces?: FontFace[];
217217
}
218218

219+
interface GPUCanvasConfiguration {
220+
alphaMode?: GPUCanvasAlphaMode;
221+
colorSpace?: PredefinedColorSpace;
222+
format: GPUTextureFormat;
223+
toneMapping?: GPUCanvasToneMapping;
224+
usage?: GPUTextureUsageFlags;
225+
viewFormats?: GPUTextureFormat[];
226+
}
227+
228+
interface GPUCanvasToneMapping {
229+
mode?: GPUCanvasToneMappingMode;
230+
}
231+
219232
interface GPUColorDict {
220233
a: number;
221234
b: number;
@@ -4129,6 +4142,50 @@ declare var GPUBuffer: {
41294142
new(): GPUBuffer;
41304143
};
41314144

4145+
/**
4146+
* The **`GPUCanvasContext`** interface of the WebGPU API represents the WebGPU rendering context of a <canvas> element, returned via an HTMLCanvasElement.getContext() call with a contextType of "webgpu".
4147+
* Available only in secure contexts.
4148+
*
4149+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext)
4150+
*/
4151+
interface GPUCanvasContext {
4152+
/**
4153+
* The **`canvas`** read-only property of the GPUCanvasContext interface returns a reference to the canvas that the context was created from.
4154+
*
4155+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/canvas)
4156+
*/
4157+
readonly canvas: OffscreenCanvas;
4158+
/**
4159+
* The **`configure()`** method of the GPUCanvasContext interface configures the context to use for rendering with a given GPUDevice. When called the canvas will initially be cleared to transparent black.
4160+
*
4161+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/configure)
4162+
*/
4163+
configure(configuration: GPUCanvasConfiguration): void;
4164+
/**
4165+
* The **`getConfiguration()`** method of the GPUCanvasContext interface returns the current configuration set for the context.
4166+
*
4167+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getConfiguration)
4168+
*/
4169+
getConfiguration(): GPUCanvasConfiguration | null;
4170+
/**
4171+
* The **`getCurrentTexture()`** method of the GPUCanvasContext interface returns the next GPUTexture to be composited to the document by the canvas context.
4172+
*
4173+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getCurrentTexture)
4174+
*/
4175+
getCurrentTexture(): GPUTexture;
4176+
/**
4177+
* The **`unconfigure()`** method of the GPUCanvasContext interface removes any previously-set context configuration, and destroys any textures returned via getCurrentTexture() while the canvas context was configured.
4178+
*
4179+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/unconfigure)
4180+
*/
4181+
unconfigure(): void;
4182+
}
4183+
4184+
declare var GPUCanvasContext: {
4185+
prototype: GPUCanvasContext;
4186+
new(): GPUCanvasContext;
4187+
};
4188+
41324189
/**
41334190
* The **`GPUCommandBuffer`** interface of the WebGPU API represents a pre-recorded list of GPU commands that can be submitted to a GPUQueue for execution.
41344191
* Available only in secure contexts.
@@ -12509,7 +12566,7 @@ type ImageDataArray = Uint8ClampedArray<ArrayBuffer>;
1250912566
type Int32List = Int32Array<ArrayBufferLike> | GLint[];
1251012567
type MessageEventSource = MessagePort | ServiceWorker;
1251112568
type NamedCurve = string;
12512-
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
12569+
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext | GPUCanvasContext;
1251312570
type OnErrorEventHandler = OnErrorEventHandlerNonNull | null;
1251412571
type PerformanceEntryList = PerformanceEntry[];
1251512572
type ReadableStreamController<T> = ReadableStreamDefaultController<T> | ReadableByteStreamController;
@@ -12546,6 +12603,8 @@ type FontDisplay = "auto" | "block" | "fallback" | "optional" | "swap";
1254612603
type FontFaceLoadStatus = "error" | "loaded" | "loading" | "unloaded";
1254712604
type FontFaceSetLoadStatus = "loaded" | "loading";
1254812605
type GPUBufferMapState = "mapped" | "pending" | "unmapped";
12606+
type GPUCanvasAlphaMode = "opaque" | "premultiplied";
12607+
type GPUCanvasToneMappingMode = "extended" | "standard";
1254912608
type GPUCompilationMessageType = "error" | "info" | "warning";
1255012609
type GPUDeviceLostReason = "destroyed" | "unknown";
1255112610
type GPUIndexFormat = "uint16" | "uint32";

baselines/ts5.5/dom.generated.d.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,19 @@ interface FullscreenOptions {
802802
navigationUI?: FullscreenNavigationUI;
803803
}
804804

805+
interface GPUCanvasConfiguration {
806+
alphaMode?: GPUCanvasAlphaMode;
807+
colorSpace?: PredefinedColorSpace;
808+
format: GPUTextureFormat;
809+
toneMapping?: GPUCanvasToneMapping;
810+
usage?: GPUTextureUsageFlags;
811+
viewFormats?: GPUTextureFormat[];
812+
}
813+
814+
interface GPUCanvasToneMapping {
815+
mode?: GPUCanvasToneMappingMode;
816+
}
817+
805818
interface GPUColorDict {
806819
a: number;
807820
b: number;
@@ -14989,6 +15002,50 @@ declare var GPUBuffer: {
1498915002
new(): GPUBuffer;
1499015003
};
1499115004

15005+
/**
15006+
* The **`GPUCanvasContext`** interface of the WebGPU API represents the WebGPU rendering context of a <canvas> element, returned via an HTMLCanvasElement.getContext() call with a contextType of "webgpu".
15007+
* Available only in secure contexts.
15008+
*
15009+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext)
15010+
*/
15011+
interface GPUCanvasContext {
15012+
/**
15013+
* The **`canvas`** read-only property of the GPUCanvasContext interface returns a reference to the canvas that the context was created from.
15014+
*
15015+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/canvas)
15016+
*/
15017+
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
15018+
/**
15019+
* The **`configure()`** method of the GPUCanvasContext interface configures the context to use for rendering with a given GPUDevice. When called the canvas will initially be cleared to transparent black.
15020+
*
15021+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/configure)
15022+
*/
15023+
configure(configuration: GPUCanvasConfiguration): void;
15024+
/**
15025+
* The **`getConfiguration()`** method of the GPUCanvasContext interface returns the current configuration set for the context.
15026+
*
15027+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getConfiguration)
15028+
*/
15029+
getConfiguration(): GPUCanvasConfiguration | null;
15030+
/**
15031+
* The **`getCurrentTexture()`** method of the GPUCanvasContext interface returns the next GPUTexture to be composited to the document by the canvas context.
15032+
*
15033+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/getCurrentTexture)
15034+
*/
15035+
getCurrentTexture(): GPUTexture;
15036+
/**
15037+
* The **`unconfigure()`** method of the GPUCanvasContext interface removes any previously-set context configuration, and destroys any textures returned via getCurrentTexture() while the canvas context was configured.
15038+
*
15039+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/GPUCanvasContext/unconfigure)
15040+
*/
15041+
unconfigure(): void;
15042+
}
15043+
15044+
declare var GPUCanvasContext: {
15045+
prototype: GPUCanvasContext;
15046+
new(): GPUCanvasContext;
15047+
};
15048+
1499215049
/**
1499315050
* The **`GPUCommandBuffer`** interface of the WebGPU API represents a pre-recorded list of GPU commands that can be submitted to a GPUQueue for execution.
1499415051
* Available only in secure contexts.
@@ -43622,7 +43679,7 @@ type MediaProvider = MediaStream | MediaSource | Blob;
4362243679
type MessageEventSource = WindowProxy | MessagePort | ServiceWorker;
4362343680
type MutationRecordType = "attributes" | "characterData" | "childList";
4362443681
type NamedCurve = string;
43625-
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
43682+
type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext | GPUCanvasContext;
4362643683
type OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull | null;
4362743684
type OnErrorEventHandler = OnErrorEventHandlerNonNull | null;
4362843685
type OptionalPostfixToken<T extends string> = ` ${T}` | "";
@@ -43634,7 +43691,7 @@ type RTCRtpSenderTransform = RTCRtpScriptTransform;
4363443691
type ReadableStreamController<T> = ReadableStreamDefaultController<T> | ReadableByteStreamController;
4363543692
type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>;
4363643693
type ReadableStreamReader<T> = ReadableStreamDefaultReader<T> | ReadableStreamBYOBReader;
43637-
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
43694+
type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext | GPUCanvasContext;
4363843695
type ReportList = Report[];
4363943696
type RequestInfo = Request | string;
4364043697
type SanitizerAttribute = string | SanitizerAttributeNamespace;
@@ -43715,6 +43772,8 @@ type FontFaceLoadStatus = "error" | "loaded" | "loading" | "unloaded";
4371543772
type FontFaceSetLoadStatus = "loaded" | "loading";
4371643773
type FullscreenNavigationUI = "auto" | "hide" | "show";
4371743774
type GPUBufferMapState = "mapped" | "pending" | "unmapped";
43775+
type GPUCanvasAlphaMode = "opaque" | "premultiplied";
43776+
type GPUCanvasToneMappingMode = "extended" | "standard";
4371843777
type GPUCompilationMessageType = "error" | "info" | "warning";
4371943778
type GPUDeviceLostReason = "destroyed" | "unknown";
4372043779
type GPUIndexFormat = "uint16" | "uint32";

0 commit comments

Comments
 (0)