Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
group.c File Reference
+ Include dependency graph for group.c:

Go to the source code of this file.

Functions

static dt_masks_form_t_group_get_child_at (dt_develop_t *dev, dt_masks_form_t *form, const int group_index, dt_masks_form_group_t **group_entry)
 
static dt_masks_form_t_group_get_selected_child (dt_masks_form_t *form, dt_masks_form_gui_t *gui, dt_masks_form_group_t **group_entry)
 
static int _group_events_mouse_scrolled (struct dt_iop_module_t *module, double x, double y, int up, const int flow, uint32_t state, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused, dt_masks_interaction_t interaction)
 
static gboolean _group_events_button_pressed (struct dt_iop_module_t *module, double x, double y, double pressure, int which, int type, uint32_t state, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused2)
 
static int _group_events_button_released (struct dt_iop_module_t *module, double x, double y, int which, uint32_t state, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused2)
 
static int _group_events_key_pressed (struct dt_iop_module_t *module, GdkEventKey *event, dt_masks_form_t *form, int parentid, dt_masks_form_gui_t *gui, int index)
 
static int _group_events_mouse_moved (struct dt_iop_module_t *module, double x, double y, double pressure, int which, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused2)
 
static void _group_events_post_expose_draw (cairo_t *cr, float zoom_scale, dt_masks_form_t *form, dt_masks_form_gui_t *gui, int pos)
 
void dt_group_events_post_expose_except (cairo_t *cr, float zoom_scale, dt_masks_form_t *form, dt_masks_form_gui_t *gui, const int except_pos)
 
void dt_group_events_post_expose_only (cairo_t *cr, float zoom_scale, dt_masks_form_t *form, dt_masks_form_gui_t *gui, const int pos)
 
void dt_group_events_post_expose (cairo_t *cr, float zoom_scale, dt_masks_form_t *form, dt_masks_form_gui_t *gui)
 
static int _inverse_mask (const dt_iop_module_t *const module, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const form, float **buffer, int *width, int *height, int *posx, int *posy)
 
static dt_masks_raster_result_t _group_get_mask (const dt_iop_module_t *const module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const form, float **buffer, int *width, int *height, int *posx, int *posy)
 
static void _combine_masks_union (float *const restrict dest, float *const restrict newmask, const size_t npixels, const float opacity, const int inverted)
 
static void _combine_masks_union_box (float *const restrict dest, const float *const restrict newmask, const int width, const dt_iop_roi_t *const box, const float opacity)
 
static void _combine_masks_intersect (float *const restrict dest, float *const restrict newmask, const size_t npixels, const float opacity, const int inverted)
 
static int both_positive (const float val1, const float val2)
 
static void _combine_masks_difference (float *const restrict dest, float *const restrict newmask, const size_t npixels, const float opacity, const int inverted)
 
static void _combine_masks_exclusion (float *const restrict dest, float *const restrict newmask, const size_t npixels, const float opacity, const int inverted)
 
static uint64_t _group_prefix_hash (const dt_masks_form_t *const form, GList *masks, const dt_dev_pixelpipe_iop_t *const piece, const dt_iop_roi_t *const roi, const int count)
 Identity of the group mask after folding the first count shapes, at this ROI.
 
static dt_masks_raster_result_t _group_get_mask_roi (const dt_iop_module_t *const restrict module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const restrict piece, dt_masks_form_t *const form, const dt_iop_roi_t *const roi, float *const restrict buffer, dt_iop_roi_t *touched)
 
dt_masks_raster_result_t dt_masks_group_render_roi (dt_iop_module_t *module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, dt_masks_form_t *form, const dt_iop_roi_t *roi, float *buffer)
 
static void _group_duplicate_points (dt_develop_t *const dev, dt_masks_form_t *const base, dt_masks_form_t *const dest)
 
static gboolean _group_get_gravity_center (dt_develop_t *dev, const dt_masks_form_t *form, float center[2], float *area)
 

Variables

const dt_masks_functions_t dt_masks_functions_group
 

Function Documentation

◆ _combine_masks_difference()

static void _combine_masks_difference ( float *const restrict  dest,
float *const restrict  newmask,
const size_t  npixels,
const float  opacity,
const int  inverted 
)
static

Definition at line 593 of file group.c.

References __OMP_FOR_SIMD__, and both_positive().

Referenced by _group_get_mask_roi().

◆ _combine_masks_exclusion()

static void _combine_masks_exclusion ( float *const restrict  dest,
float *const restrict  newmask,
const size_t  npixels,
const float  opacity,
const int  inverted 
)
static

Definition at line 617 of file group.c.

References __OMP_FOR_SIMD__, both_positive(), and MAX.

Referenced by _group_get_mask_roi().

◆ _combine_masks_intersect()

static void _combine_masks_intersect ( float *const restrict  dest,
float *const restrict  newmask,
const size_t  npixels,
const float  opacity,
const int  inverted 
)
static

Definition at line 563 of file group.c.

References __OMP_FOR_SIMD__, MAX, and MIN.

Referenced by _group_get_mask_roi().

◆ _combine_masks_union()

static void _combine_masks_union ( float *const restrict  dest,
float *const restrict  newmask,
const size_t  npixels,
const float  opacity,
const int  inverted 
)
static

Definition at line 524 of file group.c.

References __OMP_FOR_SIMD__, and MAX.

Referenced by _group_get_mask_roi().

◆ _combine_masks_union_box()

static void _combine_masks_union_box ( float *const restrict  dest,
const float *const restrict  newmask,
const int  width,
const dt_iop_roi_t *const  box,
const float  opacity 
)
static

Union bounded to ‘box’ (buffer-relative): outside it the child is zero and max(dest, 0) is dest.

Definition at line 548 of file group.c.

References dt_iop_roi_t::height, MAX, width, dt_iop_roi_t::width, x, dt_iop_roi_t::x, and dt_iop_roi_t::y.

Referenced by _group_get_mask_roi().

◆ _group_duplicate_points()

◆ _group_events_button_pressed()

static gboolean _group_events_button_pressed ( struct dt_iop_module_t module,
double  x,
double  y,
double  pressure,
int  which,
int  type,
uint32_t  state,
dt_masks_form_t form,
int  unused1,
dt_masks_form_gui_t gui,
int  unused2 
)
static

Definition at line 76 of file group.c.

References FALSE.

◆ _group_events_button_released()

static int _group_events_button_released ( struct dt_iop_module_t module,
double  x,
double  y,
int  which,
uint32_t  state,
dt_masks_form_t form,
int  unused1,
dt_masks_form_gui_t gui,
int  unused2 
)
static

Definition at line 83 of file group.c.

◆ _group_events_key_pressed()

static int _group_events_key_pressed ( struct dt_iop_module_t module,
GdkEventKey *  event,
dt_masks_form_t form,
int  parentid,
dt_masks_form_gui_t gui,
int  index 
)
static

◆ _group_events_mouse_moved()

static int _group_events_mouse_moved ( struct dt_iop_module_t module,
double  x,
double  y,
double  pressure,
int  which,
dt_masks_form_t form,
int  unused1,
dt_masks_form_gui_t gui,
int  unused2 
)
static

Definition at line 125 of file group.c.

◆ _group_events_mouse_scrolled()

static int _group_events_mouse_scrolled ( struct dt_iop_module_t module,
double  x,
double  y,
int  up,
const int  flow,
uint32_t  state,
dt_masks_form_t form,
int  unused1,
dt_masks_form_gui_t gui,
int  unused,
dt_masks_interaction_t  interaction 
)
static

Definition at line 69 of file group.c.

◆ _group_events_post_expose_draw()

◆ _group_get_child_at()

static dt_masks_form_t * _group_get_child_at ( dt_develop_t dev,
dt_masks_form_t form,
const int  group_index,
dt_masks_form_group_t **  group_entry 
)
static

◆ _group_get_gravity_center()

static gboolean _group_get_gravity_center ( dt_develop_t dev,
const dt_masks_form_t form,
float  center[2],
float *  area 
)
static

◆ _group_get_mask()

◆ _group_get_mask_roi()

static dt_masks_raster_result_t _group_get_mask_roi ( const dt_iop_module_t *const restrict  module,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t *const restrict  piece,
dt_masks_form_t *const  form,
const dt_iop_roi_t *const  roi,
float *const restrict  buffer,
dt_iop_roi_t touched 
)
static

◆ _group_get_selected_child()

static dt_masks_form_t * _group_get_selected_child ( dt_masks_form_t form,
dt_masks_form_gui_t gui,
dt_masks_form_group_t **  group_entry 
)
static

◆ _group_prefix_hash()

static uint64_t _group_prefix_hash ( const dt_masks_form_t *const  form,
GList *  masks,
const dt_dev_pixelpipe_iop_t *const  piece,
const dt_iop_roi_t *const  roi,
const int  count 
)
static

Identity of the group mask after folding the first count shapes, at this ROI.

The fold below is a left fold: the result after k shapes is a pure function of the result after k-1 and of shape k. So every PREFIX of it is a cacheable value, and the one that matters is the longest one: drawing a new stroke appends a shape and leaves every earlier prefix untouched.

What has to be in the key is everything the fold reads:

  • each shape's own content, via dt_masks_form_get_own_hash() – for a brush that is every node's position, border, fading and density, which is exactly what its rasterisation is a function of;
  • each membership's state and opacity, which decide the combine operator and its weight;
  • the ROI, which decides the pixels;
  • the module's own input and output rects, which is how a geometry change upstream (a crop moved, a keystone) reaches the rasterisation without changing any form. Deliberately NOT the pipe's history hash: that changes on every commit, including the stroke being drawn, which would make the cache miss exactly when it is worth having.

Definition at line 667 of file group.c.

References dt_dev_pixelpipe_iop_t::buf_in, dt_dev_pixelpipe_iop_t::buf_out, dt_hash(), dt_masks_form_get_own_hash(), dt_masks_get_from_id_ext(), dt_masks_form_group_t::formid, i, IS_NULL_PTR, dt_masks_form_group_t::opacity, dt_masks_form_t::points, and dt_masks_form_group_t::state.

Referenced by _group_get_mask_roi().

◆ _inverse_mask()

static int _inverse_mask ( const dt_iop_module_t *const  module,
const dt_dev_pixelpipe_iop_t *const  piece,
dt_masks_form_t *const  form,
float **  buffer,
int *  width,
int *  height,
int *  posx,
int *  posy 
)
static

◆ both_positive()

static int both_positive ( const float  val1,
const float  val2 
)
inlinestatic

Definition at line 587 of file group.c.

Referenced by _combine_masks_difference(), and _combine_masks_exclusion().

◆ dt_group_events_post_expose()

void dt_group_events_post_expose ( cairo_t *  cr,
float  zoom_scale,
dt_masks_form_t form,
dt_masks_form_gui_t gui 
)

◆ dt_group_events_post_expose_except()

void dt_group_events_post_expose_except ( cairo_t *  cr,
float  zoom_scale,
dt_masks_form_t form,
dt_masks_form_gui_t gui,
int  except_pos 
)

Draw every member of form but the one at except_pos, in the group's order.

Definition at line 164 of file group.c.

References _group_events_post_expose_draw(), and dt_masks_form_t::points.

Referenced by _static_layer_ensure().

◆ dt_group_events_post_expose_only()

void dt_group_events_post_expose_only ( cairo_t *  cr,
float  zoom_scale,
dt_masks_form_t form,
dt_masks_form_gui_t gui,
int  pos 
)

Draw the member of form at pos alone; nothing for a position the group has not.

Definition at line 172 of file group.c.

References _group_events_post_expose_draw(), and dt_masks_form_t::points.

Referenced by _overlay_draw_form().

◆ dt_masks_group_render_roi()

dt_masks_raster_result_t dt_masks_group_render_roi ( dt_iop_module_t module,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
dt_masks_form_t form,
const dt_iop_roi_t roi,
float *  buffer 
)

Rasterise form into the pre-zeroed ROI-sized buffer. touched (may be NULL) receives the buffer-relative rectangle enclosing every pixel written; empty when nothing was.

Definition at line 938 of file group.c.

References DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_get_debug_flags(), dt_get_wtime(), dt_masks_get_mask_roi(), DT_MASKS_RASTER_EMPTY, dt_print(), and IS_NULL_PTR.

Referenced by _develop_blend_init_drawn_mask().

Variable Documentation

◆ dt_masks_functions_group

const dt_masks_functions_t dt_masks_functions_group
Initial value:
= {
.point_struct_size = sizeof(struct dt_masks_form_group_t),
.sanitize_config = NULL,
.set_form_name = NULL,
.set_hint_message = NULL,
.duplicate_points = _group_duplicate_points,
.initial_source_pos = NULL,
.get_distance = NULL,
.get_points = NULL,
.get_points_border = NULL,
.get_mask = _group_get_mask,
.get_mask_roi = _group_get_mask_roi,
.get_area = NULL,
.get_source_area = NULL,
.get_gravity_center = _group_get_gravity_center,
.get_interaction_value = NULL,
.set_interaction_value = NULL,
.update_hover = NULL,
.mouse_moved = _group_events_mouse_moved,
.mouse_scrolled = _group_events_mouse_scrolled,
.button_pressed = _group_events_button_pressed,
.button_released = _group_events_button_released,
.key_pressed = _group_events_key_pressed,
.draw_shape = NULL
}
static int _group_events_mouse_moved(struct dt_iop_module_t *module, double x, double y, double pressure, int which, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused2)
Definition group.c:125
static dt_masks_raster_result_t _group_get_mask(const dt_iop_module_t *const module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, dt_masks_form_t *const form, float **buffer, int *width, int *height, int *posx, int *posy)
Definition group.c:250
static int _group_events_key_pressed(struct dt_iop_module_t *module, GdkEventKey *event, dt_masks_form_t *form, int parentid, dt_masks_form_gui_t *gui, int index)
Definition group.c:90
static int _group_events_button_released(struct dt_iop_module_t *module, double x, double y, int which, uint32_t state, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused2)
Definition group.c:83
static void _group_duplicate_points(dt_develop_t *const dev, dt_masks_form_t *const base, dt_masks_form_t *const dest)
Definition group.c:952
static gboolean _group_events_button_pressed(struct dt_iop_module_t *module, double x, double y, double pressure, int which, int type, uint32_t state, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused2)
Definition group.c:76
static gboolean _group_get_gravity_center(dt_develop_t *dev, const dt_masks_form_t *form, float center[2], float *area)
Definition group.c:968
static dt_masks_raster_result_t _group_get_mask_roi(const dt_iop_module_t *const restrict module, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const restrict piece, dt_masks_form_t *const form, const dt_iop_roi_t *const roi, float *const restrict buffer, dt_iop_roi_t *touched)
Definition group.c:693
static int _group_events_mouse_scrolled(struct dt_iop_module_t *module, double x, double y, int up, const int flow, uint32_t state, dt_masks_form_t *form, int unused1, dt_masks_form_gui_t *gui, int unused, dt_masks_interaction_t interaction)
Definition group.c:69

Definition at line 1020 of file group.c.

Referenced by _write_fixture_init(), and dt_masks_create().