Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
iop_order.c File Reference
#include "common/darktable.h"
#include "common/iop_order.h"
#include "common/styles.h"
#include "common/debug.h"
#include "common/deprecations.h"
#include "common/image.h"
#include "common/image_cache.h"
#include "develop/imageop.h"
#include "develop/pixelpipe.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for iop_order.c:

Go to the source code of this file.

Macros

#define DT_IOP_ORDER_VERSION   5
 
#define DT_IOP_ORDER_INFO   (darktable.unmuted & DT_DEBUG_IOPORDER)
 

Functions

static void _ioppr_reset_iop_order (GList *iop_order_list)
 Reset iop_order values to a sequential order for a list.
 
static dt_iop_order_entry_tdt_ioppr_get_iop_order_entry (GList *iop_order_list, const char *op_name, const int multi_priority)
 Return the first order entry matching operation/instance.
 
static gboolean dt_ioppr_write_iop_order (const dt_iop_order_t kind, GList *iop_order_list, const int32_t imgid)
 Persist an order list for a given image with a specific kind.
 
static void dt_ioppr_resync_iop_list (dt_develop_t *dev)
 Resynchronize dev->iop list order against dev->iop_order_list.
 
static void dt_ioppr_update_for_entries (dt_develop_t *dev, GList *entry_list, gboolean append)
 Update dev->iop_order_list to include entries from entry_list.
 
static void dt_ioppr_check_duplicate_iop_order (GList **_iop_list, GList *history_list)
 Detect and resolve duplicate iop_order values.
 
static void dt_ioppr_migrate_iop_order (struct dt_develop_t *dev, const int32_t imgid)
 Apply a new order list by reloading history and rebuilding UI/pipelines.
 
static GList * dt_ioppr_extract_multi_instances_list (GList *iop_order_list)
 Extract all order entries that have multiple instances.
 
static GList * dt_ioppr_merge_multi_instance_iop_order_list (GList *iop_order_list, GList *multi_instance_list)
 Merge multiple-instance entries into an order list.
 
static gboolean _ioppr_sanity_check_iop_order (GList *list)
 Basic sanity check for an order list.
 
const char * dt_iop_order_string (const dt_iop_order_t order)
 Return the human-readable name for an IOP order enum value.
 
static void_dup_iop_order_entry (const void *src, gpointer data)
 Deep-copy callback for dt_iop_order_entry_t.
 
static int _count_entries_operation (GList *e_list, const char *operation)
 Count order-list entries matching an operation name.
 
static GList * _insert_before (GList *iop_order_list, const char *module, const char *new_module)
 Insert a missing module entry before another module in an order list.
 
dt_iop_order_t dt_ioppr_get_iop_order_version (const int32_t imgid)
 Fetch the IOP order version stored for an image.
 
GList * dt_ioppr_get_iop_order_rules ()
 Return the list of ordering rules (prev/next constraints).
 
GList * dt_ioppr_get_iop_order_link (GList *iop_order_list, const char *op_name, const int multi_priority)
 Find a list link matching an operation and instance.
 
int dt_ioppr_get_iop_order (GList *iop_order_list, const char *op_name, const int multi_priority)
 Return the iop_order for a given operation/instance pair.
 
gint dt_sort_iop_list_by_order (gconstpointer a, gconstpointer b)
 
gint dt_sort_iop_list_by_order_f (gconstpointer a, gconstpointer b)
 Compare two list nodes holding modules by iop_order.
 
dt_iop_order_t dt_ioppr_get_iop_order_list_kind (GList *iop_order_list)
 Determine the kind of an order list by inspecting its content.
 
gboolean dt_ioppr_has_multiple_instances (GList *iop_order_list)
 Detect whether multiple instances are grouped for a non-custom order.
 
gboolean dt_ioppr_write_iop_order_list (GList *iop_order_list, const int32_t imgid)
 Persist an order list to the DB for a given image.
 
GList * _table_to_list (const dt_iop_order_entry_t entries[])
 Build an order list from a static entry table.
 
GList * dt_ioppr_get_iop_order_list_version (dt_iop_order_t version)
 Return the built-in order list for a given version.
 
gboolean dt_ioppr_has_iop_order_list (int32_t imgid)
 Check whether the image has an explicit order list stored in DB.
 
GList * dt_ioppr_get_iop_order_list (int32_t imgid, gboolean sorted)
 Load the order list for an image from the DB.
 
void dt_ioppr_resync_pipeline (dt_develop_t *dev, const int32_t imgid, const char *msg, gboolean check_duplicates)
 Resynchronize pipeline order and related structures.
 
void dt_ioppr_resync_modules_order (dt_develop_t *dev)
 Update dev->iop module order values from dev->iop_order_list.
 
void dt_ioppr_rebuild_iop_order_from_modules (struct dt_develop_t *dev, GList *ordered_modules)
 Rebuild dev->iop_order_list from a list of ordered modules.
 
void dt_ioppr_set_default_iop_order (dt_develop_t *dev, const int32_t imgid)
 Set dev->iop_order_list to the default order for a given image.
 
void dt_ioppr_change_iop_order (struct dt_develop_t *dev, const int32_t imgid, GList *new_iop_list)
 Replace the current order list with a new one and persist it.
 
GList * dt_ioppr_merge_module_multi_instance_iop_order_list (GList *iop_order_list, const char *operation, GList *multi_instance_list)
 Merge an operation's multiple instances into the order list.
 
static void _count_iop_module (GList *iop, const char *operation, int *max_multi_priority, int *count, int *max_multi_priority_enabled, int *count_enabled)
 Count module instances and track their highest priorities.
 
static gboolean _operation_already_handled (GList *e_list, const char *operation)
 Check if an operation was already handled earlier in the list.
 
int _get_multi_priority (dt_develop_t *dev, const char *operation, const int n, const gboolean only_disabled)
 Return the multi_priority of the n-th instance of an operation.
 
void dt_ioppr_update_for_style_items (dt_develop_t *dev, GList *st_items, gboolean append)
 Update dev->iop_order_list with modules referenced by style items.
 
void dt_ioppr_update_for_modules (dt_develop_t *dev, GList *modules, gboolean append)
 Update dev->iop_order_list with modules from a module list.
 
static dt_dev_history_item_t_ioppr_search_history_by_module (GList *history_list, dt_iop_module_t *mod)
 Find a history item referencing a given module instance.
 
int dt_ioppr_check_so_iop_order (GList *iop_list, GList *iop_order_list)
 Check whether any module .so is missing an iop_order entry.
 
GList * dt_ioppr_iop_order_copy_deep (GList *iop_order_list)
 Deep-copy an order list.
 
gint dt_sort_iop_by_order (gconstpointer a, gconstpointer b)
 Compare two module instances by iop_order for sorting.
 
gboolean dt_ioppr_check_can_move_before_iop (GList *iop_list, dt_iop_module_t *module, dt_iop_module_t *module_next)
 Validate whether module can be moved before module_next.
 
gboolean dt_ioppr_check_can_move_after_iop (GList *iop_list, dt_iop_module_t *module, dt_iop_module_t *module_prev)
 Validate whether module can be moved after module_prev.
 
gboolean dt_ioppr_move_iop_before (struct dt_develop_t *dev, dt_iop_module_t *module, dt_iop_module_t *module_next)
 Move a module instance before another module in the pipe.
 
gboolean dt_ioppr_move_iop_after (struct dt_develop_t *dev, dt_iop_module_t *module, dt_iop_module_t *module_prev)
 Move a module instance after another module in the pipe.
 
static void _ioppr_check_rules (GList *iop_list, const int32_t imgid, const char *msg)
 Validate pipeline order against fence and rule constraints.
 
void dt_ioppr_insert_module_instance (struct dt_develop_t *dev, dt_iop_module_t *module)
 Ensure a module instance has an entry in dev->iop_order_list.
 
int dt_ioppr_check_iop_order (dt_develop_t *dev, const int32_t imgid, const char *msg)
 Debug helper to validate the current order for a develop context.
 
voiddt_ioppr_serialize_iop_order_list (GList *iop_order_list, size_t *size)
 Serialize an order list into a binary blob (used for presets).
 
char * dt_ioppr_serialize_text_iop_order_list (GList *iop_order_list)
 Serialize an order list to a text representation.
 
GList * dt_ioppr_deserialize_text_iop_order_list (const char *buf)
 Deserialize an order list from a text representation.
 
GList * dt_ioppr_deserialize_iop_order_list (const char *buf, size_t size)
 Deserialize an order list from a binary blob.
 

Variables

const char * iop_order_string []
 
const dt_iop_order_entry_t legacy_order []
 
const dt_iop_order_entry_t v30_order []
 
const dt_iop_order_entry_t v30_jpg_order []
 
const dt_iop_order_entry_t ansel_jpg_order []
 
const dt_iop_order_entry_t ansel_raw_order []
 
static const dt_iop_order_entry_torders [5] = { legacy_order, v30_order, v30_jpg_order, ansel_raw_order, ansel_jpg_order }
 

Macro Definition Documentation

◆ DT_IOP_ORDER_INFO

#define DT_IOP_ORDER_INFO   (darktable.unmuted & DT_DEBUG_IOPORDER)

Definition at line 56 of file iop_order.c.

◆ DT_IOP_ORDER_VERSION

#define DT_IOP_ORDER_VERSION   5

Definition at line 54 of file iop_order.c.

Function Documentation

◆ _count_entries_operation()

static int _count_entries_operation ( GList *  e_list,
const char *  operation 
)
static

Count order-list entries matching an operation name.

Parameters
e_listEntry list.
operationOperation name to match.
Returns
Count of entries.

Definition at line 1587 of file iop_order.c.

References dt_iop_order_entry_t::operation.

Referenced by dt_ioppr_extract_multi_instances_list(), dt_ioppr_merge_module_multi_instance_iop_order_list(), and dt_ioppr_update_for_entries().

◆ _count_iop_module()

static void _count_iop_module ( GList *  iop,
const char *  operation,
int *  max_multi_priority,
int *  count,
int *  max_multi_priority_enabled,
int *  count_enabled 
)
static

Count module instances and track their highest priorities.

Parameters
iopModule list.
operationOperation name to count.
max_multi_priorityOutput: maximum multi_priority among all instances.
countOutput: total number of instances.
max_multi_priority_enabledOutput: maximum multi_priority among enabled instances.
count_enabledOutput: number of enabled instances.

Definition at line 1553 of file iop_order.c.

Referenced by dt_ioppr_update_for_entries().

◆ _dup_iop_order_entry()

static void * _dup_iop_order_entry ( const void src,
gpointer  data 
)
static

Deep-copy callback for dt_iop_order_entry_t.

Parameters
srcSource entry.
dataUnused.
Returns
Newly-allocated copy.

Definition at line 1987 of file iop_order.c.

Referenced by dt_ioppr_extract_multi_instances_list(), and dt_ioppr_iop_order_copy_deep().

◆ _get_multi_priority()

int _get_multi_priority ( dt_develop_t dev,
const char *  operation,
const int  n,
const gboolean  only_disabled 
)

Return the multi_priority of the n-th instance of an operation.

Parameters
devDevelop context.
operationOperation name.
nInstance index (1-based).
only_disabledIf TRUE, only consider disabled instances.
Returns
multi_priority or INT_MAX if not found.

Definition at line 1626 of file iop_order.c.

References FALSE, dt_develop_t::iop, and n.

Referenced by dt_ioppr_update_for_entries().

◆ _insert_before()

static GList * _insert_before ( GList *  iop_order_list,
const char *  module,
const char *  new_module 
)
static

Insert a missing module entry before another module in an order list.

This is used to migrate older/custom lists when new modules appear in built-in orders.

Parameters
iop_order_listOrder list to update.
moduleExisting module name to insert before.
new_moduleNew module name to insert if missing.
Returns
Updated list head.

Definition at line 720 of file iop_order.c.

References FALSE, dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order, dt_iop_order_entry_t::o, dt_iop_order_entry_t::operation, and TRUE.

Referenced by dt_ioppr_get_iop_order_list().

◆ _ioppr_check_rules()

static void _ioppr_check_rules ( GList *  iop_list,
const int32_t  imgid,
const char *  msg 
)
static

Validate pipeline order against fence and rule constraints.

Emits debug messages when violations are detected.

Parameters
iop_listModule list.
imgidImage id (for diagnostics).
msgOptional debug label.

Definition at line 2295 of file iop_order.c.

References darktable, and darktable_t::iop_order_rules.

Referenced by dt_ioppr_check_iop_order().

◆ _ioppr_reset_iop_order()

static void _ioppr_reset_iop_order ( GList *  iop_order_list)
static

Reset iop_order values to a sequential order for a list.

Ensures the list has monotonically increasing iop_order values.

Parameters
iop_order_listOrder list to normalize.

Definition at line 1224 of file iop_order.c.

References dt_iop_order_entry_t::iop_order, and dt_iop_order_entry_t::o.

Referenced by dt_ioppr_deserialize_iop_order_list(), dt_ioppr_deserialize_text_iop_order_list(), dt_ioppr_get_iop_order_list(), dt_ioppr_resync_modules_order(), dt_ioppr_set_default_iop_order(), and dt_ioppr_update_for_entries().

◆ _ioppr_sanity_check_iop_order()

static gboolean _ioppr_sanity_check_iop_order ( GList *  list)
static

Basic sanity check for an order list.

Ensures all entries are valid and ordering values are non-zero.

Parameters
listOrder list.
Returns
TRUE if list looks sane, FALSE otherwise.

Definition at line 2566 of file iop_order.c.

References dt_iop_order_entry_t::operation, and TRUE.

Referenced by dt_ioppr_get_iop_order_list().

◆ _ioppr_search_history_by_module()

static dt_dev_history_item_t * _ioppr_search_history_by_module ( GList *  history_list,
dt_iop_module_t mod 
)
static

Find a history item referencing a given module instance.

Parameters
history_listHistory list.
modModule instance.
Returns
First matching history item or NULL.

Definition at line 1830 of file iop_order.c.

Referenced by dt_ioppr_check_duplicate_iop_order().

◆ _operation_already_handled()

static gboolean _operation_already_handled ( GList *  e_list,
const char *  operation 
)
static

Check if an operation was already handled earlier in the list.

Parameters
e_listCurrent list node.
operationOperation name to search.
Returns
TRUE if found earlier, FALSE otherwise.

Definition at line 1607 of file iop_order.c.

References FALSE, and TRUE.

Referenced by dt_ioppr_update_for_entries().

◆ _table_to_list()

GList * _table_to_list ( const dt_iop_order_entry_t  entries[])

Build an order list from a static entry table.

Parameters
entriesZero-terminated array of dt_iop_order_entry_t.
Returns
Newly-allocated order list.

Definition at line 1025 of file iop_order.c.

References dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order_f, k, dt_iop_order_entry_t::o, and dt_iop_order_entry_t::operation.

Referenced by dt_ioppr_get_iop_order_list(), and dt_ioppr_get_iop_order_list_version().

◆ dt_iop_order_string()

const char * dt_iop_order_string ( const dt_iop_order_t  order)

Return the human-readable name for an IOP order enum value.

This is mostly used for debug strings, logs, and UI messages.

Parameters
orderIOP order enum value.
Returns
Static string describing the order.

Definition at line 80 of file iop_order.c.

References DT_IOP_ORDER_LAST, and iop_order_string.

Referenced by _gui_styles_dialog_run(), _ioporder_get_current_order_name(), dt_collection_get_property_values(), and get_query_string().

◆ dt_ioppr_change_iop_order()

void dt_ioppr_change_iop_order ( struct dt_develop_t dev,
const int32_t  imgid,
GList *  new_iop_list 
)

Replace the current order list with a new one and persist it.

Parameters
devDevelop context.
imgidImage id.
new_iop_listNew order list (ownership remains with caller).

Definition at line 1386 of file iop_order.c.

References darktable, darktable_t::develop, dt_dev_write_history(), dt_free_gpointer(), DT_IOP_ORDER_CUSTOM, dt_ioppr_extract_multi_instances_list(), dt_ioppr_iop_order_copy_deep(), dt_ioppr_merge_multi_instance_iop_order_list(), dt_ioppr_migrate_iop_order(), dt_ioppr_write_iop_order(), FALSE, and dt_develop_t::iop_order_list.

Referenced by gui_reset(), and set_params().

◆ dt_ioppr_check_can_move_after_iop()

gboolean dt_ioppr_check_can_move_after_iop ( GList *  iop_list,
struct dt_iop_module_t module,
struct dt_iop_module_t module_prev 
)

Validate whether module can be moved after module_prev.

Parameters
iop_listCurrent module list.
moduleModule to move.
module_prevTarget module that should precede.
Returns
TRUE if move is allowed, FALSE otherwise.

Definition at line 2184 of file iop_order.c.

References dt_ioppr_check_can_move_before_iop(), FALSE, dt_iop_module_t::iop_order, IS_NULL_PTR, dt_iop_module_t::multi_name, dt_iop_module_t::op, dt_iop_module_t::raster_mask, dt_iop_module_t::sink, and dt_iop_module_t::source.

Referenced by _dev_module_update_multishow(), _ioporder_drag_motion(), and _modulegroups_drag_motion().

◆ dt_ioppr_check_can_move_before_iop()

gboolean dt_ioppr_check_can_move_before_iop ( GList *  iop_list,
struct dt_iop_module_t module,
struct dt_iop_module_t module_next 
)

Validate whether module can be moved before module_next.

Parameters
iop_listCurrent module list.
moduleModule to move.
module_nextTarget module that should follow.
Returns
TRUE if move is allowed, FALSE otherwise.

Definition at line 2015 of file iop_order.c.

References darktable, FALSE, dt_iop_module_t::iop_order, darktable_t::iop_order_rules, IS_NULL_PTR, dt_iop_module_t::multi_name, dt_iop_module_t::op, dt_iop_module_t::raster_mask, dt_iop_module_t::sink, dt_iop_module_t::source, and TRUE.

Referenced by _dev_module_update_multishow(), _ioporder_drag_motion(), _modulegroups_drag_motion(), and dt_ioppr_check_can_move_after_iop().

◆ dt_ioppr_check_duplicate_iop_order()

static void dt_ioppr_check_duplicate_iop_order ( GList **  _iop_list,
GList *  history_list 
)
static

Detect and resolve duplicate iop_order values.

Walks the module list, reorders or removes disabled duplicates not present in history to keep a consistent ordering.

Parameters
_iop_listPointer to module list to mutate.
history_listHistory list used to preserve required instances.

Definition at line 1859 of file iop_order.c.

References _ioppr_search_history_by_module(), dt_ioppr_check_duplicate_iop_order(), dt_iop_module_t::enabled, dt_iop_module_t::iop_order, dt_iop_module_t::multi_name, and dt_iop_module_t::op.

Referenced by dt_ioppr_check_duplicate_iop_order(), and dt_ioppr_resync_pipeline().

◆ dt_ioppr_check_iop_order()

int dt_ioppr_check_iop_order ( struct dt_develop_t dev,
const int32_t  imgid,
const char *  msg 
)

Debug helper to validate the current order for a develop context.

Logs inconsistencies and optionally reports the state with msg.

Parameters
devDevelop context.
imgidImage id (for diagnostics).
msgOptional debug message.
Returns
0 on success, non-zero if issues were detected.

Definition at line 2377 of file iop_order.c.

References _ioppr_check_rules(), DT_DEBUG_PARAMS, dt_print(), dt_develop_t::history, dt_develop_t::iop, dt_iop_module_t::iop_order, dt_iop_module_t::multi_name, dt_iop_module_t::multi_priority, and dt_iop_module_t::op.

Referenced by _apply_style_before_export(), dt_dev_modules_update_multishow(), dt_iop_gui_commit_iop_order_change(), and dt_ioppr_resync_pipeline().

◆ dt_ioppr_check_so_iop_order()

int dt_ioppr_check_so_iop_order ( GList *  iop_list,
GList *  iop_order_list 
)

Check whether any module .so is missing an iop_order entry.

Parameters
iop_listList of module .so entries.
iop_order_listCurrent order list.
Returns
1 if any module is missing an entry, 0 otherwise.

Definition at line 1960 of file iop_order.c.

References dt_deprecated(), dt_ioppr_get_iop_order_entry(), and IS_NULL_PTR.

Referenced by dt_init().

◆ dt_ioppr_deserialize_iop_order_list()

GList * dt_ioppr_deserialize_iop_order_list ( const char *  buf,
size_t  size 
)

Deserialize an order list from a binary blob.

Parameters
bufSerialized buffer.
sizeBuffer size in bytes.
Returns
Newly-allocated order list or NULL on error.

Definition at line 2632 of file iop_order.c.

References _ioppr_reset_iop_order(), dt_free, dt_free_gpointer(), error(), dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order, dt_iop_order_entry_t::o, dt_iop_order_entry_t::operation, and size.

Referenced by _dev_auto_apply_presets(), _ioporder_get_current_order_name(), and set_params().

◆ dt_ioppr_deserialize_text_iop_order_list()

GList * dt_ioppr_deserialize_text_iop_order_list ( const char *  buf)

Deserialize an order list from a text representation.

Parameters
bufNUL-terminated string.
Returns
Newly-allocated order list or NULL on error.

Definition at line 2588 of file iop_order.c.

References _ioppr_reset_iop_order(), dt_free_gpointer(), dt_util_str_to_glist(), error(), dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order, IS_NULL_PTR, dt_iop_order_entry_t::o, and dt_iop_order_entry_t::operation.

Referenced by dt_exif_xmp_read(), dt_ioppr_get_iop_order_list(), dt_styles_module_order_list(), and dt_styles_style_text_handler().

◆ dt_ioppr_extract_multi_instances_list()

static GList * dt_ioppr_extract_multi_instances_list ( GList *  iop_order_list)
static

Extract all order entries that have multiple instances.

Parameters
iop_order_listOrder list to scan.
Returns
List of duplicated entries corresponding to multi-instance ops.

Definition at line 1407 of file iop_order.c.

References _count_entries_operation(), _dup_iop_order_entry(), and copy().

Referenced by dt_ioppr_change_iop_order().

◆ dt_ioppr_get_iop_order()

int dt_ioppr_get_iop_order ( GList *  iop_order_list,
const char *  op_name,
const int  multi_priority 
)

Return the iop_order for a given operation/instance pair.

Parameters
iop_order_listOrder list to search.
op_nameOperation name.
multi_priorityInstance priority.
Returns
The iop_order value, or 0 if not found.

Definition at line 868 of file iop_order.c.

References dt_deprecated(), and dt_ioppr_get_iop_order_entry().

Referenced by __attribute__(), _process_history_db_entry(), _show_hide_colorspace(), _styles_sync_pipeline_from_items(), default_input_format(), default_output_format(), default_tiling_callback(), dt_ioppr_get_pipe_current_profile_info(), dt_ioppr_resync_modules_order(), dt_ioppr_update_for_modules(), and dt_ioppr_update_for_style_items().

◆ dt_ioppr_get_iop_order_entry()

static dt_iop_order_entry_t * dt_ioppr_get_iop_order_entry ( GList *  iop_order_list,
const char *  op_name,
const int  multi_priority 
)
static

Return the first order entry matching operation/instance.

Parameters
iop_order_listOrder list.
op_nameOperation name.
multi_priorityInstance priority (or -1 for any).
Returns
Matching entry or NULL.

Definition at line 857 of file iop_order.c.

References dt_ioppr_get_iop_order_link().

Referenced by dt_ioppr_check_so_iop_order(), and dt_ioppr_get_iop_order().

◆ dt_ioppr_get_iop_order_link()

GList * dt_ioppr_get_iop_order_link ( GList *  iop_order_list,
const char *  op_name,
const int  multi_priority 
)

Find a list link matching an operation and instance.

Parameters
iop_order_listOrder list to search.
op_nameOperation name.
multi_priorityInstance priority.
Returns
The matching list node or NULL if not found.

Definition at line 830 of file iop_order.c.

References dt_iop_order_entry_t::instance, and dt_iop_order_entry_t::operation.

Referenced by dt_exif_xmp_read(), dt_ioppr_get_iop_order_entry(), dt_ioppr_merge_module_multi_instance_iop_order_list(), dt_ioppr_move_iop_after(), and dt_ioppr_move_iop_before().

◆ dt_ioppr_get_iop_order_list()

GList * dt_ioppr_get_iop_order_list ( int32_t  imgid,
gboolean  sorted 
)

◆ dt_ioppr_get_iop_order_list_kind()

dt_iop_order_t dt_ioppr_get_iop_order_list_kind ( GList *  iop_order_list)

Determine the kind of an order list by inspecting its content.

Compares the list ordering to the known built-in lists to decide whether this is a built-in version or a custom order.

Parameters
iop_order_listList of dt_iop_order_entry_t.
Returns
A built-in order version or DT_IOP_ORDER_CUSTOM.

Definition at line 905 of file iop_order.c.

References DT_IOP_ORDER_CUSTOM, DT_IOP_ORDER_LAST, DT_IOP_ORDER_LEGACY, FALSE, IS_NULL_PTR, k, orders, and TRUE.

Referenced by _ioporder_get_current_order_name(), _upgrade_library_schema_step(), and dt_ioppr_write_iop_order_list().

◆ dt_ioppr_get_iop_order_list_version()

GList * dt_ioppr_get_iop_order_list_version ( dt_iop_order_t  version)

◆ dt_ioppr_get_iop_order_rules()

GList * dt_ioppr_get_iop_order_rules ( )

Return the list of ordering rules (prev/next constraints).

Returns
List of dt_iop_order_rule_t.

Definition at line 793 of file iop_order.c.

References i, dt_iop_order_rule_t::op_next, and dt_iop_order_rule_t::op_prev.

Referenced by dt_init().

◆ dt_ioppr_get_iop_order_version()

dt_iop_order_t dt_ioppr_get_iop_order_version ( const int32_t  imgid)

Fetch the IOP order version stored for an image.

If the image has no stored order, this falls back to the default matching the image format, or DT_IOP_ORDER_ANSEL_RAW for UNKNOWN_IMAGE.

Parameters
imgidImage id.
Returns
Stored order version or the default built-in order.

Definition at line 761 of file iop_order.c.

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_image_cache_read_release(), dt_image_cache_testget(), dt_image_needs_rawprepare(), DT_IOP_ORDER_ANSEL_JPG, DT_IOP_ORDER_ANSEL_RAW, FALSE, darktable_t::image_cache, IS_NULL_PTR, and TRUE.

Referenced by _exif_xmp_read_data(), _exif_xmp_read_data_export(), and _gui_styles_dialog_run().

◆ dt_ioppr_has_iop_order_list()

gboolean dt_ioppr_has_iop_order_list ( int32_t  imgid)

Check whether the image has an explicit order list stored in DB.

Parameters
imgidImage id.
Returns
TRUE if an order list exists, FALSE otherwise.

Definition at line 1073 of file iop_order.c.

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and FALSE.

Referenced by _dev_auto_apply_presets().

◆ dt_ioppr_has_multiple_instances()

gboolean dt_ioppr_has_multiple_instances ( GList *  iop_order_list)

Detect whether multiple instances are grouped for a non-custom order.

Used to decide if a list follows the built-in ordering conventions.

Parameters
iop_order_listOrder list to inspect.
Returns
TRUE if instances are grouped together, FALSE otherwise.

Definition at line 945 of file iop_order.c.

References FALSE, and TRUE.

Referenced by _exif_xmp_read_data(), _exif_xmp_read_data_export(), and dt_ioppr_write_iop_order().

◆ dt_ioppr_insert_module_instance()

void dt_ioppr_insert_module_instance ( struct dt_develop_t dev,
struct dt_iop_module_t module 
)

Ensure a module instance has an entry in dev->iop_order_list.

Inserts a new entry if missing, keeping list consistency for subsequent reordering or serialization.

Parameters
devDevelop context.
moduleModule instance to insert.

Definition at line 2349 of file iop_order.c.

References dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order, dt_develop_t::iop_order_list, dt_iop_order_entry_t::o, and dt_iop_order_entry_t::operation.

Referenced by dt_dev_module_duplicate().

◆ dt_ioppr_iop_order_copy_deep()

GList * dt_ioppr_iop_order_copy_deep ( GList *  iop_order_list)

Deep-copy an order list.

Parameters
iop_order_listSource list.
Returns
Newly-allocated list with duplicated entries.

Definition at line 1996 of file iop_order.c.

References _dup_iop_order_entry().

Referenced by _hm_backup_dest(), _lib_snapshot_capture_state(), _pop_undo(), dt_dev_history_undo_end_record_locked(), dt_dev_history_undo_start_record_locked(), dt_dev_pixelpipe_create_nodes(), dt_ioppr_change_iop_order(), and dt_ioppr_merge_multi_instance_iop_order_list().

◆ dt_ioppr_merge_module_multi_instance_iop_order_list()

GList * dt_ioppr_merge_module_multi_instance_iop_order_list ( GList *  iop_order_list,
const char *  operation,
GList *  multi_instance_list 
)

Merge an operation's multiple instances into the order list.

Updates instance numbers in-place and inserts additional entries as needed.

Parameters
iop_order_listBase order list.
operationOperation name.
multi_instance_listList of instances for that operation.
Returns
Updated order list.

Definition at line 1435 of file iop_order.c.

References _count_entries_operation(), dt_free, dt_ioppr_get_iop_order_link(), g_list_shorter_than(), and dt_iop_order_entry_t::instance.

Referenced by dt_ioppr_merge_multi_instance_iop_order_list().

◆ dt_ioppr_merge_multi_instance_iop_order_list()

static GList * dt_ioppr_merge_multi_instance_iop_order_list ( GList *  iop_order_list,
GList *  multi_instance_list 
)
static

Merge multiple-instance entries into an order list.

Groups all instances of the same operation together, then merges them back into the main list while preserving relative ordering.

Parameters
iop_order_listBase order list to update.
multi_instance_listList of entries containing multiple instances.
Returns
Updated order list.

Definition at line 1498 of file iop_order.c.

References copy(), dt_ioppr_iop_order_copy_deep(), dt_ioppr_merge_module_multi_instance_iop_order_list(), and dt_iop_order_entry_t::operation.

Referenced by dt_ioppr_change_iop_order().

◆ dt_ioppr_migrate_iop_order()

static void dt_ioppr_migrate_iop_order ( struct dt_develop_t dev,
const int32_t  imgid 
)
static

Apply a new order list by reloading history and rebuilding UI/pipelines.

Parameters
devDevelop context.
imgidImage id.

Definition at line 1377 of file iop_order.c.

References dt_dev_history_gui_update(), dt_dev_history_notify_change(), dt_dev_history_pixelpipe_update(), dt_dev_reload_history_items(), dt_ioppr_set_default_iop_order(), dt_image_t::id, dt_develop_t::image_storage, and TRUE.

Referenced by dt_ioppr_change_iop_order().

◆ dt_ioppr_move_iop_after()

gboolean dt_ioppr_move_iop_after ( struct dt_develop_t dev,
struct dt_iop_module_t module,
struct dt_iop_module_t module_prev 
)

Move a module instance after another module in the pipe.

Updates module ordering and related lists.

Parameters
devDevelop context.
moduleModule to move.
module_prevModule that should precede after move.
Returns
TRUE if move succeeded, FALSE otherwise.

Definition at line 2251 of file iop_order.c.

References dt_ioppr_get_iop_order_link(), dt_ioppr_resync_modules_order(), FALSE, dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order, dt_develop_t::iop_order_list, IS_NULL_PTR, dt_iop_module_t::multi_priority, dt_iop_order_entry_t::o, dt_iop_module_t::op, dt_iop_order_entry_t::operation, and TRUE.

Referenced by dt_dev_module_duplicate(), and dt_iop_gui_move_module_after().

◆ dt_ioppr_move_iop_before()

gboolean dt_ioppr_move_iop_before ( struct dt_develop_t dev,
struct dt_iop_module_t module,
struct dt_iop_module_t module_next 
)

Move a module instance before another module in the pipe.

Updates module ordering and related lists.

Parameters
devDevelop context.
moduleModule to move.
module_nextModule that should follow after move.
Returns
TRUE if move succeeded, FALSE otherwise.

Definition at line 2219 of file iop_order.c.

References dt_ioppr_get_iop_order_link(), dt_ioppr_resync_modules_order(), FALSE, dt_iop_order_entry_t::instance, dt_iop_order_entry_t::iop_order, dt_develop_t::iop_order_list, IS_NULL_PTR, dt_iop_module_t::multi_priority, dt_iop_order_entry_t::o, dt_iop_module_t::op, dt_iop_order_entry_t::operation, and TRUE.

Referenced by dt_iop_gui_move_module_before().

◆ dt_ioppr_rebuild_iop_order_from_modules()

void dt_ioppr_rebuild_iop_order_from_modules ( struct dt_develop_t dev,
GList *  ordered_modules 
)

◆ dt_ioppr_resync_iop_list()

static void dt_ioppr_resync_iop_list ( dt_develop_t dev)
static

Resynchronize dev->iop list order against dev->iop_order_list.

This updates each module's iop_order and then sorts the module list.

Parameters
devDevelop context.

Definition at line 1243 of file iop_order.c.

References dt_free, dt_iop_get_module_by_op_priority(), dt_develop_t::iop, dt_develop_t::iop_order_list, and IS_NULL_PTR.

Referenced by dt_ioppr_resync_pipeline().

◆ dt_ioppr_resync_modules_order()

void dt_ioppr_resync_modules_order ( struct dt_develop_t dev)

◆ dt_ioppr_resync_pipeline()

void dt_ioppr_resync_pipeline ( struct dt_develop_t dev,
const int32_t  imgid,
const char *  msg,
gboolean  check_duplicates 
)

Resynchronize pipeline order and related structures.

Rebuilds ordering for modules/history and optionally checks for duplicate iop_order values.

Parameters
devDevelop context.
imgidImage id (for diagnostics).
msgOptional debug message.
check_duplicatesWhether to validate duplicate iop_order entries.

Definition at line 1263 of file iop_order.c.

References dt_ioppr_check_duplicate_iop_order(), dt_ioppr_check_iop_order(), dt_ioppr_resync_iop_list(), dt_ioppr_resync_modules_order(), dt_develop_t::history, and dt_develop_t::iop.

Referenced by _styles_sync_pipeline_from_items(), dt_dev_pop_history_items_ext(), dt_dev_read_history_ext(), dt_dev_replace_history_on_image(), dt_history_merge(), and dt_styles_apply_style_item().

◆ dt_ioppr_serialize_iop_order_list()

void * dt_ioppr_serialize_iop_order_list ( GList *  iop_order_list,
size_t *  size 
)

Serialize an order list into a binary blob (used for presets).

Parameters
iop_order_listOrder list to serialize.
sizeOutput size of the serialized blob.
Returns
Allocated buffer to be freed by the caller.

Definition at line 2491 of file iop_order.c.

References IS_NULL_PTR, and size.

Referenced by get_params(), and init_presets().

◆ dt_ioppr_serialize_text_iop_order_list()

char * dt_ioppr_serialize_text_iop_order_list ( GList *  iop_order_list)

Serialize an order list to a text representation.

Parameters
iop_order_listOrder list to serialize.
Returns
Newly-allocated NUL-terminated string.

Definition at line 2533 of file iop_order.c.

References FALSE.

Referenced by _dt_style_update_iop_order(), _exif_xmp_read_data(), _exif_xmp_read_data_export(), _ioporder_get_current_order_name(), _upgrade_library_schema_step(), dt_ioppr_write_iop_order(), dt_styles_create_style_header(), and dt_styles_save_to_file().

◆ dt_ioppr_set_default_iop_order()

void dt_ioppr_set_default_iop_order ( struct dt_develop_t dev,
const int32_t  imgid 
)

Set dev->iop_order_list to the default order for a given image.

Uses the stored image order when present. If the image has no stored order, uses dev->image_storage to pick the RAW or non-RAW built-in list so darkroom first-run history reloads and offscreen paste/style reloads use the same image state as the modules.

Parameters
devDevelop context.
imgidImage id.

Definition at line 1325 of file iop_order.c.

References _ioppr_reset_iop_order(), darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free_gpointer(), dt_image_needs_rawprepare(), DT_IOP_ORDER_ANSEL_JPG, DT_IOP_ORDER_ANSEL_RAW, dt_ioppr_get_iop_order_list(), dt_ioppr_get_iop_order_list_version(), dt_ioppr_resync_modules_order(), FALSE, dt_image_t::id, dt_develop_t::image_storage, and dt_develop_t::iop_order_list.

Referenced by _dev_auto_apply_presets(), _styles_init_source_dev(), dt_dev_read_history_ext(), and dt_ioppr_migrate_iop_order().

◆ dt_ioppr_update_for_entries()

static void dt_ioppr_update_for_entries ( dt_develop_t dev,
GList *  entry_list,
gboolean  append 
)
static

Update dev->iop_order_list to include entries from entry_list.

Used by update paths for modules and style items.

Parameters
devDevelop context.
entry_listList of dt_iop_order_entry_t.
appendWhether to append missing entries at the end.

Definition at line 1651 of file iop_order.c.

References _count_entries_operation(), _count_iop_module(), _get_multi_priority(), _ioppr_reset_iop_order(), _operation_already_handled(), dt_iop_get_module_by_instance_name(), FALSE, dt_iop_order_entry_t::instance, dt_develop_t::iop, dt_develop_t::iop_order_list, k, MAX, n, dt_iop_order_entry_t::operation, and TRUE.

Referenced by dt_ioppr_update_for_modules(), and dt_ioppr_update_for_style_items().

◆ dt_ioppr_update_for_modules()

void dt_ioppr_update_for_modules ( struct dt_develop_t dev,
GList *  modules,
gboolean  append 
)

Update dev->iop_order_list with modules from a module list.

Parameters
devDevelop context.
modulesList of module instances.
appendWhether to append new entries at the end (TRUE) or merge into list order (FALSE).

Definition at line 1784 of file iop_order.c.

References dt_free_gpointer(), dt_ioppr_get_iop_order(), dt_ioppr_update_for_entries(), dt_iop_order_entry_t::instance, dt_iop_module_t::iop_order, dt_develop_t::iop_order_list, dt_iop_module_t::multi_priority, n, and dt_iop_module_t::op.

◆ dt_ioppr_update_for_style_items()

void dt_ioppr_update_for_style_items ( struct dt_develop_t dev,
GList *  st_items,
gboolean  append 
)

Update dev->iop_order_list with modules referenced by style items.

Parameters
devDevelop context.
st_itemsStyle items list.
appendWhether to append new entries at the end (TRUE) or merge into list order (FALSE).

Definition at line 1747 of file iop_order.c.

References dt_ioppr_get_iop_order(), dt_ioppr_update_for_entries(), dt_style_item_t::iop_order, dt_develop_t::iop_order_list, dt_style_item_t::multi_priority, n, and dt_style_item_t::operation.

Referenced by _apply_style_before_export(), _styles_prepare_source_dev(), and _styles_sync_pipeline_from_items().

◆ dt_ioppr_write_iop_order()

static gboolean dt_ioppr_write_iop_order ( const dt_iop_order_t  kind,
GList *  iop_order_list,
const int32_t  imgid 
)
static

Persist an order list for a given image with a specific kind.

Handles both built-in orders (stores version only) and custom orders (stores serialized list in DB).

Parameters
kindOrder kind to store.
iop_order_listOrder list to serialize if needed.
imgidImage id.
Returns
TRUE on success, FALSE on error.

Definition at line 974 of file iop_order.c.

References darktable, darktable_t::db, dt_database_get(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, dt_free, DT_IOP_ORDER_CUSTOM, dt_ioppr_has_multiple_instances(), dt_ioppr_serialize_text_iop_order_list(), FALSE, kind, and TRUE.

Referenced by dt_ioppr_change_iop_order(), and dt_ioppr_write_iop_order_list().

◆ dt_ioppr_write_iop_order_list()

gboolean dt_ioppr_write_iop_order_list ( GList *  iop_order_list,
const int32_t  imgid 
)

Persist an order list to the DB for a given image.

Parameters
iop_order_listOrder list to store.
imgidImage id.
Returns
TRUE on success, FALSE on error.

Definition at line 1013 of file iop_order.c.

References dt_ioppr_get_iop_order_list_kind(), dt_ioppr_write_iop_order(), and kind.

Referenced by _dev_auto_apply_presets(), dt_dev_write_history_ext(), and dt_exif_xmp_read().

◆ dt_sort_iop_by_order()

gint dt_sort_iop_by_order ( gconstpointer  a,
gconstpointer  b 
)

Compare two module instances by iop_order for sorting.

Parameters
aFirst module pointer.
bSecond module pointer.
Returns
Sorting comparison result.

Definition at line 2002 of file iop_order.c.

Referenced by _check_deleted_instances(), _create_deleted_modules(), dt_dev_history_refresh_nodes_ext(), dt_dev_load_modules(), dt_dev_module_duplicate(), and dt_ioppr_resync_modules_order().

◆ dt_sort_iop_list_by_order()

gint dt_sort_iop_list_by_order ( gconstpointer  a,
gconstpointer  b 
)

Definition at line 884 of file iop_order.c.

Referenced by dt_ioppr_get_iop_order_list().

◆ dt_sort_iop_list_by_order_f()

gint dt_sort_iop_list_by_order_f ( gconstpointer  a,
gconstpointer  b 
)

Compare two list nodes holding modules by iop_order.

Parameters
aGList node containing a module.
bGList node containing a module.
Returns
Sorting comparison result.

Definition at line 893 of file iop_order.c.

Referenced by _upgrade_library_schema_step(), and dt_exif_xmp_read().

Variable Documentation

◆ ansel_jpg_order

const dt_iop_order_entry_t ansel_jpg_order[]

◆ ansel_raw_order

const dt_iop_order_entry_t ansel_raw_order[]

◆ iop_order_string

const char* iop_order_string[]
Initial value:
=
{
N_("custom"),
N_("legacy"),
N_("v3.0 RAW"),
N_("v3.0 JPEG"),
N_("Ansel RAW"),
}

Definition at line 70 of file iop_order.c.

Referenced by dt_iop_order_string().

◆ legacy_order

const dt_iop_order_entry_t legacy_order[]

Definition at line 95 of file iop_order.c.

Referenced by dt_ioppr_get_iop_order_list(), and dt_ioppr_get_iop_order_list_version().

◆ orders

◆ v30_jpg_order

const dt_iop_order_entry_t v30_jpg_order[]

◆ v30_order

const dt_iop_order_entry_t v30_order[]