2
This file is part of darktable,
3
copyright (c) 2009--2010 johannes hanika.
5
darktable 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.
10
darktable 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.
15
You should have received a copy of the GNU General Public License
16
along with darktable. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef DT_DEVELOP_IMAGEOP_H
19
#define DT_DEVELOP_IMAGEOP_H
21
#include "common/darktable.h"
22
#include "control/settings.h"
23
#include "develop/pixelpipe.h"
24
#include "dtgtk/togglebutton.h"
29
struct dt_dev_pixelpipe_t;
30
struct dt_dev_pixelpipe_iop_t;
33
#define IOP_GROUP_BASIC 1
34
#define IOP_GROUP_COLOR 2
35
#define IOP_GROUP_CORRECT 4
36
#define IOP_GROUP_EFFECT 8
38
#define IOP_GROUP_ALL (IOP_GROUP_BASIC|IOP_GROUP_COLOR|IOP_GROUP_CORRECT|IOP_GROUP_EFFECT)
40
/** Flag for the iop module to be enabled/included by default when creating a style */
41
#define IOP_FLAGS_INCLUDE_IN_STYLES 1
43
typedef struct dt_iop_params_t
48
typedef void dt_iop_gui_data_t;
49
typedef void dt_iop_data_t;
50
typedef void dt_iop_global_data_t;
52
/** part of the module which only contains the cached dlopen stuff. */
53
struct dt_iop_module_so_t;
54
struct dt_iop_module_t;
55
typedef struct dt_iop_module_so_t
59
/** string identifying this operation. */
60
dt_dev_operation_t op;
61
/** other stuff that may be needed by the module, not only in gui mode. inited only once, has to be read-only then. */
62
dt_iop_global_data_t *data;
64
/** this initializes static, hardcoded presets for this module and is called only once per run of dt. */
65
void (*init_presets) (struct dt_iop_module_so_t *self);
66
/** called once per module, at startup. */
67
void (*init_global) (struct dt_iop_module_so_t *self);
68
/** called once per module, at shutdown. */
69
void (*cleanup_global) (struct dt_iop_module_so_t *self);
71
/** callbacks, loaded once, referenced by the instances. */
73
const char* (*name) ();
76
int (*output_bpp) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
78
void (*gui_update) (struct dt_iop_module_t *self);
79
void (*gui_init) (struct dt_iop_module_t *self);
80
void (*gui_cleanup) (struct dt_iop_module_t *self);
81
void (*gui_post_expose) (struct dt_iop_module_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery);
83
int (*mouse_leave) (struct dt_iop_module_t *self);
84
int (*mouse_moved) (struct dt_iop_module_t *self, double x, double y, int which);
85
int (*button_released) (struct dt_iop_module_t *self, double x, double y, int which, uint32_t state);
86
int (*button_pressed) (struct dt_iop_module_t *self, double x, double y, int which, int type, uint32_t state);
87
int (*key_pressed) (struct dt_iop_module_t *self, uint16_t which);
88
int (*scrolled) (struct dt_iop_module_t *self, double x, double y, int up);
89
void (*configure) (struct dt_iop_module_t *self, int width, int height);
91
void (*init) (struct dt_iop_module_t *self); // this MUST set params_size!
92
void (*cleanup) (struct dt_iop_module_t *self);
93
void (*init_pipe) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
94
void (*commit_params) (struct dt_iop_module_t *self, struct dt_iop_params_t *params, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
95
void (*reload_defaults) (struct dt_iop_module_t *self);
96
void (*cleanup_pipe) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
97
void (*modify_roi_in) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, const struct dt_iop_roi_t *roi_out, struct dt_iop_roi_t *roi_in);
98
void (*modify_roi_out) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, struct dt_iop_roi_t *roi_out, const struct dt_iop_roi_t *roi_in);
99
int (*legacy_params) (struct dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version);
101
void (*process) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, void *i, void *o, const struct dt_iop_roi_t *roi_in, const struct dt_iop_roi_t *roi_out);
102
void (*process_cl) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, void *i, void *o, const struct dt_iop_roi_t *roi_in, const struct dt_iop_roi_t *roi_out);
106
typedef struct dt_iop_module_t
108
/** opened module. */
110
/** string identifying this operation. */
111
dt_dev_operation_t op;
112
/** used to identify this module in the history stack. */
114
/** order in which plugins are stacked. */
116
/** module sets this if the enable checkbox should be hidden. */
117
int32_t hide_enable_button;
118
/** set to 1 if you want an input color picked during next eval. gui mode only. */
119
int32_t request_color_pick;
120
/** bounding box in which the mean color is requested. */
121
float color_picker_box[4];
122
/** place to store the picked color. */
123
float picked_color[3], picked_color_min[3], picked_color_max[3];
124
float picked_color_Lab[3], picked_color_min_Lab[3], picked_color_max_Lab[3];
125
/** reference for dlopened libs. */
127
/** the module is used in this develop module. */
128
struct dt_develop_t *dev;
129
/** non zero if this node should be processed. */
130
int32_t enabled, default_enabled, factory_enabled;
131
/** parameters for the operation. will be replaced by history revert. */
132
dt_iop_params_t *params, *default_params, *factory_params;
133
/** exclusive access to params is needed, as gui and gegl processing is async. */
134
dt_pthread_mutex_t params_mutex;
135
/** size of individual params struct. */
137
/** parameters needed if a gui is attached. will be NULL if in export/batch mode. */
138
dt_iop_gui_data_t *gui_data;
139
/** other stuff that may be needed by the module, not only in gui mode. */
140
dt_iop_global_data_t *data;
141
/** child widget which is added to the GtkExpander. */
143
/** off button, somewhere in header, common to all plug-ins. */
144
GtkDarktableToggleButton *off;
145
/** this widget contains all of the module: expander and label decoration. */
146
GtkWidget *topwidget;
147
/** button used to show/hide this module in the plugin list. */
149
/** expander containing the widget. */
150
GtkExpander *expander;
152
/** version of the parameters in the database. */
154
/** get name of the module, to be translated. */
155
const char* (*name) ();
156
/** get the groups this module belongs to. */
158
/** get the iop module flags. */
160
/** how many bytes per pixel in the output. */
161
int (*output_bpp) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
163
/** callback methods for gui. */
164
/** synch gtk interface with gui params, if necessary. */
165
void (*gui_update) (struct dt_iop_module_t *self);
166
/** construct widget. */
167
void (*gui_init) (struct dt_iop_module_t *self);
168
/** destroy widget. */
169
void (*gui_cleanup) (struct dt_iop_module_t *self);
170
/** optional method called after darkroom expose. */
171
void (*gui_post_expose) (struct dt_iop_module_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery);
173
/** optional event callbacks */
174
int (*mouse_leave) (struct dt_iop_module_t *self);
175
int (*mouse_moved) (struct dt_iop_module_t *self, double x, double y, int which);
176
int (*button_released) (struct dt_iop_module_t *self, double x, double y, int which, uint32_t state);
177
int (*button_pressed) (struct dt_iop_module_t *self, double x, double y, int which, int type, uint32_t state);
178
int (*key_pressed) (struct dt_iop_module_t *self, uint16_t which);
179
int (*scrolled) (struct dt_iop_module_t *self, double x, double y, int up);
180
void (*configure) (struct dt_iop_module_t *self, int width, int height);
182
void (*init) (struct dt_iop_module_t *self); // this MUST set params_size!
183
void (*cleanup) (struct dt_iop_module_t *self);
184
/** this inits the piece of the pipe, allocing piece->data as necessary. */
185
void (*init_pipe) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
186
/** this resets the params to factory defaults. used at the beginning of each history synch. */
187
/** this commits (a mutex will be locked to synch gegl/gui) the given history params to the gegl pipe piece. */
188
void (*commit_params) (struct dt_iop_module_t *self, struct dt_iop_params_t *params, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
189
/** this is the chance to update default parameters, after the full raw is loaded. */
190
void (*reload_defaults) (struct dt_iop_module_t *self);
191
/** this destroys all (gegl etc) resources needed by the piece of the pipeline. */
192
void (*cleanup_pipe) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
193
void (*modify_roi_in) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, const struct dt_iop_roi_t *roi_out, struct dt_iop_roi_t *roi_in);
194
void (*modify_roi_out) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, struct dt_iop_roi_t *roi_out, const struct dt_iop_roi_t *roi_in);
195
int (*legacy_params) (struct dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version);
197
/** this is the temp homebrew callback to operations, as long as gegl is so slow.
198
* x,y, and scale are just given for orientation in the framebuffer. i and o are
199
* scaled to the same size width*height and contain a max of 3 floats. other color
200
* formats may be filled by this callback, if the pipeline can handle it. */
201
void (*process) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, void *i, void *o, const struct dt_iop_roi_t *roi_in, const struct dt_iop_roi_t *roi_out);
202
/** the opencl equivalent of process(). */
203
void (*process_cl) (struct dt_iop_module_t *self, struct dt_dev_pixelpipe_iop_t *piece, void *i, void *o, const struct dt_iop_roi_t *roi_in, const struct dt_iop_roi_t *roi_out);
207
/** loads and inits the modules in the plugins/ directory. */
208
void dt_iop_load_modules_so();
209
/** cleans up the dlopen refs. */
210
void dt_iop_unload_modules_so();
211
/** returns a list of instances referencing stuff loaded in load_modules_so. */
212
GList *dt_iop_load_modules(struct dt_develop_t *dev);
213
/** calls module->cleanup and closes the dl connection. */
214
void dt_iop_cleanup_module(dt_iop_module_t *module);
215
/** updates the gui params and the enabled switch. */
216
void dt_iop_gui_update(dt_iop_module_t *module);
217
/** commits params and updates piece hash. */
218
void dt_iop_commit_params(dt_iop_module_t *module, struct dt_iop_params_t *params, struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece);
219
/** creates a label widget for the expander, with callback to enable/disable this module. */
220
GtkWidget *dt_iop_gui_get_expander(dt_iop_module_t *module);
221
/** requests the focus for this plugin (to draw overlays over the center image) */
222
void dt_iop_request_focus(dt_iop_module_t *module);
223
/** loads default settings from database. */
224
void dt_iop_load_default_params(dt_iop_module_t *module);
225
/** reloads certain gui/param defaults when the image was switched. */
226
void dt_iop_reload_defaults(dt_iop_module_t *module);
228
/** let plugins have breakpoints: */
229
int dt_iop_breakpoint(struct dt_develop_t *dev, struct dt_dev_pixelpipe_t *pipe);
232
/** for homebrew pixel pipe: zoom pixel array. */
233
void dt_iop_clip_and_zoom(float *out, const float *const in, const struct dt_iop_roi_t *const roi_out, const struct dt_iop_roi_t * const roi_in, const int32_t out_stride, const int32_t in_stride);
235
/** clip and zoom mosaiced image without demosaicing it uint16_t -> float4 */
236
void dt_iop_clip_and_zoom_demosaic_half_size(float *out, const uint16_t *const in, const struct dt_iop_roi_t *const roi_out, const struct dt_iop_roi_t * const roi_in, const int32_t out_stride, const int32_t in_stride, const unsigned int filters);
237
void dt_iop_clip_and_zoom_demosaic_half_size_f(float *out, const float *const in, const struct dt_iop_roi_t *const roi_out, const struct dt_iop_roi_t * const roi_in, const int32_t out_stride, const int32_t in_stride, const unsigned int filters);
239
/** as dt_iop_clip_and_zoom, but for rgba 8-bit channels. */
240
void dt_iop_clip_and_zoom_8(const uint8_t *i, int32_t ix, int32_t iy, int32_t iw, int32_t ih, int32_t ibw, int32_t ibh,
241
uint8_t *o, int32_t ox, int32_t oy, int32_t ow, int32_t oh, int32_t obw, int32_t obh);
243
void dt_iop_YCbCr_to_RGB(const float *yuv, float *rgb);
244
void dt_iop_RGB_to_YCbCr(const float *rgb, float *yuv);