Skip to content

Commit

Permalink
Refine finalscale for dt_dev_image()
Browse files Browse the repository at this point in the history
For performance reasons we might not want to do late scaling via finalscale while processing
the pixelpipe via dt_dev_image() but rely on demosaicer downscaling.

This adds another parameter 'gboolean finalscale' to dt_dev_image() using the also introduced
'DT_DEV_PIXELPIPE_IMAGE_FINAL' allowing
a) overlay module use finalscale for quality and performance
b) duplicate, slideshow and snapshot to do it the old way without finalscale for performance.
   Please note that these can still be enforced to use finalscale via the 'Toggle high quality processing' button.
  • Loading branch information
jenshannoschwalm committed Mar 17, 2024
1 parent feae8e6 commit 0639006
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/develop/develop.c
Expand Up @@ -3464,14 +3464,15 @@ void dt_dev_image(const dt_imgid_t imgid,
float *zoom_y,
const int snapshot_id,
GList *module_filter_out,
const int devid)
const int devid,
const gboolean finalscale)
{
dt_develop_t dev;
dt_dev_init(&dev, TRUE);
dev.gui_attached = FALSE;
dt_dev_pixelpipe_t *pipe = dev.full.pipe;

pipe->type |= DT_DEV_PIXELPIPE_IMAGE;
pipe->type |= DT_DEV_PIXELPIPE_IMAGE | (finalscale ? DT_DEV_PIXELPIPE_IMAGE_FINAL : 0);
// load image and set history_end

dev.snapshot_id = snapshot_id;
Expand Down
3 changes: 2 additions & 1 deletion src/develop/develop.h
Expand Up @@ -646,7 +646,8 @@ void dt_dev_image(const dt_imgid_t imgid,
float *zoom_y,
const int32_t snapshot_id,
GList *module_filter_out,
const int devid);
const int devid,
const gboolean finalscale);


gboolean dt_dev_equal_chroma(const float *f, const double *d);
Expand Down
3 changes: 2 additions & 1 deletion src/develop/pixelpipe.h
Expand Up @@ -41,7 +41,8 @@ typedef enum dt_dev_pixelpipe_type_t
DT_DEV_PIXELPIPE_ANY = DT_DEV_PIXELPIPE_EXPORT | DT_DEV_PIXELPIPE_FULL | DT_DEV_PIXELPIPE_PREVIEW
| DT_DEV_PIXELPIPE_THUMBNAIL | DT_DEV_PIXELPIPE_PREVIEW2,
DT_DEV_PIXELPIPE_FAST = 1 << 8,
DT_DEV_PIXELPIPE_IMAGE = 1 << 9, // special additional flag used by dt_dev_image()
DT_DEV_PIXELPIPE_IMAGE = 1 << 9, // special additional flag used by dt_dev_image()
DT_DEV_PIXELPIPE_IMAGE_FINAL = 1 << 10, // special additional flag used by dt_dev_image(), mark to use finalscale
DT_DEV_PIXELPIPE_BASIC = DT_DEV_PIXELPIPE_FULL | DT_DEV_PIXELPIPE_PREVIEW
} dt_dev_pixelpipe_type_t;

Expand Down
3 changes: 2 additions & 1 deletion src/iop/finalscale.c
Expand Up @@ -162,8 +162,9 @@ void commit_params(dt_iop_module_t *self,
dt_dev_pixelpipe_t *pipe,
dt_dev_pixelpipe_iop_t *piece)
{
const int use_finalscale = DT_DEV_PIXELPIPE_IMAGE | DT_DEV_PIXELPIPE_IMAGE_FINAL;
piece->enabled = piece->pipe->type == DT_DEV_PIXELPIPE_EXPORT
|| pipe->type & DT_DEV_PIXELPIPE_IMAGE
|| (pipe->type & use_finalscale) == use_finalscale
|| _gui_fullpipe(piece);
}

Expand Down
2 changes: 1 addition & 1 deletion src/iop/overlay.c
Expand Up @@ -308,7 +308,7 @@ static void _setup_overlay(dt_iop_module_t *self,
-1,
&buf, NULL, &bw, &bh,
NULL, NULL,
-1, disabled_modules, piece->pipe->devid);
-1, disabled_modules, piece->pipe->devid, TRUE);

uint8_t *old_buf = *pbuf;

Expand Down
2 changes: 1 addition & 1 deletion src/libs/duplicate.c
Expand Up @@ -223,7 +223,7 @@ void gui_post_expose(dt_lib_module_t *self,
dt_dev_image(d->imgid, width, height, -1,
&d->buf, &d->scale,
&d->buf_width, &d->buf_height,
&d->zoom_x, &d->zoom_y, -1, NULL, DT_DEVICE_NONE);
&d->zoom_x, &d->zoom_y, -1, NULL, DT_DEVICE_NONE, FALSE);

d->preview_id = d->imgid;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/snapshots.c
Expand Up @@ -199,7 +199,7 @@ void gui_post_expose(dt_lib_module_t *self,
&snap->buf, &snap->scale,
&snap->width, &snap->height,
&snap->zoom_x, &snap->zoom_y,
snap->id, NULL, DT_DEVICE_NONE);
snap->id, NULL, DT_DEVICE_NONE, FALSE);
d->snap_requested = FALSE;
d->expose_again_timeout_id = 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/views/slideshow.c
Expand Up @@ -216,7 +216,8 @@ static int _process_image(dt_slideshow_t *d,
NULL,
-1,
NULL,
DT_DEVICE_NONE);
DT_DEVICE_NONE,
FALSE);

dt_pthread_mutex_lock(&d->lock);

Expand Down

0 comments on commit 0639006

Please sign in to comment.