incular_runtime/
devtools_inspection.rs1use crate::application::Application;
8use incular_devtools_protocol::{
9 DevWindowId, ErrorCode, LayerNodeWire, RuntimeDiagnosticsWire, SemanticsNodeWire,
10 WorkCountEntry,
11};
12use incular_platform::WindowId;
13
14macro_rules! with_tree {
16 ($self:ident, $window:ident, |$tree:ident| $read:expr) => {{
17 let id = WindowId::from_parts(
18 $window.index().saturating_sub(1) as u32,
19 $window.generation() as u32,
20 );
21 let registry = $self.registry.borrow();
22 let record = registry.get(id).ok_or(ErrorCode::StaleId)?;
23 let $tree = record.runtime.tree();
24 Ok($read)
25 }};
26}
27
28impl Application {
29 pub fn devtools_runtime_diagnostics(
31 &self,
32 window: DevWindowId,
33 ) -> Result<RuntimeDiagnosticsWire, ErrorCode> {
34 with_tree!(self, window, |tree| tree.devtools_runtime_counters())
35 }
36
37 pub fn devtools_semantics_tree(
39 &self,
40 window: DevWindowId,
41 ) -> Result<(Vec<SemanticsNodeWire>, bool), ErrorCode> {
42 with_tree!(self, window, |tree| tree.devtools_semantics_nodes())
43 }
44
45 pub fn devtools_layer_tree(
47 &self,
48 window: DevWindowId,
49 ) -> Result<(Vec<LayerNodeWire>, bool), ErrorCode> {
50 with_tree!(self, window, |tree| tree.devtools_layer_nodes())
51 }
52
53 pub fn devtools_work_counts(
56 &self,
57 window: DevWindowId,
58 limit: usize,
59 ) -> Result<Vec<WorkCountEntry>, ErrorCode> {
60 with_tree!(self, window, |tree| tree.devtools_work_counts(limit))
61 }
62}