65 f->dev.pipe = &
f->pipe;
66 f->dev.preview_pipe = NULL;
78 f->dev.history = NULL;
79 dt_free(
f->dev.transient_params.params);
80 dt_free(
f->dev.transient_params.blend_params);
95 assert_non_null(item);
108 f->dev.history_end = 3;
117 assert_int_equal(g_list_length(snap.
items), 3);
118 assert_ptr_equal(g_list_nth_data(snap.
items, 0), a);
119 assert_ptr_equal(g_list_nth_data(snap.
items, 1), b);
120 assert_ptr_equal(g_list_nth_data(snap.
items, 2), c);
121 assert_int_equal(
_refs(a), 2);
122 assert_int_equal(
_refs(b), 2);
123 assert_int_equal(
_refs(c), 2);
130 assert_null(snap.
items);
131 assert_int_equal(
_refs(a), 1);
132 assert_int_equal(
_refs(b), 1);
133 assert_int_equal(
_refs(c), 1);
141 f->dev.history_end = 99;
156 assert_int_equal(
_refs(item), 1);
161 assert_ptr_equal(touched, item);
162 assert_int_equal(
_refs(item), 1);
163 assert_ptr_equal(g_list_nth_data(
f->dev.history, 0), item);
177 assert_int_equal(
_refs(original), 2);
182 assert_non_null(clone);
183 assert_ptr_not_equal(clone, original);
184 assert_ptr_equal(g_list_nth_data(
f->dev.history, 0), clone);
185 assert_int_equal(
_refs(clone), 1);
186 assert_int_equal(clone->
hash, original->
hash);
190 assert_ptr_equal(g_list_nth_data(snap.
items, 0), original);
191 assert_int_equal(
_refs(original), 1);
206 f->dev.history_end = 1;
212 assert_int_equal(
_refs(original), 2);
218 assert_int_equal(
_refs(original), 3);
221 assert_ptr_not_equal(clone, original);
226 assert_int_equal(
_refs(clone), 2);
227 assert_int_equal(
_refs(original), 1);
234 assert_int_equal(
_refs(clone), 1);
242 f->dev.history_end = 2;
253 assert_ptr_not_equal(clone, second);
257 assert_int_equal(
_refs(first), 3);
258 assert_int_equal(
_refs(clone), 1);
259 assert_int_equal(
_refs(second), 1);
285 module.dev = &f->dev;
287 uint32_t
params = 0x1111u;
295 assert_int_equal(
out, 0x1111u);
296 assert_true(first != 0u);
302 assert_int_equal(
out, 0x2222u);
303 assert_true(second != first);
310 assert_true(repeat != second);
317 assert_int_equal(none, 0u);
320int main(
int argc,
char *argv[])
322 const struct CMUnitTest tests[] = {
332 return cmocka_run_group_tests(tests, NULL, NULL);
int dt_atomic_get_int(dt_atomic_int *var)
static void * dt_atomic_exch_ptr(dt_atomic_ptr *var, void *value)
static void * dt_atomic_get_ptr(const dt_atomic_ptr *var)
static void dt_atomic_set_ptr(dt_atomic_ptr *var, void *value)
const dt_colormatrix_t dt_aligned_pixel_t out
gboolean dt_dev_transient_params_get(dt_develop_t *dev, const dt_iop_module_t *module, void *out_params, const size_t out_params_size, void *out_blend, const size_t out_blend_size, gboolean *out_has_blend, uint64_t *out_serial)
void dt_dev_history_snapshot_release(dt_dev_history_snapshot_t *snapshot)
Release every reference a snapshot holds and reset it. Needs no lock.
dt_dev_history_item_t * dt_dev_history_item_create(void)
Allocate a fresh, blank history item with refcount 1.
void dt_dev_transient_params_set(dt_iop_module_t *module, const void *params, const size_t params_size, const void *blend_params, const size_t blend_size)
Out-of-history transient param channel.
void dt_dev_free_history_item(gpointer data)
Release a reference to a history item (used as GList free callback).
dt_dev_history_item_t * dt_dev_history_item_ref(dt_dev_history_item_t *item)
Take a reference on a history item. Pair with dt_dev_free_history_item().
void dt_dev_history_snapshot_take(dt_develop_t *dev, dt_dev_history_snapshot_t *snapshot) REQUIRES_SHARED(dev -> history_mutex)
Take a snapshot of dev->history. Caller holds history_mutex (reader suffices).
dt_dev_history_item_t * dt_dev_history_cow_touch(dt_develop_t *dev, dt_dev_history_item_t *hist)
Copy-on-write gate for mutating a history item in place.
static void dt_dev_set_history_hash(dt_develop_t *dev, const uint64_t history_hash)
static int dt_pthread_rwlock_unlock(dt_pthread_rwlock_t *rwlock) RELEASE_GENERIC(rwlock) NO_THREAD_SAFETY_ANALYSIS
static int dt_pthread_rwlock_rdlock(dt_pthread_rwlock_t *rwlock) ACQUIRE_SHARED(rwlock) NO_THREAD_SAFETY_ANALYSIS
static int dt_pthread_mutex_init(dt_pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr)
Initialise a mutex. With mutexattr NULL – which is how 54 of the 56 call sites in this tree spell it ...
static int dt_pthread_rwlock_destroy(dt_pthread_rwlock_t *lock)
static int dt_pthread_mutex_destroy(dt_pthread_mutex_t *mutex)
static int dt_pthread_rwlock_init(dt_pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr)
static const dt_iop_drawlayer_params_t * params
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
const float uint32_t state[4]
unsigned __int64 uint64_t
struct dt_iop_module_t *gboolean enabled
A reference-sharing snapshot of dev->history, for readers that outlive a lock.
struct dt_develop_t * dev
static void _history_end_is_clamped_to_the_list_at_snapshot_time(void **state)
static void _cow_touch_leaves_an_exclusively_owned_item_alone(void **state)
static int _setup(void **state)
static int _teardown(void **state)
static void _a_snapshot_references_every_item_and_releases_them(void **state)
static void _transient_params_serial_advances_with_every_publication(void **state)
A transient publication must be distinguishable from the one before it.
static void _cow_touch_ignores_a_marker_naming_a_different_item(void **state)
static void _cow_touch_repoints_the_pipe_marker_and_balances_every_reference(void **state)
static void _cow_touch_clones_an_item_a_snapshot_is_holding(void **state)
static dt_dev_history_item_t * _append(dt_develop_t *dev, const uint64_t hash)
static int _refs(const dt_dev_history_item_t *item)