MCPcopy Create free account
hub / github.com/elastic/devfiler / draw_level

Method draw_level

src/ui/tabs/flamegraph.rs:486–628  ·  view source on GitHub ↗
(
        // TODO: way too many args. use struct for static portion?
        &mut self,
        ctx: &egui::Context,
        cfg: &DevfilerConfig,
        painter: &Painter,
        to_screen: &RectTr

Source from the content-addressed store, hash-verified

484 }
485
486 fn draw_level(
487 // TODO: way too many args. use struct for static portion?
488 &mut self,
489 ctx: &egui::Context,
490 cfg: &DevfilerConfig,
491 painter: &Painter,
492 to_screen: &RectTransform,
493 visible_x_range: Rangef,
494 cursor_hover_pos: Option<Pos2>,
495 clicked: bool,
496 ctrl_held: bool,
497 draw_pos: Pos2,
498 avail_width: f32,
499 root: &FlameGraphNode,
500 flame: &FlameGraphNode,
501 ) -> f32 {
502 let flame_width = avail_width * (flame.weight as f32 / root.weight.max(1) as f32);
503 if flame_width < MIN_WIDTH {
504 return flame_width;
505 }
506
507 let rect = Rect::from_min_size(draw_pos, vec2(flame_width, FLAME_HEIGHT));
508 let screen_rect = to_screen.transform_rect(rect);
509
510 let flame_range = Rangef::new(rect.min.x, rect.max.x);
511 if flame_range.intersection(visible_x_range).span() <= 0.0 {
512 return flame_width;
513 }
514
515 let bg_color = if self.filter.len() >= 3 {
516 if flame.text.contains(&self.filter) {
517 flame.bg_color
518 } else {
519 flame.bg_color.gamma_multiply(0.5)
520 }
521 } else {
522 flame.bg_color
523 };
524
525 // Track matching frames for navigation (only if filter changed)
526 let is_match = self.filter.len() >= 3 && flame.text.contains(&self.filter);
527 let is_focused = if is_match {
528 if self.rebuild_matches {
529 let unscaled_pos = pos2(draw_pos.x / self.x_zoom, draw_pos.y);
530 let width_ratio = flame.weight as f32 / root.weight.max(1) as f32;
531
532 self.matching_frames.push(MatchingFrame {
533 id: flame.id,
534 pos: unscaled_pos,
535 width_ratio,
536 });
537 self.match_count += 1;
538 }
539
540 // Check if this frame is the focused one by comparing IDs
541 self.matching_frames
542 .get(self.current_match_index)
543 .map(|m| m.id == flame.id)

Callers 2

drawMethod · 0.80
draw_sandwich_viewMethod · 0.80

Calls 4

build_sandwich_viewFunction · 0.85
draw_tooltipMethod · 0.80
getMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected