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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::error::ErrorDomain;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::ToValue;
use glib::Quark;
use glib::StaticType;
use glib::Type;
use std::fmt;

/// The blend modes available for render nodes.
///
/// The implementation of each blend mode is deferred to the
/// rendering pipeline.
///
/// See <https://www.w3.org/TR/compositing-1/#blending> for more information
/// on blending and blend modes.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskBlendMode")]
pub enum BlendMode {
    /// The default blend mode, which specifies no blending
    #[doc(alias = "GSK_BLEND_MODE_DEFAULT")]
    Default,
    /// The source color is multiplied by the destination
    ///   and replaces the destination
    #[doc(alias = "GSK_BLEND_MODE_MULTIPLY")]
    Multiply,
    /// Multiplies the complements of the destination and source
    ///   color values, then complements the result.
    #[doc(alias = "GSK_BLEND_MODE_SCREEN")]
    Screen,
    /// Multiplies or screens the colors, depending on the
    ///   destination color value. This is the inverse of hard-list
    #[doc(alias = "GSK_BLEND_MODE_OVERLAY")]
    Overlay,
    /// Selects the darker of the destination and source colors
    #[doc(alias = "GSK_BLEND_MODE_DARKEN")]
    Darken,
    /// Selects the lighter of the destination and source colors
    #[doc(alias = "GSK_BLEND_MODE_LIGHTEN")]
    Lighten,
    /// Brightens the destination color to reflect the source color
    #[doc(alias = "GSK_BLEND_MODE_COLOR_DODGE")]
    ColorDodge,
    /// Darkens the destination color to reflect the source color
    #[doc(alias = "GSK_BLEND_MODE_COLOR_BURN")]
    ColorBurn,
    /// Multiplies or screens the colors, depending on the source color value
    #[doc(alias = "GSK_BLEND_MODE_HARD_LIGHT")]
    HardLight,
    /// Darkens or lightens the colors, depending on the source color value
    #[doc(alias = "GSK_BLEND_MODE_SOFT_LIGHT")]
    SoftLight,
    /// Subtracts the darker of the two constituent colors from the lighter color
    #[doc(alias = "GSK_BLEND_MODE_DIFFERENCE")]
    Difference,
    /// Produces an effect similar to that of the difference mode but lower in contrast
    #[doc(alias = "GSK_BLEND_MODE_EXCLUSION")]
    Exclusion,
    /// Creates a color with the hue and saturation of the source color and the luminosity of the destination color
    #[doc(alias = "GSK_BLEND_MODE_COLOR")]
    Color,
    /// Creates a color with the hue of the source color and the saturation and luminosity of the destination color
    #[doc(alias = "GSK_BLEND_MODE_HUE")]
    Hue,
    /// Creates a color with the saturation of the source color and the hue and luminosity of the destination color
    #[doc(alias = "GSK_BLEND_MODE_SATURATION")]
    Saturation,
    /// Creates a color with the luminosity of the source color and the hue and saturation of the destination color
    #[doc(alias = "GSK_BLEND_MODE_LUMINOSITY")]
    Luminosity,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for BlendMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "BlendMode::{}",
            match *self {
                Self::Default => "Default",
                Self::Multiply => "Multiply",
                Self::Screen => "Screen",
                Self::Overlay => "Overlay",
                Self::Darken => "Darken",
                Self::Lighten => "Lighten",
                Self::ColorDodge => "ColorDodge",
                Self::ColorBurn => "ColorBurn",
                Self::HardLight => "HardLight",
                Self::SoftLight => "SoftLight",
                Self::Difference => "Difference",
                Self::Exclusion => "Exclusion",
                Self::Color => "Color",
                Self::Hue => "Hue",
                Self::Saturation => "Saturation",
                Self::Luminosity => "Luminosity",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for BlendMode {
    type GlibType = ffi::GskBlendMode;

    fn into_glib(self) -> ffi::GskBlendMode {
        match self {
            Self::Default => ffi::GSK_BLEND_MODE_DEFAULT,
            Self::Multiply => ffi::GSK_BLEND_MODE_MULTIPLY,
            Self::Screen => ffi::GSK_BLEND_MODE_SCREEN,
            Self::Overlay => ffi::GSK_BLEND_MODE_OVERLAY,
            Self::Darken => ffi::GSK_BLEND_MODE_DARKEN,
            Self::Lighten => ffi::GSK_BLEND_MODE_LIGHTEN,
            Self::ColorDodge => ffi::GSK_BLEND_MODE_COLOR_DODGE,
            Self::ColorBurn => ffi::GSK_BLEND_MODE_COLOR_BURN,
            Self::HardLight => ffi::GSK_BLEND_MODE_HARD_LIGHT,
            Self::SoftLight => ffi::GSK_BLEND_MODE_SOFT_LIGHT,
            Self::Difference => ffi::GSK_BLEND_MODE_DIFFERENCE,
            Self::Exclusion => ffi::GSK_BLEND_MODE_EXCLUSION,
            Self::Color => ffi::GSK_BLEND_MODE_COLOR,
            Self::Hue => ffi::GSK_BLEND_MODE_HUE,
            Self::Saturation => ffi::GSK_BLEND_MODE_SATURATION,
            Self::Luminosity => ffi::GSK_BLEND_MODE_LUMINOSITY,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskBlendMode> for BlendMode {
    unsafe fn from_glib(value: ffi::GskBlendMode) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_BLEND_MODE_DEFAULT => Self::Default,
            ffi::GSK_BLEND_MODE_MULTIPLY => Self::Multiply,
            ffi::GSK_BLEND_MODE_SCREEN => Self::Screen,
            ffi::GSK_BLEND_MODE_OVERLAY => Self::Overlay,
            ffi::GSK_BLEND_MODE_DARKEN => Self::Darken,
            ffi::GSK_BLEND_MODE_LIGHTEN => Self::Lighten,
            ffi::GSK_BLEND_MODE_COLOR_DODGE => Self::ColorDodge,
            ffi::GSK_BLEND_MODE_COLOR_BURN => Self::ColorBurn,
            ffi::GSK_BLEND_MODE_HARD_LIGHT => Self::HardLight,
            ffi::GSK_BLEND_MODE_SOFT_LIGHT => Self::SoftLight,
            ffi::GSK_BLEND_MODE_DIFFERENCE => Self::Difference,
            ffi::GSK_BLEND_MODE_EXCLUSION => Self::Exclusion,
            ffi::GSK_BLEND_MODE_COLOR => Self::Color,
            ffi::GSK_BLEND_MODE_HUE => Self::Hue,
            ffi::GSK_BLEND_MODE_SATURATION => Self::Saturation,
            ffi::GSK_BLEND_MODE_LUMINOSITY => Self::Luminosity,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for BlendMode {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_blend_mode_get_type()) }
    }
}

impl glib::value::ValueType for BlendMode {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for BlendMode {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for BlendMode {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

/// The corner indices used by [`RoundedRect`][crate::RoundedRect].
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskCorner")]
pub enum Corner {
    /// The top left corner
    #[doc(alias = "GSK_CORNER_TOP_LEFT")]
    TopLeft,
    /// The top right corner
    #[doc(alias = "GSK_CORNER_TOP_RIGHT")]
    TopRight,
    /// The bottom right corner
    #[doc(alias = "GSK_CORNER_BOTTOM_RIGHT")]
    BottomRight,
    /// The bottom left corner
    #[doc(alias = "GSK_CORNER_BOTTOM_LEFT")]
    BottomLeft,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for Corner {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "Corner::{}",
            match *self {
                Self::TopLeft => "TopLeft",
                Self::TopRight => "TopRight",
                Self::BottomRight => "BottomRight",
                Self::BottomLeft => "BottomLeft",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for Corner {
    type GlibType = ffi::GskCorner;

    fn into_glib(self) -> ffi::GskCorner {
        match self {
            Self::TopLeft => ffi::GSK_CORNER_TOP_LEFT,
            Self::TopRight => ffi::GSK_CORNER_TOP_RIGHT,
            Self::BottomRight => ffi::GSK_CORNER_BOTTOM_RIGHT,
            Self::BottomLeft => ffi::GSK_CORNER_BOTTOM_LEFT,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskCorner> for Corner {
    unsafe fn from_glib(value: ffi::GskCorner) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_CORNER_TOP_LEFT => Self::TopLeft,
            ffi::GSK_CORNER_TOP_RIGHT => Self::TopRight,
            ffi::GSK_CORNER_BOTTOM_RIGHT => Self::BottomRight,
            ffi::GSK_CORNER_BOTTOM_LEFT => Self::BottomLeft,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for Corner {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_corner_get_type()) }
    }
}

impl glib::value::ValueType for Corner {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for Corner {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for Corner {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

/// This defines the types of the uniforms that `GskGLShaders`
/// declare.
///
/// It defines both what the type is called in the GLSL shader
/// code, and what the corresponding C type is on the Gtk side.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskGLUniformType")]
pub enum GLUniformType {
    /// No type, used for uninitialized or unspecified values.
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_NONE")]
    None,
    /// A float uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_FLOAT")]
    Float,
    /// A GLSL int / gint32 uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_INT")]
    Int,
    /// A GLSL uint / guint32 uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_UINT")]
    Uint,
    /// A GLSL bool / gboolean uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_BOOL")]
    Bool,
    /// A GLSL vec2 / graphene_vec2_t uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_VEC2")]
    Vec2,
    /// A GLSL vec3 / graphene_vec3_t uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_VEC3")]
    Vec3,
    /// A GLSL vec4 / graphene_vec4_t uniform
    #[doc(alias = "GSK_GL_UNIFORM_TYPE_VEC4")]
    Vec4,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for GLUniformType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "GLUniformType::{}",
            match *self {
                Self::None => "None",
                Self::Float => "Float",
                Self::Int => "Int",
                Self::Uint => "Uint",
                Self::Bool => "Bool",
                Self::Vec2 => "Vec2",
                Self::Vec3 => "Vec3",
                Self::Vec4 => "Vec4",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for GLUniformType {
    type GlibType = ffi::GskGLUniformType;

    fn into_glib(self) -> ffi::GskGLUniformType {
        match self {
            Self::None => ffi::GSK_GL_UNIFORM_TYPE_NONE,
            Self::Float => ffi::GSK_GL_UNIFORM_TYPE_FLOAT,
            Self::Int => ffi::GSK_GL_UNIFORM_TYPE_INT,
            Self::Uint => ffi::GSK_GL_UNIFORM_TYPE_UINT,
            Self::Bool => ffi::GSK_GL_UNIFORM_TYPE_BOOL,
            Self::Vec2 => ffi::GSK_GL_UNIFORM_TYPE_VEC2,
            Self::Vec3 => ffi::GSK_GL_UNIFORM_TYPE_VEC3,
            Self::Vec4 => ffi::GSK_GL_UNIFORM_TYPE_VEC4,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskGLUniformType> for GLUniformType {
    unsafe fn from_glib(value: ffi::GskGLUniformType) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_GL_UNIFORM_TYPE_NONE => Self::None,
            ffi::GSK_GL_UNIFORM_TYPE_FLOAT => Self::Float,
            ffi::GSK_GL_UNIFORM_TYPE_INT => Self::Int,
            ffi::GSK_GL_UNIFORM_TYPE_UINT => Self::Uint,
            ffi::GSK_GL_UNIFORM_TYPE_BOOL => Self::Bool,
            ffi::GSK_GL_UNIFORM_TYPE_VEC2 => Self::Vec2,
            ffi::GSK_GL_UNIFORM_TYPE_VEC3 => Self::Vec3,
            ffi::GSK_GL_UNIFORM_TYPE_VEC4 => Self::Vec4,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for GLUniformType {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_gl_uniform_type_get_type()) }
    }
}

impl glib::value::ValueType for GLUniformType {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for GLUniformType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for GLUniformType {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

/// The type of a node determines what the node is rendering.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskRenderNodeType")]
pub enum RenderNodeType {
    /// Error type. No node will ever have this type.
    #[doc(alias = "GSK_NOT_A_RENDER_NODE")]
    NotARenderNode,
    /// A node containing a stack of children
    #[doc(alias = "GSK_CONTAINER_NODE")]
    ContainerNode,
    /// A node drawing a [`cairo::Surface`][crate::cairo::Surface]
    #[doc(alias = "GSK_CAIRO_NODE")]
    CairoNode,
    /// A node drawing a single color rectangle
    #[doc(alias = "GSK_COLOR_NODE")]
    ColorNode,
    /// A node drawing a linear gradient
    #[doc(alias = "GSK_LINEAR_GRADIENT_NODE")]
    LinearGradientNode,
    /// A node drawing a repeating linear gradient
    #[doc(alias = "GSK_REPEATING_LINEAR_GRADIENT_NODE")]
    RepeatingLinearGradientNode,
    /// A node drawing a radial gradient
    #[doc(alias = "GSK_RADIAL_GRADIENT_NODE")]
    RadialGradientNode,
    /// A node drawing a repeating radial gradient
    #[doc(alias = "GSK_REPEATING_RADIAL_GRADIENT_NODE")]
    RepeatingRadialGradientNode,
    /// A node drawing a conic gradient
    #[doc(alias = "GSK_CONIC_GRADIENT_NODE")]
    ConicGradientNode,
    /// A node stroking a border around an area
    #[doc(alias = "GSK_BORDER_NODE")]
    BorderNode,
    /// A node drawing a [`gdk::Texture`][crate::gdk::Texture]
    #[doc(alias = "GSK_TEXTURE_NODE")]
    TextureNode,
    /// A node drawing an inset shadow
    #[doc(alias = "GSK_INSET_SHADOW_NODE")]
    InsetShadowNode,
    /// A node drawing an outset shadow
    #[doc(alias = "GSK_OUTSET_SHADOW_NODE")]
    OutsetShadowNode,
    /// A node that renders its child after applying a matrix transform
    #[doc(alias = "GSK_TRANSFORM_NODE")]
    TransformNode,
    /// A node that changes the opacity of its child
    #[doc(alias = "GSK_OPACITY_NODE")]
    OpacityNode,
    /// A node that applies a color matrix to every pixel
    #[doc(alias = "GSK_COLOR_MATRIX_NODE")]
    ColorMatrixNode,
    /// A node that repeats the child's contents
    #[doc(alias = "GSK_REPEAT_NODE")]
    RepeatNode,
    /// A node that clips its child to a rectangular area
    #[doc(alias = "GSK_CLIP_NODE")]
    ClipNode,
    /// A node that clips its child to a rounded rectangle
    #[doc(alias = "GSK_ROUNDED_CLIP_NODE")]
    RoundedClipNode,
    /// A node that draws a shadow below its child
    #[doc(alias = "GSK_SHADOW_NODE")]
    ShadowNode,
    /// A node that blends two children together
    #[doc(alias = "GSK_BLEND_NODE")]
    BlendNode,
    /// A node that cross-fades between two children
    #[doc(alias = "GSK_CROSS_FADE_NODE")]
    CrossFadeNode,
    /// A node containing a glyph string
    #[doc(alias = "GSK_TEXT_NODE")]
    TextNode,
    /// A node that applies a blur
    #[doc(alias = "GSK_BLUR_NODE")]
    BlurNode,
    /// Debug information that does not affect the rendering
    #[doc(alias = "GSK_DEBUG_NODE")]
    DebugNode,
    /// A node that uses OpenGL fragment shaders to render
    #[doc(alias = "GSK_GL_SHADER_NODE")]
    GlShaderNode,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for RenderNodeType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "RenderNodeType::{}",
            match *self {
                Self::NotARenderNode => "NotARenderNode",
                Self::ContainerNode => "ContainerNode",
                Self::CairoNode => "CairoNode",
                Self::ColorNode => "ColorNode",
                Self::LinearGradientNode => "LinearGradientNode",
                Self::RepeatingLinearGradientNode => "RepeatingLinearGradientNode",
                Self::RadialGradientNode => "RadialGradientNode",
                Self::RepeatingRadialGradientNode => "RepeatingRadialGradientNode",
                Self::ConicGradientNode => "ConicGradientNode",
                Self::BorderNode => "BorderNode",
                Self::TextureNode => "TextureNode",
                Self::InsetShadowNode => "InsetShadowNode",
                Self::OutsetShadowNode => "OutsetShadowNode",
                Self::TransformNode => "TransformNode",
                Self::OpacityNode => "OpacityNode",
                Self::ColorMatrixNode => "ColorMatrixNode",
                Self::RepeatNode => "RepeatNode",
                Self::ClipNode => "ClipNode",
                Self::RoundedClipNode => "RoundedClipNode",
                Self::ShadowNode => "ShadowNode",
                Self::BlendNode => "BlendNode",
                Self::CrossFadeNode => "CrossFadeNode",
                Self::TextNode => "TextNode",
                Self::BlurNode => "BlurNode",
                Self::DebugNode => "DebugNode",
                Self::GlShaderNode => "GlShaderNode",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for RenderNodeType {
    type GlibType = ffi::GskRenderNodeType;

    fn into_glib(self) -> ffi::GskRenderNodeType {
        match self {
            Self::NotARenderNode => ffi::GSK_NOT_A_RENDER_NODE,
            Self::ContainerNode => ffi::GSK_CONTAINER_NODE,
            Self::CairoNode => ffi::GSK_CAIRO_NODE,
            Self::ColorNode => ffi::GSK_COLOR_NODE,
            Self::LinearGradientNode => ffi::GSK_LINEAR_GRADIENT_NODE,
            Self::RepeatingLinearGradientNode => ffi::GSK_REPEATING_LINEAR_GRADIENT_NODE,
            Self::RadialGradientNode => ffi::GSK_RADIAL_GRADIENT_NODE,
            Self::RepeatingRadialGradientNode => ffi::GSK_REPEATING_RADIAL_GRADIENT_NODE,
            Self::ConicGradientNode => ffi::GSK_CONIC_GRADIENT_NODE,
            Self::BorderNode => ffi::GSK_BORDER_NODE,
            Self::TextureNode => ffi::GSK_TEXTURE_NODE,
            Self::InsetShadowNode => ffi::GSK_INSET_SHADOW_NODE,
            Self::OutsetShadowNode => ffi::GSK_OUTSET_SHADOW_NODE,
            Self::TransformNode => ffi::GSK_TRANSFORM_NODE,
            Self::OpacityNode => ffi::GSK_OPACITY_NODE,
            Self::ColorMatrixNode => ffi::GSK_COLOR_MATRIX_NODE,
            Self::RepeatNode => ffi::GSK_REPEAT_NODE,
            Self::ClipNode => ffi::GSK_CLIP_NODE,
            Self::RoundedClipNode => ffi::GSK_ROUNDED_CLIP_NODE,
            Self::ShadowNode => ffi::GSK_SHADOW_NODE,
            Self::BlendNode => ffi::GSK_BLEND_NODE,
            Self::CrossFadeNode => ffi::GSK_CROSS_FADE_NODE,
            Self::TextNode => ffi::GSK_TEXT_NODE,
            Self::BlurNode => ffi::GSK_BLUR_NODE,
            Self::DebugNode => ffi::GSK_DEBUG_NODE,
            Self::GlShaderNode => ffi::GSK_GL_SHADER_NODE,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskRenderNodeType> for RenderNodeType {
    unsafe fn from_glib(value: ffi::GskRenderNodeType) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_NOT_A_RENDER_NODE => Self::NotARenderNode,
            ffi::GSK_CONTAINER_NODE => Self::ContainerNode,
            ffi::GSK_CAIRO_NODE => Self::CairoNode,
            ffi::GSK_COLOR_NODE => Self::ColorNode,
            ffi::GSK_LINEAR_GRADIENT_NODE => Self::LinearGradientNode,
            ffi::GSK_REPEATING_LINEAR_GRADIENT_NODE => Self::RepeatingLinearGradientNode,
            ffi::GSK_RADIAL_GRADIENT_NODE => Self::RadialGradientNode,
            ffi::GSK_REPEATING_RADIAL_GRADIENT_NODE => Self::RepeatingRadialGradientNode,
            ffi::GSK_CONIC_GRADIENT_NODE => Self::ConicGradientNode,
            ffi::GSK_BORDER_NODE => Self::BorderNode,
            ffi::GSK_TEXTURE_NODE => Self::TextureNode,
            ffi::GSK_INSET_SHADOW_NODE => Self::InsetShadowNode,
            ffi::GSK_OUTSET_SHADOW_NODE => Self::OutsetShadowNode,
            ffi::GSK_TRANSFORM_NODE => Self::TransformNode,
            ffi::GSK_OPACITY_NODE => Self::OpacityNode,
            ffi::GSK_COLOR_MATRIX_NODE => Self::ColorMatrixNode,
            ffi::GSK_REPEAT_NODE => Self::RepeatNode,
            ffi::GSK_CLIP_NODE => Self::ClipNode,
            ffi::GSK_ROUNDED_CLIP_NODE => Self::RoundedClipNode,
            ffi::GSK_SHADOW_NODE => Self::ShadowNode,
            ffi::GSK_BLEND_NODE => Self::BlendNode,
            ffi::GSK_CROSS_FADE_NODE => Self::CrossFadeNode,
            ffi::GSK_TEXT_NODE => Self::TextNode,
            ffi::GSK_BLUR_NODE => Self::BlurNode,
            ffi::GSK_DEBUG_NODE => Self::DebugNode,
            ffi::GSK_GL_SHADER_NODE => Self::GlShaderNode,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for RenderNodeType {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_render_node_type_get_type()) }
    }
}

impl glib::value::ValueType for RenderNodeType {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for RenderNodeType {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for RenderNodeType {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

/// The filters used when scaling texture data.
///
/// The actual implementation of each filter is deferred to the
/// rendering pipeline.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskScalingFilter")]
pub enum ScalingFilter {
    /// linear interpolation filter
    #[doc(alias = "GSK_SCALING_FILTER_LINEAR")]
    Linear,
    /// nearest neighbor interpolation filter
    #[doc(alias = "GSK_SCALING_FILTER_NEAREST")]
    Nearest,
    /// linear interpolation along each axis,
    ///   plus mipmap generation, with linear interpolation along the mipmap
    ///   levels
    #[doc(alias = "GSK_SCALING_FILTER_TRILINEAR")]
    Trilinear,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for ScalingFilter {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "ScalingFilter::{}",
            match *self {
                Self::Linear => "Linear",
                Self::Nearest => "Nearest",
                Self::Trilinear => "Trilinear",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for ScalingFilter {
    type GlibType = ffi::GskScalingFilter;

    fn into_glib(self) -> ffi::GskScalingFilter {
        match self {
            Self::Linear => ffi::GSK_SCALING_FILTER_LINEAR,
            Self::Nearest => ffi::GSK_SCALING_FILTER_NEAREST,
            Self::Trilinear => ffi::GSK_SCALING_FILTER_TRILINEAR,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskScalingFilter> for ScalingFilter {
    unsafe fn from_glib(value: ffi::GskScalingFilter) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_SCALING_FILTER_LINEAR => Self::Linear,
            ffi::GSK_SCALING_FILTER_NEAREST => Self::Nearest,
            ffi::GSK_SCALING_FILTER_TRILINEAR => Self::Trilinear,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for ScalingFilter {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_scaling_filter_get_type()) }
    }
}

impl glib::value::ValueType for ScalingFilter {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for ScalingFilter {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for ScalingFilter {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

/// Errors that can happen during (de)serialization.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskSerializationError")]
pub enum SerializationError {
    /// The format can not be identified
    #[doc(alias = "GSK_SERIALIZATION_UNSUPPORTED_FORMAT")]
    UnsupportedFormat,
    /// The version of the data is not
    ///   understood
    #[doc(alias = "GSK_SERIALIZATION_UNSUPPORTED_VERSION")]
    UnsupportedVersion,
    /// The given data may not exist in
    ///   a proper serialization
    #[doc(alias = "GSK_SERIALIZATION_INVALID_DATA")]
    InvalidData,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for SerializationError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "SerializationError::{}",
            match *self {
                Self::UnsupportedFormat => "UnsupportedFormat",
                Self::UnsupportedVersion => "UnsupportedVersion",
                Self::InvalidData => "InvalidData",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for SerializationError {
    type GlibType = ffi::GskSerializationError;

    fn into_glib(self) -> ffi::GskSerializationError {
        match self {
            Self::UnsupportedFormat => ffi::GSK_SERIALIZATION_UNSUPPORTED_FORMAT,
            Self::UnsupportedVersion => ffi::GSK_SERIALIZATION_UNSUPPORTED_VERSION,
            Self::InvalidData => ffi::GSK_SERIALIZATION_INVALID_DATA,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskSerializationError> for SerializationError {
    unsafe fn from_glib(value: ffi::GskSerializationError) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_SERIALIZATION_UNSUPPORTED_FORMAT => Self::UnsupportedFormat,
            ffi::GSK_SERIALIZATION_UNSUPPORTED_VERSION => Self::UnsupportedVersion,
            ffi::GSK_SERIALIZATION_INVALID_DATA => Self::InvalidData,
            value => Self::__Unknown(value),
        }
    }
}

impl ErrorDomain for SerializationError {
    fn domain() -> Quark {
        skip_assert_initialized!();

        unsafe { from_glib(ffi::gsk_serialization_error_quark()) }
    }

    fn code(self) -> i32 {
        self.into_glib()
    }

    fn from(code: i32) -> Option<Self> {
        skip_assert_initialized!();
        match code {
            ffi::GSK_SERIALIZATION_UNSUPPORTED_FORMAT => Some(Self::UnsupportedFormat),
            ffi::GSK_SERIALIZATION_UNSUPPORTED_VERSION => Some(Self::UnsupportedVersion),
            ffi::GSK_SERIALIZATION_INVALID_DATA => Some(Self::InvalidData),
            value => Some(Self::__Unknown(value)),
        }
    }
}

impl StaticType for SerializationError {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_serialization_error_get_type()) }
    }
}

impl glib::value::ValueType for SerializationError {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for SerializationError {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for SerializationError {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}

/// The categories of matrices relevant for GSK and GTK.
///
/// Note that any category includes matrices of all later categories.
/// So if you want to for example check if a matrix is a 2D matrix,
/// `category >= GSK_TRANSFORM_CATEGORY_2D` is the way to do this.
///
/// Also keep in mind that rounding errors may cause matrices to not
/// conform to their categories. Otherwise, matrix operations done via
/// multiplication will not worsen categories. So for the matrix
/// multiplication `C = A * B`, `category(C) = MIN (category(A), category(B))`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskTransformCategory")]
pub enum TransformCategory {
    /// The category of the matrix has not been
    ///   determined.
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_UNKNOWN")]
    Unknown,
    /// Analyzing the matrix concluded that it does
    ///   not fit in any other category.
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_ANY")]
    Any,
    /// The matrix is a 3D matrix. This means that
    ///   the w column (the last column) has the values (0, 0, 0, 1).
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_3D")]
    _3d,
    /// The matrix is a 2D matrix. This is equivalent
    ///   to graphene_matrix_is_2d() returning [`true`]. In particular, this
    ///   means that Cairo can deal with the matrix.
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_2D")]
    _2d,
    /// The matrix is a combination of 2D scale
    ///   and 2D translation operations. In particular, this means that any
    ///   rectangle can be transformed exactly using this matrix.
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_2D_AFFINE")]
    _2dAffine,
    /// The matrix is a 2D translation.
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_2D_TRANSLATE")]
    _2dTranslate,
    /// The matrix is the identity matrix.
    #[doc(alias = "GSK_TRANSFORM_CATEGORY_IDENTITY")]
    Identity,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for TransformCategory {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "TransformCategory::{}",
            match *self {
                Self::Unknown => "Unknown",
                Self::Any => "Any",
                Self::_3d => "_3d",
                Self::_2d => "_2d",
                Self::_2dAffine => "_2dAffine",
                Self::_2dTranslate => "_2dTranslate",
                Self::Identity => "Identity",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl IntoGlib for TransformCategory {
    type GlibType = ffi::GskTransformCategory;

    fn into_glib(self) -> ffi::GskTransformCategory {
        match self {
            Self::Unknown => ffi::GSK_TRANSFORM_CATEGORY_UNKNOWN,
            Self::Any => ffi::GSK_TRANSFORM_CATEGORY_ANY,
            Self::_3d => ffi::GSK_TRANSFORM_CATEGORY_3D,
            Self::_2d => ffi::GSK_TRANSFORM_CATEGORY_2D,
            Self::_2dAffine => ffi::GSK_TRANSFORM_CATEGORY_2D_AFFINE,
            Self::_2dTranslate => ffi::GSK_TRANSFORM_CATEGORY_2D_TRANSLATE,
            Self::Identity => ffi::GSK_TRANSFORM_CATEGORY_IDENTITY,
            Self::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::GskTransformCategory> for TransformCategory {
    unsafe fn from_glib(value: ffi::GskTransformCategory) -> Self {
        skip_assert_initialized!();
        match value {
            ffi::GSK_TRANSFORM_CATEGORY_UNKNOWN => Self::Unknown,
            ffi::GSK_TRANSFORM_CATEGORY_ANY => Self::Any,
            ffi::GSK_TRANSFORM_CATEGORY_3D => Self::_3d,
            ffi::GSK_TRANSFORM_CATEGORY_2D => Self::_2d,
            ffi::GSK_TRANSFORM_CATEGORY_2D_AFFINE => Self::_2dAffine,
            ffi::GSK_TRANSFORM_CATEGORY_2D_TRANSLATE => Self::_2dTranslate,
            ffi::GSK_TRANSFORM_CATEGORY_IDENTITY => Self::Identity,
            value => Self::__Unknown(value),
        }
    }
}

impl StaticType for TransformCategory {
    fn static_type() -> Type {
        unsafe { from_glib(ffi::gsk_transform_category_get_type()) }
    }
}

impl glib::value::ValueType for TransformCategory {
    type Type = Self;
}

unsafe impl<'a> FromValue<'a> for TransformCategory {
    type Checker = glib::value::GenericValueTypeChecker<Self>;

    unsafe fn from_value(value: &'a glib::Value) -> Self {
        skip_assert_initialized!();
        from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
    }
}

impl ToValue for TransformCategory {
    fn to_value(&self) -> glib::Value {
        let mut value = glib::Value::for_value_type::<Self>();
        unsafe {
            glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
        }
        value
    }

    fn value_type(&self) -> glib::Type {
        Self::static_type()
    }
}