Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
darktable.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2012 johannes hanika.
4 Copyright (C) 2010-2011 Henrik Andersson.
5 Copyright (C) 2010, 2012 Pascal de Bruijn.
6 Copyright (C) 2010 Richard Hughes.
7 Copyright (C) 2010-2020 Tobias Ellinghaus.
8 Copyright (C) 2011, 2014-2015 Bruce Guenter.
9 Copyright (C) 2011-2013, 2017 Ulrich Pegelow.
10 Copyright (C) 2012 Ammon Riley.
11 Copyright (C) 2012 Christian Himpel.
12 Copyright (C) 2012 Christian Tellefsen.
13 Copyright (C) 2012 James C. McPherson.
14 Copyright (C) 2012 Jean-Sébastien Pédron.
15 Copyright (C) 2012-2014 Jérémy Rosen.
16 Copyright (C) 2012 Moritz Lipp.
17 Copyright (C) 2012 Richard Wonka.
18 Copyright (C) 2012 Simon Spannagel.
19 Copyright (C) 2013, 2021 Aldric Renaudin.
20 Copyright (C) 2013, 2015, 2019-2021 Pascal Obry.
21 Copyright (C) 2013-2017 Roman Lebedev.
22 Copyright (C) 2014-2015 Pedro Côrte-Real.
23 Copyright (C) 2015 Matthias Gehre.
24 Copyright (C) 2016-2019 Peter Budai.
25 Copyright (C) 2016 Stuart Henderson.
26 Copyright (C) 2018-2020, 2022-2026 Aurélien PIERRE.
27 Copyright (C) 2018-2019 Edgardo Hoszowski.
28 Copyright (C) 2018 parafin.
29 Copyright (C) 2018 rawfiner.
30 Copyright (C) 2019-2020 Andreas Schneider.
31 Copyright (C) 2019-2022 Hanno Schwalm.
32 Copyright (C) 2019 Heiko Bauke.
33 Copyright (C) 2020 David-Tillmann Schaefer.
34 Copyright (C) 2020-2021 Diederik Ter Rahe.
35 Copyright (C) 2020-2021 Hubert Kowalski.
36 Copyright (C) 2020-2021 Ralf Brown.
37 Copyright (C) 2021 Hubert Figuière.
38 Copyright (C) 2021 Paolo DePetrillo.
39 Copyright (C) 2021 Robert Bridge.
40 Copyright (C) 2021 Roman Khatko.
41 Copyright (C) 2022 Martin Bařinka.
42 Copyright (C) 2022 Philippe Weyland.
43 Copyright (C) 2023-2025 Alynx Zhou.
44 Copyright (C) 2023 lologor.
45 Copyright (C) 2023 Luca Zulberti.
46
47 darktable is free software: you can redistribute it and/or modify
48 it under the terms of the GNU General Public License as published by
49 the Free Software Foundation, either version 3 of the License, or
50 (at your option) any later version.
51
52 darktable is distributed in the hope that it will be useful,
53 but WITHOUT ANY WARRANTY; without even the implied warranty of
54 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 GNU General Public License for more details.
56
57 You should have received a copy of the GNU General Public License
58 along with darktable. If not, see <http://www.gnu.org/licenses/>.
59*/
60
61/* NO include guard -- a TRIPWIRE instead, on purpose.
62 *
63 * A guard makes a second inclusion a silent no-op. For the application orchestrator
64 * that is exactly the wrong behaviour: this header must be included at most ONCE, by a
65 * translation unit that genuinely needs the application (an entry point calling
66 * dt_init(), or a subsystem that owns one of the `darktable` members). Reaching it a
67 * second time means it arrived through a path nobody intended -- most likely a header
68 * started including it again, which is what this whole series removed.
69 *
70 * So: fail loudly rather than absorb it. If you hit this #error, do not add a guard --
71 * find who included it and give that code the specific lib it actually needs
72 * (common/logging.h, common/mem_alloc.h, ... ) or the accessor for the global it wants
73 * (dt_dev_get_global(), dt_control_get_global(), ...). See doc/include-graph.md.
74 *
75 * NEVER include this header from another header. As of this commit, zero headers do. */
76#ifdef DT_DARKTABLE_H
77#error "darktable.h included more than once in this translation unit -- see the comment at the top of that file"
78#endif
79#define DT_DARKTABLE_H
80
81
82// just to be sure. the build system should set this for us already:
83#if defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
84#define _WITH_DPRINTF
85#define _WITH_GETLINE
86#elif !defined _XOPEN_SOURCE && !defined _WIN32
87#define _XOPEN_SOURCE 700 // for localtime_r and dprintf
88#endif
89
90// needs to be defined before any system header includes for control/conf.h to work in C++ code
91#define __STDC_FORMAT_MACROS
92
93/* O_BINARY moved to common/paths.h, next to the other path/file portability. */
94
95#include "external/ThreadSafetyAnalysis.h"
96
97#ifdef HAVE_CONFIG_H
98#include "config.h"
99#endif
100
101/* Only what the DECLARATIONS below actually need. darktable.h used to carry a large
102 * umbrella of includes for the benefit of its consumers; that is what welded the whole
103 * application into every translation unit. A file needing dt_print(), dt_alloc_align()
104 * or DT_MODULE() must include common/logging.h, common/mem_alloc.h or
105 * common/module_versioning.h itself. */
106#include "system/dtpthread.h" // dt_pthread_mutex_t / rwlock members of darktable_t
107#include "system/sys_resources.h" // dt_sys_resources_t member of darktable_t
108#include "control/signal.h" // DT_SIGNAL_COUNT sizes the unmuted_signal_dbg array
109
110#include <glib.h>
111#include <stdint.h>
112
113/* win/win.h (windows.h/psapi + the #undef of the legacy `near`/`grp2`/`interface`
114 * macros) now comes in through system/macros.h, which every TU includes. It used to
115 * live here, which meant dropping this header silently dropped the shim too --
116 * a MinGW-only breakage, far from its cause. Nothing to do here any more. */
117
118#ifndef _RELEASE
119/* poison.h #pragma-poisons malloc/fopen/unlink/... so they cannot be used unqualified.
120 * It MUST come after every system header that legitimately declares them --
121 * glib/gstdio.h and unistd.h are included here for exactly that reason, not for the
122 * benefit of consumers. (unistd.h used to arrive by accident through json-glib, whose
123 * include left with the noiseprofiles parser; the poison on unlink then fired inside
124 * any consumer including unistd.h after this header.) */
125#include <glib/gstdio.h>
126#ifndef _WIN32
127#include <unistd.h> // conditional-ok: exists only to land BEFORE poison.h, which is itself conditional on !_RELEASE; nothing outside this block uses it
128#endif
129#include "common/poison.h"
130#endif
131
132#ifdef __cplusplus
133extern "C" {
134#endif
135
136
137// version of current performance configuration version
138// if you want to run an updated version of the performance configuration later
139// bump this number and make sure you have an updated logic in dt_configure_performance()
140#define DT_CURRENT_PERFORMANCE_CONFIGURE_VERSION 11
141#define DT_PERF_INFOSIZE 4096
142
143
144/* dt_session_id() / dt_install_id() moved to common/anonymous_ids.h */
145
146#ifdef __cplusplus
147}
148#endif
149
150/********************************* */
151
152
153#ifdef __cplusplus
154extern "C" {
155#endif
156
157
158/********************************* */
159
160struct dt_gui_gtk_t;
161struct dt_control_t;
162struct dt_develop_t;
163struct dt_lib_t;
164struct dt_conf_t;
165struct dt_points_t;
166struct dt_imageio_t;
167struct dt_bauhaus_t;
168struct dt_undo_t;
169struct dt_l10n_t;
170
171
172typedef struct darktable_t
173{
175
176 int32_t unmuted;
177 GList *iop;
180
181 // Keep track of optional features that may depend on environnement
182 // and compiling options : OpenCL
186 struct dt_lib_t *lib;
192 const struct dt_database_t *db;
198
199 // Protect appending/removing GList links to the darktable.capabilities list
200 dt_pthread_mutex_t capabilities_threadsafe;
201
202 // Prevent concurrent export/thumbnail pipelines from runnnig at the same time
203 // It brings no additional performance since the CPU is our bottleneck,
204 // and CPU pixel code is already multi-threaded internally through OpenMP
205 dt_pthread_mutex_t pipeline_threadsafe;
206
207 // Building SQL transactions through `dt_database_start_transaction_debug()`
208 // from "too many" threads (like loading all thumbnails from a new collection)
209 // leads to SQL error:
210 // `BEGIN": cannot start a transaction within a transaction`
211 // Also, we need to ensure that image metadata/history reads & writes
212 // happen each in their all time, from all pipeline jobs/threads.
213
214 char *progname;
215 char *datadir;
216 char *sharedir;
219 char *tmpdir;
221 char *cachedir;
224 GList *themes;
228
229 // Working message displayed over the main preview when working
232
233
235
236int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load_data);
237void dt_cleanup();
238
239
240/* Memory budgets and dt_worker_threads() moved to common/sys_resources.h */
241
242
243/* dt_capabilities_* moved to common/capabilities.h */
244
245
246/* dt_supported_image() moved to common/image_extensions.h */
247
248
249// helper function which loads whatever image_to_load points to: single image files or whole directories
250// it tells you if it was a single image or a directory in single_image (when it's not NULL)
251int dt_load_from_string(const gchar *image_to_load, gboolean open_image_in_dr, gboolean *single_image);
252
253
254
255
256
257#ifdef __cplusplus
258}
259#endif
260
261
262// clang-format off
263// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
264// vim: shiftwidth=2 expandtab tabstop=2 cindent
265// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
266// clang-format on
void dt_cleanup()
Definition darktable.c:1864
darktable_t darktable
Definition darktable.c:213
int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load_data)
Definition darktable.c:885
int dt_load_from_string(const gchar *image_to_load, gboolean open_image_in_dr, gboolean *single_image)
Definition darktable.c:389
@ DT_SIGNAL_COUNT
Definition signal.h:340
struct dt_dbus_t * dbus
Definition darktable.h:195
struct dt_undo_t * undo
Definition darktable.h:196
char * tmpdir
Definition darktable.h:219
char * cachedir
Definition darktable.h:221
struct dt_lib_t * lib
Definition darktable.h:186
int32_t unmuted_signal_dbg_acts
Definition darktable.h:225
struct dt_imageio_t * imageio
Definition darktable.h:194
int32_t num_openmp_threads
Definition darktable.h:174
struct dt_l10n_t * l10n
Definition darktable.h:197
struct dt_gui_gtk_t * gui
Definition darktable.h:190
GList * capabilities
Definition darktable.h:183
char * sharedir
Definition darktable.h:216
GList * iop
Definition darktable.h:177
struct dt_sys_resources_t dtresources
Definition darktable.h:227
char * moduledir
Definition darktable.h:217
dt_pthread_mutex_t capabilities_threadsafe
Definition darktable.h:200
GList * iop_order_list
Definition darktable.h:178
const struct dt_database_t * db
Definition darktable.h:192
GList * iop_order_rules
Definition darktable.h:179
struct dt_control_signal_t * signals
Definition darktable.h:189
struct dt_bauhaus_t * bauhaus
Definition darktable.h:191
char * configdir
Definition darktable.h:220
char * datadir
Definition darktable.h:215
GList * themes
Definition darktable.h:224
int32_t unmuted
Definition darktable.h:176
struct dt_develop_t * develop
Definition darktable.h:185
struct dt_points_t * points
Definition darktable.h:193
char * localedir
Definition darktable.h:218
dt_pthread_mutex_t pipeline_threadsafe
Definition darktable.h:205
struct dt_view_manager_t * view_manager
Definition darktable.h:187
char * kerneldir
Definition darktable.h:222
gboolean unmuted_signal_dbg[DT_SIGNAL_COUNT]
Definition darktable.h:226
char * main_message
Definition darktable.h:230
char * progname
Definition darktable.h:214
struct dt_conf_t * conf
Definition darktable.h:184
double start_wtime
Definition darktable.h:223
struct dt_control_t * control
Definition darktable.h:188
The whole configuration state. One instance lives at darktable.conf.
Definition conf.h:99
Definition lib.h:53