118 uint32_t **histogram, uint32_t *histogram_max)
124 if(histogram_params.
roi == NULL)
127 .
width = roi.
width, .height = roi.
height, .crop_x = 0, .crop_y = 0, .crop_width = 0, .crop_height = 0
130 histogram_params.
roi = &histogram_roi;
152 if(!strcmp(op,
"demosaic"))
154 else if(!strcmp(op,
"colorout"))
156 else if(!strcmp(op,
"gamma"))
172 return dev &&
module && dev->gui_module && darktable.lib->proxy.colorpicker.picker_proxy
173 && module == dev->gui_module && dev->gui_module->enabled
174 && dev->gui_module->request_color_pick != DT_REQUEST_COLORPICK_OFF;
199 &&
module && _get_backuf((dt_develop_t *)dev, module->op) && strcmp(module->op, "gamma") != 0;
207 &&
module && !strcmp(module->op, "gamma");
214 for(GList *pieces = g_list_first(pipe->
nodes); pieces; pieces = g_list_next(pieces))
244 && darktable.lib->proxy.colorpicker.picker_proxy
245 && dev->gui_module->enabled
246 && dev->gui_module->request_color_pick != DT_REQUEST_COLORPICK_OFF
247 && module != dev->gui_module
248 && module->iop_order > dev->gui_module->iop_order;
273 if(backbuf == NULL)
return;
301 dt_aligned_pixel_t picked_color_min, dt_aligned_pixel_t picked_color_max,
313 memcpy(fbox, sample->
box,
sizeof(
float) * 4);
318 fbox[0] = sample->
point[0];
319 fbox[1] = sample->
point[1];
337 box[0] = fminf(fbox[0], fbox[2]);
338 box[1] = fminf(fbox[1], fbox[3]);
339 box[2] = fmaxf(fbox[0], fbox[2]);
340 box[3] = fmaxf(fbox[1], fbox[3]);
345 for(
int k = 2; k < 4; k++) box[k] += 1;
349 if(box[0] >=
width || box[1] >=
height || box[2] < 0 || box[3] < 0)
return 1;
352 for(
int k = 0; k < 4; k += 2) box[k] =
MIN(
width - 1,
MAX(0, box[k]));
353 for(
int k = 1; k < 4; k += 2) box[k] =
MIN(
height - 1,
MAX(0, box[k]));
356 if(box[2] <= box[0] || box[3] <= box[1])
return 1;
361 for(
int k = 0; k < 4; k++)
363 picked_color_min[k] = INFINITY;
364 picked_color_max[k] = -INFINITY;
365 picked_color[k] = 0.0f;
381 const float *pixel,
const dt_iop_roi_t roi,
float *picked_color,
382 float *picked_color_min,
float *picked_color_max,
389 dt_aligned_pixel_t avg = { 0.0f };
390 dt_aligned_pixel_t
min = { 0.0f };
391 dt_aligned_pixel_t
max = { 0.0f };
398 for(
int k = 0; k < 4; k++)
400 picked_color_min[k] =
min[k];
401 picked_color_max[k] =
max[k];
402 picked_color[k] = avg[k];
459 module->input_colorspace(module, pipe, piece), &input_format->
cst,
467 module->histogram = realloc(module->histogram, buf_size);
469 module->histogram_stats = piece->histogram_stats;
500 input_format->
cst, picker_cst, &input_format->
cst,
549 if(strcmp(module->
op,
"gamma") == 0)
553 buf_hash = input_hash;
558 entry = output_entry;
593 GList *pieces = g_list_first(pipe->
nodes);
594 int64_t input_hash = -1;
610 if(strcmp(piece->module->op,
"gamma") == 0)
613 buf_hash = input_hash;
630 pieces = g_list_next(pieces);
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
dt_iop_colorspace_type_t
Definition color_conversion.h:30
@ IOP_CS_RAW
Definition color_conversion.h:32
@ IOP_CS_JZCZHZ
Definition color_conversion.h:37
@ IOP_CS_RGB
Definition color_conversion.h:34
@ IOP_CS_HSL
Definition color_conversion.h:36
@ IOP_CS_LAB
Definition color_conversion.h:33
@ IOP_CS_NONE
Definition color_conversion.h:31
void dt_color_picker_helper(const dt_iop_buffer_dsc_t *dsc, const float *const pixel, const dt_iop_roi_t *roi, const int *const box, dt_aligned_pixel_t picked_color, dt_aligned_pixel_t picked_color_min, dt_aligned_pixel_t picked_color_max, const dt_iop_colorspace_type_t image_cst, const dt_iop_colorspace_type_t picker_cst, const dt_iop_order_iccprofile_info_t *const profile)
Definition color_picker.c:616
dt_iop_colorspace_type_t dt_iop_color_picker_get_active_cst(dt_iop_module_t *module)
Definition color_picker_proxy.c:258
@ DT_LIB_COLORPICKER_SIZE_POINT
Definition colorpicker.h:37
@ DT_LIB_COLORPICKER_SIZE_BOX
Definition colorpicker.h:38
static const float const float const float min
Definition colorspaces_inline_conversions.h:667
const float max
Definition colorspaces_inline_conversions.h:721
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
void dt_histogram_max_helper(const dt_dev_histogram_stats_t *const histogram_stats, const dt_iop_colorspace_type_t cst, const dt_iop_colorspace_type_t cst_to, uint32_t **histogram, uint32_t *histogram_max)
Definition common/histogram.c:403
void dt_histogram_helper(dt_dev_histogram_collection_params_t *histogram_params, dt_dev_histogram_stats_t *histogram_stats, const dt_iop_colorspace_type_t cst, const dt_iop_colorspace_type_t cst_to, const void *pixel, uint32_t **histogram, const int compensate_middle_grey, const dt_iop_order_iccprofile_info_t *const profile_info)
Definition common/histogram.c:372
void dt_control_queue_redraw_widget(GtkWidget *widget)
threadsafe request of redraw of specific widget. Use this function if you need to redraw a specific w...
Definition control.c:656
darktable_t darktable
Definition darktable.c:178
float dt_boundingbox_t[4]
Definition darktable.h:630
int dt_dev_distort_backtransform_plus(dt_develop_t *dev, dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
Definition develop.c:1366
void dt_dev_coordinates_image_norm_to_preview_abs(dt_develop_t *dev, float *points, size_t num_points)
Definition develop.c:934
void dt_dev_set_backbuf(dt_backbuf_t *backbuf, const int width, const int height, const size_t bpp, const int64_t hash, const int64_t history_hash)
Definition develop.c:1629
@ DT_DEV_TRANSFORM_DIR_FORW_INCL
Definition develop.h:99
@ DT_DEV_TRANSFORM_DIR_FORW_EXCL
Definition develop.h:100
void output_format(dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc)
Definition gamma.c:119
@ DT_REQUEST_COLORPICK_OFF
Definition imageop.h:172
void dt_ioppr_transform_image_colorspace(struct dt_iop_module_t *self, const float *const image_in, float *const image_out, const int width, const int height, const int cst_from, const int cst_to, int *converted_cst, const dt_iop_order_iccprofile_info_t *const profile_info)
Definition iop_profile.c:1042
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_work_profile_info(struct dt_dev_pixelpipe_t *pipe)
Definition iop_profile.c:913
@ DT_REQUEST_ON
Definition pixelpipe.h:48
@ DT_REQUEST_ONLY_IN_GUI
Definition pixelpipe.h:49
void dt_dev_pixelpipe_cache_ref_count_entry(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Increase/Decrease the reference count on the cache line as to prevent LRU item removal....
Definition pixelpipe_cache.c:1473
gboolean dt_dev_pixelpipe_cache_peek(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, void **data, dt_iop_buffer_dsc_t **dsc, dt_pixel_cache_entry_t **entry)
Non-owning lookup of an existing cache line.
Definition pixelpipe_cache.c:1331
void dt_dev_pixelpipe_cache_rdlock_entry(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the read lock on the entry.
Definition pixelpipe_cache.c:1501
size_t dt_pixel_cache_entry_get_size(dt_pixel_cache_entry_t *entry)
Peek the size (in bytes) reserved for the host buffer of a cache entry.
Definition pixelpipe_cache.c:925
Pixelpipe cache for storing intermediate results in the pixelpipe.
#define DT_PIXELPIPE_CACHE_HASH_INVALID
Definition pixelpipe_cache.h:41
static void _sample_gui(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, void *input, void **output, const dt_iop_roi_t roi_in, const dt_iop_roi_t roi_out, dt_iop_buffer_dsc_t *input_format, dt_iop_buffer_dsc_t **output_format, dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece, const uint64_t input_hash, const uint64_t hash, const size_t in_bpp, const size_t bpp, dt_pixel_cache_entry_t *const input_entry, dt_pixel_cache_entry_t *const output_entry)
Sample all GUI observables for a processed module node.
Definition pixelpipe_gui.c:528
static int pixelpipe_picker_helper(dt_iop_module_t *module, const dt_iop_roi_t roi, dt_aligned_pixel_t picked_color, dt_aligned_pixel_t picked_color_min, dt_aligned_pixel_t picked_color_max, dt_pixelpipe_picker_source_t picker_source, int *box)
Compute the sampling box in module coordinates for the interactive color picker.
Definition pixelpipe_gui.c:300
static dt_iop_colorspace_type_t _transform_for_picker(dt_iop_module_t *self, const dt_iop_colorspace_type_t cst)
Select a safe colorspace for picker sampling.
Definition pixelpipe_gui.c:414
static void pixelpipe_picker(dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece, dt_iop_buffer_dsc_t *dsc, const float *pixel, const dt_iop_roi_t roi, float *picked_color, float *picked_color_min, float *picked_color_max, const dt_iop_colorspace_type_t image_cst, dt_pixelpipe_picker_source_t picker_source)
Sample the color picker values (avg/min/max) from a pixel buffer.
Definition pixelpipe_gui.c:380
static gboolean _module_requests_input_histogram(const dt_develop_t *dev, const dt_dev_pixelpipe_iop_t *piece)
Definition pixelpipe_gui.c:177
static gboolean _module_exact_hit_must_recurse_for_picker(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev, const dt_iop_module_t *module)
Tell whether an exact cache hit must still recurse to reach the active color picker module.
Definition pixelpipe_gui.c:236
dt_pixelpipe_picker_source_t
Identify whether the picker sampling is applied on the module input or output.
Definition pixelpipe_gui.c:105
@ PIXELPIPE_PICKER_INPUT
Definition pixelpipe_gui.c:106
@ PIXELPIPE_PICKER_OUTPUT
Definition pixelpipe_gui.c:107
static gboolean _pipe_needs_gui_sampling_traversal(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev)
Definition pixelpipe_gui.c:210
static gboolean _resync_global_histograms(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev)
Re-sync the global histogram cache references on a pure cache hit.
Definition pixelpipe_gui.c:588
static gboolean _module_needs_gui_output_backbuf_sync(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev, const dt_iop_module_t *module)
Definition pixelpipe_gui.c:194
static gboolean _pipe_tracks_gui_observables(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev)
Definition pixelpipe_gui.c:165
static void collect_histogram_on_CPU(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, float *input, const dt_iop_roi_t roi_in, dt_iop_buffer_dsc_t *input_format, dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece)
Collect the per-module histogram on CPU for GUI display.
Definition pixelpipe_gui.c:445
static dt_backbuf_t * _get_backuf(dt_develop_t *dev, const char *op)
Map an op name to the corresponding global histogram backbuffer.
Definition pixelpipe_gui.c:150
static gboolean _module_needs_gui_host_input_sampling(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev, const dt_iop_module_t *module, const dt_dev_pixelpipe_iop_t *piece)
Definition pixelpipe_gui.c:184
static void pixelpipe_get_histogram_backbuf(dt_develop_t *dev, const dt_iop_roi_t roi, dt_pixel_cache_entry_t *entry, dt_iop_module_t *module, const uint64_t hash)
Update the global histogram backbuffer to reference a specific cache entry.
Definition pixelpipe_gui.c:269
static gboolean _module_requests_color_picker(const dt_develop_t *dev, const dt_iop_module_t *module)
Definition pixelpipe_gui.c:170
static void histogram_collect(dt_dev_pixelpipe_iop_t *piece, const void *pixel, const dt_iop_roi_t roi, uint32_t **histogram, uint32_t *histogram_max)
Compute a histogram for a given module piece.
Definition pixelpipe_gui.c:117
static void _sync_module_output_backbuf_on_exact_hit(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece, dt_pixel_cache_entry_t *output_entry, const dt_iop_roi_t roi_out, const uint64_t hash)
Definition pixelpipe_gui.c:251
static void _sample_color_picker(dt_dev_pixelpipe_t *pipe, dt_develop_t *dev, float *input, dt_iop_buffer_dsc_t *input_format, const dt_iop_roi_t roi_in, void **output, dt_iop_buffer_dsc_t **out_format, const dt_iop_roi_t roi_out, dt_iop_module_t *module, dt_dev_pixelpipe_iop_t *piece)
Sample the interactive color picker for the currently edited module.
Definition pixelpipe_gui.c:483
static gboolean _module_needs_gui_input_backbuf_sync(const dt_dev_pixelpipe_t *pipe, const dt_develop_t *dev, const dt_iop_module_t *module)
Definition pixelpipe_gui.c:202
gboolean dt_dev_pixelpipe_get_realtime(const dt_dev_pixelpipe_t *pipe)
Definition pixelpipe_hb.c:590
static uint64_t dt_dev_backbuf_get_hash(const dt_backbuf_t *backbuf)
Definition pixelpipe_hb.h:158
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
Definition signal.h:317
@ DT_SIGNAL_CONTROL_PICKERDATA_READY
This signal is raised when new color picker data are available in the pixelpipe. 1 module 2 piece no ...
Definition signal.h:266
unsigned __int64 uint64_t
Definition strptime.c:74
struct dt_lib_t * lib
Definition darktable.h:698
struct dt_dev_pixelpipe_cache_t * pixelpipe_cache
Definition darktable.h:717
struct dt_control_signal_t * signals
Definition darktable.h:701
struct dt_develop_t * develop
Definition darktable.h:697
Definition pixelpipe_hb.h:150
Definition colorpicker.h:53
dt_lib_colorpicker_size_t size
Definition colorpicker.h:60
dt_boundingbox_t box
Definition colorpicker.h:59
float point[2]
Definition colorpicker.h:58
Definition pixelpipe.h:54
const struct dt_histogram_roi_t * roi
Definition pixelpipe.h:56
uint32_t bins_count
Definition pixelpipe.h:67
Definition pixelpipe_hb.h:58
gboolean enabled
Definition pixelpipe_hb.h:74
uint32_t histogram_max[4]
Definition pixelpipe_hb.h:80
dt_dev_request_flags_t request_histogram
Definition pixelpipe_hb.h:76
struct dt_iop_module_t *struct dt_dev_pixelpipe_t * pipe
Definition pixelpipe_hb.h:60
uint64_t global_hash
Definition pixelpipe_hb.h:90
dt_iop_buffer_dsc_t dsc_in
Definition pixelpipe_hb.h:104
uint32_t * histogram
Definition pixelpipe_hb.h:78
dt_dev_histogram_stats_t histogram_stats
Definition pixelpipe_hb.h:79
dt_iop_roi_t planned_roi_out
Definition pixelpipe_hb.h:99
dt_dev_histogram_collection_params_t histogram_params
Definition pixelpipe_hb.h:77
void * data
Definition pixelpipe_hb.h:61
dt_iop_roi_t planned_roi_in
Definition pixelpipe_hb.h:99
Definition pixelpipe_hb.h:179
gboolean gui_observable_source
Definition pixelpipe_hb.h:255
GList * nodes
Definition pixelpipe_hb.h:204
dt_iop_buffer_dsc_t dsc
Definition pixelpipe_hb.h:192
int32_t gui_attached
Definition develop.h:154
dt_backbuf_t display_histogram
Definition develop.h:299
dt_backbuf_t output_histogram
Definition develop.h:298
struct dt_iop_module_t * gui_module
Definition develop.h:157
struct dt_dev_pixelpipe_t * preview_pipe
Definition develop.h:227
dt_backbuf_t raw_histogram
Definition develop.h:297
Definition histogram.h:42
int width
Definition histogram.h:43
Definition develop/format.h:48
int cst
Definition develop/format.h:74
dt_dev_request_colorpick_flags_t request_color_pick
Definition imageop.h:235
dt_aligned_pixel_t picked_output_color_min
Definition imageop.h:247
GtkWidget * widget
Definition imageop.h:303
GModule *dt_dev_operation_t op
Definition imageop.h:227
dt_dev_request_flags_t request_histogram
Definition imageop.h:237
int iop_order
Definition imageop.h:231
dt_aligned_pixel_t picked_output_color_max
Definition imageop.h:247
uint32_t histogram_max[4]
Definition imageop.h:253
dt_aligned_pixel_t picked_output_color
Definition imageop.h:247
gboolean enabled
Definition imageop.h:264
dt_aligned_pixel_t picked_color_min
Definition imageop.h:245
dt_aligned_pixel_t picked_color_max
Definition imageop.h:245
uint32_t * histogram
Definition imageop.h:249
dt_aligned_pixel_t picked_color
Definition imageop.h:245
Definition iop_profile.h:52
int x
Definition imageop.h:68
int width
Definition imageop.h:68
int height
Definition imageop.h:68
int y
Definition imageop.h:68
struct dt_iop_color_picker_t * picker_proxy
Definition libs/lib.h:74
struct dt_lib_module_t *struct dt_colorpicker_sample_t * primary_sample
Definition libs/lib.h:73
struct dt_lib_t::@57 proxy
struct dt_lib_t::@57::@58 colorpicker
Definition pixelpipe_cache.h:78
#define MIN(a, b)
Definition thinplate.c:32
#define MAX(a, b)
Definition thinplate.c:29