/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
mod debug_flags; mod profiler; mod shell; mod textures; mod composite_view; mod draw_calls; mod timeline;
use eframe::egui; use webrender_api::{DebugFlags, RenderCommandInfo}; use webrender_api::debugger::{DebuggerMessage, DebuggerTextureContent, ProfileCounterId, CompositorDebugInfo}; usecrate::{command, net}; use std::collections::{HashMap, BTreeMap, VecDeque}; use std::fs; use std::io::Write; use std::sync::mpsc;
// Load layout settings if available iflet Ok(_ini) = fs::read_to_string("default-layout.ini") { // egui uses a different state persistence mechanism // This would need to be adapted for egui's state system
}
for counter in info.counters { if selected_counters.contains(&counter.name.as_str()) {
println!("Add profile counter {:?}", counter.name); self.data_model.profile_graphs.insert(
counter.id,
Graph::new(&counter.name, 512),
);
}
}
}
DebuggerMessage::UpdateFrameLog(info) => { iflet Some(updates) = info.profile_counters { for counter in &updates { iflet Some(graph) = self.data_model
.profile_graphs
.get_mut(&counter.id) {
graph.push(counter.value);
}
}
} let frame_log = &mutself.data_model.frame_log; if frame_log.frames.len() == frame_log.frames.capacity() {
frame_log.frames.pop_front();
}
frame_log.frames.push_back(LoggedFrame {
render_commands: info.render_commands.clone(),
});
frame_log.frames_end += 1; let first = frame_log.first_frame_index(); let last = frame_log.last_frame_index();
letmut current = self.data_model.timeline.current_frame;
current = current.clamp(first, last);
// Make the current frame 'stick' to the last frame (that is, we were // already viewing the last frame, and a new frame was just pushed) if last == current + 1 {
current = last
}
impl Drop for Gui { fn drop(&mutself) { // Serialize and save UI state const MAX_HISTORY_SAVED: usize = 50; let hist_len = self.cmd_history.len(); let range = if hist_len > MAX_HISTORY_SAVED {
hist_len - MAX_HISTORY_SAVED..hist_len
} else { 0..hist_len
};
let save = GuiSavedState {
version: GuiSavedState::VERSION,
ui_tiles: self.ui_tiles.take().unwrap(),
cmd_history: self.cmd_history.drain(range).collect(),
};
match serde_json::to_string(&save) {
Ok(serialized) => { iflet Err(e) = fs::File::create(config_path())
.and_then(|mut file| file.write_all(serialized.as_bytes()))
{
eprintln!("Failed to save ui_tiles state: {}", e);
}
}
Err(e) => {
eprintln!("Failed to serialize ui_tiles: {}", e);
}
}
}
}
match &doc.kind {
DocumentKind::Text { content } => {
egui::ScrollArea::both().show(ui, |ui| {
ui.label(egui::RichText::new(content).monospace());
});
}
DocumentKind::Compositor { .. } => { // We need to handle compositor separately due to borrow checker iflet Some(Document { kind: DocumentKind::Compositor { info }, .. }) =
app.data_model.documents.get_mut(idx) {
composite_view::ui(ui, info);
}
}
DocumentKind::Texture { content, handle } => { iflet Some(handle) = handle {
textures::texture_viewer_ui(ui, &content, &handle);
}
}
}
}
}
// TODO: It would be better to use confy::load/store instead of loading // files manually but for some reason serialization of the ui tiles panics // in confy. fn config_path() -> std::path::PathBuf {
confy::get_configuration_file_path("wr_debugger", None).unwrap()
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.