109#ifndef DT_DEVELOP_MASKS_H
110#define DT_DEVELOP_MASKS_H
136#define DEVELOP_MASKS_VERSION (6)
369 form->
source[0] += delta_x;
370 form->
source[1] += delta_y;
374 const float delta_x,
const float delta_y)
386 ctrl1[0] = control_points[0];
387 ctrl1[1] = control_points[1];
388 ctrl2[0] = control_points[2];
389 ctrl2[1] = control_points[3];
397 float **buffer,
int *
width,
int *
height,
int *posx,
int *posy);
547 fprintf(stderr,
"critical: out of memory for dynbuf '%s' with size request %" G_GSIZE_FORMAT
"!\n", a->tag,
size);
552 memcpy(newbuf, a->buffer, a->size *
sizeof(
float));
554 (
unsigned long)a->size, newbuf, a->buffer);
569 g_strlcpy(a->tag, tag,
sizeof(a->tag));
573 (
unsigned long)a->size, a->buffer);
585 assert(a->pos <= a->size);
586 if(__builtin_expect(a->pos + 2 >= a->size, 0))
591 a->buffer[a->pos++] = value1;
592 a->buffer[a->pos++] = value2;
600 assert(a->pos <= a->size);
601 if(__builtin_expect(a->pos +
n >= a->size, 0))
603 if(a->size == 0)
return NULL;
604 size_t newsize = a->size;
605 while(a->pos +
n >= newsize) newsize *= 2;
612 float *reserved = a->buffer + a->pos;
620 assert(a->pos <= a->size);
621 if(__builtin_expect(a->pos +
n >= a->size, 0))
623 if(a->size == 0)
return;
624 size_t newsize = a->size;
625 while(a->pos +
n >= newsize) newsize *= 2;
632 memset(a->buffer + a->pos, 0,
n *
sizeof(
float));
642 assert((
long)a->pos + offset >= 0);
643 return (a->buffer[a->pos + offset]);
651 assert((
long)a->pos + offset >= 0);
652 a->buffer[a->pos + offset] =
value;
662 float center[2],
float *area)
680 if(points_count >= 3)
686 for(
int i = 0;
i < points_count;
i++)
688 const int j = (
i + 1 < points_count) ? (
i + 1) : 0;
689 const double x0 = points[
i * 2];
690 const double y0 = points[
i * 2 + 1];
691 const double x1 = points[j * 2];
692 const double y1 = points[j * 2 + 1];
694 const double cross = x0 * y1 - x1 * y0;
696 cx += (x0 + x1) * cross;
697 cy += (y0 + y1) * cross;
700 if(fabs(area2) > 1e-12)
702 const double inv = 1.0 / (3.0 * area2);
703 center[0] = (float)(cx *
inv);
704 center[1] = (float)(cy *
inv);
706 *area = (float)(0.5 * fabs(area2));
714 const float inv_count = 1.0f / (float)points_count;
715 for(
int i = 0;
i < points_count;
i++)
717 sum_x += points[
i * 2] * inv_count;
718 sum_y += points[
i * 2 + 1] * inv_count;
748 float *
r = a->buffer;
750 a->pos = a->size = 0;
765 const int rem = num % mult;
767 return (rem == 0) ? num : num + mult - rem;
GtkWidget * status
result of the last capture
_lib_location_type_t type
int32_t dt_get_debug_flags(void)
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
int dt_masks_legacy_params(dt_develop_t *dev, void *params, const int old_version, const int new_version)
static float * dt_masks_dynbuf_buffer(dt_masks_dynbuf_t *a)
uint64_t dt_masks_group_get_hash_ext(uint64_t hash, GList *masks, dt_masks_form_t *form)
dt_masks_raster_result_t dt_masks_get_source_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)
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 void dt_masks_dynbuf_add_2(dt_masks_dynbuf_t *a, float value1, float value2)
static dt_masks_raster_result_t dt_masks_raster_from_status(const int status)
struct dt_iop_module_t * dt_masks_get_mask_manager(struct dt_develop_t *dev)
void dt_masks_free_form(dt_masks_form_t *form)
static dt_masks_dynbuf_t * dt_masks_dynbuf_init(size_t size, const char *tag)
static void dt_masks_translate_source(dt_masks_form_t *form, const float delta_x, const float delta_y)
void dt_masks_iop_use_same_as(struct dt_iop_module_t *module, struct dt_iop_module_t *src)
dt_masks_raster_result_t
What a rasterisation attempt produced.
void dt_masks_read_masks_history(dt_develop_t *dev, const int32_t imgid)
uint64_t dt_masks_form_get_own_hash(uint64_t hash, GList *masks, const dt_masks_form_t *form)
static float dt_masks_dynbuf_get(dt_masks_dynbuf_t *a, int offset)
static void dt_masks_translate_ctrl_node(float node[2], float ctrl1[2], float ctrl2[2], const float delta_x, const float delta_y)
dt_masks_form_t * dt_masks_dup_masks_form(const dt_masks_form_t *form)
Deep-copy a mask form, including its points list.
void dt_masks_duplicate_points(const dt_masks_form_t *base, dt_masks_form_t *dest, size_t node_size)
Duplicate a points list for a mask using a fixed node size.
void dt_masks_write_masks_history_item(const int32_t imgid, const int num, dt_masks_form_t *form)
static float * dt_masks_dynbuf_reserve_n(dt_masks_dynbuf_t *a, const int n)
static gboolean _dt_masks_dynbuf_growto(dt_masks_dynbuf_t *a, size_t size)
int dt_masks_version(void)
int dt_masks_form_duplicate_in_group(dt_develop_t *dev, int group_id, int form_id)
Duplicate a shape (dt_masks_form_duplicate) and, if group_id names a valid group, attach the duplicat...
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 gboolean dt_masks_center_of_gravity_from_points(const float *points, const int points_count, float center[2], float *area)
@ DT_MASKS_ELLIPSE_PROPORTIONAL
@ DT_MASKS_ELLIPSE_EQUIDISTANT
static size_t dt_masks_dynbuf_position(dt_masks_dynbuf_t *a)
dt_masks_form_t * dt_masks_create_ext(dt_develop_t *dev, dt_masks_type_t type)
dt_masks_source_pos_type_t
@ DT_MASKS_SOURCE_POS_RELATIVE_TEMP
@ DT_MASKS_SOURCE_POS_RELATIVE
@ DT_MASKS_SOURCE_POS_ABSOLUTE
void dt_masks_cleanup_unused(dt_develop_t *dev)
Cleanup unused masks and refresh the current forms snapshot.
dt_masks_form_t * dt_masks_create(dt_masks_type_t type)
int dt_masks_form_change_opacity(dt_develop_t *dev, dt_masks_form_t *form, int parentid, int up, const int flow)
static gboolean dt_masks_form_is_clone(const dt_masks_form_t *form)
static void dt_masks_dynbuf_add_zeros(dt_masks_dynbuf_t *a, const int n)
void dt_masks_form_move(dt_masks_form_t *grp, int formid, int up)
dt_masks_pressure_sensitivity_t
@ DT_MASKS_PRESSURE_OPACITY_REL
@ DT_MASKS_PRESSURE_OPACITY_ABS
@ DT_MASKS_PRESSURE_BRUSHSIZE_REL
@ DT_MASKS_PRESSURE_FADING_REL
@ DT_MASKS_PRESSURE_FADING_ABS
dt_masks_form_t * dt_masks_get_from_id_ext(GList *forms, int id)
void dt_masks_form_delete(dt_develop_t *dev, struct dt_iop_module_t *module, dt_masks_form_t *grp, dt_masks_form_t *form)
dt_masks_form_t * dt_masks_get_from_id(dt_develop_t *dev, int id)
@ DT_MASKS_POINT_STATE_NORMAL
@ DT_MASKS_POINT_STATE_USER
dt_masks_edit_mode_t dt_masks_get_edit_mode(struct dt_iop_module_t *module)
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)
dt_masks_gradient_states_t
@ DT_MASKS_GRADIENT_STATE_SIGMOIDAL
@ DT_MASKS_GRADIENT_STATE_LINEAR
static int dt_masks_roundup(int num, int mult)
static float * dt_masks_dynbuf_harvest(dt_masks_dynbuf_t *a)
void dt_masks_set_edit_mode(struct dt_iop_module_t *module, dt_masks_edit_mode_t value)
static void dt_masks_dynbuf_set(dt_masks_dynbuf_t *a, int offset, float value)
int dt_masks_form_duplicate(dt_develop_t *dev, int formid)
static gboolean dt_masks_form_uses_spot_defaults(const dt_masks_form_t *form)
static void dt_masks_dynbuf_reset(dt_masks_dynbuf_t *a)
static void dt_masks_dynbuf_free(dt_masks_dynbuf_t *a)
static void dt_masks_reset_source(dt_masks_form_t *form)
static void dt_masks_set_ctrl_points(float ctrl1[2], float ctrl2[2], const float control_points[4])
int dt_masks_copy_used_forms_for_module(dt_develop_t *dev_dest, dt_develop_t *dev_src, const struct dt_iop_module_t *mod_src)
The masks vocabulary: the enumerations a caller needs to NAME a shape or an operation,...
static size_t dt_round_size_sse(const size_t size)
Round size up to the next multiple of 64.
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id)
#define dt_pixelpipe_cache_free_align(mem)
static const dt_aligned_pixel_simd_t value
unsigned __int64 uint64_t
struct dt_develop_t * dev
Region of interest passed through the pixelpipe.
dt_masks_gradient_states_t state
dt_masks_points_states_t state
dt_masks_ellipse_flags_t flags
dt_masks_points_states_t state
static double dt_get_wtime(void)