Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dev_roi_request.h File Reference
#include <glib.h>
#include <math.h>
#include <stdint.h>
#include "system/atomic.h"
+ Include dependency graph for dev_roi_request.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_dev_roi_request_t
 The coherent set of numbers a darkroom pipe plans its ROI from. More...
 
struct  dt_dev_roi_request_store_t
 

Typedefs

typedef struct dt_dev_roi_request_t dt_dev_roi_request_t
 The coherent set of numbers a darkroom pipe plans its ROI from.
 
typedef struct dt_dev_roi_request_store_t dt_dev_roi_request_store_t
 

Functions

static float dt_dev_roi_natural_scale (const int32_t box_width, const int32_t box_height, const int32_t processed_width, const int32_t processed_height)
 natural scaling = MIN(box / processed, 1): the image fits the widget minus its borders.
 
dt_dev_roi_request_t dt_dev_roi_request_neutral (void)
 The value a pipe carries before the worker has latched anything.
 
void dt_dev_roi_request_init (struct dt_develop_t *dev)
 
uint64_t dt_dev_roi_request_publish (struct dt_develop_t *dev)
 Recompute the derived members from the viewport and the geometry record, and publish if anything changed. Returns the current generation.
 
dt_dev_roi_request_t dt_dev_roi_request_get (const struct dt_develop_t *dev)
 
void dt_dev_roi_request_latch (struct dt_dev_pixelpipe_t *pipe, const dt_dev_roi_request_t *request)
 Publish onto a pipe the request its next run is planned from. Darkroom worker only.
 
dt_dev_roi_request_t dt_dev_roi_request_of_pipe (const struct dt_dev_pixelpipe_t *pipe)
 
int32_t dt_dev_roi_request_preview_width (const struct dt_develop_t *dev)
 
int32_t dt_dev_roi_request_preview_height (const struct dt_develop_t *dev)
 
float dt_dev_roi_request_natural_scale (const struct dt_develop_t *dev)
 
gboolean dt_dev_roi_request_valid (const struct dt_develop_t *dev)
 

Typedef Documentation

◆ dt_dev_roi_request_store_t

◆ dt_dev_roi_request_t

The coherent set of numbers a darkroom pipe plans its ROI from.

These were loose fields of dev->roi, written by the GUI thread in three separate functions and read one at a time by the worker inside _update_darkroom_roi(). Every consumer uses them as a product – natural_scale * scaling * processed_size – so a read that straddles a write yields a frame whose geometry never existed, and which is internally consistent and correctly hashed, so nothing downstream can tell.

They now cross the GUI/pipeline boundary only together, published as one record with a generation. The viewport and the geometry record are the inputs; this is what is derived from them and handed to the pipeline.

Function Documentation

◆ dt_dev_roi_natural_scale()

static float dt_dev_roi_natural_scale ( const int32_t  box_width,
const int32_t  box_height,
const int32_t  processed_width,
const int32_t  processed_height 
)
inlinestatic

natural scaling = MIN(box / processed, 1): the image fits the widget minus its borders.

Pure, so the publisher and any test can call it with numbers rather than a dev. Returns -1 for a non-positive processed size, which is the sentinel dt_dev_get_natural_scale() has always returned when the geometry was not ready.

Definition at line 87 of file dev_roi_request.h.

References L.

Referenced by dt_dev_roi_request_publish().

◆ dt_dev_roi_request_get()

dt_dev_roi_request_t dt_dev_roi_request_get ( const struct dt_develop_t dev)

Coherent copy (seqlock read). The returned record is zeroed with valid == FALSE when nothing usable has been published.

◆ dt_dev_roi_request_init()

◆ dt_dev_roi_request_latch()

void dt_dev_roi_request_latch ( struct dt_dev_pixelpipe_t pipe,
const dt_dev_roi_request_t request 
)

Publish onto a pipe the request its next run is planned from. Darkroom worker only.

Same seqlock as the dev-level store, and for the same reason: the worker writes this once per loop iteration while the GUI thread can read it at any moment – dt_dev_pipelines_share_preview_output() does exactly that from the darkroom expose path, and every dt_dev_pixelpipe_has_preview_output() call from an IOP GUI callback does too. A plain struct assignment across those threads is a torn read of the same shape this record exists to prevent.

Definition at line 166 of file dev_roi_request.c.

References dt_atomic_get_uint64(), dt_atomic_set_uint64(), dt_dev_roi_request_store_t::generation, IS_NULL_PTR, L, dt_dev_pixelpipe_t::roi_request, and dt_dev_roi_request_store_t::value.

Referenced by dt_dev_darkroom_pipeline().

◆ dt_dev_roi_request_natural_scale()

float dt_dev_roi_request_natural_scale ( const struct dt_develop_t dev)

◆ dt_dev_roi_request_neutral()

dt_dev_roi_request_t dt_dev_roi_request_neutral ( void  )

The value a pipe carries before the worker has latched anything.

NOT a zeroed record. scaling = 1 and natural_scale = -1 are what dt_dev_reset_roi() left on every dev, headless ones included, before this record existed – and iop/finalscale.c multiplies exactly those two to decide whether it enables itself. Seeding zeros there would change piece->enabled on any pipe that never gets latched, which is every export, thumbnail and snapshot pipe.

Definition at line 60 of file dev_roi_request.c.

References dt_dev_roi_request_t::center_x, dt_dev_roi_request_t::center_y, L, dt_dev_roi_request_t::natural_scale, and dt_dev_roi_request_t::scaling.

Referenced by dt_dev_pixelpipe_init_cached(), dt_dev_roi_request_init(), and dt_dev_roi_request_of_pipe().

◆ dt_dev_roi_request_of_pipe()

dt_dev_roi_request_t dt_dev_roi_request_of_pipe ( const struct dt_dev_pixelpipe_t pipe)

Coherent copy of what a pipe was last latched with. Safe from any thread.

◆ dt_dev_roi_request_preview_height()

int32_t dt_dev_roi_request_preview_height ( const struct dt_develop_t dev)

◆ dt_dev_roi_request_preview_width()

int32_t dt_dev_roi_request_preview_width ( const struct dt_develop_t dev)

◆ dt_dev_roi_request_publish()

uint64_t dt_dev_roi_request_publish ( struct dt_develop_t dev)

Recompute the derived members from the viewport and the geometry record, and publish if anything changed. Returns the current generation.

The ONE place the derived values are computed, and GUI-thread only: it reads the viewport, which only the GUI thread writes. The generation advances only on a real payload change, which is what lets a consumer treat it as a cache key.

Definition at line 101 of file dev_roi_request.c.

References _payload_equal(), dt_dev_roi_request_t::box_height, dt_dev_viewport_state_t::box_height, dt_dev_roi_request_t::box_width, dt_dev_viewport_state_t::box_width, dt_dev_roi_request_t::center_x, dt_dev_viewport_state_t::center_x, dt_dev_roi_request_t::center_y, dt_dev_viewport_state_t::center_y, dt_dev_viewport_state_t::configured, dt_atomic_get_uint64(), dt_atomic_set_uint64(), dt_dev_geometry_snapshot(), dt_dev_roi_natural_scale(), dt_dev_viewport_get(), dt_dev_roi_request_t::generation, dt_dev_roi_request_store_t::generation, IS_NULL_PTR, L, dt_dev_roi_request_t::natural_scale, dt_dev_roi_request_t::preview_height, dt_dev_roi_request_t::preview_width, dt_dev_image_geometry_t::processed_height, dt_dev_roi_request_t::processed_height, dt_dev_image_geometry_t::processed_inited, dt_dev_image_geometry_t::processed_width, dt_dev_roi_request_t::processed_width, dt_dev_image_geometry_t::raw_inited, dt_develop_t::roi_request, dt_dev_roi_request_t::scaling, dt_dev_viewport_state_t::scaling, dt_dev_roi_request_t::valid, and dt_dev_roi_request_store_t::value.

Referenced by dt_dev_get_thumbnail_size(), dt_dev_viewport_reset(), dt_dev_viewport_set_border(), dt_dev_viewport_set_box(), dt_dev_viewport_set_center(), dt_dev_viewport_set_scaling(), and dt_dev_viewport_set_widget_size().

◆ dt_dev_roi_request_valid()

gboolean dt_dev_roi_request_valid ( const struct dt_develop_t dev)