Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dev_history.h
Go to the documentation of this file.
1/*
2 This file is part of the Ansel project.
3 Copyright (C) 2025 Alynx Zhou.
4 Copyright (C) 2025-2026 Aurélien PIERRE.
5
6 Ansel is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Ansel is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "common/history.h"
21
22#include <glib.h>
23
24#pragma once
25
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#ifndef DT_IOP_PARAMS_T
40#define DT_IOP_PARAMS_T
41typedef void dt_iop_params_t;
42#endif
43
44struct dt_iop_module_t;
46struct dt_develop_t;
47
49{
50 struct dt_iop_module_t *module; // pointer to image operation module
51 gboolean enabled; // switched respective module on/off
52 dt_iop_params_t *params; // parameters for this operation
53 int params_size; // serialized params size
54 int module_version; // serialized module version
56 int blendop_params_size; // serialized blend params size
57 int blendop_version; // serialized blend version
58 char op_name[32];
61 char multi_name[128];
62 GList *forms; // snapshot of dt_develop_t->forms
63 int num; // num of history on database
64
65 uint64_t hash; // module params hash.
67
68
77
83void dt_dev_free_history_item(gpointer data);
84
125 struct dt_iop_module_t *module, gboolean enabled,
126 const void *params, const int32_t params_size,
127 const struct dt_develop_blend_params_t *blend_params, GList *forms);
128
136int dt_dev_next_multi_priority_for_op(struct dt_develop_t *dev, const char *op);
137
149struct dt_iop_module_t *dt_dev_get_module_instance(struct dt_develop_t *dev, const char *op, const char *multi_name,
150 const int multi_priority);
151
162struct dt_iop_module_t *dt_dev_create_module_instance(struct dt_develop_t *dev, const char *op, const char *multi_name,
163 const int multi_priority, gboolean use_next_priority);
176int dt_dev_copy_module_contents(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src,
177 struct dt_iop_module_t *mod_dest, const struct dt_iop_module_t *mod_src);
178
193 const struct dt_dev_history_item_t *hist_src,
194 struct dt_iop_module_t *mod_dest,
195 struct dt_dev_history_item_t **out_hist);
196
208int dt_dev_merge_history_into_image(struct dt_develop_t *dev_src, int32_t dest_imgid, const GList *mod_list,
209 gboolean merge_iop_order, const dt_history_merge_strategy_t mode,
210 const gboolean paste_instances);
223int dt_dev_replace_history_on_image(struct dt_develop_t *dev_src, const int32_t dest_imgid,
224 const gboolean reload_defaults, const char *msg);
225
240gboolean dt_dev_add_history_item_ext(struct dt_develop_t *dev, struct dt_iop_module_t *module, gboolean enable,
241 gboolean force_new_item);
242
254void dt_dev_add_history_item_real(struct dt_develop_t *dev, struct dt_iop_module_t *module, gboolean enable, gboolean redraw);
255
256// Debug helper to follow calls to `dt_dev_add_history_item_real()`, but mostly to follow useless pipe recomputations.
257#define dt_dev_add_history_item(dev, module, enable, redraw) DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_add_history_item_real, (dev), (module), (enable), (redraw))
258
259
268void dt_dev_write_history_ext(struct dt_develop_t *dev, const int32_t imgid);
269
277void dt_dev_write_history(struct dt_develop_t *dev, gboolean async);
278
287
294void dt_dev_history_pixelpipe_update(struct dt_develop_t *dev, gboolean rebuild);
295
304void dt_dev_history_notify_change(struct dt_develop_t *dev, const int32_t imgid);
305
344
356gboolean dt_dev_read_history_ext(struct dt_develop_t *dev, const int32_t imgid);
357
366
373
374
384void dt_dev_reload_history_items(struct dt_develop_t *dev, const int32_t imgid);
385
386
395void dt_dev_invalidate_history_module(GList *list, struct dt_iop_module_t *module);
396
405
416
426void dt_dev_set_history_end_ext(struct dt_develop_t *dev, const uint32_t index);
427
436gboolean dt_history_module_skip_copy(const int flags);
437
450int dt_history_merge_module_into_history(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src,
451 struct dt_iop_module_t *mod_src);
452
467void dt_dev_history_compress_ext(struct dt_develop_t *dev, gboolean write_history);
477void dt_dev_history_cleanup(void);
478
491gboolean dt_dev_init_default_history(struct dt_develop_t *dev, const int32_t imgid, gboolean apply_auto_presets);
492
501
510dt_dev_history_item_t *dt_dev_history_get_last_item_by_module(GList *history_list, struct dt_iop_module_t *module, int history_end);
511
523int dt_dev_history_refresh_nodes_ext(struct dt_develop_t *dev, GList **iop, GList *history);
524
526void dt_dev_history_truncate(struct dt_develop_t *dev, const int32_t imgid);
527
528#ifdef __cplusplus
529}
530#endif
void reload_defaults(dt_iop_module_t *module)
Definition ashift.c:5665
size_t params_size(dt_imageio_module_format_t *self)
Definition avif.c:565
void dt_dev_history_compress_ext(struct dt_develop_t *dev, gboolean write_history)
Variant of history compression that optionally skips DB writeback.
Definition dev_history.c:2050
gboolean dt_dev_history_item_update_from_params(struct dt_develop_t *dev, dt_dev_history_item_t *hist, struct dt_iop_module_t *module, gboolean enabled, const void *params, const int32_t params_size, const struct dt_develop_blend_params_t *blend_params, GList *forms)
Fill/refresh a history item from explicit params and apply them to the module.
int dt_history_merge_module_into_history(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src, struct dt_iop_module_t *mod_src)
Merge a single module instance into a destination history.
Definition dev_history.c:418
dt_dev_history_item_t * dt_dev_history_get_last_item_by_module(GList *history_list, struct dt_iop_module_t *module, int history_end)
Find the last history item referencing a module up to history_end.
Definition dev_history.c:146
void dt_dev_history_free_history(struct dt_develop_t *dev)
Free the whole history list attached to dev->history.
Definition dev_history.c:966
int dt_dev_history_refresh_nodes_ext(struct dt_develop_t *dev, GList **iop, GList *history)
Refresh GUI module nodes to match history state.
Definition dev_history.c:2351
void dt_dev_reload_history_items(struct dt_develop_t *dev, const int32_t imgid)
Reload history from DB and rebuild pipelines/GUI state.
Definition dev_history.c:973
void dt_dev_history_undo_end_record(struct dt_develop_t *dev)
Finish an undo record for history changes.
Definition dev_history.c:634
struct dt_iop_module_t * dt_dev_get_module_instance(struct dt_develop_t *dev, const char *op, const char *multi_name, const int multi_priority)
Find a module instance by op name and instance metadata.
Definition dev_history.c:230
int dt_dev_history_item_from_source_history_item(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src, const struct dt_dev_history_item_t *hist_src, struct dt_iop_module_t *mod_dest, struct dt_dev_history_item_t **out_hist)
Create a history item from another history item, using a destination module.
void dt_dev_set_history_end_ext(struct dt_develop_t *dev, const uint32_t index)
Set the history end index (GUI perspective).
Definition develop.c:1527
void dt_dev_history_undo_invalidate_module(struct dt_iop_module_t *module)
Invalidate a module pointer inside undo snapshots.
Definition dev_history.c:522
int dt_dev_merge_history_into_image(struct dt_develop_t *dev_src, int32_t dest_imgid, const GList *mod_list, gboolean merge_iop_order, const dt_history_merge_strategy_t mode, const gboolean paste_instances)
Merge a list of modules into a destination image history via dt_history_merge().
Definition dev_history.c:328
void dt_dev_history_cleanup(void)
Cleanup cached statements or state used by history I/O.
Definition dev_history.c:1221
void dt_dev_pop_history_items(struct dt_develop_t *dev)
Thread-safe wrapper around dt_dev_pop_history_items_ext(), then update GUI.
Definition dev_history.c:1095
void dt_dev_free_history_item(gpointer data)
Free a single history item (used as GList free callback).
Definition dev_history.c:954
void dt_dev_history_pixelpipe_update(struct dt_develop_t *dev, gboolean rebuild)
Rebuild or resync pixelpipes after backend history changes.
Definition dev_history.c:1131
int dt_dev_replace_history_on_image(struct dt_develop_t *dev_src, const int32_t dest_imgid, const gboolean reload_defaults, const char *msg)
Replace an image history with the content of dev_src.
Definition dev_history.c:1453
gboolean dt_dev_init_default_history(struct dt_develop_t *dev, const int32_t imgid, gboolean apply_auto_presets)
Initialize module defaults and insert required default modules.
Definition dev_history.c:1431
uint64_t dt_dev_history_compute_hash(struct dt_develop_t *dev)
Get the integrity checksum of the whole history stack. This should be done ONLY when history is chang...
Definition dev_history.c:848
void dt_dev_history_undo_start_record_locked(struct dt_develop_t *dev)
Start an undo record with history_mutex already locked.
Definition dev_history.c:614
void dt_dev_pop_history_items_ext(struct dt_develop_t *dev)
Apply history items to module params up to dev->history_end.
Definition dev_history.c:1047
void dt_dev_history_truncate(struct dt_develop_t *dev, const int32_t imgid)
Definition dev_history.c:2060
void dt_dev_history_undo_start_record(struct dt_develop_t *dev)
Start an undo record for history changes.
Definition dev_history.c:606
void dt_dev_history_compress_or_truncate(struct dt_develop_t *dev)
Compress history if history_end is at top, otherwise truncate.
Definition dev_history.c:2080
void dt_dev_write_history_ext(struct dt_develop_t *dev, const int32_t imgid)
Write dev->history to DB and XMP for a given image id.
Definition dev_history.c:1228
gboolean dt_dev_read_history_ext(struct dt_develop_t *dev, const int32_t imgid)
Read history and masks from DB and populate dev->history.
Definition dev_history.c:1774
void dt_dev_history_gui_update(struct dt_develop_t *dev)
Apply history-loaded params to module GUIs.
Definition dev_history.c:1106
int32_t dt_dev_get_history_end_ext(struct dt_develop_t *dev)
Get the current history end index (GUI perspective).
Definition develop.c:1521
int dt_dev_copy_module_contents(struct dt_develop_t *dev_dest, struct dt_develop_t *dev_src, struct dt_iop_module_t *mod_dest, const struct dt_iop_module_t *mod_src)
Copy params/blend params from one module instance to another.
gboolean dt_history_module_skip_copy(const int flags)
Determine whether a module should be skipped during history copy.
Definition dev_history.c:1892
void dt_dev_history_undo_end_record_locked(struct dt_develop_t *dev)
Finish an undo record with history_mutex already locked.
Definition dev_history.c:642
void dt_iop_params_t
Definition dev_history.h:41
void dt_dev_invalidate_history_module(GList *list, struct dt_iop_module_t *module)
Remove a module pointer from a history list.
Definition dev_history.c:1880
gboolean dt_dev_add_history_item_ext(struct dt_develop_t *dev, struct dt_iop_module_t *module, gboolean enable, gboolean force_new_item)
Append or update a history item for a module.
Definition dev_history.c:745
void dt_dev_history_notify_change(struct dt_develop_t *dev, const int32_t imgid)
Notify the rest of the app that history changes were written.
Definition dev_history.c:1165
void dt_dev_write_history(struct dt_develop_t *dev, gboolean async)
Thread-safe wrapper around dt_dev_write_history_ext() for dev->image_storage.id.
Definition dev_history.c:1272
void dt_dev_history_compress(struct dt_develop_t *dev)
Compress an history from a loaded pipeline, aka simply take a snapshot of all modules parameters....
Definition dev_history.c:2055
void dt_dev_add_history_item_real(struct dt_develop_t *dev, struct dt_iop_module_t *module, gboolean enable, gboolean redraw)
Thread-safe wrapper around dt_dev_add_history_item_ext().
Definition dev_history.c:867
struct dt_iop_module_t * dt_dev_create_module_instance(struct dt_develop_t *dev, const char *op, const char *multi_name, const int multi_priority, gboolean use_next_priority)
Create a new module instance from an existing base .so.
Definition dev_history.c:242
int dt_dev_next_multi_priority_for_op(struct dt_develop_t *dev, const char *op)
Return the next available multi_priority for an operation.
Definition dev_history.c:218
dt_dev_history_item_t * dt_dev_history_get_first_item_by_module(GList *history_list, struct dt_iop_module_t *module)
Find the first history item referencing a module.
Definition dev_history.c:130
static gboolean enable(dt_image_t *image)
Definition highlights.c:2827
dt_history_merge_strategy_t
Definition history_merge.h:33
dt_mipmap_buffer_dsc_flags flags
Definition mipmap_cache.c:4
unsigned __int64 uint64_t
Definition strptime.c:75
Definition dev_history.h:49
int num
Definition dev_history.h:63
uint64_t hash
Definition dev_history.h:65
int blendop_version
Definition dev_history.h:57
int module_version
Definition dev_history.h:54
dt_iop_params_t * params
Definition dev_history.h:52
char multi_name[128]
Definition dev_history.h:61
struct dt_develop_blend_params_t * blend_params
Definition dev_history.h:55
struct dt_iop_module_t *gboolean enabled
Definition dev_history.h:50
int multi_priority
Definition dev_history.h:60
int blendop_params_size
Definition dev_history.h:56
int iop_order
Definition dev_history.h:59
int params_size
Definition dev_history.h:53
GList * forms
Definition dev_history.h:62
char op_name[32]
Definition dev_history.h:58
Definition blend.h:198
Definition develop.h:159
Definition imageop.h:246
int multi_priority
Definition imageop.h:364
char multi_name[128]
Definition imageop.h:365
struct dt_develop_t * dev
Definition imageop.h:298
GModule *dt_dev_operation_t op
Definition imageop.h:256