Fixing some style related issues in WebGPU.

Changed the Requests/Response from tuples to named struct variants and also sorted in alphabetical order.
Replaced the ID generator functions from `globalscope` with a single function,
which returns a `RefMut` and can call the appropriate method to generate resource IDs.
This commit is contained in:
Istvan Miklos 2020-02-05 11:32:52 +01:00
parent 0f9b04680a
commit 000a5d543d
10 changed files with 561 additions and 472 deletions

View file

@ -91,11 +91,17 @@ impl GPUAdapterMethods for GPUAdapter {
};
let id = self
.global()
.wgpu_create_device_id(self.adapter.0.backend());
.wgpu_id_hub()
.create_device_id(self.adapter.0.backend());
if self
.channel
.0
.send(WebGPURequest::RequestDevice(sender, self.adapter, desc, id))
.send(WebGPURequest::RequestDevice {
sender,
adapter_id: self.adapter,
descriptor: desc,
device_id: id,
})
.is_err()
{
promise.reject_error(Error::Operation);
@ -107,7 +113,11 @@ impl GPUAdapterMethods for GPUAdapter {
impl AsyncWGPUListener for GPUAdapter {
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>) {
match response {
WebGPUResponse::RequestDevice(device_id, queue_id, _descriptor) => {
WebGPUResponse::RequestDevice {
device_id,
queue_id,
_descriptor,
} => {
let device = GPUDevice::new(
&self.global(),
self.channel.clone(),