1use std::rc::Rc;
6use std::sync::Arc;
7
8use script_webgpu::promise::{WebGPUGlobalTrait, WebGPUPromiseTrait};
9
10use crate::dom::bindings::reflector::DomGlobal;
11use crate::dom::types::GPUAdapter;
12use crate::dom::{GlobalScope, Promise};
13use crate::routed_promise::callback_promise;
14
15pub(crate) mod gpu;
16pub(crate) mod gpuadapter_promise_listener;
17pub(crate) mod gpuadapter {
18 pub(crate) type GPUAdapter = script_webgpu::gpuadapter::GPUAdapter<crate::DomTypeHolder>;
19}
20pub(crate) mod gpuadapterinfo {
21 pub(crate) type GPUAdapterInfo =
22 script_webgpu::gpuadapterinfo::GPUAdapterInfo<crate::DomTypeHolder>;
23}
24pub(crate) mod gpubindgroup;
25pub(crate) mod gpubindgrouplayout;
26pub(crate) mod gpubuffer;
27pub(crate) mod gpubufferusage {
28 pub(crate) type GPUBufferUsage =
29 script_webgpu::gpubufferusage::GPUBufferUsage<crate::DomTypeHolder>;
30}
31pub(crate) mod gpucanvascontext;
32pub(crate) mod gpucolorwrite;
33pub(crate) mod gpucommandbuffer {
34 pub(crate) type GPUCommandBuffer =
35 script_webgpu::gpucommandbuffer::GPUCommandBuffer<crate::DomTypeHolder>;
36}
37pub(crate) mod gpucommandencoder;
38pub(crate) mod gpucompilationinfo {
39 pub(crate) type GPUCompilationInfo =
40 script_webgpu::gpucompilationinfo::GPUCompilationInfo<crate::DomTypeHolder>;
41}
42pub(crate) mod gpucompilationmessage {
43 pub(crate) type GPUCompilationMessage =
44 script_webgpu::gpucompilationmessage::GPUCompilationMessage<crate::DomTypeHolder>;
45}
46pub(crate) mod gpucomputepassencoder;
47pub(crate) mod gpucomputepipeline;
48pub(crate) mod gpuconvert;
49pub(crate) mod gpudevice;
50pub(crate) mod gpudevicelostinfo {
51 pub(crate) type GPUDeviceLostInfo =
52 script_webgpu::gpudevicelostinfo::GPUDeviceLostInfo<crate::DomTypeHolder>;
53}
54pub(crate) mod gpuerror;
55pub(crate) mod gpuexternaltexture;
56pub(crate) mod gpuinternalerror;
57pub(crate) mod gpumapmode {
58 pub(crate) type GPUMapMode = script_webgpu::gpumapmode::GPUMapMode<crate::DomTypeHolder>;
59}
60pub(crate) mod gpuoutofmemoryerror;
61pub(crate) mod gpupipelineerror;
62#[expect(dead_code)]
63pub(crate) mod gpupipelinelayout;
64pub(crate) mod gpuqueryset;
65pub(crate) mod gpuqueue;
66pub(crate) mod gpurenderbundle {
67 pub(crate) type GPURenderBundle =
68 script_webgpu::gpurenderbundle::GPURenderBundle<crate::DomTypeHolder>;
69}
70pub(crate) mod gpurenderbundleencoder;
71pub(crate) mod gpurenderpassencoder;
72pub(crate) mod gpurenderpipeline;
73pub(crate) mod gpusampler;
74pub(crate) mod gpushadermodule;
75pub(crate) mod gpushaderstage {
76 pub(crate) type GPUShaderStage =
77 script_webgpu::gpushaderstage::GPUShaderStage<crate::DomTypeHolder>;
78}
79pub(crate) mod gpusupportedfeatures {
80 pub(crate) type GPUSupportedFeatures =
81 script_webgpu::gpusupportedfeatures::GPUSupportedFeatures<crate::DomTypeHolder>;
82}
83pub(crate) mod gpusupportedlimits {
84 pub(crate) type GPUSupportedLimits =
85 script_webgpu::gpusupportedlimits::GPUSupportedLimits<crate::DomTypeHolder>;
86}
87pub(crate) mod gputexture;
88pub(crate) mod gputextureusage {
89 pub(crate) type GPUTextureUsage =
90 script_webgpu::gputextureusage::GPUTextureUsage<crate::DomTypeHolder>;
91}
92pub(crate) mod gputextureview;
93pub(crate) mod gpuuncapturederrorevent;
94pub(crate) mod gpuvalidationerror;
95pub(crate) mod identityhub {
96 pub(crate) type IdentityHub = script_webgpu::identityhub::IdentityHub;
97}
98pub(crate) mod wgsllanguagefeatures {
99 pub(crate) type WGSLLanguageFeatures =
100 script_webgpu::wgsllanguagefeatures::WGSLLanguageFeatures<crate::DomTypeHolder>;
101}
102
103impl WebGPUPromiseTrait<crate::DomTypeHolder> for Promise {
104 fn callback_promise(
105 self: &Rc<Self>,
106 d: &GPUAdapter,
107 ) -> servo_base::generic_channel::GenericCallback<webgpu_traits::WebGPUDeviceResponse> {
108 let task_manager = <GPUAdapter as DomGlobal>::global(d).task_manager();
109 callback_promise(self, d, task_manager.dom_manipulation_task_source())
110 }
111}
112
113impl WebGPUGlobalTrait for GlobalScope {
114 fn global_wgpu_id_hub(&self) -> Arc<script_webgpu::identityhub::IdentityHub> {
115 self.wgpu_id_hub()
116 }
117}