Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
supervisor.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel.
3 Copyright (C) 2026 Aurélien Pierre.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DT_DEVELOP_SUPERVISOR_H
20#define DT_DEVELOP_SUPERVISOR_H
21
22#include <glib.h>
23#include <stdint.h>
24
25#include "common/logging.h"
26
27struct dt_image_t;
28struct dt_iop_module_t;
30struct dt_masks_form_t;
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
75// CRUD verb for an event.
83
84// Lifecycle, called once from dt_init()/dt_cleanup().
85void dt_supervisor_init(void);
86void dt_supervisor_cleanup(void);
87
88// Runtime capture flag, set by the GUI (the supervisor window). The supervisor
89// captures events whenever this is set OR `-d supervisor` is active. Read via
90// the inline gate below; set via dt_supervisor_set_recording().
91extern gint dt_supervisor_recording;
92
93// Fast gate. TRUE when `-d supervisor` is enabled OR the GUI is recording. Guard
94// call sites with this so the per-event metadata gathering is skipped when off.
95static inline gboolean dt_supervisor_active(void)
96{
97 return (dt_get_debug_flags() & DT_DEBUG_SUPERVISOR) || g_atomic_int_get(&dt_supervisor_recording);
98}
99
105typedef struct dt_sv_link_t
106{
107 char label[16]; // edge name, e.g. "params", "input", "node", "rekeyed_to"
110
112{
113 uint64_t seq; // monotonic capture sequence, for incremental GUI updates
114 double ts;
115 char thread[24];
116 char op[12];
117 char domain[16];
118 char mnemonic[64]; // human label for the row (module, imgid, widget, pipe, …)
119 char cache_name[32]; // cacheline "name" tag (e.g. "raster mask"), empty for plain module outputs
120 uint64_t hash; // the event's own object hash
121 GArray *links; // of dt_sv_link_t
122 gchar *json; // the full NDJSON record (compact), for the detail view
124
125// Toggle runtime capture into the in-memory log (the stderr NDJSON dump stays
126// governed by `-d supervisor`).
127void dt_supervisor_set_recording(gboolean on);
128
129// GUI thread: deep-copy snapshot of the retained log, oldest-first. Free with
130// dt_supervisor_events_free(). Empty (not NULL) when nothing was captured.
131GPtrArray *dt_supervisor_events_snapshot(void);
132
133// Incremental snapshot: only events captured after `after_seq` (oldest-first).
134// `out_last_seq` receives the highest seq returned (or `after_seq` if none), so
135// a poller can advance its cursor. Free with dt_supervisor_events_free().
136GPtrArray *dt_supervisor_events_snapshot_since(uint64_t after_seq, uint64_t *out_last_seq);
137
138// Number of events currently retained.
140
141void dt_supervisor_events_free(GPtrArray *events);
142
143// Drop all retained events.
145
152uint64_t dt_supervisor_node_key(int pipe_type, const char *op_name, int multi_priority);
153
154// Key under which thumbnail events for (imgid, mip) are registered. Lets the GUI
155// memory view navigate from a mipmap cache item to its thumbnail event.
156uint64_t dt_supervisor_thumbnail_key(int32_t imgid, int mip);
157
158// Key under which mipmap cache objects (imgid, mip) are registered. Distinct
159// from the thumbnail key; used by the GUI memory view to navigate from a mipmap
160// cache item to the mipmap object's properties.
161uint64_t dt_supervisor_mipmap_key(int32_t imgid, int mip);
162
163// Key under which image cache objects (the canonical dt_image_t for an imgid)
164// are registered. Distinct from the mipmap key.
165uint64_t dt_supervisor_image_key(int32_t imgid);
166
172// `module`/`params` are optional: when the module exposes introspection, the
173// parameters are rendered human-legibly under "parameters" (pass NULL/NULL to skip).
174// `blend_params`, when given, is rendered under "blendop" (skipped when blending
175// is disabled).
176void dt_supervisor_history(dt_sv_op_t op, uint64_t param_hash, const char *op_name,
177 int multi_priority, const char *multi_name, int iop_order,
178 int history_index, int32_t imgid, gboolean enabled,
179 const struct dt_iop_module_t *module, const void *params,
180 const struct dt_develop_blend_params_t *blend_params, GList *forms);
181
182// Key under which a mask form is registered (by its formid).
184
191void dt_supervisor_form(dt_sv_op_t op, const struct dt_masks_form_t *form);
192
202void dt_supervisor_node(dt_sv_op_t op, uint64_t node_hash, uint64_t param_hash,
203 uint64_t predecessor_hash, const char *op_name, int multi_priority,
204 int iop_order, int pipe_type, int32_t imgid);
205
215void dt_supervisor_cacheline_create(uint64_t hash, uint64_t node_hash, uint64_t param_hash,
216 uint64_t input_hash, const char *op_name, int multi_priority,
217 int iop_order, int pipe_type, int32_t imgid, int roi_w,
218 int roi_h, int devid, size_t size, const char *name);
219
220// Cacheline read — every cache hit. Hash-only hot path; resolves from memory.
222
223// Cacheline eviction/free — flips `alive` to FALSE, keeps the entry as memory.
224void dt_supervisor_cacheline_delete(uint64_t hash, size_t size, int owner_pipe_id, const char *name);
225
234void dt_supervisor_rekey(uint64_t old_hash, uint64_t new_hash);
235
241void dt_supervisor_backbuf(dt_sv_op_t op, uint64_t hash, uint64_t history_hash, int w, int h,
242 int bpp, int pipe_type, int devid);
243
248void dt_supervisor_widget(dt_sv_op_t op, const char *widget_tag, uint64_t consumed_hash,
249 int pipe_type, int32_t imgid);
250
256void dt_supervisor_thumbnail(dt_sv_op_t op, int32_t imgid, int width, int height, int mip,
257 gboolean success);
258
264void dt_supervisor_mipmap(dt_sv_op_t op, int32_t imgid, int mip);
265
271void dt_supervisor_image(dt_sv_op_t op, int32_t imgid, const struct dt_image_t *img);
272
297void dt_supervisor_cache_wait(dt_sv_op_t op, uint64_t request_id, uint64_t awaited_hash,
298 const char *owner_tag, const char *op_name, int multi_priority,
299 int pipe_type, int32_t imgid, gboolean request_emitted, const char *note);
300
310
311#ifdef __cplusplus
312}
313#endif
314#endif // DT_DEVELOP_SUPERVISOR_H
gboolean enabled
–doc was passed on the command line
int bpp
int32_t dt_get_debug_flags(void)
Definition darktable.c:2085
#define DT_DEBUG_SUPERVISOR
Definition logging.h:87
uint32_t width
Definition mipmap_cache.c:0
uint32_t height
Definition mipmap_cache.c:1
size_t size
Definition mipmap_cache.c:3
const char * name
Definition pdf.h:90
unsigned __int64 uint64_t
Definition strptime.c:75
void dt_supervisor_events_free(GPtrArray *events)
void dt_supervisor_history(dt_sv_op_t op, uint64_t param_hash, const char *op_name, int multi_priority, const char *multi_name, int iop_order, int history_index, int32_t imgid, gboolean enabled, const struct dt_iop_module_t *module, const void *params, const struct dt_develop_blend_params_t *blend_params, GList *forms)
void dt_supervisor_cache_wait(dt_sv_op_t op, uint64_t request_id, uint64_t awaited_hash, const char *owner_tag, const char *op_name, int multi_priority, int pipe_type, int32_t imgid, gboolean request_emitted, const char *note)
gint dt_supervisor_recording
Definition supervisor.c:116
void dt_supervisor_thumbnail(dt_sv_op_t op, int32_t imgid, int width, int height, int mip, gboolean success)
void dt_supervisor_events_clear(void)
Definition supervisor.c:310
void dt_supervisor_mipmap(dt_sv_op_t op, int32_t imgid, int mip)
void dt_supervisor_cacheline_create(uint64_t hash, uint64_t node_hash, uint64_t param_hash, uint64_t input_hash, const char *op_name, int multi_priority, int iop_order, int pipe_type, int32_t imgid, int roi_w, int roi_h, int devid, size_t size, const char *name)
Definition supervisor.c:891
void dt_supervisor_node(dt_sv_op_t op, uint64_t node_hash, uint64_t param_hash, uint64_t predecessor_hash, const char *op_name, int multi_priority, int iop_order, int pipe_type, int32_t imgid)
Definition supervisor.c:856
void dt_supervisor_init(void)
Definition supervisor.c:283
GPtrArray * dt_supervisor_events_snapshot(void)
void dt_supervisor_form(dt_sv_op_t op, const struct dt_masks_form_t *form)
dt_sv_op_t
Definition supervisor.h:77
@ DT_SV_READ
Definition supervisor.h:80
@ DT_SV_UPDATE
Definition supervisor.h:79
@ DT_SV_CREATE
Definition supervisor.h:78
@ DT_SV_DELETE
Definition supervisor.h:81
void dt_supervisor_widget(dt_sv_op_t op, const char *widget_tag, uint64_t consumed_hash, int pipe_type, int32_t imgid)
void dt_supervisor_rekey(uint64_t old_hash, uint64_t new_hash)
GPtrArray * dt_supervisor_events_snapshot_since(uint64_t after_seq, uint64_t *out_last_seq)
void dt_supervisor_set_recording(gboolean on)
Definition supervisor.c:305
uint64_t dt_supervisor_thumbnail_key(int32_t imgid, int mip)
Definition supervisor.c:175
void dt_supervisor_cleanup(void)
Definition supervisor.c:292
void dt_supervisor_image(dt_sv_op_t op, int32_t imgid, const struct dt_image_t *img)
void dt_supervisor_cacheline_read(uint64_t hash, size_t size)
Definition supervisor.c:952
void dt_supervisor_backbuf(dt_sv_op_t op, uint64_t hash, uint64_t history_hash, int w, int h, int bpp, int pipe_type, int devid)
guint dt_supervisor_events_count(void)
void dt_supervisor_cacheline_delete(uint64_t hash, size_t size, int owner_pipe_id, const char *name)
Definition supervisor.c:982
uint64_t dt_supervisor_form_key(int formid)
Definition supervisor.c:213
static gboolean dt_supervisor_active(void)
Definition supervisor.h:95
uint64_t dt_supervisor_node_key(int pipe_type, const char *op_name, int multi_priority)
Definition supervisor.c:165
gchar * dt_supervisor_describe(uint64_t hash)
uint64_t dt_supervisor_image_key(int32_t imgid)
Definition supervisor.c:195
uint64_t dt_supervisor_mipmap_key(int32_t imgid, int mip)
Definition supervisor.c:185