mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
This breaks the `script_traits` dependency on `webgpu`. In general, the `traits` crates shouldn't depend on Servo non-`traits` crates. This is necessary to move "script to constellation" messages to the `constellation_traits` crate, making it the entire API for talking to the constellation. This will break a circular dependency when that happens. Testing: Successfully building is enough of a test for this one as it is mainly moving types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
63 lines
2 KiB
Rust
63 lines
2 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use dom_struct::dom_struct;
|
|
use js::rust::MutableHandleValue;
|
|
use webgpu_traits::ShaderCompilationInfo;
|
|
|
|
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPUCompilationInfoMethods;
|
|
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object_with_proto};
|
|
use crate::dom::bindings::root::DomRoot;
|
|
use crate::dom::bindings::utils::to_frozen_array;
|
|
use crate::dom::globalscope::GlobalScope;
|
|
use crate::dom::types::GPUCompilationMessage;
|
|
use crate::script_runtime::{CanGc, JSContext};
|
|
|
|
#[dom_struct]
|
|
pub(crate) struct GPUCompilationInfo {
|
|
reflector_: Reflector,
|
|
// currently we only get one message from wgpu
|
|
msg: Vec<DomRoot<GPUCompilationMessage>>,
|
|
}
|
|
|
|
impl GPUCompilationInfo {
|
|
pub(crate) fn new_inherited(msg: Vec<DomRoot<GPUCompilationMessage>>) -> Self {
|
|
Self {
|
|
reflector_: Reflector::new(),
|
|
msg,
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub(crate) fn new(
|
|
global: &GlobalScope,
|
|
msg: Vec<DomRoot<GPUCompilationMessage>>,
|
|
can_gc: CanGc,
|
|
) -> DomRoot<Self> {
|
|
reflect_dom_object_with_proto(Box::new(Self::new_inherited(msg)), global, None, can_gc)
|
|
}
|
|
|
|
pub(crate) fn from(
|
|
global: &GlobalScope,
|
|
error: Option<ShaderCompilationInfo>,
|
|
can_gc: CanGc,
|
|
) -> DomRoot<Self> {
|
|
Self::new(
|
|
global,
|
|
if let Some(error) = error {
|
|
vec![GPUCompilationMessage::from(global, error, can_gc)]
|
|
} else {
|
|
Vec::new()
|
|
},
|
|
can_gc,
|
|
)
|
|
}
|
|
}
|
|
|
|
impl GPUCompilationInfoMethods<crate::DomTypeHolder> for GPUCompilationInfo {
|
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpucompilationinfo-messages>
|
|
fn Messages(&self, cx: JSContext, can_gc: CanGc, retval: MutableHandleValue) {
|
|
to_frozen_array(self.msg.as_slice(), cx, retval, can_gc)
|
|
}
|
|
}
|