93 return module_picker || primary_picker;
98 return module && module->dev
99 && module->dev->color_picker.enabled
100 && module->dev->color_picker.module == module;
119 gboolean changed =
FALSE;
124 for(
int k = 0;
k < 2;
k++)
136 for(
int k = 0;
k < 4;
k++)
168 float image_point[2])
170 image_point[0] = raw_point[0];
171 image_point[1] = raw_point[1];
178 memcpy(image_box, raw_box,
sizeof(
float) * 4);
193 const float processed_width =
geometry.processed_width;
194 const float processed_height =
geometry.processed_height;
195 if(processed_width <= 0.0f || processed_height <= 0.0f)
return;
210 float min_x = fminf(fminf(quad[0], quad[2]), fminf(quad[4], quad[6]));
211 float min_y = fminf(fminf(quad[1], quad[3]), fminf(quad[5], quad[7]));
212 float max_x = fmaxf(fmaxf(quad[0], quad[2]), fmaxf(quad[4], quad[6]));
213 float max_y = fmaxf(fmaxf(quad[1], quad[3]), fmaxf(quad[5], quad[7]));
215 min_x = CLAMP(min_x / processed_width, 0.0f, 1.0f);
216 min_y = CLAMP(min_y / processed_height, 0.0f, 1.0f);
217 max_x = CLAMP(max_x / processed_width, 0.0f, 1.0f);
218 max_y = CLAMP(max_y / processed_height, 0.0f, 1.0f);
219 bounds[0] = fminf(min_x, max_x);
220 bounds[1] = fminf(min_y, max_y);
221 bounds[2] = fmaxf(min_x, max_x);
222 bounds[3] = fmaxf(min_y, max_y);
229 float bounds[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
233 const float processed_width =
geometry.processed_width;
234 const float processed_height =
geometry.processed_height;
235 if(processed_width <= 0.0f || processed_height <= 0.0f)
return;
238 const float inset_pixels = 64.0f;
239 const float inset_x = inset_pixels / processed_width;
240 const float inset_y = inset_pixels / processed_height;
241 const float width = fmaxf(bounds[2] - bounds[0], 0.0f);
242 const float height = fmaxf(bounds[3] - bounds[1], 0.0f);
243 picker->
pick_pos[0] = 0.5f * (bounds[0] + bounds[2]);
244 picker->
pick_pos[1] = 0.5f * (bounds[1] + bounds[3]);
245 picker->
pick_box[0] = bounds[0] + fminf(inset_x, 0.5f *
width);
247 picker->
pick_box[2] = bounds[2] - fminf(inset_x, 0.5f *
width);
302 const float roi_scale = roi->
scale;
303 if(roi_scale != 1.0f)
305 fbox[0] *= roi_scale;
306 fbox[1] *= roi_scale;
307 fbox[2] *= roi_scale;
308 fbox[3] *= roi_scale;
316 box[0] = fminf(fbox[0], fbox[2]);
317 box[1] = fminf(fbox[1], fbox[3]);
318 box[2] = fmaxf(fbox[0], fbox[2]);
319 box[3] = fmaxf(fbox[1], fbox[3]);
327 if(box[0] >= roi->
width || box[1] >= roi->
height || box[2] < 0 || box[3] < 0)
return 1;
334 if(box[2] <= box[0] || box[3] <= box[1])
return 1;
356 for(
int k = 0;
k < 4;
k++)
379 for(GList *pieces = g_list_first(current_pipe->
nodes); pieces; pieces = g_list_next(pieces))
384 current_piece = current;
392 "[picker] ready-data miss module=%s pending_hash=%" PRIu64
" pipe=%p\n",
398 if(pipe) *pipe = current_pipe;
399 if(piece) *piece = current_piece;
401 "[picker] ready-data module=%s hash=%" PRIu64
" pipe=%p picker=%p\n",
413 "[picker] guard bailout picker=%p enabled=%d picker_module=%s gui_module=%s "
414 "same_module=%d gui_module_enabled=%d\n",
441 "[picker] invalid hash module=%s piece=%" PRIu64
" prev=%" PRIu64
"\n",
458 const gboolean output_cache_blocked_by_policy
468 if(!have_output && !output_cache_blocked_by_policy)
472 "[picker] output cache miss module=%s hash=%" PRIu64
" (recompute will also satisfy input)\n",
501 for(
int k = 0;
k < 4;
k++)
503 piece->module->picked_output_color[
k] = 0.0f;
504 piece->module->picked_output_color_min[
k] = 666.0f;
505 piece->module->picked_output_color_max[
k] = -666.0f;
512 "[picker] non-float buffers module=%s input_type=%d output_type=%d\n",
526 const gboolean sampled_input
528 input, piece->module->picked_color, piece->module->picked_color_min,
530 const gboolean sampled_output
533 piece->module->picked_output_color, piece->module->picked_output_color_min,
537 if(!have_output && sampled_input)
543 for(
int k = 0;
k < 4;
k++)
545 piece->module->picked_output_color[
k] = piece->module->picked_color[
k];
546 piece->module->picked_output_color_min[
k] = piece->module->picked_color_min[
k];
547 piece->module->picked_output_color_max[
k] = piece->module->picked_color_max[
k];
562 piece->module->op, sampled_input, sampled_output);
569 "[picker] sampled module=%s hash=%" PRIu64
" avg=(%g,%g,%g) min=(%g,%g,%g) max=(%g,%g,%g)\n",
571 piece->module->picked_color[0], piece->module->picked_color[1], piece->module->picked_color[2],
572 piece->module->picked_color_min[0], piece->module->picked_color_min[1], piece->module->picked_color_min[2],
573 piece->module->picked_color_max[0], piece->module->picked_color_max[1], piece->module->picked_color_max[2]);
595 return G_SOURCE_REMOVE;
617 "[picker] refresh module=%s update_pending=%d widget_pending=%d processing=%d\n",
668 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(picker->
colorpick),
FALSE);
700 if(module)
module->request_color_pick = DT_REQUEST_COLORPICK_OFF;
707 if(picker && picker->module == module)
721 if(module)
module->request_color_pick = DT_REQUEST_COLORPICK_OFF;
730 picker->module =
module;
732 picker->
picker_cst =
module ? module->default_colorspace(module, NULL, NULL) : IOP_CS_NONE;
738 const float middle = 0.5f;
739 const float area = 0.975f;
741 picker->
pick_box[0] = (1.0f - area);
742 picker->
pick_box[1] = (1.0f - area);
758 module ? module->op :
"global");
763 if(prior_picker && prior_picker != self)
770 if(off) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(off),
TRUE);
779 dev->color_picker.picker = self;
780 dev->color_picker.widget = self->
colorpick;
781 dev->color_picker.module =
module;
782 dev->color_picker.kind =
kind;
783 dev->color_picker.picker_cst = self->
picker_cst;
784 dev->color_picker.enabled =
TRUE;
786 if(module)
module->request_color_pick = DT_REQUEST_COLORPICK_MODULE;
802 float image_point[2] = { 0.0f };
813 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->
colorpick),
TRUE);
823 "[picker] activate module=%s picker=%p widget=%p kind=%d cst=%d gui_module_before=%s "
824 "gui_module_after=%s widgets_suppressed=%d\n",
826 gui_module_before_focus ? gui_module_before_focus->
op :
"-",
834 dev->color_picker.picker = NULL;
835 dev->color_picker.widget = NULL;
836 dev->color_picker.module = NULL;
839 dev->color_picker.enabled =
FALSE;
840 dev->color_picker.update_pending =
FALSE;
844 module->request_color_pick = DT_REQUEST_COLORPICK_OFF;
847 module ? module->op :
"global", (
void *)self, (
void *)self->
colorpick);
852 if(dev->color_picker.enabled)
867 if(picker && picker->module == module && picker->
picker_cst != picker_cst)
878 if(picker && picker->module == module)
931 const guint64 producer_node_key, gpointer user_data)
934 (
void)producer_node_key;
941 gboolean matched =
FALSE;
1035 g_signal_connect_data(G_OBJECT(button),
"button-press-event",
1038 if(w) gtk_box_pack_start(GTK_BOX(w), button,
FALSE,
FALSE, 0);
1050 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
TRUE);
1063 g_signal_connect_data(G_OBJECT(w),
"quad-pressed",
Handle default and user-set shortcuts (accelerators)
void dt_bauhaus_widget_set_quad_toggle(GtkWidget *widget, int toggle)
void dt_bauhaus_widget_set_quad_active(GtkWidget *widget, int active)
void dt_bauhaus_widget_set_quad_paint(GtkWidget *widget, dt_bauhaus_quad_paint_f f, int paint_flags, void *paint_data)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
static const dt_adaptation_t kind
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)
static void _restart_picker_cache_wait(gpointer user_data)
static void _iop_color_picker_cacheline_ready_callback(gpointer instance, const guint64 hash, const guint64 producer_node_key, gpointer user_data)
static void _picker_raw_box_to_image_norm(const dt_develop_t *dev, const float raw_box[4], float image_box[4])
static void _color_picker_widget_destroy(GtkWidget *widget, dt_iop_color_picker_t *picker)
static void _queue_refresh_active_picker(dt_develop_t *dev)
void dt_iop_color_picker_init(void)
static void _refresh_active_picker(dt_develop_t *dev)
static int _picker_sample_box(const dt_iop_module_t *module, const dt_iop_roi_t *roi, const dt_pixelpipe_picker_source_t picker_source, int *box)
void dt_iop_color_picker_cleanup(void)
static void _iop_color_picker_notebook_tab_changed_callback(gpointer instance, gpointer owner, gpointer user_data)
static gboolean _record_point_area(dt_iop_color_picker_t *self)
Synchronize one picker cached geometry with the primary sample.
static gboolean _sample_picker_buffer(dt_dev_pixelpipe_t *pipe, dt_iop_module_t *module, const dt_iop_buffer_dsc_t *dsc, const dt_iop_roi_t *roi, const float *pixel, dt_aligned_pixel_t avg_out, dt_aligned_pixel_t min_out, dt_aligned_pixel_t max_out, const dt_pixelpipe_picker_source_t picker_source)
static void _iop_color_picker_pipe_finished_callback(gpointer instance, gpointer user_data)
void dt_iop_color_picker_request_update(void)
static void _picker_get_module_bounds_image_norm(const dt_develop_t *dev, const dt_iop_module_t *active_module, float bounds[4])
static void _track_active_picker_hashes(dt_develop_t *dev)
static gboolean _refresh_active_picker_idle(gpointer user_data)
static void _iop_color_picker_history_resync_callback(gpointer instance, gpointer user_data)
void dt_iop_color_picker_reset(dt_iop_module_t *module, gboolean keep)
int dt_iop_color_picker_get_ready_data(const dt_iop_module_t *module, GtkWidget **picker, dt_dev_pixelpipe_t **pipe, const dt_dev_pixelpipe_iop_t **piece)
dt_pixelpipe_picker_source_t
@ PIXELPIPE_PICKER_OUTPUT
static gboolean _color_picker_callback_button_press(GtkWidget *button, GdkEventButton *e, dt_iop_color_picker_t *self)
void dt_iop_color_picker_set_cst(dt_iop_module_t *module, const dt_iop_colorspace_type_t picker_cst)
GtkWidget * dt_color_picker_new_with_cst(dt_iop_module_t *module, dt_iop_color_picker_kind_t kind, GtkWidget *w, const dt_iop_colorspace_type_t cst)
static void _color_picker_reset(dt_iop_color_picker_t *picker)
static dt_color_picker_resample_status_t _sample_picker_from_cache(dt_develop_t *dev)
gboolean dt_iop_color_picker_is_active_module(const dt_iop_module_t *module)
Tell whether one module currently owns the active darkroom picker.
GtkWidget * dt_color_picker_new(dt_iop_module_t *module, dt_iop_color_picker_kind_t kind, GtkWidget *w)
static void _picker_raw_point_to_image_norm(const dt_develop_t *dev, const float raw_point[2], float image_point[2])
gboolean dt_iop_color_picker_is_visible(const dt_develop_t *dev)
static void _color_picker_callback(GtkWidget *button, dt_iop_color_picker_t *self)
dt_color_picker_resample_status_t
@ DT_COLOR_PICKER_RESAMPLE_RETRY
@ DT_COLOR_PICKER_RESAMPLE_CONSUMED
@ DT_COLOR_PICKER_RESAMPLE_EMITTED
static void _init_picker(dt_iop_color_picker_t *picker, dt_iop_module_t *module, dt_iop_color_picker_kind_t kind, GtkWidget *button)
static GtkWidget * _color_picker_new(dt_iop_module_t *module, dt_iop_color_picker_kind_t kind, GtkWidget *w, const gboolean init_cst, const dt_iop_colorspace_type_t cst)
dt_iop_colorspace_type_t dt_iop_color_picker_get_active_cst(dt_iop_module_t *module)
static void _picker_initialize_geometry_raw(dt_iop_color_picker_t *picker, dt_develop_t *dev)
enum _iop_color_picker_kind_t dt_iop_color_picker_kind_t
@ DT_COLOR_PICKER_POINT_AREA
@ DT_LIB_COLORPICKER_SIZE_POINT
@ DT_LIB_COLORPICKER_SIZE_BOX
struct _GtkWidget GtkWidget
GtkWidget, opaque, spelled exactly as GTK spells it.
static const float const float const float min
void dt_control_queue_redraw_center()
Request a redraw of the centre view.
struct dt_develop_t * dt_dev_get_global(void)
struct dt_lib_t * dt_lib_get_global(void)
dt_dev_image_geometry_t dt_dev_geometry_snapshot(const dt_develop_t *dev)
const dt_dev_pixelpipe_iop_t * dt_dev_pixelpipe_get_module_piece(const dt_dev_pixelpipe_t *pipe, const dt_iop_module_t *module)
void dt_dev_pixelpipe_cache_wait_cleanup(dt_dev_pixelpipe_cache_wait_t *wait, const char *reason)
Cancel one pending GUI cache wait request and clear its runtime state.
const dt_dev_pixelpipe_iop_t * dt_dev_pixelpipe_get_prev_enabled_piece(const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
void dt_dev_pixelpipe_cache_wait_set_owner(dt_dev_pixelpipe_cache_wait_t *wait, const char *owner_tag, gpointer owner_object)
Attach debug ownership metadata to one cache wait request.
gboolean dt_dev_pixelpipe_cache_peek_gui_retained(dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, void **data, dt_pixel_cache_entry_t **cache_entry, dt_dev_pixelpipe_cache_wait_t *wait, dt_dev_pixelpipe_cache_ready_callback_t restart, gpointer restart_data)
dt_iop_order_iccprofile_info_t * dt_ioppr_get_pipe_current_profile_info(dt_iop_module_t *module, const struct dt_dev_pixelpipe_t *pipe)
int dt_dev_distort_transform_plus(const dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
void dt_dev_coordinates_raw_norm_to_image_norm(dt_develop_t *dev, float *points, size_t num_points)
void dt_dev_coordinates_image_norm_to_raw_norm(dt_develop_t *dev, float *points, size_t num_points)
void dt_dev_coordinates_image_norm_to_image_abs(dt_develop_t *dev, float *points, size_t num_points)
int dt_dev_distort_backtransform_plus(const dt_dev_pixelpipe_t *pipe, const double iop_order, const int transf_direction, float *points, size_t points_count)
@ DT_DEV_TRANSFORM_DIR_FORW_INCL
@ DT_DEV_TRANSFORM_DIR_FORW_EXCL
GtkWidget * geometry
its size, under the preview
float dt_boundingbox_t[4]
void dt_iop_set_cache_bypass(dt_iop_module_t *module, gboolean state)
@ DT_REQUEST_COLORPICK_OFF
void dt_iop_request_focus(dt_iop_module_t *module)
Move darkroom focus to module, or clear it with NULL.
GtkWidget * dt_iop_gui_get_off(dt_iop_module_t *module)
void dt_lib_colorpicker_set_box_area(dt_lib_t *lib, const dt_boundingbox_t box)
void dt_lib_colorpicker_set_point(dt_lib_t *lib, const float pos[2])
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
float *const restrict const size_t k
#define dt_unreachable_codepath()
Mark a branch as impossible.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
void dt_dev_pixelpipe_cache_ref_count_entry(gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Increase/Decrease the reference count on the cache line as to prevent LRU item removal....
void dt_dev_pixelpipe_cache_rdlock_entry(gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the read lock on the entry.
Pixelpipe cache for storing intermediate results in the pixelpipe.
#define DT_PIXELPIPE_CACHE_HASH_INVALID
gboolean dt_dev_pixelpipe_get_realtime(const dt_dev_pixelpipe_t *pipe)
Asking the interface to repaint itself.
#define DT_DEBUG_CONTROL_SIGNAL_DISCONNECT(ctlsig, cb, user_data)
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
struct dt_control_signal_t * dt_control_signal_get_global(void)
@ DT_SIGNAL_DEVELOP_PREVIEW_PIPE_FINISHED
This signal is raised when develop preview pipe process is finished no param, no returned value.
@ DT_SIGNAL_HISTORY_RESYNC
This signal is raised once darkroom history has been resynchronized into all live pipelines....
@ DT_SIGNAL_CACHELINE_READY
This signal is raised when one cacheline write lock is released. 1 : uint64_t cacheline hash no retur...
@ DT_SIGNAL_CONTROL_NOTEBOOK_TAB_CHANGED
This signal is raised when a GtkNotebook created/registered via dt_ui_notebook_set_picker_owner() swi...
@ DT_SIGNAL_CONTROL_PICKERDATA_READY
This signal is raised when new color picker data are available in darkroom. no param,...
#define DT_DEBUG_CONTROL_SIGNAL_CONNECT(ctlsig, signal, cb, user_data)
DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4]
const float uint32_t state[4]
dt_lib_colorpicker_size_t size
Objective facts about the image a dev is working on.
dt_iop_buffer_dsc_t dsc_out
struct dt_iop_module_t *void * data
struct dt_colorpicker_sample_t * primary_sample
uint64_t wait_output_hash
gboolean(* refresh_global_picker)(struct dt_lib_module_t *self)
struct dt_develop_t::@13 color_picker
Authoritative darkroom color-picker state.
struct dt_iop_module_t * pending_module
struct dt_iop_module_t * gui_module
struct dt_dev_pixelpipe_t * preview_pipe
dt_dev_pixelpipe_cache_wait_t output_wait
struct dt_iop_module_t *struct dt_iop_color_picker_t * picker
guint refresh_idle_source
struct dt_dev_pixelpipe_t * pending_pipe
struct dt_lib_module_t * histogram_module
dt_dev_pixelpipe_cache_wait_t input_wait
dt_iop_buffer_type_t datatype
dt_iop_module_t *dt_iop_color_picker_kind_t kind
dt_boundingbox_t pick_box
dt_iop_colorspace_type_t picker_cst
A profile reduced to the arithmetic the pixel loop can run: two matrices and six tone-curve LUTs,...
Region of interest passed through the pixelpipe.