diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2015-07-14 18:28:57 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2015-07-24 17:02:17 -0700 |
commit | f10c0761802ed0f77e21d410124ef54239beb48a (patch) | |
tree | c17f2bb6b6ee77c246802a88a5b7acaa40e1f57e /components/gfx/paint_task.rs | |
parent | ed1b6a3513e7546b580693f554a081bc0c7c478a (diff) | |
download | servo-f10c0761802ed0f77e21d410124ef54239beb48a.tar.gz servo-f10c0761802ed0f77e21d410124ef54239beb48a.zip |
profile: Make the time and memory profilers run over IPC.
Uses the `Router` abstraction inside `ipc-channel` to avoid spawning new
threads.
Diffstat (limited to 'components/gfx/paint_task.rs')
-rw-r--r-- | components/gfx/paint_task.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 4083fd05aa2..4f6a907841e 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -15,6 +15,8 @@ use euclid::Matrix4; use euclid::point::Point2D; use euclid::rect::Rect; use euclid::size::Size2D; +use ipc_channel::ipc; +use ipc_channel::router::ROUTER; use layers::platform::surface::{NativeDisplay, NativeSurface}; use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet}; use layers; @@ -24,7 +26,7 @@ use msg::compositor_msg::{LayerProperties, PaintListener, ScrollPolicy}; use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::PipelineExitType; -use profile_traits::mem::{self, Reporter, ReportsChan}; +use profile_traits::mem::{self, Reporter, ReporterRequest, ReportsChan}; use profile_traits::time::{self, profile}; use rand::{self, Rng}; use std::borrow::ToOwned; @@ -98,14 +100,6 @@ impl PaintChan { } } -impl Reporter for PaintChan { - // Just injects an appropriate event into the paint task's queue. - fn collect_reports(&self, reports_chan: ReportsChan) -> bool { - let PaintChan(ref c) = *self; - c.send(Msg::CollectReports(reports_chan)).is_ok() - } -} - pub struct PaintTask<C> { id: PipelineId, _url: Url, @@ -179,11 +173,20 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { canvas_map: HashMap::new() }; - // Register this thread as a memory reporter, via its own channel. - let reporter = box chan.clone(); + // Register the memory reporter. let reporter_name = format!("paint-reporter-{}", id.0); - let msg = mem::ProfilerMsg::RegisterReporter(reporter_name.clone(), reporter); - mem_profiler_chan.send(msg); + let (reporter_sender, reporter_receiver) = + ipc::channel::<ReporterRequest>().unwrap(); + let paint_chan_for_reporter = chan.clone(); + ROUTER.add_route(reporter_receiver.to_opaque(), box move |message| { + // Just injects an appropriate event into the paint task's queue. + let request: ReporterRequest = message.to().unwrap(); + paint_chan_for_reporter.0.send(Msg::CollectReports(request.reports_channel)) + .unwrap(); + }); + mem_profiler_chan.send(mem::ProfilerMsg::RegisterReporter( + reporter_name.clone(), + Reporter(reporter_sender))); paint_task.start(); @@ -261,8 +264,9 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { Msg::PaintPermissionRevoked => { self.paint_permission = false; } - Msg::CollectReports(_) => { + Msg::CollectReports(ref channel) => { // FIXME(njn): should eventually measure the paint task. + channel.send(Vec::new()) } Msg::Exit(response_channel, _) => { // Ask the compositor to remove any layers it is holding for this paint task. |