![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Background stroke worker API for drawlayer realtime painting. More...
#include "iop/iop_api.h"#include "iop/drawlayer/common.h"#include "iop/drawlayer/paint.h"#include "develop/imageop.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 |
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) |
| 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. | |
| 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_snapshot_params (dt_drawlayer_worker_t *worker, const dt_iop_drawlayer_params_t *params) |
| 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. | |
| gboolean | dt_drawlayer_worker_wait_idle (dt_iop_module_t *self, dt_drawlayer_worker_t *worker) |
| Wait until the worker queue is drained and the thread is not busy. | |
| void | dt_drawlayer_worker_pause (dt_iop_module_t *self, dt_drawlayer_worker_t *worker) |
| Pause worker processing once the current callback returns. | |
| void | dt_drawlayer_worker_resume (dt_iop_module_t *self, dt_drawlayer_worker_t *worker) |
| Resume worker processing and wake the sleeping thread. | |
| void | dt_drawlayer_worker_cancel_async_commit (dt_drawlayer_worker_t *worker) |
| Cancel the deferred commit request state, if any. | |
| void | dt_drawlayer_worker_seal_for_commit (dt_drawlayer_worker_t *worker) |
| Seal current stroke for synchronous commit. | |
| 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). | |
| 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. | |
Background stroke worker API for drawlayer realtime painting.
Definition in file worker.h.
| typedef struct dt_drawlayer_worker_snapshot_t dt_drawlayer_worker_snapshot_t |
| typedef enum dt_drawlayer_worker_state_t dt_drawlayer_worker_state_t |
| typedef struct dt_drawlayer_worker_t dt_drawlayer_worker_t |
| 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.
Definition at line 1716 of file worker.c.
References _rt_workers_active().
Referenced by dt_drawlayer_begin_gui_stroke_capture().
| gboolean dt_drawlayer_worker_any_active | ( | const dt_drawlayer_worker_t * | worker | ) |
Query whether any worker still has pending activity.
Query whether any worker still has pending activity.
Definition at line 1722 of file worker.c.
References _rt_workers_any_active().
Referenced by _drawlayer_modal_wait_tick(), dt_drawlayer_flush_layer_cache(), and dt_drawlayer_wait_for_rasterization_modal().
| void dt_drawlayer_worker_cancel_async_commit | ( | dt_drawlayer_worker_t * | rt | ) |
Cancel the deferred commit request state, if any.
Cancel the deferred commit request state, if any.
Definition at line 1560 of file worker.c.
References dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, dt_drawlayer_worker_t::finish_commit_pending, IS_NULL_PTR, and dt_drawlayer_worker_t::worker_mutex.
Referenced by _stop_worker(), and dt_drawlayer_commit_dabs().
| void dt_drawlayer_worker_cleanup | ( | dt_drawlayer_worker_t ** | worker | ) |
Stop worker and release all resources.
Stop worker and release all resources.
Definition at line 1710 of file worker.c.
References _rt_cleanup_state().
Referenced by gui_cleanup().
| 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).
Definition at line 1817 of file worker.c.
References _enqueue_input(), and dt_drawlayer_worker_t::self.
Referenced by dt_drawlayer_runtime_manager_update().
| 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.
Definition at line 1824 of file worker.c.
References _enqueue_stroke_end(), and dt_drawlayer_worker_t::self.
Referenced by dt_drawlayer_runtime_manager_update().
| gboolean dt_drawlayer_worker_ensure_running | ( | dt_iop_module_t * | self, |
| dt_drawlayer_worker_t * | worker | ||
| ) |
Ensure realtime/backend worker threads are started.
Definition at line 1727 of file worker.c.
References _start_worker().
Referenced by dt_drawlayer_runtime_manager_update().
| 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.
Definition at line 1737 of file worker.c.
References _backend_worker_const(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_drawlayer_worker_t::finish_commit_pending, IS_NULL_PTR, drawlayer_rt_worker_t::ring_count, drawlayer_rt_worker_t::state, and dt_drawlayer_worker_t::worker_mutex.
Referenced by _collect_runtime_inputs().
| 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 | ||
| ) |
Initialize worker and bind external state mirrors.
Initialize worker and bind external state mirrors.
Definition at line 1702 of file worker.c.
References _rt_init_state().
Referenced by gui_init().
| void dt_drawlayer_worker_pause | ( | dt_iop_module_t * | self, |
| dt_drawlayer_worker_t * | rt | ||
| ) |
Pause worker processing once the current callback returns.
Pause worker processing once the current callback returns.
Definition at line 1600 of file worker.c.
References _backend_worker(), _worker_is_busy(), _worker_is_started(), DT_DRAWLAYER_WORKER_STATE_PAUSED, DT_DRAWLAYER_WORKER_STATE_PAUSING, dt_pthread_cond_wait(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, drawlayer_rt_worker_t::state, drawlayer_rt_worker_t::stop, void(), dt_drawlayer_worker_t::worker_cond, and dt_drawlayer_worker_t::worker_mutex.
Referenced by dt_drawlayer_sync_widget_cache().
| void dt_drawlayer_worker_publish_backend_stroke_damage | ( | dt_iop_module_t * | self | ) |
Publish accumulated backend stroke damage into drawlayer process/runtime state.
Definition at line 389 of file worker.c.
References dt_drawlayer_paint_merge_runtime_stroke_damage(), dt_drawlayer_paint_runtime_note_dab_damage(), dt_iop_gui_data(), g, IS_NULL_PTR, and TRUE.
Referenced by dt_drawlayer_commit_dabs().
| 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).
Definition at line 1811 of file worker.c.
References dt_drawlayer_worker_t::stroke_raw_inputs.
| void dt_drawlayer_worker_request_commit | ( | dt_drawlayer_worker_t * | worker | ) |
Request asynchronous commit once queues become idle.
Request asynchronous commit once queues become idle.
Definition at line 1753 of file worker.c.
References dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_drawlayer_worker_t::finish_commit_pending, IS_NULL_PTR, TRUE, dt_drawlayer_worker_t::worker_cond, and dt_drawlayer_worker_t::worker_mutex.
Referenced by dt_drawlayer_commit_dabs(), and dt_drawlayer_runtime_manager_update().
| void dt_drawlayer_worker_reset_backend_path | ( | dt_drawlayer_worker_t * | worker | ) |
Reset worker-owned backend damage accumulator.
Definition at line 1784 of file worker.c.
References _reset_backend_path(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and dt_drawlayer_worker_t::worker_mutex.
Referenced by _ensure_widget_cache(), dt_drawlayer_begin_gui_stroke_capture(), and dt_drawlayer_layers_reset_stroke_session().
| void dt_drawlayer_worker_reset_live_publish | ( | dt_drawlayer_worker_t * | worker | ) |
Reset worker-owned transient live-publish state.
Definition at line 1792 of file worker.c.
References _reset_live_publish(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and dt_drawlayer_worker_t::worker_mutex.
Referenced by dt_drawlayer_begin_gui_stroke_capture(), and dt_drawlayer_layers_reset_stroke_session().
| 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.
Definition at line 1801 of file worker.c.
References _reset_live_publish(), _stroke_clear(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and dt_drawlayer_worker_t::worker_mutex.
Referenced by dt_drawlayer_commit_dabs().
| void dt_drawlayer_worker_resume | ( | dt_iop_module_t * | self, |
| dt_drawlayer_worker_t * | rt | ||
| ) |
Resume worker processing and wake the sleeping thread.
Resume worker processing and wake the sleeping thread.
Definition at line 1615 of file worker.c.
References _backend_worker(), _worker_is_started(), DT_DRAWLAYER_WORKER_STATE_IDLE, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, drawlayer_rt_worker_t::state, void(), dt_drawlayer_worker_t::worker_cond, and dt_drawlayer_worker_t::worker_mutex.
Referenced by dt_drawlayer_sync_widget_cache().
| void dt_drawlayer_worker_seal_for_commit | ( | dt_drawlayer_worker_t * | worker | ) |
Seal current stroke for synchronous commit.
Definition at line 1779 of file worker.c.
References void().
Referenced by dt_drawlayer_commit_dabs().
| void dt_drawlayer_worker_snapshot_params | ( | dt_drawlayer_worker_t * | worker, |
| const dt_iop_drawlayer_params_t * | params | ||
| ) |
Flush pending events and force commit transition.
Flush pending events and force commit transition.
dt_drawlayer_touch_stroke_commit_hash is an ACCUMULATOR — it chains from whatever the blob already holds and keeps the field non-zero so "never updated" stays distinguishable. So the private copy is seeded, never zeroed, or the heartbeat would restart the chain from the 5381 seed and the commit would observe a different invariant than the one drawlayer.c documents.
Definition at line 1770 of file worker.c.
References dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, params, dt_drawlayer_worker_t::publish_params, and dt_drawlayer_worker_t::worker_mutex.
Referenced by dt_drawlayer_begin_gui_stroke_capture().
| void dt_drawlayer_worker_stop | ( | dt_iop_module_t * | self, |
| dt_drawlayer_worker_t * | worker | ||
| ) |
Stop realtime and full-resolution worker threads.
Definition at line 1732 of file worker.c.
References _stop_worker().
Referenced by dt_drawlayer_runtime_manager_update(), and quiesce().
| gboolean dt_drawlayer_worker_wait_idle | ( | dt_iop_module_t * | self, |
| dt_drawlayer_worker_t * | rt | ||
| ) |
Wait until the worker queue is drained and the thread is not busy.
Wait until the worker queue is drained and the thread is not busy.
Definition at line 1415 of file worker.c.
References _backend_worker_const(), _worker_is_busy(), _worker_is_started(), DT_DEBUG_ALWAYS, dt_print(), dt_pthread_cond_wait(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, drawlayer_rt_worker_t::ring_count, drawlayer_rt_worker_t::stop, drawlayer_rt_worker_t::thread, drawlayer_rt_worker_t::thread_started, TRUE, void(), dt_drawlayer_worker_t::worker_cond, and dt_drawlayer_worker_t::worker_mutex.
Referenced by _stop_worker(), dt_drawlayer_commit_dabs(), and dt_drawlayer_flush_layer_cache().