mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
parent
6d2f70a4fd
commit
be2cb665de
19 changed files with 315 additions and 68 deletions
|
@ -16,7 +16,7 @@ use time::PreciseTime;
|
|||
use actor::{Actor, ActorRegistry};
|
||||
use actors::memory::{MemoryActor, TimelineMemoryReply};
|
||||
use actors::framerate::FramerateActor;
|
||||
use devtools_traits::DevtoolScriptControlMsg;
|
||||
use devtools_traits::{DevtoolsControlMsg, DevtoolScriptControlMsg};
|
||||
use devtools_traits::DevtoolScriptControlMsg::{SetTimelineMarkers, DropTimelineMarkers};
|
||||
use devtools_traits::{TimelineMarker, TracingMetadata, TimelineMarkerType};
|
||||
use protocol::JsonPacketStream;
|
||||
|
@ -25,6 +25,7 @@ use util::task;
|
|||
pub struct TimelineActor {
|
||||
name: String,
|
||||
script_sender: Sender<DevtoolScriptControlMsg>,
|
||||
devtools_sender: Sender<DevtoolsControlMsg>,
|
||||
marker_types: Vec<TimelineMarkerType>,
|
||||
pipeline: PipelineId,
|
||||
is_recording: Arc<Mutex<bool>>,
|
||||
|
@ -93,21 +94,25 @@ struct FramerateEmitterReply {
|
|||
__type__: String,
|
||||
from: String,
|
||||
delta: HighResolutionStamp,
|
||||
timestamps: Vec<u64>,
|
||||
timestamps: Vec<HighResolutionStamp>,
|
||||
}
|
||||
|
||||
/// HighResolutionStamp is struct that contains duration in milliseconds
|
||||
/// with accuracy to microsecond that shows how much time has passed since
|
||||
/// actor registry inited
|
||||
/// analog https://w3c.github.io/hr-time/#sec-DOMHighResTimeStamp
|
||||
struct HighResolutionStamp(f64);
|
||||
pub struct HighResolutionStamp(f64);
|
||||
|
||||
impl HighResolutionStamp {
|
||||
fn new(start_stamp: PreciseTime, time: PreciseTime) -> HighResolutionStamp {
|
||||
pub fn new(start_stamp: PreciseTime, time: PreciseTime) -> HighResolutionStamp {
|
||||
let duration = start_stamp.to(time).num_microseconds()
|
||||
.expect("Too big duration in microseconds");
|
||||
HighResolutionStamp(duration as f64 / 1000 as f64)
|
||||
}
|
||||
|
||||
pub fn wrap(time: f64) -> HighResolutionStamp {
|
||||
HighResolutionStamp(time)
|
||||
}
|
||||
}
|
||||
|
||||
impl Encodable for HighResolutionStamp {
|
||||
|
@ -121,7 +126,8 @@ static DEFAULT_TIMELINE_DATA_PULL_TIMEOUT: u32 = 200; //ms
|
|||
impl TimelineActor {
|
||||
pub fn new(name: String,
|
||||
pipeline: PipelineId,
|
||||
script_sender: Sender<DevtoolScriptControlMsg>) -> TimelineActor {
|
||||
script_sender: Sender<DevtoolScriptControlMsg>,
|
||||
devtools_sender: Sender<DevtoolsControlMsg>) -> TimelineActor {
|
||||
|
||||
let marker_types = vec!(TimelineMarkerType::Reflow,
|
||||
TimelineMarkerType::DOMEvent);
|
||||
|
@ -131,6 +137,7 @@ impl TimelineActor {
|
|||
pipeline: pipeline,
|
||||
marker_types: marker_types,
|
||||
script_sender: script_sender,
|
||||
devtools_sender: devtools_sender,
|
||||
is_recording: Arc::new(Mutex::new(false)),
|
||||
stream: RefCell::new(None),
|
||||
|
||||
|
@ -248,7 +255,11 @@ impl Actor for TimelineActor {
|
|||
// init framerate actor
|
||||
if let Some(with_ticks) = msg.get("withTicks") {
|
||||
if let Some(true) = with_ticks.as_boolean() {
|
||||
*self.framerate_actor.borrow_mut() = Some(FramerateActor::create(registry));
|
||||
let framerate_actor = Some(FramerateActor::create(registry,
|
||||
self.pipeline.clone(),
|
||||
self.script_sender.clone(),
|
||||
self.devtools_sender.clone()));
|
||||
*self.framerate_actor.borrow_mut() = framerate_actor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,7 +363,7 @@ impl Emitter {
|
|||
if let Some(ref actor_name) = self.framerate_actor {
|
||||
let mut lock = self.registry.lock();
|
||||
let registry = lock.as_mut().unwrap();
|
||||
let mut framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
|
||||
let framerate_actor = registry.find_mut::<FramerateActor>(actor_name);
|
||||
let framerateReply = FramerateEmitterReply {
|
||||
__type__: "framerate".to_string(),
|
||||
from: framerate_actor.name(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue