Add WebGPU identity management

Issue: https://github.com/servo/servo/issues/24706#issuecomment-557891841
This commit is contained in:
Istvan Miklos 2019-11-22 10:17:25 +01:00
parent ea32495504
commit b26598d470
6 changed files with 72 additions and 13 deletions

View file

@ -5,6 +5,7 @@
use crate::compartments::InCompartment;
use crate::dom::bindings::codegen::Bindings::GPUBinding::GPURequestAdapterOptions;
use crate::dom::bindings::codegen::Bindings::GPUBinding::{self, GPUMethods, GPUPowerPreference};
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::error::Error;
use crate::dom::bindings::refcounted::{Trusted, TrustedPromise};
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
@ -120,6 +121,7 @@ impl GPUMethods for GPU {
Some(GPUPowerPreference::High_performance) => wgpu::PowerPreference::HighPerformance,
None => wgpu::PowerPreference::Default,
};
let id = self.global().as_window().Navigator().create_adapter_id();
match self.wgpu_channel() {
Some(channel) => {
@ -128,6 +130,7 @@ impl GPUMethods for GPU {
.send(WebGPURequest::RequestAdapter(
sender,
wgpu::RequestAdapterOptions { power_preference },
id,
))
.unwrap();
},