From 0639006276004116063152f69e26952cbee887b7 Mon Sep 17 00:00:00 2001 From: "hanno@schwalm-bremen.de" Date: Sat, 16 Mar 2024 13:46:01 +0100 Subject: [PATCH] Refine finalscale for dt_dev_image() 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. --- src/develop/develop.c | 5 +++-- src/develop/develop.h | 3 ++- src/develop/pixelpipe.h | 3 ++- src/iop/finalscale.c | 3 ++- src/iop/overlay.c | 2 +- src/libs/duplicate.c | 2 +- src/libs/snapshots.c | 2 +- src/views/slideshow.c | 3 ++- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/develop/develop.c b/src/develop/develop.c index a923130741f3..0cb25d6ccdaf 100644 --- a/src/develop/develop.c +++ b/src/develop/develop.c @@ -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; diff --git a/src/develop/develop.h b/src/develop/develop.h index 25077c8ee322..52d160b2d56b 100644 --- a/src/develop/develop.h +++ b/src/develop/develop.h @@ -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); diff --git a/src/develop/pixelpipe.h b/src/develop/pixelpipe.h index 075663fd6adc..f12e31a6caa3 100644 --- a/src/develop/pixelpipe.h +++ b/src/develop/pixelpipe.h @@ -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; diff --git a/src/iop/finalscale.c b/src/iop/finalscale.c index 3e9e6825336a..19b169a596a9 100644 --- a/src/iop/finalscale.c +++ b/src/iop/finalscale.c @@ -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); } diff --git a/src/iop/overlay.c b/src/iop/overlay.c index 350a1078897e..7435798dc901 100644 --- a/src/iop/overlay.c +++ b/src/iop/overlay.c @@ -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; diff --git a/src/libs/duplicate.c b/src/libs/duplicate.c index 3df3b649b8ca..2f1762299f59 100644 --- a/src/libs/duplicate.c +++ b/src/libs/duplicate.c @@ -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; } diff --git a/src/libs/snapshots.c b/src/libs/snapshots.c index 3f2cc9533152..af4b517e2f08 100644 --- a/src/libs/snapshots.c +++ b/src/libs/snapshots.c @@ -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; } diff --git a/src/views/slideshow.c b/src/views/slideshow.c index f2025005f8d0..e2022e3a4014 100644 --- a/src/views/slideshow.c +++ b/src/views/slideshow.c @@ -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);