Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
color_picker_proxy.c File Reference
#include "gui/color_picker_proxy.h"
#include "bauhaus/bauhaus.h"
#include "common/color_picker.h"
#include "control/signal.h"
#include "control/control.h"
#include "develop/dev_pixelpipe.h"
#include "develop/pixelpipe_cache.h"
#include "gui/gtk.h"
#include "libs/colorpicker.h"
#include "libs/lib.h"
#include <inttypes.h>
#include <math.h>
#include <string.h>
+ Include dependency graph for color_picker_proxy.c:

Go to the source code of this file.

Typedefs

typedef enum dt_pixelpipe_picker_source_t dt_pixelpipe_picker_source_t
 
typedef enum dt_color_picker_resample_status_t dt_color_picker_resample_status_t
 

Enumerations

enum  dt_pixelpipe_picker_source_t {
  PIXELPIPE_PICKER_INPUT = 0 ,
  PIXELPIPE_PICKER_OUTPUT = 1
}
 
enum  dt_color_picker_resample_status_t {
  DT_COLOR_PICKER_RESAMPLE_CONSUMED = 0 ,
  DT_COLOR_PICKER_RESAMPLE_RETRY = 1 ,
  DT_COLOR_PICKER_RESAMPLE_EMITTED = 2
}
 

Functions

gboolean dt_iop_color_picker_is_visible (const 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.
 
static gboolean _record_point_area (dt_iop_color_picker_t *self)
 Synchronize one picker cached geometry with the primary sample.
 
static void _refresh_active_picker (dt_develop_t *dev)
 
static void _track_active_picker_hashes (dt_develop_t *dev)
 
static void _restart_picker_cache_wait (gpointer user_data)
 
static void _picker_raw_point_to_image_norm (const dt_develop_t *dev, const float raw_point[2], float image_point[2])
 
static void _picker_raw_box_to_image_norm (const dt_develop_t *dev, const float raw_box[4], float image_box[4])
 
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 _picker_initialize_geometry_raw (dt_iop_color_picker_t *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)
 
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)
 
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)
 
static dt_color_picker_resample_status_t _sample_picker_from_cache (dt_develop_t *dev)
 
static gboolean _refresh_active_picker_idle (gpointer user_data)
 
static void _queue_refresh_active_picker (dt_develop_t *dev)
 
static void _color_picker_reset (dt_iop_color_picker_t *picker)
 
static void _color_picker_widget_destroy (GtkWidget *widget, dt_iop_color_picker_t *picker)
 
void dt_iop_color_picker_reset (dt_iop_module_t *module, gboolean keep)
 
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 gboolean _color_picker_callback_button_press (GtkWidget *button, GdkEventButton *e, dt_iop_color_picker_t *self)
 
static void _color_picker_callback (GtkWidget *button, 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)
 
dt_iop_colorspace_type_t dt_iop_color_picker_get_active_cst (dt_iop_module_t *module)
 
void dt_iop_color_picker_request_update (void)
 
gboolean dt_iop_color_picker_force_cache (const dt_dev_pixelpipe_t *pipe, const dt_iop_module_t *module)
 
static void _iop_color_picker_history_resync_callback (gpointer instance, 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 _iop_color_picker_pipe_finished_callback (gpointer instance, gpointer user_data)
 
static void _iop_color_picker_notebook_tab_changed_callback (gpointer instance, gpointer owner, gpointer user_data)
 
void dt_iop_color_picker_init (void)
 
void dt_iop_color_picker_cleanup (void)
 
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)
 
GtkWidgetdt_color_picker_new (dt_iop_module_t *module, dt_iop_color_picker_kind_t kind, GtkWidget *w)
 
GtkWidgetdt_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)
 

Typedef Documentation

◆ dt_color_picker_resample_status_t

◆ dt_pixelpipe_picker_source_t

Enumeration Type Documentation

◆ dt_color_picker_resample_status_t

Enumerator
DT_COLOR_PICKER_RESAMPLE_CONSUMED 
DT_COLOR_PICKER_RESAMPLE_RETRY 
DT_COLOR_PICKER_RESAMPLE_EMITTED 

Definition at line 154 of file color_picker_proxy.c.

◆ dt_pixelpipe_picker_source_t

Enumerator
PIXELPIPE_PICKER_INPUT 
PIXELPIPE_PICKER_OUTPUT 

Definition at line 148 of file color_picker_proxy.c.

Function Documentation

◆ _color_picker_callback()

static void _color_picker_callback ( GtkWidget button,
dt_iop_color_picker_t self 
)
static

Definition at line 835 of file color_picker_proxy.c.

References _color_picker_callback_button_press().

Referenced by _color_picker_new().

◆ _color_picker_callback_button_press()

◆ _color_picker_new()

◆ _color_picker_reset()

◆ _color_picker_widget_destroy()

static void _color_picker_widget_destroy ( GtkWidget widget,
dt_iop_color_picker_t picker 
)
static

◆ _init_picker()

◆ _iop_color_picker_cacheline_ready_callback()

static void _iop_color_picker_cacheline_ready_callback ( gpointer  instance,
const guint64  hash,
const guint64  producer_node_key,
gpointer  user_data 
)
static

◆ _iop_color_picker_history_resync_callback()

static void _iop_color_picker_history_resync_callback ( gpointer  instance,
gpointer  user_data 
)
static

◆ _iop_color_picker_notebook_tab_changed_callback()

static void _iop_color_picker_notebook_tab_changed_callback ( gpointer  instance,
gpointer  owner,
gpointer  user_data 
)
static

Any module notebook registered via dt_ui_notebook_set_picker_owner(notebook, module) relays its page switches here. Each page typically holds its own picker(s), read at apply time: leaving one active across a page switch would keep it sampling/drawing on the image for a control the user can no longer see or turn off from that hidden page. The GTK layer only carries the opaque owner pointer; we are the ones who know it is a dt_iop_module_t here.

Definition at line 979 of file color_picker_proxy.c.

References dt_iop_color_picker_reset(), FALSE, IS_NULL_PTR, and void().

Referenced by dt_iop_color_picker_cleanup(), and dt_iop_color_picker_init().

◆ _iop_color_picker_pipe_finished_callback()

static void _iop_color_picker_pipe_finished_callback ( gpointer  instance,
gpointer  user_data 
)
static

Hash-drift-proof wake-up.

The CACHELINE_READY path above matches a single hash captured up-front on the GUI thread (wait_input_hash / wait_output_hash, and the cache-wait handles inside _sample_picker_from_cache). If any hash input drifts between that capture and the worker's publish — the module's own request_color_pick / runtime_data_hash() state folding into its global_hash, a 1px ROI disagreement, etc. — the worker publishes a different hash, CACHELINE_READY never matches, and the picker waits forever (pipeline-cache.md §8; issues #955 / #957).

A completed preview run is immune to that drift: it fires once the pipe has settled and republished its outputs, and _refresh_active_picker re-reads the current piece hashes rather than a stale captured one. So even when the exact awaited hash is never republished, the picker converges on the settled state within a pipe cycle instead of hanging. This is a fallback, not a replacement: the CACHELINE_READY path still serves the common (hit) case immediately.

Definition at line 962 of file color_picker_proxy.c.

References _queue_refresh_active_picker(), darktable, darktable_t::develop, IS_NULL_PTR, and void().

Referenced by dt_iop_color_picker_cleanup(), and dt_iop_color_picker_init().

◆ _picker_get_module_bounds_image_norm()

◆ _picker_initialize_geometry_raw()

◆ _picker_raw_box_to_image_norm()

static void _picker_raw_box_to_image_norm ( const dt_develop_t dev,
const float  raw_box[4],
float  image_box[4] 
)
inlinestatic

◆ _picker_raw_point_to_image_norm()

static void _picker_raw_point_to_image_norm ( const dt_develop_t dev,
const float  raw_point[2],
float  image_point[2] 
)
inlinestatic

◆ _picker_sample_box()

◆ _queue_refresh_active_picker()

◆ _record_point_area()

static gboolean _record_point_area ( dt_iop_color_picker_t self)
static

Synchronize one picker cached geometry with the primary sample.

The active picker keeps a copy of the sample point/box so reopening it restores the previous GUI geometry. This function only mirrors the current primary sample into that cached geometry and reports whether the coordinates changed since the previous sampling pass.

It does not consume self->update_pending. That flag is the same update logic seen from the non-geometric side: first activation and colorspace changes request one callback even if the picker geometry itself did not move.

Definition at line 113 of file color_picker_proxy.c.

References dt_colorpicker_sample_t::box, dt_develop_t::color_picker, darktable, darktable_t::develop, DT_LIB_COLORPICKER_SIZE_BOX, DT_LIB_COLORPICKER_SIZE_POINT, FALSE, dt_iop_color_picker_t::geometry_is_raw, k, dt_iop_color_picker_t::pick_box, dt_iop_color_picker_t::pick_pos, dt_colorpicker_sample_t::point, dt_develop_t::primary_sample, dt_colorpicker_sample_t::size, and TRUE.

Referenced by _refresh_active_picker().

◆ _refresh_active_picker()

◆ _refresh_active_picker_idle()

static gboolean _refresh_active_picker_idle ( gpointer  user_data)
static

◆ _restart_picker_cache_wait()

static void _restart_picker_cache_wait ( gpointer  user_data)
static

Definition at line 599 of file color_picker_proxy.c.

References _queue_refresh_active_picker().

Referenced by _sample_picker_from_cache().

◆ _sample_picker_buffer()

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

◆ _sample_picker_from_cache()

static dt_color_picker_resample_status_t _sample_picker_from_cache ( dt_develop_t dev)
static

◆ _track_active_picker_hashes()

◆ dt_color_picker_new()

GtkWidget * dt_color_picker_new ( dt_iop_module_t module,
dt_iop_color_picker_kind_t  kind,
GtkWidget w 
)

◆ dt_color_picker_new_with_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 
)

Definition at line 1077 of file color_picker_proxy.c.

References _color_picker_new(), kind, and TRUE.

Referenced by gui_init(), and gui_init().

◆ dt_iop_color_picker_cleanup()

◆ dt_iop_color_picker_force_cache()

gboolean dt_iop_color_picker_force_cache ( const dt_dev_pixelpipe_t pipe,
const dt_iop_module_t module 
)

◆ dt_iop_color_picker_get_active_cst()

◆ dt_iop_color_picker_get_ready_data()

◆ dt_iop_color_picker_init()

◆ dt_iop_color_picker_is_active_module()

gboolean dt_iop_color_picker_is_active_module ( const dt_iop_module_t module)

Tell whether one module currently owns the active darkroom picker.

Module code often needs to know whether a GUI callback is running for the module that currently captures picker updates. That ownership lives under dt_develop_t::color_picker, so callers should query it through this API instead of open-coding the develop-state test at each call site.

Parameters
moduleCandidate module.
Returns
TRUE when the picker manager is enabled and the active picker belongs to module.

Definition at line 94 of file color_picker_proxy.c.

Referenced by _spot_settings_changed_callback(), and _spot_settings_changed_callback().

◆ dt_iop_color_picker_is_visible()

◆ dt_iop_color_picker_request_update()

◆ dt_iop_color_picker_reset()

void dt_iop_color_picker_reset ( dt_iop_module_t module,
gboolean  keep 
)

Definition at line 680 of file color_picker_proxy.c.

References _color_picker_reset(), dt_develop_t::color_picker, darktable, darktable_t::develop, DT_COLOR_PICKER_POINT, dt_dev_pixelpipe_cache_wait_cleanup(), dt_develop_t::enabled, FALSE, dt_develop_t::input_wait, IOP_CS_NONE, dt_develop_t::kind, dt_develop_t::output_wait, dt_develop_t::picker, dt_develop_t::picker_cst, dt_develop_t::update_pending, and dt_develop_t::widget.

Referenced by _area_button_press_callback(), _area_button_press_callback(), _area_key_press_callback(), _area_key_press_callback(), _area_motion_notify_callback(), _area_motion_notify_callback(), _area_scrolled_callback(), _area_scrolled_callback(), _autoexp_disable(), _blendop_blendif_reset(), _blendop_blendif_sliders_callback(), _blendop_blendif_tab_switch(), _blendop_masks_shape_can_start(), _blendop_masks_show_and_edit(), _delete_node(), _edit_masks(), _gui_reset_callback(), _interpolator_callback(), _iop_color_picker_notebook_tab_changed_callback(), _select_region_toggled_callback(), _select_region_toggled_callback(), _turn_selregion_picker_off(), _turn_selregion_picker_off(), apply_autocolor(), apply_autoluma(), area_button_press(), aspect_changed(), balance_callback(), black_point_source_callback(), black_point_target_callback(), center_callback(), colorpick_color_set(), colorpicker_callback(), contrast_callback(), controls_callback(), Dmin_picker_callback(), dt_iop_gui_changed(), dt_iop_gui_update_blendif(), dt_iop_gui_update_blending(), dt_iop_levels_autoadjust_callback(), dt_iop_levels_scroll(), dt_iop_monochrome_button_press(), dt_iop_monochrome_button_release(), dt_iop_monochrome_scrolled(), dt_iop_request_focus(), frame_colorpick_color_set(), global_saturation_callback(), grey_point_source_callback(), grey_point_target_callback(), gui_changed(), gui_cleanup(), gui_reset(), gui_reset(), gui_reset(), gui_update(), gui_update(), gui_update(), interpolator_callback(), latitude_stops_callback(), leave(), notebook_button_press(), output_power_callback(), patch_callback(), position_h_changed(), position_v_changed(), preset_tune_callback(), rt_colorpick_color_set_callback(), rt_edit_masks_callback(), rt_shape_buttons_can_start(), saturation_callback(), security_threshold_callback(), show_luminance_mask_callback(), smoothing_callback(), target_callback(), temp_tint_callback(), WB_high_picker_callback(), WB_low_picker_callback(), white_point_source_callback(), and white_point_target_callback().

◆ dt_iop_color_picker_set_cst()