Trace and malloc_size_of workarounds for servo_media types

This commit is contained in:
Fernando Jiménez Moreno 2018-06-21 10:34:06 +02:00
parent 4602951656
commit ba9dfb0293
3 changed files with 10 additions and 5 deletions

View file

@ -10,10 +10,11 @@ use dom::bindings::reflector::Reflector;
use dom::bindings::root::DomRoot;
use dom::audioparam::AudioParam;
use dom_struct::dom_struct;
use servo_media::audio::graph_impl::NodeId;
use servo_media::audio::node::AudioNodeType;
use std::cell::Cell;
// 32 is the minimum required by the spec for createBuffer() and
// 32 is the minimum required by the spec for createBuffer() and the deprecated
// createScriptProcessor() and matches what is used by Blink and Gecko.
// The limit protects against large memory allocations.
pub static MAX_CHANNEL_COUNT: u32 = 32;
@ -21,7 +22,8 @@ pub static MAX_CHANNEL_COUNT: u32 = 32;
#[dom_struct]
pub struct AudioNode {
reflector_: Reflector,
engine_id: usize,
#[ignore_malloc_size_of = "servo_media"]
node_id: NodeId,
context: DomRoot<BaseAudioContext>,
number_of_inputs: u32,
number_of_outputs: u32,
@ -38,7 +40,7 @@ impl AudioNode {
number_of_outputs: u32) -> AudioNode {
AudioNode {
reflector_: Reflector::new(),
engine_id: context.create_node_engine(node_type),
node_id: context.create_node_engine(node_type),
context: DomRoot::from_ref(context),
number_of_inputs,
number_of_outputs,

View file

@ -17,13 +17,14 @@ use dom::oscillatornode::OscillatorNode;
use dom_struct::dom_struct;
use servo_media::ServoMedia;
use servo_media::audio::graph::AudioGraph;
use servo_media::audio::graph_impl::NodeId;
use servo_media::audio::node::AudioNodeType;
use std::rc::Rc;
#[dom_struct]
pub struct BaseAudioContext {
reflector_: Reflector,
#[ignore_malloc_size_of = "XXX"]
#[ignore_malloc_size_of = "servo_media"]
audio_graph: AudioGraph,
destination: Option<DomRoot<AudioDestinationNode>>,
sample_rate: f32,
@ -58,7 +59,7 @@ impl BaseAudioContext {
context
}
pub fn create_node_engine(&self, node_type: AudioNodeType) -> usize {
pub fn create_node_engine(&self, node_type: AudioNodeType) -> NodeId {
self.audio_graph.create_node(node_type)
}
}

View file

@ -81,6 +81,7 @@ use parking_lot::RwLock;
use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::time::ProfilerChan as TimeProfilerChan;
use servo_media::audio::graph::AudioGraph;
use servo_media::audio::graph_impl::NodeId;
use script_layout_interface::OpaqueStyleAndLayoutData;
use script_layout_interface::reporter::CSSErrorReporter;
use script_layout_interface::rpc::LayoutRPC;
@ -431,6 +432,7 @@ unsafe_no_jsmanaged_fields!(InteractiveWindow);
unsafe_no_jsmanaged_fields!(CanvasId);
unsafe_no_jsmanaged_fields!(SourceSet);
unsafe_no_jsmanaged_fields!(AudioGraph);
unsafe_no_jsmanaged_fields!(NodeId);
unsafe impl<'a> JSTraceable for &'a str {
#[inline]