103 float buffer[16] = { 0.0f };
127 float buffer[16] = { 0.0f };
149 float *points = NULL;
150 float *border = NULL;
151 int points_count = -1;
152 int border_count = -1;
158 &border_count, NULL, NULL, 0, NULL),
179 float *buffer = (
float *)(intptr_t)-1;
186 assert_int_equal(
width, 0);
187 assert_int_equal(
height, 0);
188 assert_int_equal(posx, 0);
189 assert_int_equal(posy, 0);
202 assert_int_equal(
width, 0);
203 assert_int_equal(
height, 0);
204 assert_int_equal(posx, 0);
205 assert_int_equal(posy, 0);
226 g_strlcpy(form.
name,
"circle #2",
sizeof(form.
name));
230 assert_int_equal(info.
formid, 4242);
231 assert_int_equal(info.
version, 6);
235 assert_string_equal(info.
name,
"circle #2");
249 assert_int_equal(info.
formid, -999);
262 for(
int i = 0;
i < 3;
i++) group.
points = g_list_append(group.
points, &rows[
i]);
274 for(guint
i = 0;
i < 3;
i++)
279 assert_int_equal(members[
i].index,
i);
280 assert_int_equal(members[
i].formid, rows[
i].formid);
281 assert_int_equal(members[
i].parentid, rows[
i].parentid);
284 assert_true(members[0].opacity == rows[0].opacity);
290 assert_int_equal(two[0].formid, 11);
291 assert_int_equal(two[1].formid, 22);
293 g_list_free(group.
points);
305 shape.
points = g_list_append(NULL, &node);
311 g_list_free(shape.
points);
353 memset(
f, 0,
sizeof(*
f));
371 for(
int i = 0;
i < 2;
i++)
f->group.points = g_list_append(
f->group.points, &
f->rows[
i]);
372 f->dev.forms = g_list_append(NULL, &
f->group);
377 g_list_free(
f->group.points);
378 g_list_free(
f->dev.forms);
397 assert_int_equal(
m.formid, 22);
398 assert_int_equal(
m.index, 1);
399 assert_true(
m.opacity == 1.0f);
424 const int before =
f.rows[0].state;
433 assert_int_equal(
f.rows[0].state, before);
472 assert_int_equal(
m.formid, 22);
473 assert_int_equal(
m.parentid, 7);
474 assert_int_equal(
m.index, 1);
475 assert_true(
m.opacity == 1.0f);
495 assert_true(
f.rows[0].opacity == 0.25f);
496 assert_true(
m.opacity == 0.25f);
501 assert_true(
f.rows[0].opacity == 1.0f);
502 assert_true(
m.opacity == 1.0f);
505 assert_true(
f.rows[0].opacity == 0.0f);
528 assert_true(
f.rows[0].opacity == 0.5f);
549 assert_true(
f.rows[0].opacity == 0.5f);
553 assert_ptr_not_equal(live, &
f.group);
554 assert_true(
m.opacity == 0.25f);
558 assert_true(read_back.
opacity == 0.25f);
580 const struct CMUnitTest tests[] = {
602 return cmocka_run_group_tests(tests, NULL, NULL);
void dt_atomic_set_int(dt_atomic_int *var, int value)
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const dt_masks_functions_t dt_masks_functions_circle
static int dt_pthread_rwlock_destroy(dt_pthread_rwlock_t *lock)
static int dt_pthread_rwlock_init(dt_pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr)
const dt_masks_functions_t dt_masks_functions_ellipse
const dt_masks_functions_t dt_masks_functions_gradient
const dt_masks_functions_t dt_masks_functions_group
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
dt_masks_result_t dt_masks_group_get_member(dt_develop_t *dev, const int group_id, const int formid, dt_masks_member_t *out)
Read one group member by identity.
dt_masks_result_t dt_masks_group_set_member_operation(dt_develop_t *dev, const int group_id, const int formid, const dt_masks_state_t operation, dt_masks_member_t *out)
Set a group member's combination operator, or toggle its inversion.
dt_masks_raster_result_t dt_masks_get_points_border(dt_develop_t *develop, dt_masks_form_t *mask_form, float **point_buffer, int *point_count, float **border_buffer, int *border_count, dt_masks_skip_range_t **border_skips, int *border_skip_count, int source, dt_iop_module_t *module)
dt_masks_raster_result_t dt_masks_get_mask_roi(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, const dt_iop_roi_t *roi, float *buffer, dt_iop_roi_t *touched)
gboolean dt_masks_form_get_info(const dt_masks_form_t *form, dt_masks_form_info_t *out)
int dt_masks_group_find_holder(dt_develop_t *dev, const int formid)
Which group references formid, searching every group in dev->forms depth-first.
dt_masks_result_t dt_masks_group_set_member_opacity(dt_develop_t *dev, const int group_id, const int formid, const float opacity, dt_masks_member_t *out)
Set a group member's opacity.
guint dt_masks_group_copy_members(const dt_masks_form_t *group, dt_masks_member_t *out, const guint out_max)
const char * dt_masks_type_name(const dt_masks_type_t type)
The stable, untranslated token for a shape kind: circle, ellipse, polygon, brush, gradient,...
dt_masks_raster_result_t dt_masks_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 dt_masks_raster_result_t dt_masks_raster_from_status(const int status)
dt_masks_raster_result_t
What a rasterisation attempt produced.
dt_masks_raster_result_t dt_masks_get_area(dt_iop_module_t *module, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece, dt_masks_form_t *form, int *width, int *height, int *posx, int *posy)
The per-shape function table, private to the masks implementation.
Ask the masks module about a shape or a group, instead of reading its structs.
void dt_masks_form_unref(dt_masks_form_t *form)
static int dt_masks_touched_is_empty(const dt_iop_roi_t *touched)
@ DT_MASKS_STATE_DIFFERENCE
@ DT_MASKS_STATE_INTERSECTION
const float uint32_t state[4]
gboolean area_depends_on_geometry
const dt_masks_functions_t * functions
Region of interest passed through the pixelpipe.
dt_masks_raster_result_t(* get_area)(const dt_iop_module_t *const module, struct dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, struct dt_masks_form_t *const form, int *width, int *height, int *posx, int *posy)
dt_masks_raster_result_t(* get_mask)(const dt_iop_module_t *const module, struct dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *const piece, struct dt_masks_form_t *const form, float **buffer, int *width, int *height, int *posx, int *posy)
One shape's membership of one group, BY VALUE.
static dt_masks_form_t _empty_form(const _shape_t *shape)
static void _from_status_maps_zero_to_ok_and_everything_else_to_error(void **state)
static void _inverse_toggles_and_leaves_the_operator_alone(void **state)
static void _a_shape_with_no_rasteriser_is_an_error(void **state)
static void _find_holder_names_the_group_that_references_a_shape(void **state)
static void _a_shape_with_no_geometry_rasterises_empty(void **state)
static const size_t _shape_count
static void _write_fixture_cleanup(_write_fixture_t *f)
static void _get_member_reads_a_row_by_identity(void **state)
static void _write_fixture_init(_write_fixture_t *f)
static void _form_info_leaves_out_untouched_on_failure(void **state)
static void _copy_members_refuses_anything_that_is_not_a_group(void **state)
static void _set_opacity_refuses_a_nan_rather_than_clamping_it(void **state)
static void _set_operation_rejects_what_it_cannot_do(void **state)
static void _a_shared_group_is_cloned_before_its_opacity_changes(void **state)
static const _shape_t _shapes[]
static void _an_unbuildable_outline_is_never_reported_as_built(void **state)
static void _type_tokens_are_the_persisted_conf_key_spellings(void **state)
static void _set_operation_replaces_the_combine_op(void **state)
static void _area_and_mask_always_write_their_out_parameters(void **state)
static void _set_opacity_clamps_and_reports_what_it_stored(void **state)
static void _setting_the_state_it_already_has_is_unchanged(void **state)
static void _form_info_describes_a_shape(void **state)
static void _copy_members_preserves_order_and_reports_the_total(void **state)