Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
worker.h File Reference

Background stroke worker API for drawlayer realtime painting. More...

#include "iop/iop_api.h"
#include "iop/drawlayer/paint.h"
+ Include dependency graph for worker.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_drawlayer_worker_snapshot_t
 

Typedefs

typedef struct dt_drawlayer_worker_t dt_drawlayer_worker_t
 Opaque worker state (thread, queue, stroke runtime).
 
typedef enum dt_drawlayer_worker_state_t dt_drawlayer_worker_state_t
 
typedef struct dt_drawlayer_worker_snapshot_t dt_drawlayer_worker_snapshot_t
 
typedef gboolean(* dt_drawlayer_worker_finished_stroke_cb) (dt_iop_module_t *self, const GArray *raw_inputs)
 Callback processing one finished stroke on the deferred full-resolution worker.
 

Enumerations

enum  dt_drawlayer_worker_state_t {
  DT_DRAWLAYER_WORKER_STATE_STOPPED = 0 ,
  DT_DRAWLAYER_WORKER_STATE_IDLE ,
  DT_DRAWLAYER_WORKER_STATE_BUSY ,
  DT_DRAWLAYER_WORKER_STATE_PAUSING ,
  DT_DRAWLAYER_WORKER_STATE_PAUSED
}
 

Functions

void dt_drawlayer_worker_init (dt_iop_module_t *self, dt_drawlayer_worker_t **worker, gboolean *painting, gboolean *finish_commit_pending, guint *stroke_sample_count, uint32_t *current_stroke_batch, dt_drawlayer_worker_finished_stroke_cb finished_stroke_cb)
 Initialize worker and bind external state mirrors.
 
void dt_drawlayer_worker_cleanup (dt_drawlayer_worker_t **worker)
 Stop worker and release all resources.
 
gboolean dt_drawlayer_worker_active (const dt_drawlayer_worker_t *worker)
 Query whether realtime/backend worker still has pending activity.
 
gboolean dt_drawlayer_worker_any_active (const dt_drawlayer_worker_t *worker)
 Query whether any worker still has pending activity, including full-resolution replay.
 
void dt_drawlayer_worker_get_snapshot (const dt_drawlayer_worker_t *worker, dt_drawlayer_worker_snapshot_t *snapshot)
 Return a thread-safe worker snapshot for runtime scheduling.
 
void dt_drawlayer_worker_request_commit (dt_drawlayer_worker_t *worker)
 Request asynchronous commit once queues become idle.
 
void dt_drawlayer_worker_flush_pending (dt_drawlayer_worker_t *worker)
 Flush pending events and force commit transition.
 
gboolean dt_drawlayer_worker_ensure_running (dt_iop_module_t *self, dt_drawlayer_worker_t *worker)
 Ensure realtime/backend worker threads are started.
 
void dt_drawlayer_worker_stop (dt_iop_module_t *self, dt_drawlayer_worker_t *worker)
 Stop realtime and full-resolution worker threads.
 
void dt_drawlayer_worker_seal_for_commit (dt_drawlayer_worker_t *worker)
 Seal current stroke for synchronous commit by folding queued raw inputs into preserved history.
 
void dt_drawlayer_worker_flush_finished_strokes (dt_drawlayer_worker_t *worker)
 Wait until deferred full-resolution replay queue is idle.
 
void dt_drawlayer_worker_publish_backend_stroke_damage (dt_iop_module_t *self)
 Publish accumulated backend stroke damage into drawlayer process/runtime state.
 
void dt_drawlayer_worker_reset_backend_path (dt_drawlayer_worker_t *worker)
 Reset worker-owned backend damage accumulator.
 
void dt_drawlayer_worker_reset_live_publish (dt_drawlayer_worker_t *worker)
 Reset worker-owned transient live-publish state.
 
void dt_drawlayer_worker_reset_stroke (dt_drawlayer_worker_t *worker)
 Clear preserved stroke runtime/history after a completed commit.
 
GArray * dt_drawlayer_worker_raw_inputs (dt_drawlayer_worker_t *worker)
 Read-only access to preserved raw input queue for current stroke (valid only while worker is idle).
 
dt_drawlayer_paint_stroke_tdt_drawlayer_worker_stroke (dt_drawlayer_worker_t *worker)
 Read-only access to preserved stroke runtime (valid only while worker is idle).
 
guint dt_drawlayer_worker_pending_dab_count (const dt_drawlayer_worker_t *worker)
 Return the number of interpolated-but-not-yet-rasterized dabs in the current stroke batch.
 
gboolean dt_drawlayer_worker_finished_stroke_queued (const dt_drawlayer_worker_t *worker)
 Query whether the current preserved stroke has already been handed off for full-resolution replay.
 
gboolean dt_drawlayer_worker_replay_finished_stroke_to_base_patch (dt_iop_module_t *self, const GArray *raw_inputs)
 Replay one finished stroke into the authoritative base patch from preserved raw inputs.
 
gboolean dt_drawlayer_worker_enqueue_input (dt_drawlayer_worker_t *worker, const dt_drawlayer_paint_raw_input_t *input)
 Enqueue one raw input event (FIFO, no coalescing).
 
gboolean dt_drawlayer_worker_enqueue_stroke_end (dt_drawlayer_worker_t *worker, const dt_drawlayer_paint_raw_input_t *input)
 Enqueue stroke-end marker carrying final raw input sample.
 

Detailed Description

Background stroke worker API for drawlayer realtime painting.

Typedef Documentation

◆ dt_drawlayer_worker_finished_stroke_cb

typedef gboolean(* dt_drawlayer_worker_finished_stroke_cb) (dt_iop_module_t *self, const GArray *raw_inputs)

Callback processing one finished stroke on the deferred full-resolution worker.

◆ dt_drawlayer_worker_snapshot_t

◆ dt_drawlayer_worker_state_t

◆ dt_drawlayer_worker_t

Opaque worker state (thread, queue, stroke runtime).

Enumeration Type Documentation

◆ dt_drawlayer_worker_state_t

Enumerator
DT_DRAWLAYER_WORKER_STATE_STOPPED 
DT_DRAWLAYER_WORKER_STATE_IDLE 
DT_DRAWLAYER_WORKER_STATE_BUSY 
DT_DRAWLAYER_WORKER_STATE_PAUSING 
DT_DRAWLAYER_WORKER_STATE_PAUSED 

Function Documentation

◆ dt_drawlayer_worker_active()

gboolean dt_drawlayer_worker_active ( const dt_drawlayer_worker_t worker)

Query whether realtime/backend worker still has pending activity.

Query whether realtime/backend worker still has pending activity.

References _rt_workers_active().

Referenced by dt_drawlayer_begin_gui_stroke_capture().

◆ dt_drawlayer_worker_any_active()

gboolean dt_drawlayer_worker_any_active ( const dt_drawlayer_worker_t worker)

Query whether any worker still has pending activity, including full-resolution replay.

Query whether any worker still has pending activity, including full-resolution replay.

References _rt_workers_any_active().

Referenced by _drawlayer_modal_wait_tick(), dt_drawlayer_build_process_patch_from_base(), dt_drawlayer_flush_layer_cache(), dt_drawlayer_flush_process_patch_to_base(), and dt_drawlayer_wait_for_rasterization_modal().

◆ dt_drawlayer_worker_cleanup()

void dt_drawlayer_worker_cleanup ( dt_drawlayer_worker_t **  worker)

Stop worker and release all resources.

Stop worker and release all resources.

References _rt_cleanup_state().

Referenced by gui_cleanup().

◆ dt_drawlayer_worker_enqueue_input()

gboolean dt_drawlayer_worker_enqueue_input ( dt_drawlayer_worker_t worker,
const dt_drawlayer_paint_raw_input_t input 
)

Enqueue one raw input event (FIFO, no coalescing).

Enqueue one raw input event (FIFO, no coalescing).

References _enqueue_input(), and dt_drawlayer_worker_t::self.

Referenced by dt_drawlayer_runtime_manager_update().

◆ dt_drawlayer_worker_enqueue_stroke_end()

gboolean dt_drawlayer_worker_enqueue_stroke_end ( dt_drawlayer_worker_t worker,
const dt_drawlayer_paint_raw_input_t input 
)

Enqueue stroke-end marker carrying final raw input sample.

Enqueue stroke-end marker carrying final raw input sample.

References _enqueue_stroke_end(), and dt_drawlayer_worker_t::self.

Referenced by dt_drawlayer_runtime_manager_update().

◆ dt_drawlayer_worker_ensure_running()

gboolean dt_drawlayer_worker_ensure_running ( dt_iop_module_t self,
dt_drawlayer_worker_t worker 
)

Ensure realtime/backend worker threads are started.

References _start_worker().

Referenced by dt_drawlayer_runtime_manager_update().

◆ dt_drawlayer_worker_finished_stroke_queued()

gboolean dt_drawlayer_worker_finished_stroke_queued ( const dt_drawlayer_worker_t worker)

Query whether the current preserved stroke has already been handed off for full-resolution replay.

Query whether the current preserved stroke has already been handed off for full-resolution replay.

References FALSE, and dt_drawlayer_worker_t::finished_stroke_queued.

Referenced by dt_drawlayer_commit_dabs().

◆ dt_drawlayer_worker_flush_finished_strokes()

void dt_drawlayer_worker_flush_finished_strokes ( dt_drawlayer_worker_t worker)

Wait until deferred full-resolution replay queue is idle.

Wait until deferred full-resolution replay queue is idle.

References _wait_fullres_idle().

Referenced by dt_drawlayer_commit_dabs(), dt_drawlayer_flush_layer_cache(), dt_drawlayer_flush_process_patch_to_base(), and dt_drawlayer_runtime_manager_update().

◆ dt_drawlayer_worker_flush_pending()

void dt_drawlayer_worker_flush_pending ( dt_drawlayer_worker_t worker)

Flush pending events and force commit transition.

Flush pending events and force commit transition.

References _wait_worker_idle(), and dt_drawlayer_worker_t::self.

◆ dt_drawlayer_worker_get_snapshot()

◆ dt_drawlayer_worker_init()

void dt_drawlayer_worker_init ( dt_iop_module_t self,
dt_drawlayer_worker_t **  worker,
gboolean *  painting,
gboolean *  finish_commit_pending,
guint *  stroke_sample_count,
uint32_t *  current_stroke_batch,
dt_drawlayer_worker_finished_stroke_cb  finished_stroke_cb 
)

Initialize worker and bind external state mirrors.

Initialize worker and bind external state mirrors.

References _rt_init_state().

Referenced by gui_init().

◆ dt_drawlayer_worker_pending_dab_count()

guint dt_drawlayer_worker_pending_dab_count ( const dt_drawlayer_worker_t worker)

Return the number of interpolated-but-not-yet-rasterized dabs in the current stroke batch.

References dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_drawlayer_paint_stroke_t::pending_dabs, dt_drawlayer_worker_t::stroke, and dt_drawlayer_worker_t::worker_mutex.

Referenced by dt_drawlayer_build_process_patch_from_base().

◆ dt_drawlayer_worker_publish_backend_stroke_damage()

void dt_drawlayer_worker_publish_backend_stroke_damage ( dt_iop_module_t self)

Publish accumulated backend stroke damage into drawlayer process/runtime state.

References dt_drawlayer_paint_merge_runtime_stroke_damage(), g, dt_iop_module_t::gui_data, and TRUE.

Referenced by dt_drawlayer_commit_dabs().

◆ dt_drawlayer_worker_raw_inputs()

GArray * dt_drawlayer_worker_raw_inputs ( dt_drawlayer_worker_t worker)

Read-only access to preserved raw input queue for current stroke (valid only while worker is idle).

Read-only access to preserved raw input queue for current stroke (valid only while worker is idle).

References dt_drawlayer_worker_t::stroke_raw_inputs.

Referenced by dt_drawlayer_commit_dabs().

◆ dt_drawlayer_worker_replay_finished_stroke_to_base_patch()

gboolean dt_drawlayer_worker_replay_finished_stroke_to_base_patch ( dt_iop_module_t self,
const GArray *  raw_inputs 
)

Replay one finished stroke into the authoritative base patch from preserved raw inputs.

References _clamp01(), _dab_batch_supports_outer_loop(), _ensure_fullres_replay_float_buffer(), _get_fullres_replay_scratch(), _log_worker_batch_timing(), _paint_build_dab_cb(), _paint_emit_noop_cb(), _paint_layer_to_widget_cb(), _paint_stroke_seed_cb(), _worker_batch_min_size(), dt_drawlayer_paint_callbacks_t::build_dab, dt_drawlayer_paint_stroke_t::dab_window, darktable, dt_drawlayer_paint_stroke_t::distance_percent, DRAWLAYER_OUTER_FULLRES_BATCH_MULTIPLIER, dt_dev_pixelpipe_cache_flush_host_pinned_image(), dt_drawlayer_cache_patch_rdlock(), dt_drawlayer_cache_patch_rdunlock(), dt_drawlayer_cache_patch_wrlock(), dt_drawlayer_cache_patch_wrunlock(), dt_drawlayer_paint_finalize_path(), dt_drawlayer_paint_interpolate_path(), dt_drawlayer_paint_path_state_reset(), dt_drawlayer_paint_queue_raw_input(), dt_drawlayer_paint_raster_path(), dt_drawlayer_paint_runtime_note_dab_damage(), dt_drawlayer_paint_runtime_private_reset(), dt_get_wtime(), dt_iop_nap(), FALSE, g, dt_iop_module_t::gui_data, dt_drawlayer_paint_stroke_t::history, i, MIN, dt_drawlayer_damaged_rect_t::nw, dt_drawlayer_paint_stroke_t::pending_dabs, darktable_t::pixelpipe_cache, dt_drawlayer_brush_dab_t::radius, drawlayer_fullres_replay_scratch_t::replay_pixels, drawlayer_fullres_replay_scratch_t::replay_pixels_capacity, dt_drawlayer_damaged_rect_t::se, drawlayer_paint_backend_ctx_t::self, drawlayer_fullres_replay_scratch_t::stroke, drawlayer_fullres_replay_scratch_t::stroke_mask, drawlayer_fullres_replay_scratch_t::stroke_mask_capacity, TRUE, dt_drawlayer_damaged_rect_t::valid, dt_drawlayer_brush_dab_t::x, dt_drawlayer_cache_patch_t::x, and dt_drawlayer_brush_dab_t::y.

Referenced by dt_drawlayer_commit_dabs(), and gui_init().

◆ dt_drawlayer_worker_request_commit()

void dt_drawlayer_worker_request_commit ( dt_drawlayer_worker_t worker)

◆ dt_drawlayer_worker_reset_backend_path()

void dt_drawlayer_worker_reset_backend_path ( dt_drawlayer_worker_t worker)

◆ dt_drawlayer_worker_reset_live_publish()

void dt_drawlayer_worker_reset_live_publish ( dt_drawlayer_worker_t worker)

◆ dt_drawlayer_worker_reset_stroke()

void dt_drawlayer_worker_reset_stroke ( dt_drawlayer_worker_t worker)

Clear preserved stroke runtime/history after a completed commit.

Clear preserved stroke runtime/history after a completed commit.

References _reset_live_publish(), _stroke_clear(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and dt_drawlayer_worker_t::worker_mutex.

Referenced by dt_drawlayer_commit_dabs().

◆ dt_drawlayer_worker_seal_for_commit()

◆ dt_drawlayer_worker_stop()

void dt_drawlayer_worker_stop ( dt_iop_module_t self,
dt_drawlayer_worker_t worker 
)

Stop realtime and full-resolution worker threads.

References _stop_worker().

Referenced by dt_drawlayer_runtime_manager_update().

◆ dt_drawlayer_worker_stroke()

dt_drawlayer_paint_stroke_t * dt_drawlayer_worker_stroke ( dt_drawlayer_worker_t worker)

Read-only access to preserved stroke runtime (valid only while worker is idle).

Read-only access to preserved stroke runtime (valid only while worker is idle).

References dt_drawlayer_worker_t::stroke.

Referenced by dt_drawlayer_commit_dabs().