Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
blend.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2011 Henrik Andersson.
4 Copyright (C) 2011-2012 johannes hanika.
5 Copyright (C) 2011-2013, 2016-2017, 2019 Ulrich Pegelow.
6 Copyright (C) 2012 Richard Wonka.
7 Copyright (C) 2013 Aldric Renaudin.
8 Copyright (C) 2013-2014, 2016, 2018-2019 Tobias Ellinghaus.
9 Copyright (C) 2014, 2016 Roman Lebedev.
10 Copyright (C) 2017-2018, 2020 Heiko Bauke.
11 Copyright (C) 2017 luzpaz.
12 Copyright (C) 2019 Edgardo Hoszowski.
13 Copyright (C) 2019 Florian Wernert.
14 Copyright (C) 2020 Diederik Ter Rahe.
15 Copyright (C) 2020-2021 Harold le Clément de Saint-Marcq.
16 Copyright (C) 2020-2021 Pascal Obry.
17 Copyright (C) 2021 Chris Elston.
18 Copyright (C) 2021 Hanno Schwalm.
19 Copyright (C) 2022 Martin Bařinka.
20 Copyright (C) 2023, 2025 Aurélien PIERRE.
21 Copyright (C) 2025 Alynx Zhou.
22
23 darktable is free software: you can redistribute it and/or modify
24 it under the terms of the GNU General Public License as published by
25 the Free Software Foundation, either version 3 of the License, or
26 (at your option) any later version.
27
28 darktable is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU General Public License for more details.
32
33 You should have received a copy of the GNU General Public License
34 along with darktable. If not, see <http://www.gnu.org/licenses/>.
35*/
36
37#ifndef DT_DEVELOP_BLEND_H
38#define DT_DEVELOP_BLEND_H
39
40#include "develop/iop_profile.h"
41#include "history/history.h" // dt_dev_operation_t (raster_mask_source)
42#include "common/opencl.h"
43#include "develop/develop.h" // dt_develop_t, and dt_iop_module_t/_so_t through imageop.h
44#include "develop/pixelpipe.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50#define DEVELOP_BLEND_VERSION (11)
51
60
62{
63 DEVELOP_BLEND_DISABLED_OBSOLETE = 0x00, /* same as the new normal */
64 DEVELOP_BLEND_NORMAL_OBSOLETE = 0x01, /* obsolete as it did clamping */
71 DEVELOP_BLEND_DIFFERENCE = 0x08, /* deprecated */
83 DEVELOP_BLEND_INVERSE_OBSOLETE = 0x14, /* obsolete */
84 DEVELOP_BLEND_UNBOUNDED_OBSOLETE = 0x15, /* obsolete as new normal takes over */
99 DEVELOP_BLEND_MULTIPLY_REVERSE_OBSOLETE = 0x24, /* obsoleted by MULTIPLY + REVERSE */
105
109
111{
113 DEVELOP_MASK_ENABLED = 1, // uniformly
114 DEVELOP_MASK_SHAPE = 1 << 1, // drawn mask
115 DEVELOP_MASK_PARAMETRIC = 1 << 2, // parametric mask
116 DEVELOP_MASK_RASTER = 1 << 3, // raster mask
119
132
140
194
195
238
239
260
261
262/* Maps each persisted blend enum value to a translatable display name. Backend
263 * vocabulary, not GUI: develop/supervisor.c reads these tables with no GUI loaded,
264 * and their definitions live in blend.c. */
270
278
279/* The blending GUI state (dt_iop_gui_blend_data_t and its channel/colorstop/filter
280 * companions) and the dt_iop_gui_*_blending() API live in develop/blend_gui.h: they
281 * are what forced this header to feed three widgets/gui headers to every consumer
282 * that only wanted the params vocabulary or the pixel entry points. */
283
284
292
294int dt_develop_blend_process(struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe,
295 const struct dt_dev_pixelpipe_iop_t *piece, const void *const i, void *const o);
296
299
302
315
326
330
334
338
341gboolean dt_develop_blend_params_is_all_zero(const void *params, size_t length);
342
344int dt_develop_blend_legacy_params(dt_iop_module_t *module, const void *const old_params,
345 const int old_version, void *new_params, const int new_version,
346 const int length);
347int dt_develop_blend_legacy_params_from_so(dt_iop_module_so_t *module_so, const void *const old_params,
348 const int old_version, void *new_params, const int new_version,
349 const int length);
350
353#define DEVELOP_BLENDIF_PARAMETER_ITEMS 6
354
356void dt_develop_blendif_process_parameters(float *const parameters, const dt_develop_blend_params_t *const params);
357
380 const dt_develop_blend_params_t *params,
381 gboolean *top_enabled,
382 gboolean *raster_used,
383 gboolean *drawn_used,
384 gboolean *parametric_used);
385
398 const struct dt_dev_pixelpipe_iop_t *piece,
399 dt_iop_order_iccprofile_info_t *blending_profile,
401
404void dt_develop_blendif_raw_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const a,
405 const float *const b, float *const mask);
406void dt_develop_blendif_lab_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const a,
407 const float *const b, float *const mask);
409 const struct dt_dev_pixelpipe_iop_t *piece,
410 const float *const a, const float *const b, float *const mask);
412 const struct dt_dev_pixelpipe_iop_t *piece,
413 const float *const a, const float *const b, float *const mask);
414
418 const struct dt_dev_pixelpipe_iop_t *piece, const float *const a,
419 float *const b, const float *const mask,
420 const dt_dev_pixelpipe_display_mask_t request_mask_display);
422 const struct dt_dev_pixelpipe_iop_t *piece, const float *const a,
423 float *const b, const float *const mask,
424 const dt_dev_pixelpipe_display_mask_t request_mask_display);
426 const struct dt_dev_pixelpipe_iop_t *piece, const float *const a,
427 float *const b, const float *const mask,
428 const dt_dev_pixelpipe_display_mask_t request_mask_display);
430 const struct dt_dev_pixelpipe_iop_t *piece, const float *const a,
431 float *const b, const float *const mask,
432 const dt_dev_pixelpipe_display_mask_t request_mask_display);
433
434
435
436
437#ifdef HAVE_OPENCL
440 const struct dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out);
441#endif
442
443#ifdef __cplusplus
444}
445#endif
446
447#endif // DT_DEVELOP_BLEND_H
448
449// clang-format off
450// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
451// vim: shiftwidth=2 expandtab tabstop=2 cindent
452// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
453// clang-format on
void dt_develop_blendif_raw_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
gboolean dt_develop_blend_colorspace_is_compatible(dt_iop_module_t *module, dt_develop_blend_colorspace_t cst)
Whether the given module may blend in the given color space.
Definition blend.c:158
struct dt_develop_blend_params_t dt_develop_blend_params_t
void dt_develop_blendif_rgb_jzczhz_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void dt_develop_blendif_rgb_hsl_make_mask(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
void dt_develop_blend_init_blend_parameters(dt_develop_blend_params_t *blend_params, dt_develop_blend_colorspace_t cst)
Definition blend.c:212
dt_develop_mask_feathering_guide_t
Definition blend.h:134
@ DEVELOP_MASK_GUIDE_OUT_BEFORE_BLUR
Definition blend.h:136
@ DEVELOP_MASK_GUIDE_IN_AFTER_BLUR
Definition blend.h:137
@ DEVELOP_MASK_GUIDE_OUT_AFTER_BLUR
Definition blend.h:138
@ DEVELOP_MASK_GUIDE_IN_BEFORE_BLUR
Definition blend.h:135
const dt_develop_name_value_t dt_develop_invert_mask_names[]
Definition blend.c:2376
const dt_develop_name_value_t dt_develop_mask_mode_names[]
Definition blend.c:2353
dt_develop_blend_colorspace_t
Definition blend.h:53
@ DEVELOP_BLEND_CS_NONE
Definition blend.h:54
@ DEVELOP_BLEND_CS_LAB
Definition blend.h:56
@ DEVELOP_BLEND_CS_RGB_SCENE
Definition blend.h:58
@ DEVELOP_BLEND_CS_RGB_DISPLAY
Definition blend.h:57
@ DEVELOP_BLEND_CS_RAW
Definition blend.h:55
void dt_develop_blend_free_cl_global(void)
Definition blend.c:1685
void dt_develop_blend_init_cl_global(void)
Definition blend.c:1654
int dt_develop_blend_process(struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const void *const i, void *const o)
Definition blend.c:704
int dt_develop_blend_process_cl(struct dt_iop_module_t *self, struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
Definition blend.c:1160
dt_develop_mask_combine_mode_t
Definition blend.h:121
@ DEVELOP_COMBINE_INV
Definition blend.h:123
@ DEVELOP_COMBINE_NORM
Definition blend.h:122
@ DEVELOP_COMBINE_INCL
Definition blend.h:125
@ DEVELOP_COMBINE_EXCL
Definition blend.h:124
@ DEVELOP_COMBINE_MASKS_POS
Definition blend.h:126
@ DEVELOP_COMBINE_NORM_INCL
Definition blend.h:128
@ DEVELOP_COMBINE_INV_INCL
Definition blend.h:130
@ DEVELOP_COMBINE_INV_EXCL
Definition blend.h:129
@ DEVELOP_COMBINE_NORM_EXCL
Definition blend.h:127
void dt_develop_blendif_process_parameters(float *const parameters, const dt_develop_blend_params_t *const params)
void dt_develop_blendif_rgb_jzczhz_make_mask(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
void dt_develop_blendif_lab_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
void dt_develop_blendif_raw_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
dt_iop_colorspace_type_t dt_develop_blend_colorspace(const dt_dev_pixelpipe_iop_t *const piece, dt_iop_colorspace_type_t cst)
Definition blend.c:234
int dt_develop_blendif_init_masking_profile(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, dt_iop_order_iccprofile_info_t *blending_profile, dt_develop_blend_colorspace_t cst)
Definition blend.c:361
void dt_develop_blendif_rgb_hsl_blend(const struct dt_dev_pixelpipe_t *pipe, const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, float *const b, const float *const mask, const dt_dev_pixelpipe_display_mask_t request_mask_display)
int dt_develop_blend_legacy_params_from_so(dt_iop_module_so_t *module_so, const void *const old_params, const int old_version, void *new_params, const int new_version, const int length)
Definition blend.c:2264
dt_develop_blend_colorspace_t dt_develop_blend_default_module_blend_colorspace(dt_iop_module_t *module)
Definition blend.c:153
int dt_develop_blend_version(void)
Definition blend.c:1714
int dt_develop_blend_legacy_params(dt_iop_module_t *module, const void *const old_params, const int old_version, void *new_params, const int new_version, const int length)
Definition blend.c:1778
void dt_develop_blend_get_mask_usage(const dt_iop_module_t *module, const dt_develop_blend_params_t *params, gboolean *top_enabled, gboolean *raster_used, gboolean *drawn_used, gboolean *parametric_used)
Definition blend.c:301
void dt_develop_blendif_lab_make_mask(const struct dt_dev_pixelpipe_iop_t *piece, const float *const a, const float *const b, float *const mask)
const dt_develop_name_value_t dt_develop_blend_colorspace_names[]
Definition blend.c:2345
dt_develop_blendif_channels_t
Definition blend.h:142
@ DEVELOP_BLENDIF_GRAY_out
Definition blend.h:156
@ DEVELOP_BLENDIF_hz_in
Definition blend.h:177
@ DEVELOP_BLENDIF_Cz_in
Definition blend.h:176
@ DEVELOP_BLENDIF_MAX
Definition blend.h:183
@ DEVELOP_BLENDIF_S_out
Definition blend.h:172
@ DEVELOP_BLENDIF_RED_in
Definition blend.h:152
@ DEVELOP_BLENDIF_C_out
Definition blend.h:164
@ DEVELOP_BLENDIF_A_in
Definition blend.h:144
@ DEVELOP_BLENDIF_C_in
Definition blend.h:161
@ DEVELOP_BLENDIF_l_in
Definition blend.h:169
@ DEVELOP_BLENDIF_L_out
Definition blend.h:147
@ DEVELOP_BLENDIF_GREEN_in
Definition blend.h:153
@ DEVELOP_BLENDIF_h_in
Definition blend.h:162
@ DEVELOP_BLENDIF_H_in
Definition blend.h:167
@ DEVELOP_BLENDIF_RED_out
Definition blend.h:157
@ DEVELOP_BLENDIF_Lab_MASK
Definition blend.h:190
@ DEVELOP_BLENDIF_Jz_out
Definition blend.h:179
@ DEVELOP_BLENDIF_SIZE
Definition blend.h:188
@ DEVELOP_BLENDIF_B_in
Definition blend.h:145
@ DEVELOP_BLENDIF_Cz_out
Definition blend.h:180
@ DEVELOP_BLENDIF_Jz_in
Definition blend.h:175
@ DEVELOP_BLENDIF_H_out
Definition blend.h:171
@ DEVELOP_BLENDIF_A_out
Definition blend.h:148
@ DEVELOP_BLENDIF_unused
Definition blend.h:184
@ DEVELOP_BLENDIF_B_out
Definition blend.h:149
@ DEVELOP_BLENDIF_h_out
Definition blend.h:165
@ DEVELOP_BLENDIF_OUTPUT_MASK
Definition blend.h:192
@ DEVELOP_BLENDIF_BLUE_in
Definition blend.h:154
@ DEVELOP_BLENDIF_L_in
Definition blend.h:143
@ DEVELOP_BLENDIF_active
Definition blend.h:186
@ DEVELOP_BLENDIF_hz_out
Definition blend.h:181
@ DEVELOP_BLENDIF_BLUE_out
Definition blend.h:159
@ DEVELOP_BLENDIF_RGB_MASK
Definition blend.h:191
@ DEVELOP_BLENDIF_S_in
Definition blend.h:168
@ DEVELOP_BLENDIF_GRAY_in
Definition blend.h:151
@ DEVELOP_BLENDIF_GREEN_out
Definition blend.h:158
@ DEVELOP_BLENDIF_l_out
Definition blend.h:173
void dt_develop_blend_resolve_default_colorspace(dt_iop_module_t *module, dt_develop_blend_params_t *blend_params)
Replace DEVELOP_BLEND_CS_NONE, which stands for "whichever space this module blends in",...
Definition blend.c:205
gboolean dt_develop_blend_params_is_all_zero(const void *params, size_t length)
Definition blend.c:1741
dt_blendop_cl_global_t * dt_develop_blend_get_cl_global(void)
Definition blend.c:72
const dt_develop_name_value_t dt_develop_blend_mode_flag_names[]
Definition blend.c:2340
dt_develop_blend_mode_t
Definition blend.h:62
@ DEVELOP_BLEND_LIGHTEN
Definition blend.h:65
@ DEVELOP_BLEND_COLOR
Definition blend.h:82
@ DEVELOP_BLEND_CHROMATICITY
Definition blend.h:80
@ DEVELOP_BLEND_DIFFERENCE
Definition blend.h:71
@ DEVELOP_BLEND_RGB_B
Definition blend.h:98
@ DEVELOP_BLEND_LIGHTNESS
Definition blend.h:79
@ DEVELOP_BLEND_BOUNDED
Definition blend.h:88
@ DEVELOP_BLEND_SUBTRACT
Definition blend.h:70
@ DEVELOP_BLEND_MODE_MASK
Definition blend.h:107
@ DEVELOP_BLEND_DIVIDE_INVERSE
Definition blend.h:102
@ DEVELOP_BLEND_MULTIPLY_REVERSE_OBSOLETE
Definition blend.h:99
@ DEVELOP_BLEND_NORMAL2
Definition blend.h:87
@ DEVELOP_BLEND_HARDLIGHT
Definition blend.h:75
@ DEVELOP_BLEND_HUE
Definition blend.h:81
@ DEVELOP_BLEND_OVERLAY
Definition blend.h:73
@ DEVELOP_BLEND_RGB_R
Definition blend.h:96
@ DEVELOP_BLEND_LAB_A
Definition blend.h:94
@ DEVELOP_BLEND_LAB_COLOR
Definition blend.h:90
@ DEVELOP_BLEND_REVERSE
Definition blend.h:106
@ DEVELOP_BLEND_DISABLED_OBSOLETE
Definition blend.h:63
@ DEVELOP_BLEND_AVERAGE
Definition blend.h:68
@ DEVELOP_BLEND_DIVIDE
Definition blend.h:101
@ DEVELOP_BLEND_HSV_COLOR
Definition blend.h:92
@ DEVELOP_BLEND_MULTIPLY
Definition blend.h:67
@ DEVELOP_BLEND_SCREEN
Definition blend.h:72
@ DEVELOP_BLEND_HARMONIC_MEAN
Definition blend.h:104
@ DEVELOP_BLEND_PINLIGHT
Definition blend.h:78
@ DEVELOP_BLEND_HSV_VALUE
Definition blend.h:91
@ DEVELOP_BLEND_LAB_L
Definition blend.h:93
@ DEVELOP_BLEND_LINEARLIGHT
Definition blend.h:77
@ DEVELOP_BLEND_ADD
Definition blend.h:69
@ DEVELOP_BLEND_VIVIDLIGHT
Definition blend.h:76
@ DEVELOP_BLEND_GEOMETRIC_MEAN
Definition blend.h:103
@ DEVELOP_BLEND_NORMAL_OBSOLETE
Definition blend.h:64
@ DEVELOP_BLEND_SOFTLIGHT
Definition blend.h:74
@ DEVELOP_BLEND_UNBOUNDED_OBSOLETE
Definition blend.h:84
@ DEVELOP_BLEND_COLORADJUST
Definition blend.h:85
@ DEVELOP_BLEND_DARKEN
Definition blend.h:66
@ DEVELOP_BLEND_INVERSE_OBSOLETE
Definition blend.h:83
@ DEVELOP_BLEND_LAB_B
Definition blend.h:95
@ DEVELOP_BLEND_LAB_LIGHTNESS
Definition blend.h:89
@ DEVELOP_BLEND_DIFFERENCE2
Definition blend.h:86
@ DEVELOP_BLEND_SUBTRACT_INVERSE
Definition blend.h:100
@ DEVELOP_BLEND_RGB_G
Definition blend.h:97
const dt_develop_name_value_t dt_develop_combine_masks_names[]
Definition blend.c:2362
const dt_develop_name_value_t dt_develop_blend_mode_names[]
Definition blend.c:2298
void dt_develop_blend_init_blendif_parameters(dt_develop_blend_params_t *blend_params, dt_develop_blend_colorspace_t cst)
Definition blend.c:220
const dt_develop_name_value_t dt_develop_feathering_guide_names[]
Definition blend.c:2369
struct dt_iop_blend_name_value_t dt_develop_name_value_t
dt_develop_mask_mode_t
Definition blend.h:111
@ DEVELOP_MASK_RASTER
Definition blend.h:116
@ DEVELOP_MASK_PARAMETRIC
Definition blend.h:115
@ DEVELOP_MASK_DISABLED
Definition blend.h:112
@ DEVELOP_MASK_ENABLED
Definition blend.h:113
@ DEVELOP_MASK_SHAPE_PARAMETRIC
Definition blend.h:117
@ DEVELOP_MASK_SHAPE
Definition blend.h:114
dt_iop_colorspace_type_t
dt_dev_pixelpipe_display_mask_t
Definition develop.h:121
char dt_dev_operation_t[20]
The string identifying an operation in the history stack ("exposure", "colorbalancergb",...
Definition history.h:50
#define DEVELOP_BLENDIF_SIZE
Definition lightroom.c:236
int kernel_blendop_mask_rgb_jzczhz
Definition blend.h:245
int kernel_blendop_display_channel
Definition blend.h:252
int kernel_blendop_rgb_jzczhz
Definition blend.h:249
int kernel_blendop_mask_rgb_hsl
Definition blend.h:244
int kernel_blendop_mask_tone_curve
Definition blend.h:250
uint32_t feathering_guide
Definition blend.h:219
uint32_t reserved[3]
Definition blend.h:229
dt_dev_operation_t raster_mask_source
Definition blend.h:233
float blendif_parameters[4 *DEVELOP_BLENDIF_SIZE]
Definition blend.h:231
float blendif_boost_factors[DEVELOP_BLENDIF_SIZE]
Definition blend.h:232
gboolean raster_mask_invert
Definition blend.h:236
A profile reduced to the arithmetic the pixel loop can run: two matrices and six tone-curve LUTs,...