tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

draw_calls.rs (1733B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 use super::Gui;
      6 use webrender_api::RenderCommandInfo;
      7 
      8 pub fn ui(app: &mut Gui, ui: &mut egui::Ui) {
      9    if ui.checkbox(&mut app.data_model.frame_log.enabled, "Log render commands").changed() {
     10        app.net.post_with_content("render-cmd-log", &app.data_model.frame_log.enabled).ok();
     11    }
     12 
     13    if let Some(frame) = app.data_model.frame_log.frame(app.data_model.timeline.current_frame) {
     14        if let Some(cmds) = &frame.render_commands {
     15            draw_calls_ui(cmds, ui);
     16        }
     17    }
     18 }
     19 
     20 pub fn draw_calls_ui(cmds: &[RenderCommandInfo], ui: &mut egui::Ui) {
     21    egui::ScrollArea::vertical().show(ui, |ui| {
     22        egui::Grid::new("").show(ui, |ui| {
     23            for cmd in cmds {
     24                match cmd {
     25                    RenderCommandInfo::RenderTarget { kind, size } => {
     26                        ui.end_row();
     27                        ui.label(egui::RichText::new("Target"));
     28                        ui.label(egui::RichText::new(format!("{kind} {}x{}", size.width, size.height)));
     29                    }
     30                    RenderCommandInfo::DrawCall { shader, instances } => {
     31                        ui.label(egui::RichText::new("  Draw"));
     32                        ui.label(egui::RichText::new(shader.clone()).strong());
     33                        let inst = format!("{} instance{}", instances, if *instances > 1 { "s"} else { "" });
     34                        ui.label(egui::RichText::new(inst).weak());
     35                    }
     36                }
     37                ui.end_row();
     38            }
     39        });
     40    });
     41 }