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#pragma once
20
21#include <glib.h>
22#include <stdint.h>
23
24#include "common/darktable.h"
25
26struct dt_image_t;
27struct dt_iop_module_t;
29struct dt_masks_form_t;
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
74// CRUD verb for an event.
82
83// Lifecycle, called once from dt_init()/dt_cleanup().
84void dt_supervisor_init(void);
85void dt_supervisor_cleanup(void);
86
87// Runtime capture flag, set by the GUI (the supervisor window). The supervisor
88// captures events whenever this is set OR `-d supervisor` is active. Read via
89// the inline gate below; set via dt_supervisor_set_recording().
90extern gint dt_supervisor_recording;
91
92// Fast gate. TRUE when `-d supervisor` is enabled OR the GUI is recording. Guard
93// call sites with this so the per-event metadata gathering is skipped when off.
94static inline gboolean dt_supervisor_active(void)
95{
96 return (darktable.unmuted & DT_DEBUG_SUPERVISOR) || g_atomic_int_get(&dt_supervisor_recording);
97}
98
104typedef struct dt_sv_link_t
105{
106 char label[16]; // edge name, e.g. "params", "input", "node", "rekeyed_to"
109
111{
112 uint64_t seq; // monotonic capture sequence, for incremental GUI updates
113 double ts;
114 char thread[24];
115 char op[12];
116 char domain[16];
117 char mnemonic[64]; // human label for the row (module, imgid, widget, pipe, …)
118 char cache_name[32]; // cacheline "name" tag (e.g. "raster mask"), empty for plain module outputs
119 uint64_t hash; // the event's own object hash
120 GArray *links; // of dt_sv_link_t
121 gchar *json; // the full NDJSON record (compact), for the detail view
123
124// Toggle runtime capture into the in-memory log (the stderr NDJSON dump stays
125// governed by `-d supervisor`).
126void dt_supervisor_set_recording(gboolean on);
127
128// GUI thread: deep-copy snapshot of the retained log, oldest-first. Free with
129// dt_supervisor_events_free(). Empty (not NULL) when nothing was captured.
130GPtrArray *dt_supervisor_events_snapshot(void);
131
132// Incremental snapshot: only events captured after `after_seq` (oldest-first).
133// `out_last_seq` receives the highest seq returned (or `after_seq` if none), so
134// a poller can advance its cursor. Free with dt_supervisor_events_free().
135GPtrArray *dt_supervisor_events_snapshot_since(uint64_t after_seq, uint64_t *out_last_seq);
136
137// Number of events currently retained.
139
140void dt_supervisor_events_free(GPtrArray *events);
141
142// Drop all retained events.
144
151uint64_t dt_supervisor_node_key(int pipe_type, const char *op_name, int multi_priority);
152
153// Key under which thumbnail events for (imgid, mip) are registered. Lets the GUI
154// memory view navigate from a mipmap cache item to its thumbnail event.
155uint64_t dt_supervisor_thumbnail_key(int32_t imgid, int mip);
156
157// Key under which mipmap cache objects (imgid, mip) are registered. Distinct
158// from the thumbnail key; used by the GUI memory view to navigate from a mipmap
159// cache item to the mipmap object's properties.
160uint64_t dt_supervisor_mipmap_key(int32_t imgid, int mip);
161
162// Key under which image cache objects (the canonical dt_image_t for an imgid)
163// are registered. Distinct from the mipmap key.
164uint64_t dt_supervisor_image_key(int32_t imgid);
165
171// `module`/`params` are optional: when the module exposes introspection, the
172// parameters are rendered human-legibly under "parameters" (pass NULL/NULL to skip).
173// `blend_params`, when given, is rendered under "blendop" (skipped when blending
174// is disabled).
175void dt_supervisor_history(dt_sv_op_t op, uint64_t param_hash, const char *op_name,
176 int multi_priority, const char *multi_name, int iop_order,
177 int history_index, int32_t imgid, gboolean enabled,
178 const struct dt_iop_module_t *module, const void *params,
179 const struct dt_develop_blend_params_t *blend_params, GList *forms);
180
181// Key under which a mask form is registered (by its formid).
183
190void dt_supervisor_form(dt_sv_op_t op, const struct dt_masks_form_t *form);
191
201void dt_supervisor_node(dt_sv_op_t op, uint64_t node_hash, uint64_t param_hash,
202 uint64_t predecessor_hash, const char *op_name, int multi_priority,
203 int iop_order, int pipe_type, int32_t imgid);
204
214void dt_supervisor_cacheline_create(uint64_t hash, uint64_t node_hash, uint64_t param_hash,
215 uint64_t input_hash, const char *op_name, int multi_priority,
216 int iop_order, int pipe_type, int32_t imgid, int roi_w,
217 int roi_h, int devid, size_t size, const char *name);
218
219// Cacheline read — every cache hit. Hash-only hot path; resolves from memory.
221
222// Cacheline eviction/free — flips `alive` to FALSE, keeps the entry as memory.
223void dt_supervisor_cacheline_delete(uint64_t hash, size_t size, int owner_pipe_id, const char *name);
224
233void dt_supervisor_rekey(uint64_t old_hash, uint64_t new_hash);
234
240void dt_supervisor_backbuf(dt_sv_op_t op, uint64_t hash, uint64_t history_hash, int w, int h,
241 int bpp, int pipe_type, int devid);
242
247void dt_supervisor_widget(dt_sv_op_t op, const char *widget_tag, uint64_t consumed_hash,
248 int pipe_type, int32_t imgid);
249
255void dt_supervisor_thumbnail(dt_sv_op_t op, int32_t imgid, int width, int height, int mip,
256 gboolean success);
257
263void dt_supervisor_mipmap(dt_sv_op_t op, int32_t imgid, int mip);
264
270void dt_supervisor_image(dt_sv_op_t op, int32_t imgid, const struct dt_image_t *img);
271
296void dt_supervisor_cache_wait(dt_sv_op_t op, uint64_t request_id, uint64_t awaited_hash,
297 const char *owner_tag, const char *op_name, int multi_priority,
298 int pipe_type, int32_t imgid, gboolean request_emitted, const char *note);
299
309
310#ifdef __cplusplus
311}
312#endif
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
char * name
darktable_t darktable
Definition darktable.c:183
#define DT_DEBUG_SUPERVISOR
Definition darktable.h:764
int bpp
size_t size
Definition mipmap_cache.c:3
unsigned __int64 uint64_t
Definition strptime.c:75
int32_t unmuted
Definition darktable.h:778
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:112
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:76
@ DT_SV_READ
Definition supervisor.h:79
@ DT_SV_UPDATE
Definition supervisor.h:78
@ DT_SV_CREATE
Definition supervisor.h:77
@ DT_SV_DELETE
Definition supervisor.h:80
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:171
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:209
static gboolean dt_supervisor_active(void)
Definition supervisor.h:94
uint64_t dt_supervisor_node_key(int pipe_type, const char *op_name, int multi_priority)
Definition supervisor.c:161
gchar * dt_supervisor_describe(uint64_t hash)
uint64_t dt_supervisor_image_key(int32_t imgid)
Definition supervisor.c:191
uint64_t dt_supervisor_mipmap_key(int32_t imgid, int mip)
Definition supervisor.c:181