RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
chart_flame.h File Reference

chart_flame.h — icicle (flame) graph: a flat frame array with parent indices, laid out root-first from the top of the rect. More...

#include <stddef.h>
#include <stdint.h>
#include "fb.h"
#include "font.h"
#include "geom.h"
#include "style.h"
#include "draw_target.h"
#include "ui_context.h"

Data Structures

struct  rmgui_chart_frame_t
 One flame frame. More...
struct  rmgui_chart_flame_view_t
 A flame graph borrowing up to INT32_MAX frames and their label bytes. More...

Functions

void rmgui_chart_flame_paint (rmgui_fb_t *fb, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_style_resolved_t *rs, rmgui_font_t *font, int font_px, const rmgui_chart_frame_t *frames, size_t count, int32_t total)
 Paints the icicle of frames[0, count): root frames (parent -1) on the top row share rect's width proportionally to their values against total; each frame's children sit on the row below, laid out left to right in array order inside their parent's span, widths proportional to their values against the parent's value and clamped to the parent's span (overflowing children are cut at the parent's right edge, never painted wider).
int rmgui_chart_flame_hit (const rmgui_rect_t *rect, const rmgui_chart_frame_t *frames, size_t count, int32_t total, int x, int y, size_t *idx)
 Hit test of the layout rmgui_chart_flame_paint paints: on a hit returns 0 and writes the index of the frame whose cell contains (x, y) to *idx; returns -1 when no painted cell contains the point (outside rect, on a zero-width or dropped frame) or any argument is NULL or empty (count 0, total <= 0).
void rmgui_chart_flame_paint_to (rmgui_target_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_style_resolved_t *, rmgui_font_t *, int, const rmgui_chart_frame_t *, size_t, int32_t)
 Explicit destination flame paint; prepare label glyphs before RECORD.
int rmgui_chart_flame_prepare (const rmgui_ui_t *ui, const rmgui_chart_flame_view_t *flame)
 Prepare frame labels before recording.
int rmgui_chart_flame_draw (const rmgui_ui_t *ui, const rmgui_chart_flame_view_t *flame, rmgui_rect_t rect)
 Draw the flame graph.

Detailed Description

chart_flame.h — icicle (flame) graph: a flat frame array with parent indices, laid out root-first from the top of the rect.

Values are inclusive int32 weights; all geometry is integer pixels computed in 64 bits; nothing is allocated.

Function Documentation

◆ rmgui_chart_flame_paint()

void rmgui_chart_flame_paint ( rmgui_fb_t * fb,
rmgui_rect_t rect,
rmgui_rect_t clip,
const rmgui_style_resolved_t * rs,
rmgui_font_t * font,
int font_px,
const rmgui_chart_frame_t * frames,
size_t count,
int32_t total )

Paints the icicle of frames[0, count): root frames (parent -1) on the top row share rect's width proportionally to their values against total; each frame's children sit on the row below, laid out left to right in array order inside their parent's span, widths proportional to their values against the parent's value and clamped to the parent's span (overflowing children are cut at the parent's right edge, never painted wider).

Row depth d spans y rect.y + d*rect.h/(max_depth+1) to rect.y + (d+1)*rect.h/(max_depth+1) over the deepest painted depth max_depth. A frame with a non-positive value, an invalid parent (out of range, itself, or a cycle) is not painted, nor are its descendants' widths derived from it (they still resolve through their own chain).

A frame at depth d paints rs->series[d % 6] blended d steps toward rs->background: each step maps every channel c to (c*224 + background*32)/256, alpha stays 255. The label text uses whichever of rs->text and rs->background is farther in (54R+183G+19B)/256 luminance from its fill. It paints at font_px through font, top-left inset 2 px, vertically centred in the cell, and clipped to the cell.

NULL fb, rs or frames, zero count, an empty rect, or total <= 0 paints nothing. Count must fit INT32_MAX, the parent-index type ceiling; larger counts are refused without painting. Ancestor walks use no scratch. A NULL font paints the cells without their labels. Pixels are written only inside clip ∩ rect.

◆ rmgui_chart_flame_hit()

int rmgui_chart_flame_hit ( const rmgui_rect_t * rect,
const rmgui_chart_frame_t * frames,
size_t count,
int32_t total,
int x,
int y,
size_t * idx )

Hit test of the layout rmgui_chart_flame_paint paints: on a hit returns 0 and writes the index of the frame whose cell contains (x, y) to *idx; returns -1 when no painted cell contains the point (outside rect, on a zero-width or dropped frame) or any argument is NULL or empty (count 0, total <= 0).

Cells are the paint cells exactly, so the cell centre of every painted frame round-trips to that frame.

◆ rmgui_chart_flame_paint_to()

void rmgui_chart_flame_paint_to ( rmgui_target_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const rmgui_style_resolved_t * ,
rmgui_font_t * ,
int ,
const rmgui_chart_frame_t * ,
size_t ,
int32_t  )

Explicit destination flame paint; prepare label glyphs before RECORD.

Frame geometry is unchanged; bounded command and glyph failures latch.

◆ rmgui_chart_flame_prepare()

int rmgui_chart_flame_prepare ( const rmgui_ui_t * ui,
const rmgui_chart_flame_view_t * flame )

Prepare frame labels before recording.

CPU targets and contexts without a font need no preparation. Returns 0 or -1 on error.

◆ rmgui_chart_flame_draw()

int rmgui_chart_flame_draw ( const rmgui_ui_t * ui,
const rmgui_chart_flame_view_t * flame,
rmgui_rect_t rect )

Draw the flame graph.

A NULL font omits labels. Returns 0 or -1 for invalid arguments or style; paint errors are reported by the target.