Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
dev_roi_request.c File Reference
#include "develop/dev_roi_request.h"
#include "common/conf.h"
#include "develop/dev_geometry.h"
#include "develop/dev_viewport.h"
#include "develop/develop.h"
#include "develop/pixelpipe_hb.h"
#include <string.h>
+ Include dependency graph for dev_roi_request.c:

Go to the source code of this file.

Functions

static gboolean _payload_equal (const dt_dev_roi_request_t *a, const dt_dev_roi_request_t *b)
 Do these two records carry the same numbers, ignoring the generation stamp?
 
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 (dt_develop_t *dev)
 
dt_dev_roi_request_t dt_dev_roi_request_get (const dt_develop_t *dev)
 
uint64_t dt_dev_roi_request_publish (dt_develop_t *dev)
 Recompute the derived members from the viewport and the geometry record, and publish if anything changed. Returns the current generation.
 
void dt_dev_roi_request_latch (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 dt_dev_pixelpipe_t *pipe)
 
int32_t dt_dev_roi_request_preview_width (const dt_develop_t *dev)
 
int32_t dt_dev_roi_request_preview_height (const dt_develop_t *dev)
 
float dt_dev_roi_request_natural_scale (const dt_develop_t *dev)
 
gboolean dt_dev_roi_request_valid (const dt_develop_t *dev)
 

Function Documentation

◆ _payload_equal()

static gboolean _payload_equal ( const dt_dev_roi_request_t *  a,
const dt_dev_roi_request_t *  b 
)
inlinestatic

Do these two records carry the same numbers, ignoring the generation stamp?

Member by member, NOT memcmp: the record's uint64_t generation forces 8-byte alignment, so there are four bytes of tail padding after ‘valid’ whose contents C does not define across an assignment. A memcmp would occasionally report a change where none happened, and since the generation is meant to be a cache key, that is not a cosmetic difference – it is a spurious invalidation of the pipeline cache chain, of exactly the kind this gate exists to prevent.

The floats are compared with ==, deliberately: these are copied verbatim from the viewport and the geometry record, never recomputed here, so the question really is "are these the same bits I published last time", not "are these numerically close".

Definition at line 46 of file dev_roi_request.c.

Referenced by dt_dev_roi_request_publish().

◆ dt_dev_roi_request_get()

◆ 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 241 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, pipe, 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()

◆ 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 61 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_preview_height()

◆ dt_dev_roi_request_preview_width()

◆ 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 102 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_int(), dt_atomic_set_uint64(), dt_conf_get_string(), dt_dev_geometry_snapshot(), DT_DEV_PIPE_ZOOMED, dt_dev_pixelpipe_or_changed(), dt_dev_pixelpipe_set_mask_rasterization_step(), dt_dev_roi_natural_scale(), dt_dev_viewport_get(), dt_dev_roi_request_t::generation, dt_dev_roi_request_store_t::generation, geometry, dt_develop_t::gui_attached, IS_NULL_PTR, L, dt_dev_roi_request_t::natural_scale, dt_develop_t::pipe, dt_dev_roi_request_t::preview_height, dt_develop_t::preview_pipe, dt_dev_roi_request_t::preview_width, dt_dev_roi_request_t::processed_height, dt_dev_roi_request_t::processed_width, dt_develop_t::roi_request, dt_dev_roi_request_t::scaling, dt_dev_viewport_state_t::scaling, dt_dev_pixelpipe_t::shutdown, TRUE, dt_dev_roi_request_t::valid, and dt_dev_roi_request_store_t::value.

Referenced by _darkroom_change_mask_rasterization(), 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 dt_develop_t *  dev)