Skip to content

Commit

Permalink
Fix dt_iop_commit_params() for blending
Browse files Browse the repository at this point in the history
In dt_iop_commit_params() we calculate the hash for the piece.

Principally we don't need to take blending parameters into account if the piece->module
does not blend.

But if a blending module is **in focus** we must do that as we don't know the internals of the
module and might miss changed blend parameters.
  • Loading branch information
jenshannoschwalm authored and TurboGit committed Aug 3, 2024
1 parent a6bad70 commit ff81f96
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
11 changes: 7 additions & 4 deletions src/develop/imageop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2092,12 +2092,15 @@ void dt_iop_commit_params(dt_iop_module_t *module,
phash = dt_hash(phash, &module->instance, sizeof(int32_t));
phash = dt_hash(phash, module->params, module->params_size);

const gboolean is_blending = (module->flags() & IOP_FLAGS_SUPPORTS_BLENDING)
&& (blendop_params->mask_mode != DEVELOP_MASK_DISABLED);

/* We have to take blending parameters into account for the hash if
a) there is some blending active detected via the mask_mode or
b) we have a blending module in focus so we have valid cachelines
*/
const gboolean is_blending = module->flags() & IOP_FLAGS_SUPPORTS_BLENDING
&& (blendop_params->mask_mode != DEVELOP_MASK_DISABLED
|| dt_dev_gui_module() == module);
if(is_blending)
{
/* if module supports blend op add blend params into account */
phash = dt_hash(phash, blendop_params, sizeof(dt_develop_blend_params_t));

dt_masks_form_t *grp = dt_masks_get_from_id(darktable.develop, blendop_params->mask_id);
Expand Down
31 changes: 16 additions & 15 deletions src/iop/retouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ static void rt_shape_selection_changed(dt_iop_module_t *self)

--darktable.gui->reset;

if(selection_changed) dt_dev_add_history_item(darktable.develop, self, TRUE);
if(selection_changed)
dt_dev_add_history_item(darktable.develop, self, TRUE);
}

//---------------------------------------------------------------------------------
Expand Down Expand Up @@ -3527,7 +3528,7 @@ static void _retouch_clone(float *const in,
rt_copy_image_masked(img_src, in, roi_in, mask_scaled, roi_mask_scaled, opacity);

cleanup:
if(img_src) dt_free_align(img_src);
dt_free_align(img_src);
}

static void _retouch_blur(dt_iop_module_t *self,
Expand Down Expand Up @@ -3619,7 +3620,7 @@ static void _retouch_blur(dt_iop_module_t *self,
rt_copy_image_masked(img_dest, in, roi_in, mask_scaled, roi_mask_scaled, opacity);

cleanup:
if(img_dest) dt_free_align(img_dest);
dt_free_align(img_dest);
}

static void _retouch_heal(float *const in,
Expand Down Expand Up @@ -3657,8 +3658,8 @@ static void _retouch_heal(float *const in,
rt_copy_image_masked(img_dest, in, roi_in, mask_scaled, roi_mask_scaled, opacity);

cleanup:
if(img_src) dt_free_align(img_src);
if(img_dest) dt_free_align(img_dest);
dt_free_align(img_src);
dt_free_align(img_dest);
}

static void rt_process_forms(float *layer, dwt_params_t *const wt_p, const int scale1)
Expand Down Expand Up @@ -3767,7 +3768,7 @@ static void rt_process_forms(float *layer, dwt_params_t *const wt_p, const int s
if(!rt_masks_get_delta_to_destination(self, piece, roi_layer, form, &dx, &dy,
p->rt_forms[index].distort_mode))
{
if(mask) dt_free_align(mask);
dt_free_align(mask);
continue;
}
}
Expand Down Expand Up @@ -3848,8 +3849,8 @@ static void rt_process_forms(float *layer, dwt_params_t *const wt_p, const int s
mask_scaled, &roi_mask_scaled, form_opacity);
}

if(mask) dt_free_align(mask);
if(mask_scaled) dt_free_align(mask_scaled);
dt_free_align(mask);
dt_free_align(mask_scaled);
}
}
}
Expand Down Expand Up @@ -3993,8 +3994,8 @@ void process(struct dt_iop_module_t *self,
rt_copy_in_to_out(in_retouch, roi_rt, ovoid, roi_out, 4, 0, 0);

cleanup:
if(in_retouch) dt_free_align(in_retouch);
if(dwt_p) dt_dwt_free(dwt_p);
dt_free_align(in_retouch);
dt_dwt_free(dwt_p);
}

void distort_mask(struct dt_iop_module_t *self,
Expand Down Expand Up @@ -4052,7 +4053,7 @@ cl_int rt_process_stats_cl(struct dt_iop_module_t *self,
}

cleanup:
if(src_buffer) dt_free_align(src_buffer);
dt_free_align(src_buffer);

return err;
}
Expand Down Expand Up @@ -4100,7 +4101,7 @@ cl_int rt_adjust_levels_cl(struct dt_iop_module_t *self,
}

cleanup:
if(src_buffer) dt_free_align(src_buffer);
dt_free_align(src_buffer);

return err;
}
Expand Down Expand Up @@ -4696,7 +4697,7 @@ static cl_int rt_process_forms_cl(cl_mem dev_layer,
if(!rt_masks_get_delta_to_destination(self, piece, roi_layer, form, &dx, &dy,
p->rt_forms[index].distort_mode))
{
if(mask) dt_free_align(mask);
dt_free_align(mask);
continue;
}
}
Expand Down Expand Up @@ -4796,8 +4797,8 @@ static cl_int rt_process_forms_cl(cl_mem dev_layer,
gd);
}

if(mask) dt_free_align(mask);
if(mask_scaled) dt_free_align(mask_scaled);
dt_free_align(mask);
dt_free_align(mask_scaled);
if(dev_mask_scaled) dt_opencl_release_mem_object(dev_mask_scaled);
}
}
Expand Down

0 comments on commit ff81f96

Please sign in to comment.