aboutsummaryrefslogtreecommitdiffstats
path: root/components/compositing/compositor.rs
diff options
context:
space:
mode:
authorGlenn Watson <github@intuitionlibrary.com>2016-11-04 12:49:28 +1000
committerGlenn Watson <github@intuitionlibrary.com>2016-11-04 12:49:28 +1000
commit2843f069334932dbf0b3a087fd53300f349390fb (patch)
treebc39f623e7ddea6cef5f26471a7e3e35a9c57fc4 /components/compositing/compositor.rs
parenteb5dacb137ea13a806a0204732bac377d9257869 (diff)
downloadservo-2843f069334932dbf0b3a087fd53300f349390fb.tar.gz
servo-2843f069334932dbf0b3a087fd53300f349390fb.zip
Add runtime switch for webrender profiler (-Z wr-stats) which
can be toggled by pressing Ctrl-F12.
Diffstat (limited to 'components/compositing/compositor.rs')
-rw-r--r--components/compositing/compositor.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index 55127bd64fe..d0b73928232 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -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};
@@ -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);