Skip to content

Commit

Permalink
Refactor the module operations filtering & fix some "silent" bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
aurelienpierre committed Jan 14, 2025
1 parent e356fa3 commit 42b262c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/develop/develop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2360,8 +2360,7 @@ int dt_dev_distort_transform_locked(dt_develop_t *dev, dt_dev_pixelpipe_t *pipe,
|| (transf_direction == DT_DEV_TRANSFORM_DIR_FORW_EXCL && module->iop_order > iop_order)
|| (transf_direction == DT_DEV_TRANSFORM_DIR_BACK_INCL && module->iop_order <= iop_order)
|| (transf_direction == DT_DEV_TRANSFORM_DIR_BACK_EXCL && module->iop_order < iop_order))
&& !(dev->gui_module && dev->gui_module != module
&& (dev->gui_module->operation_tags_filter() & module->operation_tags())))
&& !dt_dev_pixelpipe_activemodule_disables_currentmodule(dev, module))
{
module->distort_transform(module, piece, points, points_count);
}
Expand Down Expand Up @@ -2400,8 +2399,7 @@ int dt_dev_distort_backtransform_locked(dt_develop_t *dev, dt_dev_pixelpipe_t *p
|| (transf_direction == DT_DEV_TRANSFORM_DIR_FORW_EXCL && module->iop_order > iop_order)
|| (transf_direction == DT_DEV_TRANSFORM_DIR_BACK_INCL && module->iop_order <= iop_order)
|| (transf_direction == DT_DEV_TRANSFORM_DIR_BACK_EXCL && module->iop_order < iop_order))
&& !(dev->gui_module && dev->gui_module != module
&& (dev->gui_module->operation_tags_filter() & module->operation_tags())))
&& !dt_dev_pixelpipe_activemodule_disables_currentmodule(dev, module))
{
module->distort_backtransform(module, piece, points, points_count);
}
Expand Down
21 changes: 13 additions & 8 deletions src/develop/pixelpipe_hb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,15 @@ void dt_dev_pixelpipe_flush_caches(dt_dev_pixelpipe_t *pipe)
dt_dev_pixelpipe_cache_flush(&pipe->cache);
}

gboolean dt_dev_pixelpipe_activemodule_disables_currentmodule(struct dt_develop_t *dev, struct dt_iop_module_t *current_module)
{
return (dev // don't segfault
&& dev->gui_module // don't segfault
&& dev->gui_module != current_module // current_module is not capturing editing mode
&& dev->gui_module->operation_tags_filter() & current_module->operation_tags());
// current_module does operation(s) that active module doesn't want
}

void dt_dev_pixelpipe_get_roi_out(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, int width_in,
int height_in, int *width, int *height)
{
Expand All @@ -2405,8 +2414,7 @@ void dt_dev_pixelpipe_get_roi_out(dt_dev_pixelpipe_t *pipe, struct dt_develop_t

// skip this module?
if(piece->enabled
&& !(dev->gui_module && dev->gui_module != module
&& dev->gui_module->operation_tags_filter() & module->operation_tags()))
&& !dt_dev_pixelpipe_activemodule_disables_currentmodule(dev, module))
{
module->modify_roi_out(module, piece, &roi_out, &roi_in);
}
Expand Down Expand Up @@ -2448,8 +2456,7 @@ void dt_dev_pixelpipe_get_roi_in(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *
piece->planned_roi_out = roi_out_temp;

// skip this module?
if(piece->enabled && !(dev->gui_module && dev->gui_module != module
&& dev->gui_module->operation_tags_filter() & module->operation_tags()))
if(piece->enabled && !dt_dev_pixelpipe_activemodule_disables_currentmodule(dev, module))
{
module->modify_roi_in(module, piece, &roi_out_temp, &roi_in);

Expand Down Expand Up @@ -2546,8 +2553,7 @@ float *dt_dev_get_raster_mask(dt_dev_pixelpipe_t *pipe, const dt_iop_module_t *r
dt_dev_pixelpipe_iop_t *module = (dt_dev_pixelpipe_iop_t *)iter->data;

if(module->enabled
&& !(module->module->dev->gui_module
&& (module->module->dev->gui_module->operation_tags_filter() & module->module->operation_tags())))
&& !dt_dev_pixelpipe_activemodule_disables_currentmodule(module->module->dev, module->module))
{
if(module->module->distort_mask
&& !(!strcmp(module->module->op, "finalscale") // hack against pipes not using finalscale
Expand Down Expand Up @@ -2775,8 +2781,7 @@ float *dt_dev_distort_detail_mask(const dt_dev_pixelpipe_t *pipe, float *src, co
{
dt_dev_pixelpipe_iop_t *module = (dt_dev_pixelpipe_iop_t *)iter->data;
if(module->enabled
&& !(module->module->dev->gui_module
&& module->module->dev->gui_module->operation_tags_filter() & module->module->operation_tags()))
&& !dt_dev_pixelpipe_activemodule_disables_currentmodule(module->module->dev, module->module))
{
if(module->module->distort_mask
&& !(!strcmp(module->module->op, "finalscale") // hack against pipes not using finalscale
Expand Down
11 changes: 11 additions & 0 deletions src/develop/pixelpipe_hb.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,17 @@ void dt_dev_pixelpipe_get_roi_out(dt_dev_pixelpipe_t *pipe, struct dt_develop_t
int height_in, int *width, int *height);
void dt_dev_pixelpipe_get_roi_in(dt_dev_pixelpipe_t *pipe, struct dt_develop_t *dev, const struct dt_iop_roi_t roi_out);

// Check if current_module is performing operations that dev->gui_module (active GUI module)
// wants disabled. Use that to disable some features of current_module.
// This is used mostly with distortion operations when the active GUI module
// needs a full-ROI/undistorted input for its own editing mode,
// like moving the framing on the full image.
// WARNING: this doesn't check WHAT particular operations are performed and
// and what operations should be cancelled (nor if they should all be cancelled).
// So far, all the code uses that to prevent distortions on module output, masks and roi_out changes (cropping).
// Meaning ANY of these operations will disable ALL of these operations.
gboolean dt_dev_pixelpipe_activemodule_disables_currentmodule(struct dt_develop_t *dev,
struct dt_iop_module_t *current_module);
// destroys all allocated data.
void dt_dev_pixelpipe_cleanup(dt_dev_pixelpipe_t *pipe);

Expand Down
2 changes: 1 addition & 1 deletion src/iop/ashift.c
Original file line number Diff line number Diff line change
Expand Up @@ -3657,7 +3657,7 @@ static int call_distort_transform(dt_develop_t *dev, dt_dev_pixelpipe_t *pipe, s
dt_dev_pixelpipe_iop_t *piece = dt_dev_distort_get_iop_pipe(self->dev, self->dev->preview_pipe, self);
if(!piece) return ret;
if(piece->module == self && /*piece->enabled && */ //see note below
!(dev->gui_module && dev->gui_module->operation_tags_filter() & piece->module->operation_tags()))
!dt_dev_pixelpipe_activemodule_disables_currentmodule(dev, piece->module))
{
ret = piece->module->distort_transform(piece->module, piece, points, points_count);
}
Expand Down

0 comments on commit 42b262c

Please sign in to comment.