![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
The per-shape function table, private to the masks implementation. More...
Include dependency graph for masks_functions.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | dt_masks_functions_t |
| struct | dt_masks_sample_grid_t |
Macros | |
| #define | DT_MASKS_OUTLINE_TILT_MAX 1.0f |
| #define | DT_MASKS_GRID_MAX_STEP 8 |
Typedefs | |
| typedef struct dt_masks_functions_t | dt_masks_functions_t |
| typedef struct dt_masks_sample_grid_t | dt_masks_sample_grid_t |
The per-shape function table, private to the masks implementation.
Every member is dispatched from inside src/develop/masks/ and nowhere else (measured before the move), so nothing outside the shape files and the masks core has any business seeing the table's layout. Public code holds it only as the opaque dt_masks_form_t.functions pointer, forward-declared in develop/masks.h. Keeping the definition here is also what keeps drawing and event types out of the public header: several members take dt_masks_form_gui_t* or a shape_draw_function_t.
Definition in file masks_functions.h.
| #define DT_MASKS_GRID_MAX_STEP 8 |
Largest cell spacing any caller of the sample-grid helpers may ask for.
The ROI rasterisers clamp their step to 4; _gradient_get_mask() uses a fixed 8. The interpolator sizes its per-cell weight tables from this, so a caller wanting a coarser grid must raise it here rather than locally.
Definition at line 270 of file masks_functions.h.
| #define DT_MASKS_OUTLINE_TILT_MAX 1.0f |
How far off the normal a border sample may tilt, as the sine of the angle: the rate of the radius along the spine, |dr/ds|, up to which the envelope is followed. At 1 the discs nest and there is no envelope beyond it, so this is the exact envelope and the clamp only keeps the square root real. A first version capped it at 0.7 to keep the spokes painted from the samples reaching across the stroke, on the argument that a family tilted further leans too far along the spine to paint the width. Measured, the raster oracle reports no missing pixel anywhere in the corpus at the exact envelope, while the cap left a real hole: a segment whose rate peaks near 1 – a brush flaring from a 132 px node to a 342 px one over 287 px – has its union's top on the rear envelope of the flare, 40 px outside the wide node's circle at a tilt of 64 degrees, and no sample reached it, so the outline lost the whole top of the shape.
Definition at line 192 of file masks_functions.h.
structure used to store pointers to the functions implementing operations on a mask shape plus a few per-class descriptive data items
One rectangular lattice of sample points over a rasterisation ROI.
Every shape whose mask is evaluated on a coarse grid and then interpolated back up describes that grid the same way: a cell count, a spacing in output pixels, the ROI origin, and the inverse of the ROI scale. x0/y0 are the index of the first cell – non-zero for the shapes that grid only their own bounding box (circle, ellipse), zero for the ones that grid the whole ROI (gradient).
| void _check_id | ( | dt_develop_t * | dev, |
| dt_masks_form_t * | mask_form | ||
| ) |
Definition at line 125 of file masks.c.
References dt_develop_t::forms, and L.
Referenced by _group_create(), dt_masks_form_duplicate(), and dt_masks_gui_form_save_creation().
| int _find_in_group | ( | dt_develop_t * | dev, |
| dt_masks_form_t * | group_form, | ||
| int | form_id | ||
| ) |
Definition at line 1405 of file masks.c.
References _find_in_group(), dt_masks_get_from_id(), DT_MASKS_GROUP, and L.
Referenced by _find_in_group(), and dt_masks_group_add_form_with_state().
| dt_masks_form_t * _group_create | ( | dt_develop_t * | develop, |
| dt_iop_module_t * | module, | ||
| dt_masks_type_t | group_type | ||
| ) |
Definition at line 170 of file masks.c.
References _check_id(), _set_group_name_from_module(), dt_masks_append_form(), dt_masks_create(), and L.
Referenced by _menu_add_exist(), dt_masks_gui_form_save_creation(), and dt_masks_iop_use_same_as().
| dt_masks_form_t * _group_from_module | ( | dt_develop_t * | develop, |
| dt_iop_module_t * | module | ||
| ) |
Definition at line 181 of file masks.c.
References dt_develop_t::blend_params, dt_masks_get_from_id(), and L.
Referenced by _menu_add_exist(), _menu_no_masks(), dt_masks_form_delete(), dt_masks_gui_form_save_creation(), dt_masks_iop_combo_populate(), and dt_masks_iop_use_same_as().
| void _set_group_name_from_module | ( | dt_iop_module_t * | module, |
| dt_masks_form_t * | group_form | ||
| ) |
Definition at line 161 of file masks.c.
References dt_free, dt_masks_group_name_for_module(), IS_NULL_PTR, and L.
Referenced by _group_create().
| void dt_masks_form_gui_points_free | ( | gpointer | data | ) |
init dt_masks_form_gui_t struct with default values
Definition at line 112 of file masks.c.
References dt_free, dt_pixelpipe_cache_free_align, IS_NULL_PTR, and L.
Referenced by _masks_draw_creation_session_forms(), _session_gui_reset(), dt_masks_clear_form_gui(), dt_masks_gui_form_save_creation(), and dt_masks_gui_form_test_create().
| dt_masks_raster_result_t dt_masks_get_mask_roi | ( | const dt_iop_module_t *const | module, |
| const dt_dev_pixelpipe_t * | pipe, | ||
| const dt_dev_pixelpipe_iop_t *const | piece, | ||
| dt_masks_form_t *const | form, | ||
| const dt_iop_roi_t * | roi, | ||
| float * | buffer, | ||
| dt_iop_roi_t * | touched | ||
| ) |
Definition at line 1661 of file masks.c.
References DT_MASKS_RASTER_ERROR, dt_masks_touched_none(), dt_masks_form_t::functions, dt_masks_functions_t::get_mask_roi, L, piece, and pipe.
Referenced by _a_shape_with_no_geometry_rasterises_empty(), _a_shape_with_no_rasteriser_is_an_error(), _group_get_mask_roi(), dt_masks_debug_rasterise(), and dt_masks_group_render_roi().
| dt_masks_raster_result_t dt_masks_get_points_border | ( | struct dt_develop_t * | dev, |
| dt_masks_form_t * | form, | ||
| float ** | points, | ||
| int * | points_count, | ||
| float ** | border, | ||
| int * | border_count, | ||
| dt_masks_skip_range_t ** | border_skips, | ||
| int * | border_skip_count, | ||
| int | source, | ||
| dt_iop_module_t * | module | ||
| ) |
Definition at line 238 of file masks.c.
References DT_MASKS_RASTER_ERROR, IS_NULL_PTR, L, and status.
Referenced by _an_unbuildable_outline_is_never_reported_as_built(), _outline_band_check(), dt_masks_debug_write_outline_csv(), and dt_masks_gui_form_create().
| void dt_masks_group_entry_apply_operation | ( | struct dt_masks_form_group_t * | group_entry, |
| const dt_masks_state_t | apply_state | ||
| ) |
Apply a mask state operation on a group entry.
Inverse toggles its flag, combine operations replace the combine bits.
Definition at line 5795 of file masks_gui.c.
References DT_MASKS_STATE_INVERSE, DT_MASKS_STATE_IS_COMBINE_OP, IS_NULL_PTR, and L.
Referenced by _masks_operation_callback().
| int dt_masks_outline_boundary_skips | ( | const float *const | points, |
| const float *const | border, | ||
| const int | count, | ||
| const int | header, | ||
| dt_masks_skip_range_t ** | skips_out | ||
| ) |
The boundary of a shape's outline: which border samples are not strictly inside any other sample's disc, published as the skip ranges every consumer of the outline already reads. points and border are the index-aligned centreline and border arrays, header the per-node header triplets both carry. See masks_outline.c.
Definition at line 735 of file masks_outline.c.
References _outline_boundary_alloc(), _outline_boundary_free(), _outline_cells_build(), _outline_discs_from_outline(), _outline_grid_build(), _outline_keep_specks(), _outline_probe_samples(), _outline_skips_from_dropped(), bbox, dt_alloc_align(), DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_free_align, dt_get_debug_flags(), dt_get_wtime(), dt_print(), i, IS_NULL_PTR, L, and n.
Referenced by _brush_get_points_border(), and _polygon_get_points_border().
| void dt_masks_outline_envelope_offset | ( | const float * | centre, |
| float | dx, | ||
| float | dy, | ||
| float | radius, | ||
| float | radius_rate, | ||
| float * | out | ||
| ) |
Place the border sample of a disc of radius centred at centre, when the disc belongs to a family whose centre moves along the tangent (dx, dy) – any length, the derivative of the spine by its parameter – and whose radius changes by radius_rate per unit of that same parameter.
A border sample on the NORMAL of its spine sample is on the boundary of the union only while the radius is constant. Where the radius grows or shrinks along the spine the boundary is the envelope of the discs, c + r * (-r' T + sqrt(1 - r'^2) N) with r' = dr/ds, tilted off the normal by asin(r'); the normal sample sits inside the union by about r'^2 r / 2 – a fraction of a pixel at the rates a pen draws, invisible to the eye and exactly what the boundary detector rejects, so the outline of a stroke whose radius varied lost whole stretches of both sides (a 37% skipped border on the #1313 corpus brush, most of it along the sides). The tilt is capped at DT_MASKS_OUTLINE_TILT_MAX. The normal is (dy, -dx), the side every border in this module offsets to.
Definition at line 62 of file masks_outline.c.
References DT_MASKS_OUTLINE_TILT_MAX, L, and out.
Referenced by _brush_border_get_XY(), and _polygon_border_get_XY().
| void dt_masks_outline_offset_along | ( | const float *const | centre, |
| float | dx, | ||
| float | dy, | ||
| const float | radius, | ||
| float *const | border | ||
| ) |
A border sample at radius from centre in the direction (dx, dy); (1, 0) if none.
Definition at line 44 of file masks_outline.c.
References L.
Referenced by _brush_leaf_borrow_border(), _brush_walk_segment(), _polygon_points_recurs(), and _polygon_walk_segment().
| gboolean dt_masks_outline_short_way | ( | const float *const | centre, |
| const float *const | from, | ||
| const float *const | to, | ||
| const gboolean | default_clockwise | ||
| ) |
Which way round a joint arc from from to to about centre goes: the short way, or default_clockwise on a tie.
Definition at line 95 of file masks_outline.c.
References FALSE, L, M_PI, and TRUE.
Referenced by _brush_joint_arc(), and _polygon_joint_arc().
| int dt_masks_point_in_form_exact | ( | const float * | test_points, |
| int | test_point_count, | ||
| const float * | form_points, | ||
| int | form_points_start, | ||
| int | form_points_count, | ||
| const dt_masks_skip_range_t * | skips, | ||
| int | skip_count | ||
| ) |
Ray-cast point-in-polygon over a form point stream, honouring skip ranges.
Walks [points_start, points_count) forward, wrapping to points_start exactly once. A skip range closes the contour with a chord from the point before jump_from to resume_at. A range that does not move the walk strictly forward is IGNORED AND REPORTED rather than followed: a backward jump would re-walk the span just left and spin until the visit cap – the silent-garbage mode both historical bugs of the in-band encoding shipped as.
| skips | may be NULL (with skip_count 0): no cuts, the common case for every shape but polygon and for path (non-border) walks. |
Ray-cast point-in-polygon over a form point stream, honouring skip ranges.
We use the ray casting algorithm for each tested point.
| pts | Flat array of tested points [x0, y0, x1, y1, ...]. |
| num_pts | Number of tested points in pts. |
| points | The array of form vertices. |
| points_start | The starting index of the form vertices in the array. |
| points_count | The total number of vertices in the form. |
Definition at line 5403 of file masks_gui.c.
References DT_DEBUG_ALWAYS, dt_print(), FALSE, i, IS_NULL_PTR, L, and TRUE.
Referenced by _circle_get_distance(), _ellipse_get_distance(), _polygon_get_distance(), and dt_masks_draw_source().
| void dt_masks_points_bounding_box | ( | const float *const | points, |
| const int | num_points, | ||
| int * | width, | ||
| int * | height, | ||
| int * | posx, | ||
| int * | posy | ||
| ) |
Axis-aligned bounding box of an outline, in the outline's own coordinates.
points is the interleaved x/y array a shape's get_points_border produced, and point 0 is SKIPPED: every shape that uses this stores its centre there, not a point on the outline.
Definition at line 322 of file masks.c.
References height, i, L, and width.
Referenced by _circle_get_area(), _circle_get_source_area(), _ellipse_get_area(), and _ellipse_get_source_area().
| int dt_masks_points_shift_to_source | ( | struct dt_develop_t * | dev, |
| const struct dt_iop_module_t * | module, | ||
| float ** | points, | ||
| int * | points_count, | ||
| const float | xs, | ||
| const float | ys, | ||
| const int | first_shifted | ||
| ) |
Turn an outline of a shape into the outline of its clone source, in final image reference.
*points arrives as the TARGET outline in RAW reference and leaves as the SOURCE outline with every distortion applied. first_shifted is the index the outline proper begins at: shapes that keep handle points in their header pass the index past them and get their centre written directly, shapes whose point 0 is the centre and nothing else pass 0 and have it shifted with the rest. On failure the buffer is freed and *points/*points_count are cleared.
Returns 0 on success, 1 on failure.
Referenced by _circle_get_points_source(), and _ellipse_get_points_source().
| int dt_masks_preview_add_clone_source | ( | struct dt_masks_form_gui_t * | gui, |
| struct dt_masks_preview_buffers_t * | preview | ||
| ) |
Give a creation preview its clone-source outline: the target outline, offset by the drag.
Allocates preview->source_points from preview->points, which must already be populated. Returns 0 on success, 1 on allocation failure – the caller's own error convention.
Definition at line 6083 of file masks_gui.c.
References dt_masks_calculate_source_pos_origin(), dt_pixelpipe_cache_alloc_align_float_cache, FALSE, i, IS_NULL_PTR, L, dt_masks_form_gui_t::pos, and preview.
Referenced by _circle_get_creation_preview(), and _ellipse_get_creation_preview().
| float * dt_masks_sample_grid_backtransform | ( | const struct dt_dev_pixelpipe_t * | pipe, |
| const double | iop_order, | ||
| const dt_masks_sample_grid_t *const | grid, | ||
| const char *const | shape, | ||
| const char *const | form_name | ||
| ) |
Definition at line 345 of file masks.c.
References __OMP_PARALLEL_FOR__, DT_DEBUG_MASKS, DT_DEBUG_PERF, dt_dev_distort_backtransform_plus(), DT_DEV_TRANSFORM_DIR_BACK_INCL, dt_get_debug_flags(), dt_get_wtime(), dt_pixelpipe_cache_alloc_align_float_cache, dt_pixelpipe_cache_free_align, dt_print(), gh(), dt_masks_sample_grid_t::height, i, IS_NULL_PTR, iscale, dt_masks_sample_grid_t::iscale, L, pipe, dt_masks_sample_grid_t::px, dt_masks_sample_grid_t::py, dt_masks_sample_grid_t::step, dt_masks_sample_grid_t::width, dt_masks_sample_grid_t::x0, and dt_masks_sample_grid_t::y0.
Referenced by _circle_get_mask_roi(), _ellipse_get_mask_roi(), _gradient_get_mask(), and _gradient_get_mask_roi().
| void dt_masks_sample_grid_interpolate | ( | const float *const | points, |
| const dt_masks_sample_grid_t *const | grid, | ||
| float *const | buffer, | ||
| const int | buf_width, | ||
| const int | buf_height, | ||
| int *const | endx, | ||
| int *const | endy | ||
| ) |
Bilinear expansion of a coarse grid of mask values back to full ROI resolution.
points is the buffer dt_masks_sample_grid_backtransform() returned, with each cell's mask value written over its x coordinate (that is, at points[index * 2]) – every shape evaluates in place like that, so the interpolator reads the same stride whatever the shape.
Writes into buffer over the rectangle the grid covers, clipped to the buffer, and reports the exclusive end of that rectangle through endx/endy for callers that go on to mark the touched box.
Definition at line 393 of file masks.c.
References __OMP_PARALLEL_FOR__, DT_MASKS_GRID_MAX_STEP, dt_masks_sample_grid_t::height, i, L, MIN, row, dt_masks_sample_grid_t::step, w1, dt_masks_sample_grid_t::width, dt_masks_sample_grid_t::x0, and dt_masks_sample_grid_t::y0.
Referenced by _circle_get_mask_roi(), _ellipse_get_mask_roi(), _gradient_get_mask(), and _gradient_get_mask_roi().
| gboolean dt_masks_skip_contains | ( | const dt_masks_skip_range_t * | skips, |
| const int | skip_count, | ||
| const int | index | ||
| ) |
Is index inside one of the excluded spans? For a consumer that SEARCHES the outline rather than walking it; a forward walk should use dt_masks_draw_outline_runs() instead.
Is index inside one of the excluded spans? For a consumer that SEARCHES the outline rather than walking it forward – a forward walk should use dt_masks_draw_outline_runs() or carry its own cursor. skips must be sorted and disjoint.
Definition at line 306 of file masks.c.
References FALSE, IS_NULL_PTR, L, and TRUE.
Referenced by _brush_get_border_handle_resampled(), and _outline_band_check().
|
extern |
Definition at line 3609 of file develop/masks/brush.c.
Referenced by _brush_events_post_expose(), _run_brush_nodes_at(), _time_overlay_brush(), _time_overlay_group(), and dt_masks_create().
|
extern |
the shape-specific function tables
Definition at line 1078 of file circle.c.
Referenced by _circle_events_post_expose(), dt_masks_create(), and main().
|
extern |
Definition at line 1643 of file ellipse.c.
Referenced by _ellipse_events_post_expose(), dt_masks_create(), and main().
|
extern |
Definition at line 1470 of file gradient.c.
Referenced by _gradient_events_post_expose(), dt_masks_create(), and main().
|
extern |
Definition at line 1045 of file group.c.
Referenced by _write_fixture_init(), and dt_masks_create().
|
extern |
Definition at line 3630 of file polygon.c.
Referenced by _polygon_events_post_expose(), _time_overlay_all(), _time_overlay_group(), dt_masks_create(), and main().