Skip to content

Commit

Permalink
Add runtime switch for webrender profiler (-Z wr-stats) which
Browse files Browse the repository at this point in the history
can be toggled by pressing Ctrl-F12.
  • Loading branch information
gw3583 committed Nov 4, 2016
1 parent eb5dacb commit 2843f06
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions components/compositing/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use gleam::gl::types::{GLint, GLsizei};
use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
use ipc_channel::router::ROUTER;
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, CONTROL};
use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId, TraversalDirection};
use net_traits::image::base::{Image, PixelFormat};
use profile_traits::mem::{self, Reporter, ReporterRequest};
Expand Down Expand Up @@ -1301,7 +1301,23 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
}

fn on_key_event(&self, ch: Option<char>, key: Key, state: KeyState, modifiers: KeyModifiers) {
fn on_key_event(&mut self,
ch: Option<char>,
key: Key,
state: KeyState,
modifiers: KeyModifiers) {
// Steal a few key events for webrender debug options.
if modifiers.contains(CONTROL) && state == KeyState::Pressed {
match key {
Key::F12 => {
let profiler_enabled = self.webrender.get_profiler_enabled();
self.webrender.set_profiler_enabled(!profiler_enabled);
return;
}
_ => {}
}
}

let msg = ConstellationMsg::KeyEvent(ch, key, state, modifiers);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending key event to constellation failed ({}).", e);
Expand Down

0 comments on commit 2843f06

Please sign in to comment.