gegl 0.4.0

GEGL Rust bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
// Generated by gir (https://github.com/gtk-rs/gir @ 36917718ae60)
// from
// from gir-files (https://github.com/gtk-rs/gir-files @ 4488813a3fc3)
// DO NOT EDIT

use crate::{ffi, Config, Node, Path, Rectangle, SerializeFlag, SplitStrategy, Stats};
use glib::translate::*;

//#[doc(alias = "gegl_apply_op")]
//pub fn apply_op(buffer: &Buffer, operation_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
//    unsafe { TODO: call ffi:gegl_apply_op() }
//}

//#[doc(alias = "gegl_apply_op_valist")]
//pub fn apply_op_valist(buffer: &Buffer, operation_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
//    unsafe { TODO: call ffi:gegl_apply_op_valist() }
//}

//#[doc(alias = "gegl_calloc")]
//pub fn calloc(size: usize, n_memb: i32) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_calloc() }
//}

#[doc(alias = "gegl_cl_disable")]
pub fn cl_disable() {
    unsafe {
        ffi::gegl_cl_disable();
    }
}

#[doc(alias = "gegl_cl_init")]
pub fn cl_init() -> Result<(), glib::Error> {
    unsafe {
        let mut error = std::ptr::null_mut();
        let is_ok = ffi::gegl_cl_init(&mut error);
        debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
        if error.is_null() {
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
    }
}

#[doc(alias = "gegl_cl_is_accelerated")]
pub fn cl_is_accelerated() -> bool {
    unsafe { from_glib(ffi::gegl_cl_is_accelerated()) }
}

#[doc(alias = "gegl_config")]
pub fn config() -> Config {
    unsafe { from_glib_none(ffi::gegl_config()) }
}

#[doc(alias = "gegl_create_chain")]
pub fn create_chain(
    ops: &str,
    op_start: &Node,
    op_end: &Node,
    time: f64,
    rel_dim: i32,
    path_root: &str,
) -> Result<(), glib::Error> {
    unsafe {
        let mut error = std::ptr::null_mut();
        let _ = ffi::gegl_create_chain(
            ops.to_glib_none().0,
            op_start.to_glib_none().0,
            op_end.to_glib_none().0,
            time,
            rel_dim,
            path_root.to_glib_none().0,
            &mut error,
        );
        if error.is_null() {
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
    }
}

#[doc(alias = "gegl_exit")]
pub fn exit() {
    unsafe {
        ffi::gegl_exit();
    }
}

//#[doc(alias = "gegl_filter_op")]
//pub fn filter_op(source_buffer: &Buffer, operation_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option<Buffer> {
//    unsafe { TODO: call ffi:gegl_filter_op() }
//}

//#[doc(alias = "gegl_filter_op_valist")]
//pub fn filter_op_valist(source_buffer: &Buffer, operation_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<Buffer> {
//    unsafe { TODO: call ffi:gegl_filter_op_valist() }
//}

#[doc(alias = "gegl_format")]
pub fn format(format_name: &str) -> Option<glib::Value> {
    unsafe { from_glib_full(ffi::gegl_format(format_name.to_glib_none().0)) }
}

#[doc(alias = "gegl_format_get_name")]
pub fn format_get_name(format: &mut glib::Value) -> Option<glib::GString> {
    unsafe { from_glib_none(ffi::gegl_format_get_name(format.to_glib_none_mut().0)) }
}

//#[doc(alias = "gegl_free")]
//pub fn free(mem: /*Unimplemented*/Option<Basic: Pointer>) {
//    unsafe { TODO: call ffi:gegl_free() }
//}

#[doc(alias = "gegl_get_version")]
#[doc(alias = "get_version")]
pub fn version() -> (i32, i32, i32) {
    unsafe {
        let mut major = std::mem::MaybeUninit::uninit();
        let mut minor = std::mem::MaybeUninit::uninit();
        let mut micro = std::mem::MaybeUninit::uninit();
        ffi::gegl_get_version(major.as_mut_ptr(), minor.as_mut_ptr(), micro.as_mut_ptr());
        (
            major.assume_init(),
            minor.assume_init(),
            micro.assume_init(),
        )
    }
}

#[doc(alias = "gegl_graph_dump_outputs")]
pub fn graph_dump_outputs(node: &Node) {
    unsafe {
        ffi::gegl_graph_dump_outputs(node.to_glib_none().0);
    }
}

#[doc(alias = "gegl_graph_dump_request")]
pub fn graph_dump_request(node: &Node, roi: &Rectangle) {
    unsafe {
        ffi::gegl_graph_dump_request(node.to_glib_none().0, roi.to_glib_none().0);
    }
}

#[doc(alias = "gegl_has_operation")]
pub fn has_operation(operation_type: &str) -> bool {
    unsafe { from_glib(ffi::gegl_has_operation(operation_type.to_glib_none().0)) }
}

//#[doc(alias = "gegl_init")]
//pub fn init(argv: /*Unimplemented*/Vec<glib::GString>) {
//    unsafe { TODO: call ffi:gegl_init() }
//}

#[doc(alias = "gegl_is_main_thread")]
pub fn is_main_thread() -> bool {
    unsafe { from_glib(ffi::gegl_is_main_thread()) }
}

#[doc(alias = "gegl_list_operations")]
pub fn list_operations() -> Vec<glib::GString> {
    unsafe {
        let mut n_operations_p = std::mem::MaybeUninit::uninit();
        let ret = FromGlibContainer::from_glib_container_num(
            ffi::gegl_list_operations(n_operations_p.as_mut_ptr()),
            n_operations_p.assume_init() as _,
        );
        ret
    }
}

#[doc(alias = "gegl_load_module_directory")]
pub fn load_module_directory(path: &str) {
    unsafe {
        ffi::gegl_load_module_directory(path.to_glib_none().0);
    }
}

//#[doc(alias = "gegl_malloc")]
//pub fn malloc(n_bytes: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_malloc() }
//}

//#[doc(alias = "gegl_memeq_zero")]
//pub fn memeq_zero(ptr: /*Unimplemented*/Option<Basic: Pointer>, size: usize) -> bool {
//    unsafe { TODO: call ffi:gegl_memeq_zero() }
//}

//#[doc(alias = "gegl_memset_pattern")]
//pub fn memset_pattern(dst_ptr: /*Unimplemented*/Option<Basic: Pointer>, src_ptr: /*Unimplemented*/Option<Basic: Pointer>, pattern_size: i32, count: i32) {
//    unsafe { TODO: call ffi:gegl_memset_pattern() }
//}

#[doc(alias = "gegl_parallel_distribute")]
pub fn parallel_distribute<P: FnMut(i32, i32)>(max_n: i32, func: P) {
    let mut func_data: P = func;
    unsafe extern "C" fn func_func<P: FnMut(i32, i32)>(
        i: std::ffi::c_int,
        n: std::ffi::c_int,
        user_data: glib::ffi::gpointer,
    ) {
        unsafe {
            let callback = user_data as *mut P;
            (*callback)(i, n)
        }
    }
    let func = Some(func_func::<P> as _);
    let super_callback0: &mut P = &mut func_data;
    unsafe {
        ffi::gegl_parallel_distribute(max_n, func, super_callback0 as *mut _ as *mut _);
    }
}

#[doc(alias = "gegl_parallel_distribute_area")]
pub fn parallel_distribute_area<P: FnMut(&Rectangle)>(
    area: &Rectangle,
    thread_cost: f64,
    split_strategy: SplitStrategy,
    func: P,
) {
    let mut func_data: P = func;
    unsafe extern "C" fn func_func<P: FnMut(&Rectangle)>(
        area: *const ffi::GeglRectangle,
        user_data: glib::ffi::gpointer,
    ) {
        unsafe {
            let area = from_glib_borrow(area);
            let callback = user_data as *mut P;
            (*callback)(&area)
        }
    }
    let func = Some(func_func::<P> as _);
    let super_callback0: &mut P = &mut func_data;
    unsafe {
        ffi::gegl_parallel_distribute_area(
            area.to_glib_none().0,
            thread_cost,
            split_strategy.into_glib(),
            func,
            super_callback0 as *mut _ as *mut _,
        );
    }
}

#[doc(alias = "gegl_parallel_distribute_range")]
pub fn parallel_distribute_range<P: FnMut(usize, usize)>(size: usize, thread_cost: f64, func: P) {
    let mut func_data: P = func;
    unsafe extern "C" fn func_func<P: FnMut(usize, usize)>(
        offset: libc::size_t,
        size: libc::size_t,
        user_data: glib::ffi::gpointer,
    ) {
        unsafe {
            let callback = user_data as *mut P;
            (*callback)(offset, size)
        }
    }
    let func = Some(func_func::<P> as _);
    let super_callback0: &mut P = &mut func_data;
    unsafe {
        ffi::gegl_parallel_distribute_range(
            size,
            thread_cost,
            func,
            super_callback0 as *mut _ as *mut _,
        );
    }
}

#[doc(alias = "gegl_param_spec_audio_fragment")]
pub fn param_spec_audio_fragment(
    name: &str,
    nick: &str,
    blurb: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_audio_fragment(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_color_from_string")]
pub fn param_spec_color_from_string(
    name: &str,
    nick: &str,
    blurb: &str,
    default_color_string: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_color_from_string(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            default_color_string.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

//#[doc(alias = "gegl_param_spec_curve")]
//pub fn param_spec_curve(name: &str, nick: &str, blurb: &str, default_curve: /*Ignored*/&Curve, flags: glib::ParamFlags) -> Option<glib::ParamSpec> {
//    unsafe { TODO: call ffi:gegl_param_spec_curve() }
//}

#[doc(alias = "gegl_param_spec_double")]
pub fn param_spec_double(
    name: &str,
    nick: &str,
    blurb: &str,
    minimum: f64,
    maximum: f64,
    default_value: f64,
    ui_minimum: f64,
    ui_maximum: f64,
    ui_gamma: f64,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_double(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            minimum,
            maximum,
            default_value,
            ui_minimum,
            ui_maximum,
            ui_gamma,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_enum")]
pub fn param_spec_enum(
    name: &str,
    nick: &str,
    blurb: &str,
    enum_type: glib::types::Type,
    default_value: i32,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_enum(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            enum_type.into_glib(),
            default_value,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_file_path")]
pub fn param_spec_file_path(
    name: &str,
    nick: &str,
    blurb: &str,
    no_validate: bool,
    null_ok: bool,
    default_value: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_file_path(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            no_validate.into_glib(),
            null_ok.into_glib(),
            default_value.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_format")]
pub fn param_spec_format(
    name: &str,
    nick: &str,
    blurb: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_format(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_int")]
pub fn param_spec_int(
    name: &str,
    nick: &str,
    blurb: &str,
    minimum: i32,
    maximum: i32,
    default_value: i32,
    ui_minimum: i32,
    ui_maximum: i32,
    ui_gamma: f64,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_int(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            minimum,
            maximum,
            default_value,
            ui_minimum,
            ui_maximum,
            ui_gamma,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_path")]
pub fn param_spec_path(
    name: &str,
    nick: &str,
    blurb: &str,
    default_path: &Path,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_path(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            default_path.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_seed")]
pub fn param_spec_seed(
    name: &str,
    nick: &str,
    blurb: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_seed(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_string")]
pub fn param_spec_string(
    name: &str,
    nick: &str,
    blurb: &str,
    no_validate: bool,
    null_ok: bool,
    default_value: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_string(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            no_validate.into_glib(),
            null_ok.into_glib(),
            default_value.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_param_spec_uri")]
pub fn param_spec_uri(
    name: &str,
    nick: &str,
    blurb: &str,
    no_validate: bool,
    null_ok: bool,
    default_value: &str,
    flags: glib::ParamFlags,
) -> Option<glib::ParamSpec> {
    unsafe {
        from_glib_full(ffi::gegl_param_spec_uri(
            name.to_glib_none().0,
            nick.to_glib_none().0,
            blurb.to_glib_none().0,
            no_validate.into_glib(),
            null_ok.into_glib(),
            default_value.to_glib_none().0,
            flags.into_glib(),
        ))
    }
}

//#[doc(alias = "gegl_render_op")]
//pub fn render_op(source_buffer: &Buffer, target_buffer: &Buffer, operation_name: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) {
//    unsafe { TODO: call ffi:gegl_render_op() }
//}

//#[doc(alias = "gegl_render_op_valist")]
//pub fn render_op_valist(source_buffer: &Buffer, target_buffer: &Buffer, operation_name: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) {
//    unsafe { TODO: call ffi:gegl_render_op_valist() }
//}

#[doc(alias = "gegl_reset_stats")]
pub fn reset_stats() {
    unsafe {
        ffi::gegl_reset_stats();
    }
}

//#[doc(alias = "gegl_scratch_alloc")]
//pub fn scratch_alloc(size: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_scratch_alloc() }
//}

//#[doc(alias = "gegl_scratch_alloc0")]
//pub fn scratch_alloc0(size: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_scratch_alloc0() }
//}

//#[doc(alias = "gegl_scratch_free")]
//pub fn scratch_free(ptr: /*Unimplemented*/Option<Basic: Pointer>) {
//    unsafe { TODO: call ffi:gegl_scratch_free() }
//}

#[doc(alias = "gegl_serialize")]
pub fn serialize(
    start: &Node,
    end: &Node,
    basepath: &str,
    serialize_flags: SerializeFlag,
) -> Option<glib::GString> {
    unsafe {
        from_glib_full(ffi::gegl_serialize(
            start.to_glib_none().0,
            end.to_glib_none().0,
            basepath.to_glib_none().0,
            serialize_flags.into_glib(),
        ))
    }
}

#[doc(alias = "gegl_stats")]
pub fn stats() -> Option<Stats> {
    unsafe { from_glib_none(ffi::gegl_stats()) }
}

//#[doc(alias = "gegl_try_malloc")]
//pub fn try_malloc(n_bytes: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
//    unsafe { TODO: call ffi:gegl_try_malloc() }
//}