Skip to content

Commit

Permalink
Merge branch 'refac_masks_update' of https://github.com/dterrahe/dark…
Browse files Browse the repository at this point in the history
  • Loading branch information
TurboGit committed Feb 2, 2024
2 parents e6bec3f + 22eb64c commit 5b2bbb2
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 120 deletions.
3 changes: 3 additions & 0 deletions src/develop/develop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,9 @@ void dt_dev_add_masks_history_item(
}

// invalidate buffers and force redraw of darkroom
dev->full.pipe->changed |= DT_DEV_PIPE_SYNCH;
dev->preview_pipe->changed |= DT_DEV_PIPE_SYNCH;
dev->preview2.pipe->changed |= DT_DEV_PIPE_SYNCH;
dt_dev_invalidate_all(dev);
dt_pthread_mutex_unlock(&dev->history_mutex);

Expand Down
1 change: 0 additions & 1 deletion src/develop/masks.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ void dt_masks_write_masks_history_item(const dt_imgid_t imgid,
const int num,
dt_masks_form_t *form);
void dt_masks_free_form(dt_masks_form_t *form);
void dt_masks_update_image(dt_develop_t *dev);
void dt_masks_cleanup_unused(dt_develop_t *dev);

/** function used to manipulate forms for masks */
Expand Down
22 changes: 0 additions & 22 deletions src/develop/masks/brush.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,6 @@ static int _brush_events_mouse_scrolled(struct dt_iop_module_t *module,

// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);
}
return 1;
}
Expand Down Expand Up @@ -1610,8 +1607,6 @@ static int _brush_events_button_pressed(struct dt_iop_module_t *module,

// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);
// we save the move
dt_masks_update_image(darktable.develop);
return 1;
}
// we register the current position to avoid accidental move
Expand Down Expand Up @@ -1757,8 +1752,6 @@ static int _brush_events_button_pressed(struct dt_iop_module_t *module,

// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);
// we save the move
dt_masks_update_image(darktable.develop);

return 1;
}
Expand All @@ -1775,8 +1768,6 @@ static int _brush_events_button_pressed(struct dt_iop_module_t *module,

// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);
// we save the move
dt_masks_update_image(darktable.develop);
}
return 1;
}
Expand Down Expand Up @@ -2061,9 +2052,6 @@ static int _brush_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->source_dragging)
Expand All @@ -2081,16 +2069,12 @@ static int _brush_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->seg_dragging >= 0)
{
gui->seg_dragging = -1;
dt_dev_add_masks_history_item(darktable.develop, module, TRUE);
dt_masks_update_image(darktable.develop);
return 1;
}
else if(gui->point_dragging >= 0)
Expand Down Expand Up @@ -2122,8 +2106,6 @@ static int _brush_events_button_released(struct dt_iop_module_t *module,

// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);
// we save the move
dt_masks_update_image(darktable.develop);

return 1;
}
Expand Down Expand Up @@ -2153,8 +2135,6 @@ static int _brush_events_button_released(struct dt_iop_module_t *module,

// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);
// we save the move
dt_masks_update_image(darktable.develop);

return 1;
}
Expand All @@ -2164,8 +2144,6 @@ static int _brush_events_button_released(struct dt_iop_module_t *module,

// we save the move
dt_dev_add_masks_history_item(darktable.develop, module, TRUE);
dt_masks_update_image(darktable.develop);
dt_control_queue_redraw_center();
return 1;
}

Expand Down
9 changes: 0 additions & 9 deletions src/develop/masks/circle.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ static int _circle_events_mouse_scrolled(struct dt_iop_module_t *module,
{
return 0;
}
dt_masks_update_image(darktable.develop);
}
return 1;
}
Expand Down Expand Up @@ -452,9 +451,6 @@ static int _circle_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

if(gui->creation_continuous)
{
dt_masks_form_t *form_new = dt_masks_create(form->type);
Expand Down Expand Up @@ -488,9 +484,6 @@ static int _circle_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

if(gui->creation_continuous)
{
dt_masks_form_t *form_new = dt_masks_create(form->type);
Expand All @@ -512,8 +505,6 @@ static int _circle_events_button_released(struct dt_iop_module_t *module,
gui->point_dragging = gui->point_border_dragging = -1;

dt_dev_add_masks_history_item(darktable.develop, module, TRUE);
// we save the updated shape
dt_masks_update_image(darktable.develop);
}

return 0;
Expand Down
19 changes: 0 additions & 19 deletions src/develop/masks/ellipse.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ static int _ellipse_events_mouse_scrolled(struct dt_iop_module_t *module,
{
return 0;
}
dt_masks_update_image(darktable.develop);
}
return 1;
}
Expand Down Expand Up @@ -826,9 +825,6 @@ static int _ellipse_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

if(gui->creation_continuous)
{
dt_masks_form_t *form_new = dt_masks_create(form->type);
Expand Down Expand Up @@ -871,9 +867,6 @@ static int _ellipse_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the new parameters
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->form_rotating && gui->edit_mode == DT_MASKS_EDIT_FULL)
Expand Down Expand Up @@ -922,9 +915,6 @@ static int _ellipse_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the rotation
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->point_dragging >= 1
Expand All @@ -935,9 +925,6 @@ static int _ellipse_events_button_released(struct dt_iop_module_t *module,

dt_dev_add_masks_history_item(darktable.develop, module, TRUE);

// we save the updated shape
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->point_border_dragging >= 1
Expand All @@ -948,9 +935,6 @@ static int _ellipse_events_button_released(struct dt_iop_module_t *module,

dt_dev_add_masks_history_item(darktable.develop, module, TRUE);

// we save the updated shape
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->source_dragging)
Expand Down Expand Up @@ -979,9 +963,6 @@ static int _ellipse_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

if(gui->creation_continuous)
{
dt_masks_form_t *form_new = dt_masks_create(form->type);
Expand Down
13 changes: 0 additions & 13 deletions src/develop/masks/gradient.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ static int _gradient_events_mouse_scrolled(struct dt_iop_module_t *module,
dt_conf_set_float(DT_MASKS_CONF(form->type, gradient, compression),
gradient->compression);
dt_toast_log(_("compression: %3.2f%%"), gradient->compression*100.0f);
dt_masks_update_image(darktable.develop);
}
else if(gui->edit_mode == DT_MASKS_EDIT_FULL)
{
Expand All @@ -186,7 +185,6 @@ static int _gradient_events_mouse_scrolled(struct dt_iop_module_t *module,
dt_toast_log(_("curvature: %3.2f%%"), gradient->curvature*50.0f);
dt_dev_add_masks_history_item(darktable.develop, module, TRUE);
dt_masks_gui_form_create(form, gui, index, module);
dt_masks_update_image(darktable.develop);
}
return 1;
}
Expand Down Expand Up @@ -219,8 +217,6 @@ static int _gradient_events_button_pressed(struct dt_iop_module_t *module,

dt_masks_gui_form_create(form, gui, index, module);

dt_masks_update_image(darktable.develop);

return 1;
}
else if(!gui->creation
Expand Down Expand Up @@ -405,9 +401,6 @@ static int _gradient_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the move
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->form_rotating
Expand Down Expand Up @@ -456,9 +449,6 @@ static int _gradient_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the rotation
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->gradient_toggling)
Expand All @@ -481,9 +471,6 @@ static int _gradient_events_button_released(struct dt_iop_module_t *module,
// we recreate the form points
dt_masks_gui_form_create(form, gui, index, module);

// we save the new parameters
dt_masks_update_image(darktable.develop);

return 1;
}
else if(gui->creation)
Expand Down
19 changes: 2 additions & 17 deletions src/develop/masks/masks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,11 +1770,10 @@ void dt_masks_form_remove(struct dt_iop_module_t *module,
break;
}
}
if(ok) dt_dev_add_masks_history_item(darktable.develop, module, TRUE);
if(ok && module)
if(ok)
{
dt_dev_add_masks_history_item(darktable.develop, module, TRUE);
dt_masks_iop_update(module);
dt_masks_update_image(darktable.develop);
}
if(ok && grp->points == NULL) dt_masks_form_remove(module, NULL, grp);
return;
Expand Down Expand Up @@ -1835,7 +1834,6 @@ void dt_masks_form_remove(struct dt_iop_module_t *module,
{
form_removed = TRUE;
dt_masks_iop_update(m);
dt_masks_update_image(darktable.develop);
if(iopgrp->points == NULL) dt_masks_form_remove(m, NULL, iopgrp);
}
}
Expand Down Expand Up @@ -1880,7 +1878,6 @@ float dt_masks_form_change_opacity(dt_masks_form_t *form,
fpt->opacity = opacity;
dt_toast_log(_("opacity: %.0f%%"), opacity * 100);
dt_dev_add_masks_history_item(darktable.develop, NULL, TRUE);
dt_masks_update_image(darktable.develop);
}
return opacity;
}
Expand Down Expand Up @@ -2073,18 +2070,6 @@ char *dt_masks_group_get_hash_buffer(dt_masks_form_t *form, char *str)
return str + pos;
}

void dt_masks_update_image(dt_develop_t *dev)
{
/* invalidate image data*/
// dt_similarity_image_dirty(dev->image_storage.id);

// invalidate buffers and force redraw of darkroom
dev->full.pipe->changed |= DT_DEV_PIPE_SYNCH;
dev->preview_pipe->changed |= DT_DEV_PIPE_SYNCH;
dev->preview2.pipe->changed |= DT_DEV_PIPE_SYNCH;
dt_dev_invalidate_all(dev);
}

// adds formid to used array
// if formid is a group it adds all the forms that belongs to that group
static void _cleanup_unused_recurs(GList *forms,
Expand Down
Loading

0 comments on commit 5b2bbb2

Please sign in to comment.