Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
histogram.c File Reference
#include <stdint.h>
#include <inttypes.h>
#include "develop/imageop_gui.h"
#include "widgets/bauhaus.h"
#include "widgets/resize_handle.h"
#include "widgets/widget_settings.h"
#include "common/color_picker.h"
#include "common/color_vocabulary.h"
#include "caches/pixelpipe_cache_alloc.h"
#include "common/histogram.h"
#include "common/image.h"
#include "imageio/imageio_core.h"
#include "develop/iop_profile.h"
#include "common/logging.h"
#include "system/macros.h"
#include "math/math.h"
#include "system/mem_alloc.h"
#include "common/module_versioning.h"
#include "system/openmp.h"
#include "system/simd.h"
#include "common/times.h"
#include "common/conf.h"
#include "control/control.h"
#include "control/signal.h"
#include "develop/dev_pixelpipe.h"
#include "develop/develop.h"
#include "caches/pixelpipe_cache.h"
#include "widgets/button.h"
#include "gui/color_picker_proxy.h"
#include "widgets/draw.h"
#include "gui/application.h"
#include "libs/lib.h"
#include "libs/lib_api.h"
#include "libs/colorpicker.h"
#include "widgets/collapsible_section.h"
#include "widgets/label.h"
#include "widgets/scroll_wrap.h"
#include "widgets/widget_style.h"
#include "gui/screen_metrics.h"
#include "widgets/togglebutton.h"
+ Include dependency graph for libs/histogram.c:

Go to the source code of this file.

Data Structures

struct  dt_lib_histogram_cache_t
 
struct  dt_lib_histogram_t
 
struct  dt_histogram_pending_module_refresh_t
 
struct  dt_histogram_preview_refresh_state_t
 
struct  dt_histogram_scope_buf_t
 

Macros

#define HISTOGRAM_BINS   256
 
#define GAMMA   1.f / 2.f
 
#define DT_LIB_HISTOGRAM_SCOPE_MIN_VALUE   (1.f / 256.f)
 
#define DT_LIB_HISTOGRAM_SCOPE_ENABLE_SMOOTHING   1
 
#define DT_LIB_HISTOGRAM_SCOPE_SMOOTH_SPATIAL_PASSES   1
 
#define DT_LIB_HISTOGRAM_SCOPE_SMOOTH_TONE_PASSES   4
 
#define DT_LIB_HISTOGRAM_SCOPE_SMOOTH_FORCE   (256 * 0.33)
 
#define DT_LIB_HISTOGRAM_SCOPE_RESTRICTED_LABEL_OPERATOR   CAIRO_OPERATOR_ADD
 
#define DT_LIB_HISTOGRAM_SCOPE_DEFAULT_HEIGHT   250
 
#define DT_LIB_HISTOGRAM_SCOPE_MIN_HEIGHT   120
 
#define DT_LIB_HISTOGRAM_SCOPE_MAX_HEIGHT   500
 
#define DT_LIB_HISTOGRAM_SCOPE_HANDLE_HEIGHT   8
 
#define DT_LIB_HISTOGRAM_SCOPE_HEIGHT_CONF   "plugin/darkroom/histogram/scope_height"
 

Typedefs

typedef enum dt_lib_histogram_scope_type_t dt_lib_histogram_scope_type_t
 
typedef struct dt_lib_histogram_cache_t dt_lib_histogram_cache_t
 
typedef enum dt_lib_colorpicker_model_t dt_lib_colorpicker_model_t
 
typedef struct dt_lib_histogram_t dt_lib_histogram_t
 
typedef struct dt_histogram_pending_module_refresh_t dt_histogram_pending_module_refresh_t
 
typedef struct dt_histogram_preview_refresh_state_t dt_histogram_preview_refresh_state_t
 
typedef struct dt_histogram_scope_buf_t dt_histogram_scope_buf_t
 

Enumerations

enum  dt_lib_histogram_scope_type_t {
  DT_LIB_HISTOGRAM_SCOPE_HISTOGRAM = 0 ,
  DT_LIB_HISTOGRAM_SCOPE_WAVEFORM_HORIZONTAL ,
  DT_LIB_HISTOGRAM_SCOPE_WAVEFORM_VERTICAL ,
  DT_LIB_HISTOGRAM_SCOPE_PARADE_HORIZONTAL ,
  DT_LIB_HISTOGRAM_SCOPE_PARADE_VERTICAL ,
  DT_LIB_HISTOGRAM_SCOPE_VECTORSCOPE ,
  DT_LIB_HISTOGRAM_SCOPE_N
}
 
enum  dt_lib_colorpicker_model_t {
  DT_LIB_COLORPICKER_MODEL_RGB = 0 ,
  DT_LIB_COLORPICKER_MODEL_LAB ,
  DT_LIB_COLORPICKER_MODEL_LCH ,
  DT_LIB_COLORPICKER_MODEL_HSL ,
  DT_LIB_COLORPICKER_MODEL_HSV ,
  DT_LIB_COLORPICKER_MODEL_NONE
}
 

Functions

static void _schedule_histogram_refresh (dt_lib_module_t *self)
 
static void _reset_cache (dt_lib_histogram_t *d)
 
static void _histogram_restart_cache_wait (gpointer user_data)
 
static void _histogram_restart_scope_cache_wait (gpointer user_data)
 Retry a scope render after its source cacheline has been published.
 
static void _clear_pending_preview_histograms (void)
 
static void _refresh_module_histogram (const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *const roi, const dt_iop_colorspace_type_t cst, const float *pixel, dt_iop_module_t *module)
 
static dt_backbuf_t * _get_histogram_backbuf (dt_develop_t *dev, const char *op)
 
static void _clear_histogram_backbuf (dt_backbuf_t *backbuf)
 
static gboolean _refresh_global_histogram_backbuf_for_hash (dt_develop_t *dev, const char *op, const uint64_t expected_hash)
 
static gboolean _refresh_preview_module_histogram_for_hash (dt_develop_t *dev, dt_iop_module_t *module, const uint64_t expected_hash)
 
static void _refresh_preview_histograms (dt_develop_t *dev)
 
static void _preview_history_resync_callback (gpointer instance, gpointer user_data)
 
static void _preview_cacheline_ready_callback (gpointer instance, const guint64 hash, const guint64 producer_node_key, gpointer user_data)
 
const char * name (struct dt_lib_module_t *self)
 
const char ** views (dt_lib_module_t *self)
 
uint32_t container (dt_lib_module_t *self)
 
int expandable (dt_lib_module_t *self)
 
int position ()
 
static void _update_picker_output (dt_lib_module_t *self)
 
static void _update_sample_label (dt_lib_module_t *self, dt_colorpicker_sample_t *sample)
 
static void _update_everything (dt_lib_module_t *self)
 
void _backbuf_int_to_op (const int value, dt_lib_histogram_t *d)
 
int _backbuf_op_to_int (dt_lib_histogram_t *d)
 
void _scope_pixel_to_xyz (const dt_aligned_pixel_t rgb_in, dt_aligned_pixel_t xyz_out, dt_lib_histogram_t *d)
 
void _scope_pixel_to_display_rgb (const dt_aligned_pixel_t rgb_in, dt_aligned_pixel_t rgb_out, dt_lib_histogram_t *d)
 
static void _clear_pending_hashes (dt_lib_histogram_t *d)
 
static gboolean _has_pending_hash (const dt_lib_histogram_t *d, const uint64_t hash)
 
static void _add_pending_hash (dt_lib_histogram_t *d, const uint64_t hash)
 
static gboolean _remove_pending_hash (dt_lib_histogram_t *d, const uint64_t hash)
 
static uint64_t _get_live_histogram_hash (const char *op)
 
static gboolean _histogram_refresh_idle (gpointer user_data)
 
static void _sync_pending_histogram_hashes (dt_lib_module_t *self)
 
static const dt_dev_pixelpipe_iop_t * _get_backbuf_source_piece (const dt_backbuf_t *backbuf, const char *op)
 
static gboolean _is_backbuf_ready (dt_lib_histogram_t *d)
 Check that the selected histogram backbuffer belongs to the current preview graph.
 
static void _redraw_scopes (dt_lib_histogram_t *d)
 
uint32_t _find_max_histogram (const uint32_t *const restrict bins, const size_t binning_size)
 
static void _sample_raw_box_to_image_norm (const dt_colorpicker_sample_t *const sample, float box[4])
 
static void _sample_raw_point_to_image_norm (const dt_colorpicker_sample_t *const sample, float point[2])
 
static void _bin_pixels_histogram_in_roi (const float *const restrict image, uint32_t *const restrict bins, const size_t min_x, const size_t max_x, const size_t min_y, const size_t max_y, const size_t stride)
 
static void _bin_pickers_histogram (const float *const restrict image, const size_t width, const size_t height, uint32_t *bins, dt_colorpicker_sample_t *sample)
 
static gboolean _is_restricted (dt_lib_histogram_t *d)
 
static dt_histogram_scope_buf_t _orient_scope_buf (const void *data, const dt_backbuf_t *backbuf, const char *op)
 
static void _process_histogram (dt_backbuf_t *backbuf, const char *op, cairo_t *cr, const int width, const int height, dt_lib_histogram_t *d)
 
static void _bin_pixels_waveform_in_roi (const float *const restrict image, uint32_t *const restrict bins, const size_t min_x, const size_t max_x, const size_t min_y, const size_t max_y, const size_t source_width, const size_t source_height, const size_t tone_bins, const size_t raster_extent, const gboolean vertical)
 
static void _bin_pickers_waveforms (const float *const restrict image, uint32_t *const restrict bins, const size_t width, const size_t height, const size_t tone_bins, const size_t raster_extent, const gboolean vertical, dt_colorpicker_sample_t *sample)
 
static void _bin_pixels_waveform (const float *const restrict image, uint32_t *const restrict bins, const size_t width, const size_t height, const size_t binning_size, const size_t tone_bins, const size_t raster_extent, const gboolean vertical, const gboolean restricted)
 
static void _create_waveform_image (const uint32_t *const restrict bins, uint8_t *const restrict image, const uint32_t max_hist, const size_t width, const size_t height)
 
static void _paint_waveform (cairo_t *cr, uint8_t *const restrict image, const int width, const int height, const size_t img_width, const size_t img_height, const size_t tone_bins, const gboolean vertical)
 
static float _Luv_to_vectorscope_coord_zoom (const float value, const float zoom)
 
static float _vectorscope_coord_zoom_to_Luv (const float value, const float zoom)
 
static void _bin_pixels_vectorscope_in_roi (const float *const restrict image, uint32_t *const restrict vectorscope, const size_t min_x, const size_t max_x, const size_t min_y, const size_t max_y, const size_t width, const float zoom, dt_lib_histogram_t *d)
 
static void _bin_pickers_vectorscope (const float *const restrict image, uint32_t *const restrict vectorscope, const size_t width, const size_t height, const float zoom, dt_lib_histogram_t *d, const dt_colorpicker_sample_t *const sample)
 
static void _create_vectorscope_image (const uint32_t *const restrict vectorscope, uint8_t *const restrict image, const uint32_t max_hist, const float zoom)
 
static void _bin_vectorscope (const float *const restrict image, uint32_t *const vectorscope, const size_t width, const size_t height, const float zoom, dt_lib_histogram_t *d)
 
static void _process_vectorscope (dt_backbuf_t *backbuf, const char *op, cairo_t *cr, const int width, const int height, const float zoom, dt_lib_histogram_t *d)
 
gboolean _needs_recompute (dt_lib_histogram_t *d, const int width, const int height)
 
static gboolean _draw_callback (GtkWidget *widget, cairo_t *crf, gpointer user_data)
 
void _get_allocation_size (dt_lib_histogram_t *d, int *width, int *height)
 
static void _process_restricted_text (dt_lib_histogram_t *d, cairo_t *cr, const int height)
 Draw the restricted-scope label over the current Cairo surface.
 
gboolean _redraw_surface (dt_lib_histogram_t *d)
 
static void _destroy_surface (dt_lib_histogram_t *d)
 
gboolean _trigger_recompute (dt_lib_histogram_t *d)
 
static gboolean _resolve_backbuf_sampling_source (const char *const op, const dt_backbuf_t *const backbuf, dt_iop_roi_t *const roi, dt_iop_buffer_dsc_t *const dsc, double *const iop_order, int *const direction)
 Resolve the live preview-stage geometry behind one global histogram backbuffer.
 
static void _pixelpipe_pick_from_image (const dt_backbuf_t *const backbuf, dt_colorpicker_sample_t *const sample, dt_lib_histogram_t *d, const char *op)
 
static void _pixelpipe_pick_samples (dt_lib_histogram_t *d)
 
static gboolean _refresh_global_picker (dt_lib_module_t *self)
 
static void _lib_histogram_history_resync_callback (gpointer instance, dt_lib_module_t *self)
 
static void _lib_histogram_cacheline_ready_callback (gpointer instance, const guint64 hash, const guint64 producer_node_key, dt_lib_module_t *self)
 
void view_enter (struct dt_lib_module_t *self, struct dt_view_t *old_view, struct dt_view_t *new_view)
 
void view_leave (struct dt_lib_module_t *self, struct dt_view_t *old_view, struct dt_view_t *new_view)
 
static void _set_stage (dt_lib_module_t *self, int value)
 
static void _set_scope (dt_lib_module_t *self, dt_lib_histogram_scope_type_t scope)
 
static void _resize_callback (GtkWidget *widget, GdkRectangle *allocation, dt_lib_histogram_t *d)
 
static gboolean _area_scrolled_callback (GtkWidget *widget, GdkEventScroll *event, dt_lib_histogram_t *d)
 
static int _scope_resize_handle_get_size (gpointer user_data)
 
static int _scope_resize_handle_resize (int requested_size, gboolean finished, gpointer user_data)
 Apply one vertical size request from the generic Bauhaus resize handle.
 
void _set_params (dt_lib_histogram_t *d)
 
static gboolean _sample_draw_callback (GtkWidget *widget, cairo_t *cr, dt_colorpicker_sample_t *sample)
 
static void _picker_button_toggled (GtkToggleButton *button, dt_lib_histogram_t *d)
 
static void _set_sample_box_area (dt_lib_module_t *self, const dt_boundingbox_t box)
 
static void _set_sample_point (dt_lib_module_t *self, const float pos[2])
 
static gboolean _sample_tooltip_callback (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, const dt_colorpicker_sample_t *sample)
 
static void _statistic_changed (GtkWidget *widget, dt_lib_module_t *self)
 
static void _color_mode_changed (GtkWidget *widget, dt_lib_module_t *self)
 
static void _label_size_allocate_callback (GtkWidget *widget, GdkRectangle *allocation, gpointer user_data)
 
static gboolean _sample_enter_callback (GtkWidget *widget, GdkEvent *event, dt_colorpicker_sample_t *sample)
 
static gboolean _sample_leave_callback (GtkWidget *widget, GdkEvent *event, gpointer data)
 
static void _remove_sample (dt_colorpicker_sample_t *sample)
 
static void _remove_sample_cb (GtkButton *widget, dt_colorpicker_sample_t *sample)
 
static gboolean _live_sample_button (GtkWidget *widget, GdkEventButton *event, dt_colorpicker_sample_t *sample)
 
static void _add_sample (GtkButton *widget, dt_lib_module_t *self)
 
static void _display_samples_changed (GtkToggleButton *button, dt_lib_module_t *self)
 
static void _restrict_histogram_changed (GtkToggleButton *button, dt_lib_module_t *self)
 
void gui_reset (dt_lib_module_t *self)
 
static void _pref_stage_toggled (GtkCheckMenuItem *item, gpointer user_data)
 
static void _pref_display_toggled (GtkCheckMenuItem *item, gpointer user_data)
 
void set_preferences (void *menu, dt_lib_module_t *self)
 
void gui_cleanup (dt_lib_module_t *self)
 

Variables

const gchar * dt_lib_colorpicker_model_names [] = { N_("RGB"), N_("Lab"), N_("LCh"), N_("HSL"), N_("HSV"), N_("none"), NULL }
 
const gchar * dt_lib_colorpicker_statistic_names [] = { N_("mean"), N_("min"), N_("max"), NULL }
 
static dt_histogram_preview_refresh_state_t _preview_refresh_state
 

Macro Definition Documentation

◆ DT_LIB_HISTOGRAM_SCOPE_DEFAULT_HEIGHT

#define DT_LIB_HISTOGRAM_SCOPE_DEFAULT_HEIGHT   250

Definition at line 107 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_ENABLE_SMOOTHING

#define DT_LIB_HISTOGRAM_SCOPE_ENABLE_SMOOTHING   1

Definition at line 102 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_HANDLE_HEIGHT

#define DT_LIB_HISTOGRAM_SCOPE_HANDLE_HEIGHT   8

Definition at line 110 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_HEIGHT_CONF

#define DT_LIB_HISTOGRAM_SCOPE_HEIGHT_CONF   "plugin/darkroom/histogram/scope_height"

Definition at line 111 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_MAX_HEIGHT

#define DT_LIB_HISTOGRAM_SCOPE_MAX_HEIGHT   500

Definition at line 109 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_MIN_HEIGHT

#define DT_LIB_HISTOGRAM_SCOPE_MIN_HEIGHT   120

Definition at line 108 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_MIN_VALUE

#define DT_LIB_HISTOGRAM_SCOPE_MIN_VALUE   (1.f / 256.f)

Definition at line 101 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_RESTRICTED_LABEL_OPERATOR

#define DT_LIB_HISTOGRAM_SCOPE_RESTRICTED_LABEL_OPERATOR   CAIRO_OPERATOR_ADD

Definition at line 106 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_SMOOTH_FORCE

#define DT_LIB_HISTOGRAM_SCOPE_SMOOTH_FORCE   (256 * 0.33)

Definition at line 105 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_SMOOTH_SPATIAL_PASSES

#define DT_LIB_HISTOGRAM_SCOPE_SMOOTH_SPATIAL_PASSES   1

Definition at line 103 of file libs/histogram.c.

◆ DT_LIB_HISTOGRAM_SCOPE_SMOOTH_TONE_PASSES

#define DT_LIB_HISTOGRAM_SCOPE_SMOOTH_TONE_PASSES   4

Definition at line 104 of file libs/histogram.c.

◆ GAMMA

#define GAMMA   1.f / 2.f

Definition at line 100 of file libs/histogram.c.

◆ HISTOGRAM_BINS

#define HISTOGRAM_BINS   256

Definition at line 99 of file libs/histogram.c.

Typedef Documentation

◆ dt_histogram_pending_module_refresh_t

◆ dt_histogram_preview_refresh_state_t

◆ dt_histogram_scope_buf_t

A scope backbuffer, reoriented to match the darkroom view when it comes from a pre-flip pipeline stage. Every scope binning function should read data/width/height from here instead of the raw backbuf/cache pointer – for already-view-oriented stages, or an identity orientation, this is a plain passthrough (no copy, no allocation).

Only "initialscale" (the "Raw image" scope stage) lives upstream of the flip module in iop_order; "colorout" and "gamma" already sit downstream of it, i.e. already in the same orientation the darkroom view shows – so those are always a passthrough regardless of the image's own orientation.

◆ dt_lib_colorpicker_model_t

◆ dt_lib_histogram_cache_t

◆ dt_lib_histogram_scope_type_t

◆ dt_lib_histogram_t

Enumeration Type Documentation

◆ dt_lib_colorpicker_model_t

Enumerator
DT_LIB_COLORPICKER_MODEL_RGB 
DT_LIB_COLORPICKER_MODEL_LAB 
DT_LIB_COLORPICKER_MODEL_LCH 
DT_LIB_COLORPICKER_MODEL_HSL 
DT_LIB_COLORPICKER_MODEL_HSV 
DT_LIB_COLORPICKER_MODEL_NONE 

Definition at line 137 of file libs/histogram.c.

◆ dt_lib_histogram_scope_type_t

Enumerator
DT_LIB_HISTOGRAM_SCOPE_HISTOGRAM 
DT_LIB_HISTOGRAM_SCOPE_WAVEFORM_HORIZONTAL 
DT_LIB_HISTOGRAM_SCOPE_WAVEFORM_VERTICAL 
DT_LIB_HISTOGRAM_SCOPE_PARADE_HORIZONTAL 
DT_LIB_HISTOGRAM_SCOPE_PARADE_VERTICAL 
DT_LIB_HISTOGRAM_SCOPE_VECTORSCOPE 
DT_LIB_HISTOGRAM_SCOPE_N 

Definition at line 115 of file libs/histogram.c.

Function Documentation

◆ _add_pending_hash()

static void _add_pending_hash ( dt_lib_histogram_t *  d,
const uint64_t  hash 
)
static

◆ _add_sample()

◆ _area_scrolled_callback()

static gboolean _area_scrolled_callback ( GtkWidget *  widget,
GdkEventScroll *  event,
dt_lib_histogram_t *  d 
)
static

◆ _backbuf_int_to_op()

void _backbuf_int_to_op ( const int  value,
dt_lib_histogram_t *  d 
)

Definition at line 673 of file libs/histogram.c.

References d, and value.

Referenced by _set_stage().

◆ _backbuf_op_to_int()

int _backbuf_op_to_int ( dt_lib_histogram_t *  d)

Definition at line 695 of file libs/histogram.c.

References d, and L.

Referenced by _scope_pixel_to_display_rgb(), _scope_pixel_to_xyz(), and set_preferences().

◆ _bin_pickers_histogram()

static void _bin_pickers_histogram ( const float *const restrict  image,
const size_t  width,
const size_t  height,
uint32_t *  bins,
dt_colorpicker_sample_t *  sample 
)
inlinestatic

◆ _bin_pickers_vectorscope()

static void _bin_pickers_vectorscope ( const float *const restrict  image,
uint32_t *const restrict  vectorscope,
const size_t  width,
const size_t  height,
const float  zoom,
dt_lib_histogram_t *  d,
const dt_colorpicker_sample_t *const  sample 
)
inlinestatic

◆ _bin_pickers_waveforms()

static void _bin_pickers_waveforms ( const float *const restrict  image,
uint32_t *const restrict  bins,
const size_t  width,
const size_t  height,
const size_t  tone_bins,
const size_t  raster_extent,
const gboolean  vertical,
dt_colorpicker_sample_t *  sample 
)
inlinestatic

◆ _bin_pixels_histogram_in_roi()

static void _bin_pixels_histogram_in_roi ( const float *const restrict  image,
uint32_t *const restrict  bins,
const size_t  min_x,
const size_t  max_x,
const size_t  min_y,
const size_t  max_y,
const size_t  stride 
)
inlinestatic

Definition at line 917 of file libs/histogram.c.

References __OMP_PARALLEL_FOR__, HISTOGRAM_BINS, i, L, and value.

Referenced by _bin_pickers_histogram(), and _process_histogram().

◆ _bin_pixels_vectorscope_in_roi()

static void _bin_pixels_vectorscope_in_roi ( const float *const restrict  image,
uint32_t *const restrict  vectorscope,
const size_t  min_x,
const size_t  max_x,
const size_t  min_y,
const size_t  max_y,
const size_t  width,
const float  zoom,
dt_lib_histogram_t *  d 
)
static

◆ _bin_pixels_waveform()

static void _bin_pixels_waveform ( const float *const restrict  image,
uint32_t *const restrict  bins,
const size_t  width,
const size_t  height,
const size_t  binning_size,
const size_t  tone_bins,
const size_t  raster_extent,
const gboolean  vertical,
const gboolean  restricted 
)
inlinestatic

◆ _bin_pixels_waveform_in_roi()

static void _bin_pixels_waveform_in_roi ( const float *const restrict  image,
uint32_t *const restrict  bins,
const size_t  min_x,
const size_t  max_x,
const size_t  min_y,
const size_t  max_y,
const size_t  source_width,
const size_t  source_height,
const size_t  tone_bins,
const size_t  raster_extent,
const gboolean  vertical 
)
inlinestatic

Definition at line 1119 of file libs/histogram.c.

References __OMP_PARALLEL_FOR__, CLAMPF, double(), i, L, MAX, MIN, value, and weight().

Referenced by _bin_pickers_waveforms(), and _bin_pixels_waveform().

◆ _bin_vectorscope()

◆ _clear_histogram_backbuf()

◆ _clear_pending_hashes()

static void _clear_pending_hashes ( dt_lib_histogram_t *  d)
static

Definition at line 762 of file libs/histogram.c.

References d, IS_NULL_PTR, and L.

Referenced by _sync_pending_histogram_hashes(), gui_cleanup(), and view_leave().

◆ _clear_pending_preview_histograms()

◆ _color_mode_changed()

static void _color_mode_changed ( GtkWidget *  widget,
dt_lib_module_t *  self 
)
static

◆ _create_vectorscope_image()

◆ _create_waveform_image()

static void _create_waveform_image ( const uint32_t *const restrict  bins,
uint8_t *const restrict  image,
const uint32_t  max_hist,
const size_t  width,
const size_t  height 
)
static

Definition at line 1259 of file libs/histogram.c.

References __OMP_FOR_SIMD__, GAMMA, height, k, L, and width.

◆ _destroy_surface()

static void _destroy_surface ( dt_lib_histogram_t *  d)
static

Definition at line 2140 of file libs/histogram.c.

References d, and L.

Referenced by _trigger_recompute(), gui_cleanup(), and gui_reset().

◆ _display_samples_changed()

static void _display_samples_changed ( GtkToggleButton *  button,
dt_lib_module_t *  self 
)
static

◆ _draw_callback()

static gboolean _draw_callback ( GtkWidget *  widget,
cairo_t *  crf,
gpointer  user_data 
)
static

Definition at line 1998 of file libs/histogram.c.

References d, IS_NULL_PTR, and L.

◆ _find_max_histogram()

uint32_t _find_max_histogram ( const uint32_t *const restrict  bins,
const size_t  binning_size 
)

Definition at line 890 of file libs/histogram.c.

References __OMP_PARALLEL_FOR_SIMD__, k, L, and max.

Referenced by _process_histogram(), and _process_vectorscope().

◆ _get_allocation_size()

void _get_allocation_size ( dt_lib_histogram_t *  d,
int *  width,
int *  height 
)

Definition at line 2010 of file libs/histogram.c.

References d, height, L, and width.

Referenced by _redraw_surface(), and _trigger_recompute().

◆ _get_backbuf_source_piece()

◆ _get_histogram_backbuf()

◆ _get_live_histogram_hash()

◆ _has_pending_hash()

static gboolean _has_pending_hash ( const dt_lib_histogram_t *  d,
const uint64_t  hash 
)
static

Definition at line 768 of file libs/histogram.c.

References d, DT_PIXELPIPE_CACHE_HASH_INVALID, FALSE, hash, i, IS_NULL_PTR, L, and TRUE.

Referenced by _add_pending_hash().

◆ _histogram_refresh_idle()

static gboolean _histogram_refresh_idle ( gpointer  user_data)
static

◆ _histogram_restart_cache_wait()

static void _histogram_restart_cache_wait ( gpointer  user_data)
static

◆ _histogram_restart_scope_cache_wait()

static void _histogram_restart_scope_cache_wait ( gpointer  user_data)
static

Retry a scope render after its source cacheline has been published.

The first render attempt stores the current backbuffer hash in the Cairo cache before the non-blocking GUI cache probe can report a miss. Invalidate that rendered-state cache here so the wait-manager wake-up retries pixel binning instead of treating the incomplete surface as current.

Definition at line 221 of file libs/histogram.c.

References _reset_cache(), _schedule_histogram_refresh(), d, dt_lib_module_t::data, IS_NULL_PTR, and L.

Referenced by _process_histogram(), and _process_vectorscope().

◆ _is_backbuf_ready()

static gboolean _is_backbuf_ready ( dt_lib_histogram_t *  d)
static

Check that the selected histogram backbuffer belongs to the current preview graph.

Global histogram stages are independent published cachelines. Their CACHELINE_READY signal is raised while the preview pipeline is still processing, before its final backbuffer becomes valid. Requiring that final backbuffer here would discard the only refresh scheduled for the newly published histogram stage after a module parameter change.

Matching the stage hash against the current piece is sufficient: the histogram backbuffer owns its cache reference, and the piece hash proves that its pixels and geometry belong to the synchronized preview graph.

Definition at line 878 of file libs/histogram.c.

References _get_backbuf_source_piece(), d, FALSE, and IS_NULL_PTR.

Referenced by _area_scrolled_callback(), _refresh_global_picker(), and _trigger_recompute().

◆ _is_restricted()

static gboolean _is_restricted ( dt_lib_histogram_t *  d)
static

Definition at line 969 of file libs/histogram.c.

References d, FALSE, IS_NULL_PTR, and L.

Referenced by _bin_vectorscope(), _process_histogram(), and _process_restricted_text().

◆ _label_size_allocate_callback()

static void _label_size_allocate_callback ( GtkWidget *  widget,
GdkRectangle *  allocation,
gpointer  user_data 
)
static

Definition at line 2773 of file libs/histogram.c.

References L.

Referenced by _add_sample().

◆ _lib_histogram_cacheline_ready_callback()

static void _lib_histogram_cacheline_ready_callback ( gpointer  instance,
const guint64  hash,
const guint64  producer_node_key,
dt_lib_module_t *  self 
)
static

◆ _lib_histogram_history_resync_callback()

static void _lib_histogram_history_resync_callback ( gpointer  instance,
dt_lib_module_t *  self 
)
static

Definition at line 2421 of file libs/histogram.c.

References _sync_pending_histogram_hashes(), and void().

Referenced by view_enter(), and view_leave().

◆ _live_sample_button()

◆ _Luv_to_vectorscope_coord_zoom()

static float _Luv_to_vectorscope_coord_zoom ( const float  value,
const float  zoom 
)
static

Definition at line 1667 of file libs/histogram.c.

References HISTOGRAM_BINS, and value.

Referenced by _bin_pixels_vectorscope_in_roi(), and _process_vectorscope().

◆ _needs_recompute()

gboolean _needs_recompute ( dt_lib_histogram_t *  d,
const int  width,
const int  height 
)

Definition at line 1985 of file libs/histogram.c.

References d, dt_dev_backbuf_get_hash(), height, IS_NULL_PTR, L, view, and width.

Referenced by _trigger_recompute().

◆ _orient_scope_buf()

◆ _paint_waveform()

static void _paint_waveform ( cairo_t *  cr,
uint8_t *const restrict  image,
const int  width,
const int  height,
const size_t  img_width,
const size_t  img_height,
const size_t  tone_bins,
const gboolean  vertical 
)
static

Definition at line 1275 of file libs/histogram.c.

References double(), height, L, and width.

◆ _picker_button_toggled()

static void _picker_button_toggled ( GtkToggleButton *  button,
dt_lib_histogram_t *  d 
)
static

Definition at line 2671 of file libs/histogram.c.

References _redraw_scopes(), _reset_cache(), _trigger_recompute(), d, IS_NULL_PTR, and L.

◆ _pixelpipe_pick_from_image()

◆ _pixelpipe_pick_samples()

◆ _pref_display_toggled()

static void _pref_display_toggled ( GtkCheckMenuItem *  item,
gpointer  user_data 
)
static

Definition at line 3013 of file libs/histogram.c.

References _set_scope(), and L.

Referenced by set_preferences().

◆ _pref_stage_toggled()

static void _pref_stage_toggled ( GtkCheckMenuItem *  item,
gpointer  user_data 
)
static

Definition at line 3006 of file libs/histogram.c.

References _set_stage(), and L.

Referenced by set_preferences().

◆ _preview_cacheline_ready_callback()

◆ _preview_history_resync_callback()

static void _preview_history_resync_callback ( gpointer  instance,
gpointer  user_data 
)
static

Definition at line 593 of file libs/histogram.c.

References _refresh_preview_histograms(), dt_dev_get_global(), and void().

Referenced by view_enter(), and view_leave().

◆ _process_histogram()

◆ _process_restricted_text()

static void _process_restricted_text ( dt_lib_histogram_t *  d,
cairo_t *  cr,
const int  height 
)
static

Draw the restricted-scope label over the current Cairo surface.

The scope content is rendered first because the label describes the final visible state. The theme owns the text color through graph_scope_restricted, while the module keeps the Cairo operator explicit because it controls how the label is composited with the already-rendered graph pixels.

Definition at line 2041 of file libs/histogram.c.

References _is_restricted(), d, dt_bauhaus_get_global(), DT_LIB_HISTOGRAM_SCOPE_RESTRICTED_LABEL_OPERATOR, DT_PIXEL_APPLY_DPI, height, L, MAX, and set_color().

Referenced by _redraw_surface().

◆ _process_vectorscope()

◆ _redraw_scopes()

static void _redraw_scopes ( dt_lib_histogram_t *  d)
static

Definition at line 885 of file libs/histogram.c.

References d, and L.

Referenced by _area_scrolled_callback(), _picker_button_toggled(), _set_scope(), and _update_everything().

◆ _redraw_surface()

◆ _refresh_global_histogram_backbuf_for_hash()

◆ _refresh_global_picker()

◆ _refresh_module_histogram()

◆ _refresh_preview_histograms()

◆ _refresh_preview_module_histogram_for_hash()

◆ _remove_pending_hash()

static gboolean _remove_pending_hash ( dt_lib_histogram_t *  d,
const uint64_t  hash 
)
static

◆ _remove_sample()

◆ _remove_sample_cb()

◆ _reset_cache()

◆ _resize_callback()

static void _resize_callback ( GtkWidget *  widget,
GdkRectangle *  allocation,
dt_lib_histogram_t *  d 
)
static

Definition at line 2503 of file libs/histogram.c.

References _reset_cache(), _trigger_recompute(), and d.

◆ _resolve_backbuf_sampling_source()

static gboolean _resolve_backbuf_sampling_source ( const char *const  op,
const dt_backbuf_t *const  backbuf,
dt_iop_roi_t *const  roi,
dt_iop_buffer_dsc_t *const  dsc,
double *const  iop_order,
int *const  direction 
)
static

Resolve the live preview-stage geometry behind one global histogram backbuffer.

The global histogram stores only the published cache hash, width, and height. For color-picker sampling we also need the live ROI, colorspace, and backtransform cut in the current preview graph so the picker point drawn on the final image is mapped back to the selected histogram stage before sampling pixels.

We reopen the stage by operation name because the current preview graph is authoritative once the preview run completed. The published backbuffer hash must still match that live graph, otherwise we are looking at stale geometry and should not trust it.

Parameters
opHistogram stage operation name.
backbufPublished histogram backbuffer for op.
roiOutput ROI of the sampled stage buffer.
dscBuffer descriptor of the sampled stage buffer.
iop_orderIOP order at which to stop the backtransform.
directionInclusive/exclusive transform cut matching the sampled stage buffer.
Returns
TRUE when the live preview graph still matches the published backbuffer, FALSE otherwise.

Definition at line 2207 of file libs/histogram.c.

References dt_dev_backbuf_get_hash(), dt_dev_get_global(), dt_dev_pixelpipe_get_module_piece(), dt_dev_pixelpipe_get_prev_enabled_piece(), DT_DEV_TRANSFORM_DIR_FORW_EXCL, DT_DEV_TRANSFORM_DIR_FORW_INCL, FALSE, hash, IS_NULL_PTR, L, piece, pipe, and dt_develop_t::preview_pipe.

Referenced by _pixelpipe_pick_from_image().

◆ _restrict_histogram_changed()

static void _restrict_histogram_changed ( GtkToggleButton *  button,
dt_lib_module_t *  self 
)
static

◆ _sample_draw_callback()

static gboolean _sample_draw_callback ( GtkWidget *  widget,
cairo_t *  cr,
dt_colorpicker_sample_t *  sample 
)
static

◆ _sample_enter_callback()

static gboolean _sample_enter_callback ( GtkWidget *  widget,
GdkEvent *  event,
dt_colorpicker_sample_t *  sample 
)
static

◆ _sample_leave_callback()

static gboolean _sample_leave_callback ( GtkWidget *  widget,
GdkEvent *  event,
gpointer  data 
)
static

◆ _sample_raw_box_to_image_norm()

◆ _sample_raw_point_to_image_norm()

◆ _sample_tooltip_callback()

◆ _schedule_histogram_refresh()

◆ _scope_pixel_to_display_rgb()

◆ _scope_pixel_to_xyz()

◆ _scope_resize_handle_get_size()

static int _scope_resize_handle_get_size ( gpointer  user_data)
static

Definition at line 2532 of file libs/histogram.c.

References d, and L.

◆ _scope_resize_handle_resize()

static int _scope_resize_handle_resize ( int  requested_size,
gboolean  finished,
gpointer  user_data 
)
static

Apply one vertical size request from the generic Bauhaus resize handle.

The Bauhaus widget owns pointer tracking and sends requested heights here. The histogram owns the scope widget, the window-relative clamp, and persistence, so these side effects remain explicit in the module that owns the resized surface.

Definition at line 2545 of file libs/histogram.c.

References d, dt_conf_set_int(), dt_gui_main_window(), DT_LIB_HISTOGRAM_SCOPE_HEIGHT_CONF, DT_LIB_HISTOGRAM_SCOPE_MAX_HEIGHT, DT_LIB_HISTOGRAM_SCOPE_MIN_HEIGHT, DT_PIXEL_APPLY_DPI, L, MAX, and MIN.

◆ _set_params()

◆ _set_sample_box_area()

◆ _set_sample_point()

static void _set_sample_point ( dt_lib_module_t *  self,
const float  pos[2] 
)
static

◆ _set_scope()

static void _set_scope ( dt_lib_module_t *  self,
dt_lib_histogram_scope_type_t  scope 
)
static

◆ _set_stage()

◆ _statistic_changed()

◆ _sync_pending_histogram_hashes()

◆ _trigger_recompute()

◆ _update_everything()

◆ _update_picker_output()

static void _update_picker_output ( dt_lib_module_t *  self)
static

Definition at line 2666 of file libs/histogram.c.

References _update_everything().

Referenced by gui_reset().

◆ _update_sample_label()

◆ _vectorscope_coord_zoom_to_Luv()

static float _vectorscope_coord_zoom_to_Luv ( const float  value,
const float  zoom 
)
static

Definition at line 1674 of file libs/histogram.c.

References HISTOGRAM_BINS, and value.

Referenced by _create_vectorscope_image().

◆ container()

uint32_t container ( dt_lib_module_t *  self)

Definition at line 653 of file libs/histogram.c.

References DT_UI_CONTAINER_PANEL_LEFT_CENTER.

Referenced by _add_sample().

◆ expandable()

int expandable ( dt_lib_module_t *  self)

Definition at line 658 of file libs/histogram.c.

◆ gui_cleanup()

◆ gui_reset()

◆ name()

const char * name ( struct dt_lib_module_t *  self)

Definition at line 642 of file libs/histogram.c.

References L.

◆ position()

int position ( )

Definition at line 663 of file libs/histogram.c.

◆ set_preferences()

◆ view_enter()

◆ view_leave()

◆ views()

const char ** views ( dt_lib_module_t *  self)

Definition at line 647 of file libs/histogram.c.

References L, and v.

Variable Documentation

◆ _preview_refresh_state

◆ dt_lib_colorpicker_model_names

const gchar* dt_lib_colorpicker_model_names[] = { N_("RGB"), N_("Lab"), N_("LCh"), N_("HSL"), N_("HSV"), N_("none"), NULL }

Definition at line 147 of file libs/histogram.c.

Referenced by _color_mode_changed().

◆ dt_lib_colorpicker_statistic_names

const gchar* dt_lib_colorpicker_statistic_names[] = { N_("mean"), N_("min"), N_("max"), NULL }

Definition at line 149 of file libs/histogram.c.

Referenced by _sample_tooltip_callback(), and _statistic_changed().