debug: Add profiler view
This commit is contained in:
parent
d2b049332c
commit
26743d6bdc
4 changed files with 140 additions and 4 deletions
|
|
@ -6,7 +6,10 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
use crate::{debug::fps_ui, utils::prelude::*};
|
use crate::{
|
||||||
|
debug::{fps_ui, profiler_ui},
|
||||||
|
utils::prelude::*,
|
||||||
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
shell::{layout::floating::SeatMoveGrabState, CosmicMappedRenderElement},
|
shell::{layout::floating::SeatMoveGrabState, CosmicMappedRenderElement},
|
||||||
state::{Common, Fps},
|
state::{Common, Fps},
|
||||||
|
|
@ -301,8 +304,6 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspace = state.shell.space_for_handle(&handle).ok_or(OutputNoMode)?;
|
|
||||||
|
|
||||||
let screencopy_contains_embedded = screencopy.as_ref().map_or(false, |(_, sessions)| {
|
let screencopy_contains_embedded = screencopy.as_ref().map_or(false, |(_, sessions)| {
|
||||||
sessions
|
sessions
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -341,8 +342,23 @@ where
|
||||||
.map_err(RenderError::Rendering)?;
|
.map_err(RenderError::Rendering)?;
|
||||||
elements.push(fps_overlay.into());
|
elements.push(fps_overlay.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if state.shell.outputs.first() == Some(output) {
|
||||||
|
if let Some(profiler_overlay) = profiler_ui(
|
||||||
|
state,
|
||||||
|
renderer.glow_renderer_mut(),
|
||||||
|
Rectangle::from_loc_and_size((0, 0), output_geo.size),
|
||||||
|
scale,
|
||||||
|
)
|
||||||
|
.map_err(<R as Renderer>::Error::from)
|
||||||
|
.map_err(RenderError::Rendering)?
|
||||||
|
{
|
||||||
|
elements.push(profiler_overlay.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let workspace = state.shell.space_for_handle(&handle).ok_or(OutputNoMode)?;
|
||||||
let last_active_seat = state.last_active_seat().clone();
|
let last_active_seat = state.last_active_seat().clone();
|
||||||
let move_active = last_active_seat
|
let move_active = last_active_seat
|
||||||
.user_data()
|
.user_data()
|
||||||
|
|
|
||||||
25
src/debug.rs
25
src/debug.rs
|
|
@ -29,6 +29,31 @@ pub const RENDER_COLOR: Color32 = Color32::from_rgb(29, 114, 58);
|
||||||
pub const SCREENCOPY_COLOR: Color32 = Color32::from_rgb(253, 178, 39);
|
pub const SCREENCOPY_COLOR: Color32 = Color32::from_rgb(253, 178, 39);
|
||||||
pub const DISPLAY_COLOR: Color32 = Color32::from_rgb(41, 184, 209);
|
pub const DISPLAY_COLOR: Color32 = Color32::from_rgb(41, 184, 209);
|
||||||
|
|
||||||
|
pub fn profiler_ui(
|
||||||
|
state: &mut Common,
|
||||||
|
renderer: &mut GlowRenderer,
|
||||||
|
area: Rectangle<i32, Logical>,
|
||||||
|
scale: f64,
|
||||||
|
) -> Result<Option<TextureRenderElement<Gles2Texture>>, Gles2Error> {
|
||||||
|
if !state.egui.active {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
|
||||||
|
state
|
||||||
|
.egui
|
||||||
|
.state
|
||||||
|
.render(
|
||||||
|
|ctx| {
|
||||||
|
puffin_egui::profiler_window(ctx);
|
||||||
|
},
|
||||||
|
renderer,
|
||||||
|
area,
|
||||||
|
scale,
|
||||||
|
0.8,
|
||||||
|
)
|
||||||
|
.map(Some)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn fps_ui(
|
pub fn fps_ui(
|
||||||
gpu: Option<&DrmNode>,
|
gpu: Option<&DrmNode>,
|
||||||
state: &Common,
|
state: &Common,
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,10 @@ impl State {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
{
|
||||||
|
self.common.egui.state.handle_device_added(&device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InputEvent::DeviceRemoved { device } => {
|
InputEvent::DeviceRemoved { device } => {
|
||||||
for seat in &mut self.common.seats() {
|
for seat in &mut self.common.seats() {
|
||||||
|
|
@ -182,6 +186,10 @@ impl State {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
{
|
||||||
|
self.common.egui.state.handle_device_removed(&device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InputEvent::Keyboard { event, .. } => {
|
InputEvent::Keyboard { event, .. } => {
|
||||||
use smithay::backend::input::KeyboardKeyEvent;
|
use smithay::backend::input::KeyboardKeyEvent;
|
||||||
|
|
@ -227,6 +235,26 @@ impl State {
|
||||||
return FilterResult::Intercept(None);
|
return FilterResult::Intercept(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
{
|
||||||
|
if data.common.seats().position(|x| x == seat).unwrap() == 0
|
||||||
|
&& data.common.egui.active
|
||||||
|
{
|
||||||
|
if data.common.egui.state.wants_keyboard() {
|
||||||
|
data.common.egui.state.handle_keyboard(
|
||||||
|
&handle,
|
||||||
|
state == KeyState::Pressed,
|
||||||
|
modifiers.clone(),
|
||||||
|
);
|
||||||
|
userdata
|
||||||
|
.get::<SupressedKeys>()
|
||||||
|
.unwrap()
|
||||||
|
.add(&handle);
|
||||||
|
return FilterResult::Intercept(None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if state == KeyState::Pressed
|
if state == KeyState::Pressed
|
||||||
&& (keysyms::KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12)
|
&& (keysyms::KEY_XF86Switch_VT_1..=KEY_XF86Switch_VT_12)
|
||||||
.contains(&handle.modified_sym())
|
.contains(&handle.modified_sym())
|
||||||
|
|
@ -356,6 +384,18 @@ impl State {
|
||||||
utime: event.time(),
|
utime: event.time(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
if self.common.seats().position(|x| x == seat).unwrap() == 0 {
|
||||||
|
let location = if let Some(output) = self.common.shell.outputs.first() {
|
||||||
|
self.common
|
||||||
|
.shell
|
||||||
|
.map_global_to_space(position, output)
|
||||||
|
.to_i32_round()
|
||||||
|
} else {
|
||||||
|
position.to_i32_round()
|
||||||
|
};
|
||||||
|
self.common.egui.state.handle_pointer_motion(location);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -406,6 +446,18 @@ impl State {
|
||||||
time: event.time_msec(),
|
time: event.time_msec(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
if self.common.seats().position(|x| x == seat).unwrap() == 0 {
|
||||||
|
let location = if let Some(output) = self.common.shell.outputs.first() {
|
||||||
|
self.common
|
||||||
|
.shell
|
||||||
|
.map_global_to_space(position, output)
|
||||||
|
.to_i32_round()
|
||||||
|
} else {
|
||||||
|
position.to_i32_round()
|
||||||
|
};
|
||||||
|
self.common.egui.state.handle_pointer_motion(location);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -419,6 +471,21 @@ impl State {
|
||||||
let userdata = seat.user_data();
|
let userdata = seat.user_data();
|
||||||
let devices = userdata.get::<Devices>().unwrap();
|
let devices = userdata.get::<Devices>().unwrap();
|
||||||
if devices.has_device(&device) {
|
if devices.has_device(&device) {
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
if self.common.seats().position(|x| x == seat).unwrap() == 0
|
||||||
|
&& self.common.egui.active
|
||||||
|
{
|
||||||
|
if self.common.egui.state.wants_pointer() {
|
||||||
|
if let Some(button) = event.button() {
|
||||||
|
self.common.egui.state.handle_pointer_button(
|
||||||
|
button,
|
||||||
|
event.state() == ButtonState::Pressed,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let serial = SERIAL_COUNTER.next_serial();
|
let serial = SERIAL_COUNTER.next_serial();
|
||||||
let button = event.button_code();
|
let button = event.button_code();
|
||||||
if event.state() == ButtonState::Pressed {
|
if event.state() == ButtonState::Pressed {
|
||||||
|
|
@ -512,6 +579,25 @@ impl State {
|
||||||
InputEvent::PointerAxis { event, .. } => {
|
InputEvent::PointerAxis { event, .. } => {
|
||||||
let device = event.device();
|
let device = event.device();
|
||||||
for seat in self.common.seats().cloned().collect::<Vec<_>>().iter() {
|
for seat in self.common.seats().cloned().collect::<Vec<_>>().iter() {
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
if self.common.seats().position(|x| x == seat).unwrap() == 0
|
||||||
|
&& self.common.egui.active
|
||||||
|
{
|
||||||
|
if self.common.egui.state.wants_pointer() {
|
||||||
|
self.common.egui.state.handle_pointer_axis(
|
||||||
|
event
|
||||||
|
.amount_discrete(Axis::Horizontal)
|
||||||
|
.or_else(|| event.amount(Axis::Horizontal).map(|x| x * 3.0))
|
||||||
|
.unwrap_or(0.0),
|
||||||
|
event
|
||||||
|
.amount_discrete(Axis::Vertical)
|
||||||
|
.or_else(|| event.amount(Axis::Vertical).map(|x| x * 3.0))
|
||||||
|
.unwrap_or(0.0),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let userdata = seat.user_data();
|
let userdata = seat.user_data();
|
||||||
let devices = userdata.get::<Devices>().unwrap();
|
let devices = userdata.get::<Devices>().unwrap();
|
||||||
if devices.has_device(&device) {
|
if devices.has_device(&device) {
|
||||||
|
|
|
||||||
11
src/state.rs
11
src/state.rs
|
|
@ -14,6 +14,8 @@ use crate::{
|
||||||
xwayland::XWaylandState,
|
xwayland::XWaylandState,
|
||||||
};
|
};
|
||||||
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_manager_v1::CursorMode;
|
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_manager_v1::CursorMode;
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
use smithay::utils::Rectangle;
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
drm::DrmNode,
|
drm::DrmNode,
|
||||||
|
|
@ -264,7 +266,13 @@ impl State {
|
||||||
should_stop: false,
|
should_stop: false,
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
egui: Egui { active: false },
|
egui: Egui {
|
||||||
|
active: false,
|
||||||
|
state: smithay_egui::EguiState::new(Rectangle::from_loc_and_size(
|
||||||
|
(0, 0),
|
||||||
|
(800, 600),
|
||||||
|
)),
|
||||||
|
},
|
||||||
|
|
||||||
compositor_state,
|
compositor_state,
|
||||||
data_device_state,
|
data_device_state,
|
||||||
|
|
@ -517,6 +525,7 @@ impl Common {
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
pub struct Egui {
|
pub struct Egui {
|
||||||
pub active: bool,
|
pub active: bool,
|
||||||
|
pub state: smithay_egui::EguiState,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Fps {
|
pub struct Fps {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue