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
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
#![allow(
    clippy::too_many_arguments,
    clippy::let_and_return,
    clippy::from_over_into,
    clippy::upper_case_acronyms
)]

use glib::translate::*;
use glib::{
    error::ErrorDomain,
    value::{FromValue, FromValueOptional, SetValue, Value},
    Quark, StaticType, Type,
};

use std::fmt;

/// Data types for the components of a vertex attribute.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum AttributeType {
    /// Data is the same size of a byte
    Byte,
    /// Data is the same size of an
    ///  unsigned byte
    UnsignedByte,
    /// Data is the same size of a short integer
    Short,
    /// Data is the same size of
    ///  an unsigned short integer
    UnsignedShort,
    /// Data is the same size of a float
    Float,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for AttributeType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "AttributeType::{}",
            match *self {
                AttributeType::Byte => "Byte",
                AttributeType::UnsignedByte => "UnsignedByte",
                AttributeType::Short => "Short",
                AttributeType::UnsignedShort => "UnsignedShort",
                AttributeType::Float => "Float",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for AttributeType {
    type GlibType = ffi::CoglAttributeType;

    fn to_glib(&self) -> ffi::CoglAttributeType {
        match *self {
            AttributeType::Byte => ffi::COGL_ATTRIBUTE_TYPE_BYTE,
            AttributeType::UnsignedByte => ffi::COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
            AttributeType::Short => ffi::COGL_ATTRIBUTE_TYPE_SHORT,
            AttributeType::UnsignedShort => ffi::COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT,
            AttributeType::Float => ffi::COGL_ATTRIBUTE_TYPE_FLOAT,
            AttributeType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglAttributeType> for AttributeType {
    fn from_glib(value: ffi::CoglAttributeType) -> Self {
        match value {
            5120 => AttributeType::Byte,
            5121 => AttributeType::UnsignedByte,
            5122 => AttributeType::Short,
            5123 => AttributeType::UnsignedShort,
            5126 => AttributeType::Float,
            value => AttributeType::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for AttributeType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for AttributeType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for AttributeType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Error codes that can be thrown when performing bitmap
/// operations. Note that `gdk_pixbuf_new_from_file` can also throw
/// errors directly from the underlying image loading library. For
/// example, if `GdkPixbuf` is used then errors ``GdkPixbufError``<!-- -->s
/// will be used directly.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum BitmapError {
    /// Generic failure code, something went
    ///  wrong.
    Failed,
    /// Unknown image type.
    UnknownType,
    /// An image file was broken somehow.
    CorruptImage,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for BitmapError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "BitmapError::{}",
            match *self {
                BitmapError::Failed => "Failed",
                BitmapError::UnknownType => "UnknownType",
                BitmapError::CorruptImage => "CorruptImage",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for BitmapError {
    type GlibType = ffi::CoglBitmapError;

    fn to_glib(&self) -> ffi::CoglBitmapError {
        match *self {
            BitmapError::Failed => ffi::COGL_BITMAP_ERROR_FAILED,
            BitmapError::UnknownType => ffi::COGL_BITMAP_ERROR_UNKNOWN_TYPE,
            BitmapError::CorruptImage => ffi::COGL_BITMAP_ERROR_CORRUPT_IMAGE,
            BitmapError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglBitmapError> for BitmapError {
    fn from_glib(value: ffi::CoglBitmapError) -> Self {
        match value {
            0 => BitmapError::Failed,
            1 => BitmapError::UnknownType,
            2 => BitmapError::CorruptImage,
            value => BitmapError::__Unknown(value),
        }
    }
}

impl ErrorDomain for BitmapError {
    fn domain() -> Quark {
        unsafe { from_glib(ffi::cogl_bitmap_error_quark()) }
    }

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

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(BitmapError::Failed),
            1 => Some(BitmapError::UnknownType),
            2 => Some(BitmapError::CorruptImage),
            _ => Some(BitmapError::Failed),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for BitmapError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for BitmapError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for BitmapError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Error enumeration for the blend strings parser
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum BlendStringError {
    /// Generic parse error
    ParseError,
    /// Argument parse error
    ArgumentParseError,
    /// Internal parser error
    InvalidError,
    /// Blend string not
    ///  supported by the GPU
    GpuUnsupportedError,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for BlendStringError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "BlendStringError::{}",
            match *self {
                BlendStringError::ParseError => "ParseError",
                BlendStringError::ArgumentParseError => "ArgumentParseError",
                BlendStringError::InvalidError => "InvalidError",
                BlendStringError::GpuUnsupportedError => "GpuUnsupportedError",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for BlendStringError {
    type GlibType = ffi::CoglBlendStringError;

    fn to_glib(&self) -> ffi::CoglBlendStringError {
        match *self {
            BlendStringError::ParseError => ffi::COGL_BLEND_STRING_ERROR_PARSE_ERROR,
            BlendStringError::ArgumentParseError => {
                ffi::COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR
            }
            BlendStringError::InvalidError => ffi::COGL_BLEND_STRING_ERROR_INVALID_ERROR,
            BlendStringError::GpuUnsupportedError => {
                ffi::COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR
            }
            BlendStringError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglBlendStringError> for BlendStringError {
    fn from_glib(value: ffi::CoglBlendStringError) -> Self {
        match value {
            0 => BlendStringError::ParseError,
            1 => BlendStringError::ArgumentParseError,
            2 => BlendStringError::InvalidError,
            3 => BlendStringError::GpuUnsupportedError,
            value => BlendStringError::__Unknown(value),
        }
    }
}

impl ErrorDomain for BlendStringError {
    fn domain() -> Quark {
        unsafe { from_glib(ffi::cogl_blend_string_error_quark()) }
    }

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

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(BlendStringError::ParseError),
            1 => Some(BlendStringError::ArgumentParseError),
            2 => Some(BlendStringError::InvalidError),
            3 => Some(BlendStringError::GpuUnsupportedError),
            value => Some(BlendStringError::__Unknown(value)),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for BlendStringError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for BlendStringError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for BlendStringError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Error enumeration for `Buffer`
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum BufferError {
    /// A buffer could not be mapped either
    ///  because the feature isn't supported or because a system
    ///  limitation was hit.
    BufferErrorMap,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for BufferError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "BufferError::{}",
            match *self {
                BufferError::BufferErrorMap => "BufferErrorMap",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for BufferError {
    type GlibType = ffi::CoglBufferError;

    fn to_glib(&self) -> ffi::CoglBufferError {
        match *self {
            BufferError::BufferErrorMap => ffi::COGL_BUFFER_ERROR_MAP,
            BufferError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglBufferError> for BufferError {
    fn from_glib(value: ffi::CoglBufferError) -> Self {
        match value {
            0 => BufferError::BufferErrorMap,
            value => BufferError::__Unknown(value),
        }
    }
}

/// The update hint on a buffer allows the user to give some detail on how often
/// the buffer data is going to be updated.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum BufferUpdateHint {
    /// the buffer will not change over time
    Static,
    /// the buffer will change from time to time
    Dynamic,
    /// the buffer will be used once or a couple of
    ///  times
    Stream,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for BufferUpdateHint {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "BufferUpdateHint::{}",
            match *self {
                BufferUpdateHint::Static => "Static",
                BufferUpdateHint::Dynamic => "Dynamic",
                BufferUpdateHint::Stream => "Stream",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for BufferUpdateHint {
    type GlibType = ffi::CoglBufferUpdateHint;

    fn to_glib(&self) -> ffi::CoglBufferUpdateHint {
        match *self {
            BufferUpdateHint::Static => ffi::COGL_BUFFER_UPDATE_HINT_STATIC,
            BufferUpdateHint::Dynamic => ffi::COGL_BUFFER_UPDATE_HINT_DYNAMIC,
            BufferUpdateHint::Stream => ffi::COGL_BUFFER_UPDATE_HINT_STREAM,
            BufferUpdateHint::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglBufferUpdateHint> for BufferUpdateHint {
    fn from_glib(value: ffi::CoglBufferUpdateHint) -> Self {
        match value {
            0 => BufferUpdateHint::Static,
            1 => BufferUpdateHint::Dynamic,
            2 => BufferUpdateHint::Stream,
            value => BufferUpdateHint::__Unknown(value),
        }
    }
}

/// When using depth testing one of these functions is used to compare
/// the depth of an incoming fragment against the depth value currently
/// stored in the depth buffer. The function is changed using
/// `DepthState::set_test_function`.
///
/// The test is only done when depth testing is explicitly enabled. (See
/// `DepthState::set_test_enabled`)
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum DepthTestFunction {
    /// Never passes.
    Never,
    /// Passes if the fragment's depth
    /// value is less than the value currently in the depth buffer.
    Less,
    /// Passes if the fragment's depth
    /// value is equal to the value currently in the depth buffer.
    Equal,
    /// Passes if the fragment's depth
    /// value is less or equal to the value currently in the depth buffer.
    Lequal,
    /// Passes if the fragment's depth
    /// value is greater than the value currently in the depth buffer.
    Greater,
    /// Passes if the fragment's depth
    /// value is not equal to the value currently in the depth buffer.
    Notequal,
    /// Passes if the fragment's depth
    /// value greater than or equal to the value currently in the depth buffer.
    Gequal,
    /// Always passes.
    Always,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for DepthTestFunction {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "DepthTestFunction::{}",
            match *self {
                DepthTestFunction::Never => "Never",
                DepthTestFunction::Less => "Less",
                DepthTestFunction::Equal => "Equal",
                DepthTestFunction::Lequal => "Lequal",
                DepthTestFunction::Greater => "Greater",
                DepthTestFunction::Notequal => "Notequal",
                DepthTestFunction::Gequal => "Gequal",
                DepthTestFunction::Always => "Always",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for DepthTestFunction {
    type GlibType = ffi::CoglDepthTestFunction;

    fn to_glib(&self) -> ffi::CoglDepthTestFunction {
        match *self {
            DepthTestFunction::Never => ffi::COGL_DEPTH_TEST_FUNCTION_NEVER,
            DepthTestFunction::Less => ffi::COGL_DEPTH_TEST_FUNCTION_LESS,
            DepthTestFunction::Equal => ffi::COGL_DEPTH_TEST_FUNCTION_EQUAL,
            DepthTestFunction::Lequal => ffi::COGL_DEPTH_TEST_FUNCTION_LEQUAL,
            DepthTestFunction::Greater => ffi::COGL_DEPTH_TEST_FUNCTION_GREATER,
            DepthTestFunction::Notequal => ffi::COGL_DEPTH_TEST_FUNCTION_NOTEQUAL,
            DepthTestFunction::Gequal => ffi::COGL_DEPTH_TEST_FUNCTION_GEQUAL,
            DepthTestFunction::Always => ffi::COGL_DEPTH_TEST_FUNCTION_ALWAYS,
            DepthTestFunction::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglDepthTestFunction> for DepthTestFunction {
    fn from_glib(value: ffi::CoglDepthTestFunction) -> Self {
        match value {
            512 => DepthTestFunction::Never,
            513 => DepthTestFunction::Less,
            514 => DepthTestFunction::Equal,
            515 => DepthTestFunction::Lequal,
            516 => DepthTestFunction::Greater,
            517 => DepthTestFunction::Notequal,
            518 => DepthTestFunction::Gequal,
            519 => DepthTestFunction::Always,
            value => DepthTestFunction::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for DepthTestFunction {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for DepthTestFunction {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for DepthTestFunction {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Identifiers for underlying hardware drivers that may be used by
/// Cogl for rendering.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum Driver {
    /// Implies no preference for which driver is used
    Any,
    /// A No-Op driver.
    Nop,
    /// An OpenGL driver.
    Gl,
    /// An OpenGL driver using the core GL 3.1 profile
    Gl3,
    /// An OpenGL ES 1.1 driver.
    Gles1,
    /// An OpenGL ES 2.0 driver.
    Gles2,
    /// A WebGL driver.
    Webgl,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for Driver {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "Driver::{}",
            match *self {
                Driver::Any => "Any",
                Driver::Nop => "Nop",
                Driver::Gl => "Gl",
                Driver::Gl3 => "Gl3",
                Driver::Gles1 => "Gles1",
                Driver::Gles2 => "Gles2",
                Driver::Webgl => "Webgl",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for Driver {
    type GlibType = ffi::CoglDriver;

    fn to_glib(&self) -> ffi::CoglDriver {
        match *self {
            Driver::Any => ffi::COGL_DRIVER_ANY,
            Driver::Nop => ffi::COGL_DRIVER_NOP,
            Driver::Gl => ffi::COGL_DRIVER_GL,
            Driver::Gl3 => ffi::COGL_DRIVER_GL3,
            Driver::Gles1 => ffi::COGL_DRIVER_GLES1,
            Driver::Gles2 => ffi::COGL_DRIVER_GLES2,
            Driver::Webgl => ffi::COGL_DRIVER_WEBGL,
            Driver::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglDriver> for Driver {
    fn from_glib(value: ffi::CoglDriver) -> Self {
        match value {
            0 => Driver::Any,
            1 => Driver::Nop,
            2 => Driver::Gl,
            3 => Driver::Gl3,
            4 => Driver::Gles1,
            5 => Driver::Gles2,
            6 => Driver::Webgl,
            value => Driver::__Unknown(value),
        }
    }
}

/// All the capabilities that can vary between different GPUs supported
/// by Cogl. Applications that depend on any of these features should explicitly
/// check for them using `cogl_has_feature` or `cogl_has_features`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum FeatureID {
    /// The hardware supports non power
    ///  of two textures, but you also need to check the
    ///  `FeatureID::OglFeatureIdTextureNpotMipmap` and `FeatureID::OglFeatureIdTextureNpotRepeat`
    ///  features to know if the hardware supports npot texture mipmaps
    ///  or repeat modes other than
    ///  `PipelineWrapMode::ClampToEdge` respectively.
    OglFeatureIdTextureNpotBasic,
    /// Mipmapping is supported in
    ///  conjuntion with non power of two textures.
    OglFeatureIdTextureNpotMipmap,
    /// Repeat modes other than
    ///  `PipelineWrapMode::ClampToEdge` are supported by the
    ///  hardware.
    OglFeatureIdTextureNpotRepeat,
    /// Non power of two textures are supported
    ///  by the hardware. This is a equivalent to the
    ///  `FeatureID::OglFeatureIdTextureNpotBasic`, `FeatureID::OglFeatureIdTextureNpotMipmap`
    ///  and `FeatureID::OglFeatureIdTextureNpotRepeat` features combined.
    OglFeatureIdTextureNpot,
    /// Support for rectangular
    ///  textures with non-normalized texture coordinates.
    OglFeatureIdTextureRectangle,
    /// 3D texture support
    OglFeatureIdTexture3d,
    /// GLSL support
    OglFeatureIdGlsl,
    /// ARBFP support
    OglFeatureIdArbfp,
    /// Offscreen rendering support
    OglFeatureIdOffscreen,
    /// Multisample support for
    ///  offscreen framebuffers
    OglFeatureIdOffscreenMultisample,
    /// Multiple onscreen framebuffers
    ///  supported.
    OglFeatureIdOnscreenMultiple,
    /// Set if
    ///  `IndicesType::Int` is supported in
    ///  `Indices::new`.
    OglFeatureIdUnsignedIntIndices,
    /// `cogl_pipeline_set_depth_range` support
    OglFeatureIdDepthRange,
    /// Whether
    ///  `Pipeline::set_layer_point_sprite_coords_enabled` is supported.
    OglFeatureIdPointSprite,
    /// Whether `cogl_buffer_map` is
    ///  supported with CoglBufferAccess including read support.
    OglFeatureIdMapBufferForRead,
    /// Whether `cogl_buffer_map` is
    ///  supported with CoglBufferAccess including write support.
    OglFeatureIdMapBufferForWrite,
    /// Whether
    ///  `PipelineWrapMode::MirroredRepeat` is supported.
    OglFeatureIdMirroredRepeat,
    /// Available if the window system supports reporting an event
    ///  for swap buffer completions.
    OglFeatureIdSwapBuffersEvent,
    /// Whether creating new GLES2 contexts is
    ///  suported.
    OglFeatureIdGles2Context,
    /// Whether `Framebuffer` support rendering
    ///  the depth buffer to a texture.
    OglFeatureIdDepthTexture,
    /// Whether frame presentation
    ///  time stamps will be recorded in `FrameInfo` objects.
    OglFeatureIdPresentationTime,
    OglFeatureIdFence,
    /// Whether cogl_point_size_in
    ///  can be used as an attribute to set a per-vertex point size.
    OglFeatureIdPerVertexPointSize,
    /// Support for
    ///  `TextureComponents::Rg` as the internal components of a
    ///  texture.
    OglFeatureIdTextureRg,
    /// Available if the age of `Onscreen` back
    ///  buffers are tracked and so `Onscreen::get_buffer_age` can be
    ///  expected to return age values other than 0.
    OglFeatureIdBufferAge,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for FeatureID {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "FeatureID::{}",
            match *self {
                FeatureID::OglFeatureIdTextureNpotBasic => "OglFeatureIdTextureNpotBasic",
                FeatureID::OglFeatureIdTextureNpotMipmap => "OglFeatureIdTextureNpotMipmap",
                FeatureID::OglFeatureIdTextureNpotRepeat => "OglFeatureIdTextureNpotRepeat",
                FeatureID::OglFeatureIdTextureNpot => "OglFeatureIdTextureNpot",
                FeatureID::OglFeatureIdTextureRectangle => "OglFeatureIdTextureRectangle",
                FeatureID::OglFeatureIdTexture3d => "OglFeatureIdTexture3d",
                FeatureID::OglFeatureIdGlsl => "OglFeatureIdGlsl",
                FeatureID::OglFeatureIdArbfp => "OglFeatureIdArbfp",
                FeatureID::OglFeatureIdOffscreen => "OglFeatureIdOffscreen",
                FeatureID::OglFeatureIdOffscreenMultisample => "OglFeatureIdOffscreenMultisample",
                FeatureID::OglFeatureIdOnscreenMultiple => "OglFeatureIdOnscreenMultiple",
                FeatureID::OglFeatureIdUnsignedIntIndices => "OglFeatureIdUnsignedIntIndices",
                FeatureID::OglFeatureIdDepthRange => "OglFeatureIdDepthRange",
                FeatureID::OglFeatureIdPointSprite => "OglFeatureIdPointSprite",
                FeatureID::OglFeatureIdMapBufferForRead => "OglFeatureIdMapBufferForRead",
                FeatureID::OglFeatureIdMapBufferForWrite => "OglFeatureIdMapBufferForWrite",
                FeatureID::OglFeatureIdMirroredRepeat => "OglFeatureIdMirroredRepeat",
                FeatureID::OglFeatureIdSwapBuffersEvent => "OglFeatureIdSwapBuffersEvent",
                FeatureID::OglFeatureIdGles2Context => "OglFeatureIdGles2Context",
                FeatureID::OglFeatureIdDepthTexture => "OglFeatureIdDepthTexture",
                FeatureID::OglFeatureIdPresentationTime => "OglFeatureIdPresentationTime",
                FeatureID::OglFeatureIdFence => "OglFeatureIdFence",
                FeatureID::OglFeatureIdPerVertexPointSize => "OglFeatureIdPerVertexPointSize",
                FeatureID::OglFeatureIdTextureRg => "OglFeatureIdTextureRg",
                FeatureID::OglFeatureIdBufferAge => "OglFeatureIdBufferAge",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for FeatureID {
    type GlibType = ffi::CoglFeatureID;

    fn to_glib(&self) -> ffi::CoglFeatureID {
        match *self {
            FeatureID::OglFeatureIdTextureNpotBasic => ffi::COGL_FEATURE_ID_TEXTURE_NPOT_BASIC,
            FeatureID::OglFeatureIdTextureNpotMipmap => ffi::COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP,
            FeatureID::OglFeatureIdTextureNpotRepeat => ffi::COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT,
            FeatureID::OglFeatureIdTextureNpot => ffi::COGL_FEATURE_ID_TEXTURE_NPOT,
            FeatureID::OglFeatureIdTextureRectangle => ffi::COGL_FEATURE_ID_TEXTURE_RECTANGLE,
            FeatureID::OglFeatureIdTexture3d => ffi::COGL_FEATURE_ID_TEXTURE_3D,
            FeatureID::OglFeatureIdGlsl => ffi::COGL_FEATURE_ID_GLSL,
            FeatureID::OglFeatureIdArbfp => ffi::COGL_FEATURE_ID_ARBFP,
            FeatureID::OglFeatureIdOffscreen => ffi::COGL_FEATURE_ID_OFFSCREEN,
            FeatureID::OglFeatureIdOffscreenMultisample => {
                ffi::COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE
            }
            FeatureID::OglFeatureIdOnscreenMultiple => ffi::COGL_FEATURE_ID_ONSCREEN_MULTIPLE,
            FeatureID::OglFeatureIdUnsignedIntIndices => ffi::COGL_FEATURE_ID_UNSIGNED_INT_INDICES,
            FeatureID::OglFeatureIdDepthRange => ffi::COGL_FEATURE_ID_DEPTH_RANGE,
            FeatureID::OglFeatureIdPointSprite => ffi::COGL_FEATURE_ID_POINT_SPRITE,
            FeatureID::OglFeatureIdMapBufferForRead => ffi::COGL_FEATURE_ID_MAP_BUFFER_FOR_READ,
            FeatureID::OglFeatureIdMapBufferForWrite => ffi::COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE,
            FeatureID::OglFeatureIdMirroredRepeat => ffi::COGL_FEATURE_ID_MIRRORED_REPEAT,
            FeatureID::OglFeatureIdSwapBuffersEvent => ffi::COGL_FEATURE_ID_SWAP_BUFFERS_EVENT,
            FeatureID::OglFeatureIdGles2Context => ffi::COGL_FEATURE_ID_GLES2_CONTEXT,
            FeatureID::OglFeatureIdDepthTexture => ffi::COGL_FEATURE_ID_DEPTH_TEXTURE,
            FeatureID::OglFeatureIdPresentationTime => ffi::COGL_FEATURE_ID_PRESENTATION_TIME,
            FeatureID::OglFeatureIdFence => ffi::COGL_FEATURE_ID_FENCE,
            FeatureID::OglFeatureIdPerVertexPointSize => ffi::COGL_FEATURE_ID_PER_VERTEX_POINT_SIZE,
            FeatureID::OglFeatureIdTextureRg => ffi::COGL_FEATURE_ID_TEXTURE_RG,
            FeatureID::OglFeatureIdBufferAge => ffi::COGL_FEATURE_ID_BUFFER_AGE,
            FeatureID::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglFeatureID> for FeatureID {
    fn from_glib(value: ffi::CoglFeatureID) -> Self {
        match value {
            1 => FeatureID::OglFeatureIdTextureNpotBasic,
            2 => FeatureID::OglFeatureIdTextureNpotMipmap,
            3 => FeatureID::OglFeatureIdTextureNpotRepeat,
            4 => FeatureID::OglFeatureIdTextureNpot,
            5 => FeatureID::OglFeatureIdTextureRectangle,
            6 => FeatureID::OglFeatureIdTexture3d,
            7 => FeatureID::OglFeatureIdGlsl,
            8 => FeatureID::OglFeatureIdArbfp,
            9 => FeatureID::OglFeatureIdOffscreen,
            10 => FeatureID::OglFeatureIdOffscreenMultisample,
            11 => FeatureID::OglFeatureIdOnscreenMultiple,
            12 => FeatureID::OglFeatureIdUnsignedIntIndices,
            13 => FeatureID::OglFeatureIdDepthRange,
            14 => FeatureID::OglFeatureIdPointSprite,
            15 => FeatureID::OglFeatureIdMapBufferForRead,
            16 => FeatureID::OglFeatureIdMapBufferForWrite,
            17 => FeatureID::OglFeatureIdMirroredRepeat,
            18 => FeatureID::OglFeatureIdSwapBuffersEvent,
            19 => FeatureID::OglFeatureIdGles2Context,
            20 => FeatureID::OglFeatureIdDepthTexture,
            21 => FeatureID::OglFeatureIdPresentationTime,
            22 => FeatureID::OglFeatureIdFence,
            23 => FeatureID::OglFeatureIdPerVertexPointSize,
            24 => FeatureID::OglFeatureIdTextureRg,
            25 => FeatureID::OglFeatureIdBufferAge,
            value => FeatureID::__Unknown(value),
        }
    }
}

/// Return values for the `CoglXlibFilterFunc` and `CoglWin32FilterFunc` functions.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum FilterReturn {
    /// The event was not handled, continues the
    ///  processing
    Continue,
    /// Remove the event, stops the processing
    Remove,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for FilterReturn {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "FilterReturn::{}",
            match *self {
                FilterReturn::Continue => "Continue",
                FilterReturn::Remove => "Remove",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for FilterReturn {
    type GlibType = ffi::CoglFilterReturn;

    fn to_glib(&self) -> ffi::CoglFilterReturn {
        match *self {
            FilterReturn::Continue => ffi::COGL_FILTER_CONTINUE,
            FilterReturn::Remove => ffi::COGL_FILTER_REMOVE,
            FilterReturn::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglFilterReturn> for FilterReturn {
    fn from_glib(value: ffi::CoglFilterReturn) -> Self {
        match value {
            0 => FilterReturn::Continue,
            1 => FilterReturn::Remove,
            value => FilterReturn::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for FilterReturn {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for FilterReturn {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for FilterReturn {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The fog mode determines the equation used to calculate the fogging blend
/// factor while fogging is enabled. The simplest `FogMode::Linear` mode
/// determines f as:
///
///
/// ```text
///   f = end - eye_distance / end - start
/// ```
///
/// Where eye_distance is the distance of the current fragment in eye
/// coordinates from the origin.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum FogMode {
    /// Calculates the fog blend factor as:
    ///
    /// ```text
    ///   f = end - eye_distance / end - start
    /// ```
    Linear,
    /// Calculates the fog blend factor as:
    ///
    /// ```text
    ///   f = e ^ -(density * eye_distance)
    /// ```
    Exponential,
    /// Calculates the fog blend factor as:
    ///
    /// ```text
    ///   f = e ^ -(density * eye_distance)^2
    /// ```
    ExponentialSquared,
    #[doc(hidden)]
    __Unknown(i32),
}

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

#[doc(hidden)]
impl ToGlib for FogMode {
    type GlibType = ffi::CoglFogMode;

    fn to_glib(&self) -> ffi::CoglFogMode {
        match *self {
            FogMode::Linear => ffi::COGL_FOG_MODE_LINEAR,
            FogMode::Exponential => ffi::COGL_FOG_MODE_EXPONENTIAL,
            FogMode::ExponentialSquared => ffi::COGL_FOG_MODE_EXPONENTIAL_SQUARED,
            FogMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglFogMode> for FogMode {
    fn from_glib(value: ffi::CoglFogMode) -> Self {
        match value {
            0 => FogMode::Linear,
            1 => FogMode::Exponential,
            2 => FogMode::ExponentialSquared,
            value => FogMode::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for FogMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for FogMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for FogMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Identifiers that are passed to `CoglFrameCallback` functions
/// (registered using `Onscreen::add_frame_callback`) that
/// mark the progression of a frame in some way which usually
/// means that new information will have been accumulated in the
/// frame's corresponding `FrameInfo` object.
///
/// The last event that will be sent for a frame will be a
/// `FrameEvent::Complete` event and so these are a good
/// opportunity to collect statistics about a frame since the
/// `FrameInfo` should hold the most data at this point.
///
/// `<note>`A frame may not be completed before the next frame can start
/// so applications should avoid needing to collect all statistics for
/// a particular frame before they can start a new frame.`</note>`
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum FrameEvent {
    /// Notifies that the system compositor has
    ///  acknowledged a frame and is ready for a
    ///  new frame to be created.
    Sync,
    /// Notifies that a frame has ended. This
    ///  is a good time for applications to
    ///  collect statistics about the frame
    ///  since the `FrameInfo` should hold
    ///  the most data at this point. No other
    ///  events should be expected after a
    ///  `FrameEvent::Complete` event.
    Complete,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for FrameEvent {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "FrameEvent::{}",
            match *self {
                FrameEvent::Sync => "Sync",
                FrameEvent::Complete => "Complete",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for FrameEvent {
    type GlibType = ffi::CoglFrameEvent;

    fn to_glib(&self) -> ffi::CoglFrameEvent {
        match *self {
            FrameEvent::Sync => ffi::COGL_FRAME_EVENT_SYNC,
            FrameEvent::Complete => ffi::COGL_FRAME_EVENT_COMPLETE,
            FrameEvent::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglFrameEvent> for FrameEvent {
    fn from_glib(value: ffi::CoglFrameEvent) -> Self {
        match value {
            1 => FrameEvent::Sync,
            2 => FrameEvent::Complete,
            value => FrameEvent::__Unknown(value),
        }
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum FramebufferError {
    FramebufferErrorAllocate,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for FramebufferError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "FramebufferError::{}",
            match *self {
                FramebufferError::FramebufferErrorAllocate => "FramebufferErrorAllocate",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for FramebufferError {
    type GlibType = ffi::CoglFramebufferError;

    fn to_glib(&self) -> ffi::CoglFramebufferError {
        match *self {
            FramebufferError::FramebufferErrorAllocate => ffi::COGL_FRAMEBUFFER_ERROR_ALLOCATE,
            FramebufferError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglFramebufferError> for FramebufferError {
    fn from_glib(value: ffi::CoglFramebufferError) -> Self {
        match value {
            0 => FramebufferError::FramebufferErrorAllocate,
            value => FramebufferError::__Unknown(value),
        }
    }
}

/// Error codes that relate to the cogl_gles2_context api.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum GLES2ContextError {
    /// Creating GLES2 contexts
    ///  isn't supported. Applications should use `cogl_has_feature` to
    ///  check for the `FeatureID::OglFeatureIdGles2Context`.
    Unsupported,
    /// An underlying driver error
    ///  occured.
    Driver,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for GLES2ContextError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "GLES2ContextError::{}",
            match *self {
                GLES2ContextError::Unsupported => "Unsupported",
                GLES2ContextError::Driver => "Driver",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for GLES2ContextError {
    type GlibType = ffi::CoglGLES2ContextError;

    fn to_glib(&self) -> ffi::CoglGLES2ContextError {
        match *self {
            GLES2ContextError::Unsupported => ffi::COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED,
            GLES2ContextError::Driver => ffi::COGL_GLES2_CONTEXT_ERROR_DRIVER,
            GLES2ContextError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglGLES2ContextError> for GLES2ContextError {
    fn from_glib(value: ffi::CoglGLES2ContextError) -> Self {
        match value {
            0 => GLES2ContextError::Unsupported,
            1 => GLES2ContextError::Driver,
            value => GLES2ContextError::__Unknown(value),
        }
    }
}

/// You should aim to use the smallest data type that gives you enough
/// range, since it reduces the size of your index array and can help
/// reduce the demand on memory bandwidth.
///
/// Note that `IndicesType::Int` is only supported if the
/// `FeatureID::OglFeatureIdUnsignedIntIndices` feature is available. This
/// should always be available on OpenGL but on OpenGL ES it will only
/// be available if the GL_OES_element_index_uint extension is
/// advertized.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum IndicesType {
    /// Your indices are unsigned bytes
    Byte,
    /// Your indices are unsigned shorts
    Short,
    /// Your indices are unsigned ints
    Int,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for IndicesType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "IndicesType::{}",
            match *self {
                IndicesType::Byte => "Byte",
                IndicesType::Short => "Short",
                IndicesType::Int => "Int",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for IndicesType {
    type GlibType = ffi::CoglIndicesType;

    fn to_glib(&self) -> ffi::CoglIndicesType {
        match *self {
            IndicesType::Byte => ffi::COGL_INDICES_TYPE_UNSIGNED_BYTE,
            IndicesType::Short => ffi::COGL_INDICES_TYPE_UNSIGNED_SHORT,
            IndicesType::Int => ffi::COGL_INDICES_TYPE_UNSIGNED_INT,
            IndicesType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglIndicesType> for IndicesType {
    fn from_glib(value: ffi::CoglIndicesType) -> Self {
        match value {
            0 => IndicesType::Byte,
            1 => IndicesType::Short,
            2 => IndicesType::Int,
            value => IndicesType::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for IndicesType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for IndicesType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for IndicesType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Alpha testing happens before blending primitives with the framebuffer and
/// gives an opportunity to discard fragments based on a comparison with the
/// incoming alpha value and a reference alpha value. The `MaterialAlphaFunc`
/// determines how the comparison is done.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum MaterialAlphaFunc {
    /// Never let the fragment through.
    Never,
    /// Let the fragment through if the incoming
    ///  alpha value is less than the reference alpha value
    Less,
    /// Let the fragment through if the incoming
    ///  alpha value equals the reference alpha value
    Equal,
    /// Let the fragment through if the incoming
    ///  alpha value is less than or equal to the reference alpha value
    Lequal,
    /// Let the fragment through if the incoming
    ///  alpha value is greater than the reference alpha value
    Greater,
    /// Let the fragment through if the incoming
    ///  alpha value does not equal the reference alpha value
    Notequal,
    /// Let the fragment through if the incoming
    ///  alpha value is greater than or equal to the reference alpha value.
    Gequal,
    /// Always let the fragment through.
    Always,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for MaterialAlphaFunc {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "MaterialAlphaFunc::{}",
            match *self {
                MaterialAlphaFunc::Never => "Never",
                MaterialAlphaFunc::Less => "Less",
                MaterialAlphaFunc::Equal => "Equal",
                MaterialAlphaFunc::Lequal => "Lequal",
                MaterialAlphaFunc::Greater => "Greater",
                MaterialAlphaFunc::Notequal => "Notequal",
                MaterialAlphaFunc::Gequal => "Gequal",
                MaterialAlphaFunc::Always => "Always",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for MaterialAlphaFunc {
    type GlibType = ffi::CoglMaterialAlphaFunc;

    fn to_glib(&self) -> ffi::CoglMaterialAlphaFunc {
        match *self {
            MaterialAlphaFunc::Never => ffi::COGL_MATERIAL_ALPHA_FUNC_NEVER,
            MaterialAlphaFunc::Less => ffi::COGL_MATERIAL_ALPHA_FUNC_LESS,
            MaterialAlphaFunc::Equal => ffi::COGL_MATERIAL_ALPHA_FUNC_EQUAL,
            MaterialAlphaFunc::Lequal => ffi::COGL_MATERIAL_ALPHA_FUNC_LEQUAL,
            MaterialAlphaFunc::Greater => ffi::COGL_MATERIAL_ALPHA_FUNC_GREATER,
            MaterialAlphaFunc::Notequal => ffi::COGL_MATERIAL_ALPHA_FUNC_NOTEQUAL,
            MaterialAlphaFunc::Gequal => ffi::COGL_MATERIAL_ALPHA_FUNC_GEQUAL,
            MaterialAlphaFunc::Always => ffi::COGL_MATERIAL_ALPHA_FUNC_ALWAYS,
            MaterialAlphaFunc::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglMaterialAlphaFunc> for MaterialAlphaFunc {
    fn from_glib(value: ffi::CoglMaterialAlphaFunc) -> Self {
        match value {
            512 => MaterialAlphaFunc::Never,
            513 => MaterialAlphaFunc::Less,
            514 => MaterialAlphaFunc::Equal,
            515 => MaterialAlphaFunc::Lequal,
            516 => MaterialAlphaFunc::Greater,
            517 => MaterialAlphaFunc::Notequal,
            518 => MaterialAlphaFunc::Gequal,
            519 => MaterialAlphaFunc::Always,
            value => MaterialAlphaFunc::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for MaterialAlphaFunc {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for MaterialAlphaFunc {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for MaterialAlphaFunc {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Texture filtering is used whenever the current pixel maps either to more
/// than one texture element (texel) or less than one. These filter enums
/// correspond to different strategies used to come up with a pixel color, by
/// possibly referring to multiple neighbouring texels and taking a weighted
/// average or simply using the nearest texel.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum MaterialFilter {
    /// Measuring in manhatten distance from the,
    ///  current pixel center, use the nearest texture texel
    Nearest,
    /// Use the weighted average of the 4 texels
    ///  nearest the current pixel center
    Linear,
    /// Select the mimap level whose
    ///  texel size most closely matches the current pixel, and use the
    ///  `MaterialFilter::Nearest` criterion
    NearestMipmapNearest,
    /// Select the mimap level whose
    ///  texel size most closely matches the current pixel, and use the
    ///  `MaterialFilter::Linear` criterion
    LinearMipmapNearest,
    /// Select the two mimap levels
    ///  whose texel size most closely matches the current pixel, use
    ///  the `MaterialFilter::Nearest` criterion on each one and take
    ///  their weighted average
    NearestMipmapLinear,
    /// Select the two mimap levels
    ///  whose texel size most closely matches the current pixel, use
    ///  the `MaterialFilter::Linear` criterion on each one and take
    ///  their weighted average
    LinearMipmapLinear,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for MaterialFilter {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "MaterialFilter::{}",
            match *self {
                MaterialFilter::Nearest => "Nearest",
                MaterialFilter::Linear => "Linear",
                MaterialFilter::NearestMipmapNearest => "NearestMipmapNearest",
                MaterialFilter::LinearMipmapNearest => "LinearMipmapNearest",
                MaterialFilter::NearestMipmapLinear => "NearestMipmapLinear",
                MaterialFilter::LinearMipmapLinear => "LinearMipmapLinear",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for MaterialFilter {
    type GlibType = ffi::CoglMaterialFilter;

    fn to_glib(&self) -> ffi::CoglMaterialFilter {
        match *self {
            MaterialFilter::Nearest => ffi::COGL_MATERIAL_FILTER_NEAREST,
            MaterialFilter::Linear => ffi::COGL_MATERIAL_FILTER_LINEAR,
            MaterialFilter::NearestMipmapNearest => {
                ffi::COGL_MATERIAL_FILTER_NEAREST_MIPMAP_NEAREST
            }
            MaterialFilter::LinearMipmapNearest => ffi::COGL_MATERIAL_FILTER_LINEAR_MIPMAP_NEAREST,
            MaterialFilter::NearestMipmapLinear => ffi::COGL_MATERIAL_FILTER_NEAREST_MIPMAP_LINEAR,
            MaterialFilter::LinearMipmapLinear => ffi::COGL_MATERIAL_FILTER_LINEAR_MIPMAP_LINEAR,
            MaterialFilter::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglMaterialFilter> for MaterialFilter {
    fn from_glib(value: ffi::CoglMaterialFilter) -> Self {
        match value {
            9728 => MaterialFilter::Nearest,
            9729 => MaterialFilter::Linear,
            9984 => MaterialFilter::NearestMipmapNearest,
            9985 => MaterialFilter::LinearMipmapNearest,
            9986 => MaterialFilter::NearestMipmapLinear,
            9987 => MaterialFilter::LinearMipmapLinear,
            value => MaterialFilter::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for MaterialFilter {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for MaterialFilter {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for MaterialFilter {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Available types of layers for a `Material`. This enumeration
/// might be expanded in later versions.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum MaterialLayerType {
    /// The layer represents a
    ///  <link linkend="cogl-Textures">texture`</link>`
    Texture,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for MaterialLayerType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "MaterialLayerType::{}",
            match *self {
                MaterialLayerType::Texture => "Texture",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for MaterialLayerType {
    type GlibType = ffi::CoglMaterialLayerType;

    fn to_glib(&self) -> ffi::CoglMaterialLayerType {
        match *self {
            MaterialLayerType::Texture => ffi::COGL_MATERIAL_LAYER_TYPE_TEXTURE,
            MaterialLayerType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglMaterialLayerType> for MaterialLayerType {
    fn from_glib(value: ffi::CoglMaterialLayerType) -> Self {
        match value {
            0 => MaterialLayerType::Texture,
            value => MaterialLayerType::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for MaterialLayerType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for MaterialLayerType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for MaterialLayerType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// The wrap mode specifies what happens when texture coordinates
/// outside the range 0→1 are used. Note that if the filter mode is
/// anything but `MaterialFilter::Nearest` then texels outside the
/// range 0→1 might be used even when the coordinate is exactly 0 or 1
/// because OpenGL will try to sample neighbouring pixels. For example
/// if you are trying to render the full texture then you may get
/// artifacts around the edges when the pixels from the other side are
/// merged in if the wrap mode is set to repeat.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum MaterialWrapMode {
    /// The texture will be repeated. This
    ///  is useful for example to draw a tiled background.
    Repeat,
    /// The coordinates outside the
    ///  range 0→1 will sample copies of the edge pixels of the
    ///  texture. This is useful to avoid artifacts if only one copy of
    ///  the texture is being rendered.
    ClampToEdge,
    /// Cogl will try to automatically
    ///  decide which of the above two to use. For `cogl_rectangle`, it
    ///  will use repeat mode if any of the texture coordinates are
    ///  outside the range 0→1, otherwise it will use clamp to edge. For
    ///  `cogl_polygon` it will always use repeat mode. For
    ///  `cogl_vertex_buffer_draw` it will use repeat mode except for
    ///  layers that have point sprite coordinate generation enabled. This
    ///  is the default value.
    Automatic,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for MaterialWrapMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "MaterialWrapMode::{}",
            match *self {
                MaterialWrapMode::Repeat => "Repeat",
                MaterialWrapMode::ClampToEdge => "ClampToEdge",
                MaterialWrapMode::Automatic => "Automatic",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for MaterialWrapMode {
    type GlibType = ffi::CoglMaterialWrapMode;

    fn to_glib(&self) -> ffi::CoglMaterialWrapMode {
        match *self {
            MaterialWrapMode::Repeat => ffi::COGL_MATERIAL_WRAP_MODE_REPEAT,
            MaterialWrapMode::ClampToEdge => ffi::COGL_MATERIAL_WRAP_MODE_CLAMP_TO_EDGE,
            MaterialWrapMode::Automatic => ffi::COGL_MATERIAL_WRAP_MODE_AUTOMATIC,
            MaterialWrapMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglMaterialWrapMode> for MaterialWrapMode {
    fn from_glib(value: ffi::CoglMaterialWrapMode) -> Self {
        match value {
            10497 => MaterialWrapMode::Repeat,
            33071 => MaterialWrapMode::ClampToEdge,
            519 => MaterialWrapMode::Automatic,
            value => MaterialWrapMode::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for MaterialWrapMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for MaterialWrapMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for MaterialWrapMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Alpha testing happens before blending primitives with the framebuffer and
/// gives an opportunity to discard fragments based on a comparison with the
/// incoming alpha value and a reference alpha value. The `PipelineAlphaFunc`
/// determines how the comparison is done.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PipelineAlphaFunc {
    /// Never let the fragment through.
    Never,
    /// Let the fragment through if the incoming
    ///  alpha value is less than the reference alpha value
    Less,
    /// Let the fragment through if the incoming
    ///  alpha value equals the reference alpha value
    Equal,
    /// Let the fragment through if the incoming
    ///  alpha value is less than or equal to the reference alpha value
    Lequal,
    /// Let the fragment through if the incoming
    ///  alpha value is greater than the reference alpha value
    Greater,
    /// Let the fragment through if the incoming
    ///  alpha value does not equal the reference alpha value
    Notequal,
    /// Let the fragment through if the incoming
    ///  alpha value is greater than or equal to the reference alpha value.
    Gequal,
    /// Always let the fragment through.
    Always,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PipelineAlphaFunc {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PipelineAlphaFunc::{}",
            match *self {
                PipelineAlphaFunc::Never => "Never",
                PipelineAlphaFunc::Less => "Less",
                PipelineAlphaFunc::Equal => "Equal",
                PipelineAlphaFunc::Lequal => "Lequal",
                PipelineAlphaFunc::Greater => "Greater",
                PipelineAlphaFunc::Notequal => "Notequal",
                PipelineAlphaFunc::Gequal => "Gequal",
                PipelineAlphaFunc::Always => "Always",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PipelineAlphaFunc {
    type GlibType = ffi::CoglPipelineAlphaFunc;

    fn to_glib(&self) -> ffi::CoglPipelineAlphaFunc {
        match *self {
            PipelineAlphaFunc::Never => ffi::COGL_PIPELINE_ALPHA_FUNC_NEVER,
            PipelineAlphaFunc::Less => ffi::COGL_PIPELINE_ALPHA_FUNC_LESS,
            PipelineAlphaFunc::Equal => ffi::COGL_PIPELINE_ALPHA_FUNC_EQUAL,
            PipelineAlphaFunc::Lequal => ffi::COGL_PIPELINE_ALPHA_FUNC_LEQUAL,
            PipelineAlphaFunc::Greater => ffi::COGL_PIPELINE_ALPHA_FUNC_GREATER,
            PipelineAlphaFunc::Notequal => ffi::COGL_PIPELINE_ALPHA_FUNC_NOTEQUAL,
            PipelineAlphaFunc::Gequal => ffi::COGL_PIPELINE_ALPHA_FUNC_GEQUAL,
            PipelineAlphaFunc::Always => ffi::COGL_PIPELINE_ALPHA_FUNC_ALWAYS,
            PipelineAlphaFunc::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglPipelineAlphaFunc> for PipelineAlphaFunc {
    fn from_glib(value: ffi::CoglPipelineAlphaFunc) -> Self {
        match value {
            512 => PipelineAlphaFunc::Never,
            513 => PipelineAlphaFunc::Less,
            514 => PipelineAlphaFunc::Equal,
            515 => PipelineAlphaFunc::Lequal,
            516 => PipelineAlphaFunc::Greater,
            517 => PipelineAlphaFunc::Notequal,
            518 => PipelineAlphaFunc::Gequal,
            519 => PipelineAlphaFunc::Always,
            value => PipelineAlphaFunc::__Unknown(value),
        }
    }
}

/// Specifies which faces should be culled. This can be set on a
/// pipeline using `Pipeline::set_cull_face_mode`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PipelineCullFaceMode {
    /// Neither face will be
    ///  culled. This is the default.
    None,
    /// Front faces will be culled.
    Front,
    /// Back faces will be culled.
    Back,
    /// All faces will be culled.
    Both,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PipelineCullFaceMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PipelineCullFaceMode::{}",
            match *self {
                PipelineCullFaceMode::None => "None",
                PipelineCullFaceMode::Front => "Front",
                PipelineCullFaceMode::Back => "Back",
                PipelineCullFaceMode::Both => "Both",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PipelineCullFaceMode {
    type GlibType = ffi::CoglPipelineCullFaceMode;

    fn to_glib(&self) -> ffi::CoglPipelineCullFaceMode {
        match *self {
            PipelineCullFaceMode::None => ffi::COGL_PIPELINE_CULL_FACE_MODE_NONE,
            PipelineCullFaceMode::Front => ffi::COGL_PIPELINE_CULL_FACE_MODE_FRONT,
            PipelineCullFaceMode::Back => ffi::COGL_PIPELINE_CULL_FACE_MODE_BACK,
            PipelineCullFaceMode::Both => ffi::COGL_PIPELINE_CULL_FACE_MODE_BOTH,
            PipelineCullFaceMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglPipelineCullFaceMode> for PipelineCullFaceMode {
    fn from_glib(value: ffi::CoglPipelineCullFaceMode) -> Self {
        match value {
            0 => PipelineCullFaceMode::None,
            1 => PipelineCullFaceMode::Front,
            2 => PipelineCullFaceMode::Back,
            3 => PipelineCullFaceMode::Both,
            value => PipelineCullFaceMode::__Unknown(value),
        }
    }
}

/// Texture filtering is used whenever the current pixel maps either to more
/// than one texture element (texel) or less than one. These filter enums
/// correspond to different strategies used to come up with a pixel color, by
/// possibly referring to multiple neighbouring texels and taking a weighted
/// average or simply using the nearest texel.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PipelineFilter {
    /// Measuring in manhatten distance from the,
    ///  current pixel center, use the nearest texture texel
    Nearest,
    /// Use the weighted average of the 4 texels
    ///  nearest the current pixel center
    Linear,
    /// Select the mimap level whose
    ///  texel size most closely matches the current pixel, and use the
    ///  `PipelineFilter::Nearest` criterion
    NearestMipmapNearest,
    /// Select the mimap level whose
    ///  texel size most closely matches the current pixel, and use the
    ///  `PipelineFilter::Linear` criterion
    LinearMipmapNearest,
    /// Select the two mimap levels
    ///  whose texel size most closely matches the current pixel, use
    ///  the `PipelineFilter::Nearest` criterion on each one and take
    ///  their weighted average
    NearestMipmapLinear,
    /// Select the two mimap levels
    ///  whose texel size most closely matches the current pixel, use
    ///  the `PipelineFilter::Linear` criterion on each one and take
    ///  their weighted average
    LinearMipmapLinear,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PipelineFilter {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PipelineFilter::{}",
            match *self {
                PipelineFilter::Nearest => "Nearest",
                PipelineFilter::Linear => "Linear",
                PipelineFilter::NearestMipmapNearest => "NearestMipmapNearest",
                PipelineFilter::LinearMipmapNearest => "LinearMipmapNearest",
                PipelineFilter::NearestMipmapLinear => "NearestMipmapLinear",
                PipelineFilter::LinearMipmapLinear => "LinearMipmapLinear",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PipelineFilter {
    type GlibType = ffi::CoglPipelineFilter;

    fn to_glib(&self) -> ffi::CoglPipelineFilter {
        match *self {
            PipelineFilter::Nearest => ffi::COGL_PIPELINE_FILTER_NEAREST,
            PipelineFilter::Linear => ffi::COGL_PIPELINE_FILTER_LINEAR,
            PipelineFilter::NearestMipmapNearest => {
                ffi::COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST
            }
            PipelineFilter::LinearMipmapNearest => ffi::COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST,
            PipelineFilter::NearestMipmapLinear => ffi::COGL_PIPELINE_FILTER_NEAREST_MIPMAP_LINEAR,
            PipelineFilter::LinearMipmapLinear => ffi::COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR,
            PipelineFilter::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglPipelineFilter> for PipelineFilter {
    fn from_glib(value: ffi::CoglPipelineFilter) -> Self {
        match value {
            9728 => PipelineFilter::Nearest,
            9729 => PipelineFilter::Linear,
            9984 => PipelineFilter::NearestMipmapNearest,
            9985 => PipelineFilter::LinearMipmapNearest,
            9986 => PipelineFilter::NearestMipmapLinear,
            9987 => PipelineFilter::LinearMipmapLinear,
            value => PipelineFilter::__Unknown(value),
        }
    }
}

/// The wrap mode specifies what happens when texture coordinates
/// outside the range 0→1 are used. Note that if the filter mode is
/// anything but `PipelineFilter::Nearest` then texels outside the
/// range 0→1 might be used even when the coordinate is exactly 0 or 1
/// because OpenGL will try to sample neighbouring pixels. For example
/// if you are trying to render the full texture then you may get
/// artifacts around the edges when the pixels from the other side are
/// merged in if the wrap mode is set to repeat.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PipelineWrapMode {
    /// The texture will be repeated. This
    ///  is useful for example to draw a tiled background.
    Repeat,
    MirroredRepeat,
    /// The coordinates outside the
    ///  range 0→1 will sample copies of the edge pixels of the
    ///  texture. This is useful to avoid artifacts if only one copy of
    ///  the texture is being rendered.
    ClampToEdge,
    /// Cogl will try to automatically
    ///  decide which of the above two to use. For `cogl_rectangle`, it
    ///  will use repeat mode if any of the texture coordinates are
    ///  outside the range 0→1, otherwise it will use clamp to edge. For
    ///  `cogl_polygon` it will always use repeat mode. For
    ///  `cogl_vertex_buffer_draw` it will use repeat mode except for
    ///  layers that have point sprite coordinate generation enabled. This
    ///  is the default value.
    ///
    Automatic,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PipelineWrapMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PipelineWrapMode::{}",
            match *self {
                PipelineWrapMode::Repeat => "Repeat",
                PipelineWrapMode::MirroredRepeat => "MirroredRepeat",
                PipelineWrapMode::ClampToEdge => "ClampToEdge",
                PipelineWrapMode::Automatic => "Automatic",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PipelineWrapMode {
    type GlibType = ffi::CoglPipelineWrapMode;

    fn to_glib(&self) -> ffi::CoglPipelineWrapMode {
        match *self {
            PipelineWrapMode::Repeat => ffi::COGL_PIPELINE_WRAP_MODE_REPEAT,
            PipelineWrapMode::MirroredRepeat => ffi::COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT,
            PipelineWrapMode::ClampToEdge => ffi::COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE,
            PipelineWrapMode::Automatic => ffi::COGL_PIPELINE_WRAP_MODE_AUTOMATIC,
            PipelineWrapMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglPipelineWrapMode> for PipelineWrapMode {
    fn from_glib(value: ffi::CoglPipelineWrapMode) -> Self {
        match value {
            10497 => PipelineWrapMode::Repeat,
            33648 => PipelineWrapMode::MirroredRepeat,
            33071 => PipelineWrapMode::ClampToEdge,
            519 => PipelineWrapMode::Automatic,
            value => PipelineWrapMode::__Unknown(value),
        }
    }
}

/// Pixel formats used by Cogl. For the formats with a byte per
/// component, the order of the components specify the order in
/// increasing memory addresses. So for example
/// `PixelFormat::Rgb888` would have the red component in the
/// lowest address, green in the next address and blue after that
/// regardless of the endianness of the system.
///
/// For the formats with non byte aligned components the component
/// order specifies the order within a 16-bit or 32-bit number from
/// most significant bit to least significant. So for
/// `PixelFormat::Rgb565`, the red component would be in bits
/// 11-15, the green component would be in 6-11 and the blue component
/// would be in 1-5. Therefore the order in memory depends on the
/// endianness of the system.
///
/// When uploading a texture `PixelFormat::Any` can be used as the
/// internal format. Cogl will try to pick the best format to use
/// internally and convert the texture data if necessary.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PixelFormat {
    /// Any format
    Any,
    /// 8 bits alpha mask
    A8,
    /// RGB, 16 bits
    Rgb565,
    /// RGBA, 16 bits
    Rgba4444,
    /// RGBA, 16 bits
    Rgba5551,
    /// Not currently supported
    Yuv,
    /// Single luminance component
    G8,
    /// RG, 16 bits. Note that red-green textures
    ///  are only available if `FeatureID::OglFeatureIdTextureRg` is advertised.
    ///  See `Texture::set_components` for details.
    Rg88,
    /// RGB, 24 bits
    Rgb888,
    /// BGR, 24 bits
    Bgr888,
    /// RGBA, 32 bits
    Rgba8888,
    /// BGRA, 32 bits
    Bgra8888,
    /// ARGB, 32 bits
    Argb8888,
    /// ABGR, 32 bits
    Abgr8888,
    /// RGBA, 32 bits, 10 bpc
    Rgba1010102,
    /// BGRA, 32 bits, 10 bpc
    Bgra1010102,
    /// ARGB, 32 bits, 10 bpc
    Argb2101010,
    /// ABGR, 32 bits, 10 bpc
    Abgr2101010,
    /// Premultiplied RGBA, 32 bits
    Rgba8888Pre,
    /// Premultiplied BGRA, 32 bits
    Bgra8888Pre,
    /// Premultiplied ARGB, 32 bits
    Argb8888Pre,
    /// Premultiplied ABGR, 32 bits
    Abgr8888Pre,
    /// Premultiplied RGBA, 16 bits
    Rgba4444Pre,
    /// Premultiplied RGBA, 16 bits
    Rgba5551Pre,
    /// Premultiplied RGBA, 32 bits, 10 bpc
    Rgba1010102Pre,
    /// Premultiplied BGRA, 32 bits, 10 bpc
    Bgra1010102Pre,
    /// Premultiplied ARGB, 32 bits, 10 bpc
    Argb2101010Pre,
    /// Premultiplied ABGR, 32 bits, 10 bpc
    Abgr2101010Pre,
    Depth16,
    Depth32,
    Depth24Stencil8,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PixelFormat {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PixelFormat::{}",
            match *self {
                PixelFormat::Any => "Any",
                PixelFormat::A8 => "A8",
                PixelFormat::Rgb565 => "Rgb565",
                PixelFormat::Rgba4444 => "Rgba4444",
                PixelFormat::Rgba5551 => "Rgba5551",
                PixelFormat::Yuv => "Yuv",
                PixelFormat::G8 => "G8",
                PixelFormat::Rg88 => "Rg88",
                PixelFormat::Rgb888 => "Rgb888",
                PixelFormat::Bgr888 => "Bgr888",
                PixelFormat::Rgba8888 => "Rgba8888",
                PixelFormat::Bgra8888 => "Bgra8888",
                PixelFormat::Argb8888 => "Argb8888",
                PixelFormat::Abgr8888 => "Abgr8888",
                PixelFormat::Rgba1010102 => "Rgba1010102",
                PixelFormat::Bgra1010102 => "Bgra1010102",
                PixelFormat::Argb2101010 => "Argb2101010",
                PixelFormat::Abgr2101010 => "Abgr2101010",
                PixelFormat::Rgba8888Pre => "Rgba8888Pre",
                PixelFormat::Bgra8888Pre => "Bgra8888Pre",
                PixelFormat::Argb8888Pre => "Argb8888Pre",
                PixelFormat::Abgr8888Pre => "Abgr8888Pre",
                PixelFormat::Rgba4444Pre => "Rgba4444Pre",
                PixelFormat::Rgba5551Pre => "Rgba5551Pre",
                PixelFormat::Rgba1010102Pre => "Rgba1010102Pre",
                PixelFormat::Bgra1010102Pre => "Bgra1010102Pre",
                PixelFormat::Argb2101010Pre => "Argb2101010Pre",
                PixelFormat::Abgr2101010Pre => "Abgr2101010Pre",
                PixelFormat::Depth16 => "Depth16",
                PixelFormat::Depth32 => "Depth32",
                PixelFormat::Depth24Stencil8 => "Depth24Stencil8",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PixelFormat {
    type GlibType = ffi::CoglPixelFormat;

    fn to_glib(&self) -> ffi::CoglPixelFormat {
        match *self {
            PixelFormat::Any => ffi::COGL_PIXEL_FORMAT_ANY,
            PixelFormat::A8 => ffi::COGL_PIXEL_FORMAT_A_8,
            PixelFormat::Rgb565 => ffi::COGL_PIXEL_FORMAT_RGB_565,
            PixelFormat::Rgba4444 => ffi::COGL_PIXEL_FORMAT_RGBA_4444,
            PixelFormat::Rgba5551 => ffi::COGL_PIXEL_FORMAT_RGBA_5551,
            PixelFormat::Yuv => ffi::COGL_PIXEL_FORMAT_YUV,
            PixelFormat::G8 => ffi::COGL_PIXEL_FORMAT_G_8,
            PixelFormat::Rg88 => ffi::COGL_PIXEL_FORMAT_RG_88,
            PixelFormat::Rgb888 => ffi::COGL_PIXEL_FORMAT_RGB_888,
            PixelFormat::Bgr888 => ffi::COGL_PIXEL_FORMAT_BGR_888,
            PixelFormat::Rgba8888 => ffi::COGL_PIXEL_FORMAT_RGBA_8888,
            PixelFormat::Bgra8888 => ffi::COGL_PIXEL_FORMAT_BGRA_8888,
            PixelFormat::Argb8888 => ffi::COGL_PIXEL_FORMAT_ARGB_8888,
            PixelFormat::Abgr8888 => ffi::COGL_PIXEL_FORMAT_ABGR_8888,
            PixelFormat::Rgba1010102 => ffi::COGL_PIXEL_FORMAT_RGBA_1010102,
            PixelFormat::Bgra1010102 => ffi::COGL_PIXEL_FORMAT_BGRA_1010102,
            PixelFormat::Argb2101010 => ffi::COGL_PIXEL_FORMAT_ARGB_2101010,
            PixelFormat::Abgr2101010 => ffi::COGL_PIXEL_FORMAT_ABGR_2101010,
            PixelFormat::Rgba8888Pre => ffi::COGL_PIXEL_FORMAT_RGBA_8888_PRE,
            PixelFormat::Bgra8888Pre => ffi::COGL_PIXEL_FORMAT_BGRA_8888_PRE,
            PixelFormat::Argb8888Pre => ffi::COGL_PIXEL_FORMAT_ARGB_8888_PRE,
            PixelFormat::Abgr8888Pre => ffi::COGL_PIXEL_FORMAT_ABGR_8888_PRE,
            PixelFormat::Rgba4444Pre => ffi::COGL_PIXEL_FORMAT_RGBA_4444_PRE,
            PixelFormat::Rgba5551Pre => ffi::COGL_PIXEL_FORMAT_RGBA_5551_PRE,
            PixelFormat::Rgba1010102Pre => ffi::COGL_PIXEL_FORMAT_RGBA_1010102_PRE,
            PixelFormat::Bgra1010102Pre => ffi::COGL_PIXEL_FORMAT_BGRA_1010102_PRE,
            PixelFormat::Argb2101010Pre => ffi::COGL_PIXEL_FORMAT_ARGB_2101010_PRE,
            PixelFormat::Abgr2101010Pre => ffi::COGL_PIXEL_FORMAT_ABGR_2101010_PRE,
            PixelFormat::Depth16 => ffi::COGL_PIXEL_FORMAT_DEPTH_16,
            PixelFormat::Depth32 => ffi::COGL_PIXEL_FORMAT_DEPTH_32,
            PixelFormat::Depth24Stencil8 => ffi::COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8,
            PixelFormat::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglPixelFormat> for PixelFormat {
    fn from_glib(value: ffi::CoglPixelFormat) -> Self {
        match value {
            0 => PixelFormat::Any,
            17 => PixelFormat::A8,
            4 => PixelFormat::Rgb565,
            21 => PixelFormat::Rgba4444,
            22 => PixelFormat::Rgba5551,
            7 => PixelFormat::Yuv,
            8 => PixelFormat::G8,
            9 => PixelFormat::Rg88,
            2 => PixelFormat::Rgb888,
            34 => PixelFormat::Bgr888,
            19 => PixelFormat::Rgba8888,
            51 => PixelFormat::Bgra8888,
            83 => PixelFormat::Argb8888,
            115 => PixelFormat::Abgr8888,
            29 => PixelFormat::Rgba1010102,
            61 => PixelFormat::Bgra1010102,
            93 => PixelFormat::Argb2101010,
            125 => PixelFormat::Abgr2101010,
            147 => PixelFormat::Rgba8888Pre,
            179 => PixelFormat::Bgra8888Pre,
            211 => PixelFormat::Argb8888Pre,
            243 => PixelFormat::Abgr8888Pre,
            149 => PixelFormat::Rgba4444Pre,
            150 => PixelFormat::Rgba5551Pre,
            157 => PixelFormat::Rgba1010102Pre,
            189 => PixelFormat::Bgra1010102Pre,
            221 => PixelFormat::Argb2101010Pre,
            253 => PixelFormat::Abgr2101010Pre,
            265 => PixelFormat::Depth16,
            259 => PixelFormat::Depth32,
            771 => PixelFormat::Depth24Stencil8,
            value => PixelFormat::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for PixelFormat {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for PixelFormat {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for PixelFormat {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// A bitmask of events that Cogl may need to wake on for a file
/// descriptor. Note that these all have the same values as the
/// corresponding defines for the poll function call on Unix so they
/// may be directly passed to poll.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum PollFDEvent {
    /// there is data to read
    In,
    /// data can be written (without blocking)
    Pri,
    /// there is urgent data to read.
    Out,
    /// error condition
    Err,
    /// hung up (the connection has been broken, usually
    ///  for pipes and sockets).
    Hup,
    /// invalid request. The file descriptor is not open.
    Nval,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for PollFDEvent {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "PollFDEvent::{}",
            match *self {
                PollFDEvent::In => "In",
                PollFDEvent::Pri => "Pri",
                PollFDEvent::Out => "Out",
                PollFDEvent::Err => "Err",
                PollFDEvent::Hup => "Hup",
                PollFDEvent::Nval => "Nval",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for PollFDEvent {
    type GlibType = ffi::CoglPollFDEvent;

    fn to_glib(&self) -> ffi::CoglPollFDEvent {
        match *self {
            PollFDEvent::In => ffi::COGL_POLL_FD_EVENT_IN,
            PollFDEvent::Pri => ffi::COGL_POLL_FD_EVENT_PRI,
            PollFDEvent::Out => ffi::COGL_POLL_FD_EVENT_OUT,
            PollFDEvent::Err => ffi::COGL_POLL_FD_EVENT_ERR,
            PollFDEvent::Hup => ffi::COGL_POLL_FD_EVENT_HUP,
            PollFDEvent::Nval => ffi::COGL_POLL_FD_EVENT_NVAL,
            PollFDEvent::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglPollFDEvent> for PollFDEvent {
    fn from_glib(value: ffi::CoglPollFDEvent) -> Self {
        match value {
            1 => PollFDEvent::In,
            2 => PollFDEvent::Pri,
            4 => PollFDEvent::Out,
            8 => PollFDEvent::Err,
            16 => PollFDEvent::Hup,
            32 => PollFDEvent::Nval,
            value => PollFDEvent::__Unknown(value),
        }
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum RendererError {
    XlibDisplayOpen,
    BadConstraint,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for RendererError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "RendererError::{}",
            match *self {
                RendererError::XlibDisplayOpen => "XlibDisplayOpen",
                RendererError::BadConstraint => "BadConstraint",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for RendererError {
    type GlibType = ffi::CoglRendererError;

    fn to_glib(&self) -> ffi::CoglRendererError {
        match *self {
            RendererError::XlibDisplayOpen => ffi::COGL_RENDERER_ERROR_XLIB_DISPLAY_OPEN,
            RendererError::BadConstraint => ffi::COGL_RENDERER_ERROR_BAD_CONSTRAINT,
            RendererError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglRendererError> for RendererError {
    fn from_glib(value: ffi::CoglRendererError) -> Self {
        match value {
            0 => RendererError::XlibDisplayOpen,
            1 => RendererError::BadConstraint,
            value => RendererError::__Unknown(value),
        }
    }
}

impl ErrorDomain for RendererError {
    fn domain() -> Quark {
        unsafe { from_glib(ffi::cogl_renderer_error_quark()) }
    }

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

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(RendererError::XlibDisplayOpen),
            1 => Some(RendererError::BadConstraint),
            value => Some(RendererError::__Unknown(value)),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for RendererError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for RendererError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for RendererError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Types of shaders
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum ShaderType {
    /// A program for proccessing vertices
    Vertex,
    /// A program for processing fragments
    Fragment,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for ShaderType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "ShaderType::{}",
            match *self {
                ShaderType::Vertex => "Vertex",
                ShaderType::Fragment => "Fragment",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for ShaderType {
    type GlibType = ffi::CoglShaderType;

    fn to_glib(&self) -> ffi::CoglShaderType {
        match *self {
            ShaderType::Vertex => ffi::COGL_SHADER_TYPE_VERTEX,
            ShaderType::Fragment => ffi::COGL_SHADER_TYPE_FRAGMENT,
            ShaderType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglShaderType> for ShaderType {
    fn from_glib(value: ffi::CoglShaderType) -> Self {
        match value {
            0 => ShaderType::Vertex,
            1 => ShaderType::Fragment,
            value => ShaderType::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for ShaderType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for ShaderType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for ShaderType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// `SnippetHook` is used to specify a location within a
/// `Pipeline` where the code of the snippet should be used when it
/// is attached to a pipeline.
///
/// `<glosslist>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::VertexGlobals``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet at the beginning of the global section of the
/// shader for the vertex processing. Any declarations here can be
/// shared with all other snippets that are attached to a vertex hook.
/// Only the ‘declarations’ string is used and the other strings are
/// ignored.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::FragmentGlobals``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet at the beginning of the global section of the
/// shader for the fragment processing. Any declarations here can be
/// shared with all other snippets that are attached to a fragment
/// hook. Only the ‘declarations’ string is used and the other strings
/// are ignored.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::Vertex``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the vertex processing
/// stage of the pipeline. This gives a chance for the application to
/// modify the vertex attributes generated by the shader. Typically the
/// snippet will modify cogl_color_out or cogl_position_out builtins.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted at the top of the
/// `main` function before any vertex processing is done.
/// `</para>`
/// `<para>`
/// The ‘replace’ string in `snippet` will be used instead of the
/// generated vertex processing if it is present. This can be used if
/// the application wants to provide a complete vertex shader and
/// doesn't need the generated output from Cogl.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted after all of the
/// standard vertex processing is done. This can be used to modify the
/// outputs.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::VertexTransform``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the vertex transform stage.
/// Typically the snippet will use the cogl_modelview_matrix,
/// cogl_projection_matrix and cogl_modelview_projection_matrix matrices and the
/// cogl_position_in attribute. The hook must write to cogl_position_out.
/// The default processing for this hook will multiply cogl_position_in by
/// the combined modelview-projection matrix and store it on cogl_position_out.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted at the top of the
/// `main` function before the vertex transform is done.
/// `</para>`
/// `<para>`
/// The ‘replace’ string in `snippet` will be used instead of the
/// generated vertex transform if it is present.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted after all of the
/// standard vertex transformation is done. This can be used to modify the
/// cogl_position_out in addition to the default processing.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::PointSize``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the point size
/// calculation step within the vertex shader stage. The snippet should
/// write to the builtin cogl_point_size_out with the new point size.
/// The snippet can either read cogl_point_size_in directly and write a
/// new value or first read an existing value in cogl_point_size_out
/// that would be set by a previous snippet. Note that this hook is
/// only used if `Pipeline::set_per_vertex_point_size` is enabled
/// on the pipeline.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted just before
/// calculating the point size.
/// `</para>`
/// `<para>`
/// The ‘replace’ string in `snippet` will be used instead of the
/// generated point size calculation if it is present.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted after the
/// standard point size calculation is done. This can be used to modify
/// cogl_point_size_out in addition to the default processing.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::Fragment``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the fragment processing
/// stage of the pipeline. This gives a chance for the application to
/// modify the fragment color generated by the shader. Typically the
/// snippet will modify cogl_color_out.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted at the top of the
/// `main` function before any fragment processing is done.
/// `</para>`
/// `<para>`
/// The ‘replace’ string in `snippet` will be used instead of the
/// generated fragment processing if it is present. This can be used if
/// the application wants to provide a complete fragment shader and
/// doesn't need the generated output from Cogl.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted after all of the
/// standard fragment processing is done. At this point the generated
/// value for the rest of the pipeline state will already be in
/// cogl_color_out so the application can modify the result by altering
/// this variable.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::TextureCoordTransform``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the texture coordinate
/// transformation of a particular layer. This can be used to replace
/// the processing for a layer or to modify the results.
/// `</para>`
/// `<para>`
/// Within the snippet code for this hook there are two extra
/// variables. The first is a mat4 called cogl_matrix which represents
/// the user matrix for this layer. The second is called cogl_tex_coord
/// and represents the incoming and outgoing texture coordinate. On
/// entry to the hook, cogl_tex_coord contains the value of the
/// corresponding texture coordinate attribute for this layer. The hook
/// is expected to modify this variable. The output will be passed as a
/// varying to the fragment processing stage. The default code will
/// just multiply cogl_matrix by cogl_tex_coord and store the result in
/// cogl_tex_coord.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted just before the
/// fragment processing for this layer. At this point cogl_tex_coord
/// still contains the value of the texture coordinate attribute.
/// `</para>`
/// `<para>`
/// If a ‘replace’ string is given then this will be used instead of
/// the default fragment processing for this layer. The snippet can
/// modify cogl_tex_coord or leave it as is to apply no transformation.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted just after the
/// transformation. At this point cogl_tex_coord will contain the
/// results of the transformation but it can be further modified by the
/// snippet.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::LayerFragment``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the fragment processing
/// of a particular layer. This can be used to replace the processing
/// for a layer or to modify the results.
/// `</para>`
/// `<para>`
/// Within the snippet code for this hook there is an extra vec4
/// variable called ‘cogl_layer’. This contains the resulting color
/// that will be used for the layer. This can be modified in the ‘post’
/// section or it the default processing can be replaced entirely using
/// the ‘replace’ section.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted just before the
/// fragment processing for this layer.
/// `</para>`
/// `<para>`
/// If a ‘replace’ string is given then this will be used instead of
/// the default fragment processing for this layer. The snippet must write to
/// the ‘cogl_layer’ variable in that case.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted just after the
/// fragment processing for the layer. The results can be modified by changing
/// the value of the ‘cogl_layer’ variable.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
///  `<glossentry>`
///  `<glossterm>``SnippetHook::TextureLookup``</glossterm>`
///  `<glossdef>`
/// `<para>`
/// Adds a shader snippet that will hook on to the texture lookup part
/// of a given layer. This gives a chance for the application to modify
/// the coordinates that will be used for the texture lookup or to
/// alter the returned texel.
/// `</para>`
/// `<para>`
/// Within the snippet code for this hook there are three extra
/// variables available. ‘cogl_sampler’ is a sampler object
/// representing the sampler for the layer where the snippet is
/// attached. ‘cogl_tex_coord’ is a vec4 which contains the texture
/// coordinates that will be used for the texture lookup. This can be
/// modified. ‘cogl_texel’ will contain the result of the texture
/// lookup. This can also be modified.
/// `</para>`
/// `<para>`
/// The ‘declarations’ string in `snippet` will be inserted in the
/// global scope of the shader. Use this to declare any uniforms,
/// attributes or functions that the snippet requires.
/// `</para>`
/// `<para>`
/// The ‘pre’ string in `snippet` will be inserted at the top of the
/// `main` function before any fragment processing is done. This is a
/// good place to modify the cogl_tex_coord variable.
/// `</para>`
/// `<para>`
/// If a ‘replace’ string is given then this will be used instead of a
/// the default texture lookup. The snippet would typically use its own
/// sampler in this case.
/// `</para>`
/// `<para>`
/// The ‘post’ string in `snippet` will be inserted after texture lookup
/// has been preformed. Here the snippet can modify the cogl_texel
/// variable to alter the returned texel.
/// `</para>`
///  `</glossdef>`
///  `</glossentry>`
/// `</glosslist>`
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum SnippetHook {
    /// A hook for the entire vertex processing
    ///  stage of the pipeline.
    Vertex,
    /// A hook for the vertex transformation.
    VertexTransform,
    /// A hook for declaring global data
    ///  that can be shared with all other snippets that are on a vertex
    ///  hook.
    VertexGlobals,
    /// A hook for manipulating the point
    ///  size of a vertex. This is only used if
    ///  `Pipeline::set_per_vertex_point_size` is enabled on the
    ///  pipeline.
    PointSize,
    /// A hook for the entire fragment
    ///  processing stage of the pipeline.
    Fragment,
    /// A hook for declaring global
    ///  data wthat can be shared with all other snippets that are on a
    ///  fragment hook.
    FragmentGlobals,
    /// A hook for applying the
    ///  layer matrix to a texture coordinate for a layer.
    TextureCoordTransform,
    /// A hook for the fragment
    ///  processing of a particular layer.
    LayerFragment,
    /// A hook for the texture lookup
    ///  stage of a given layer in a pipeline.
    TextureLookup,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for SnippetHook {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "SnippetHook::{}",
            match *self {
                SnippetHook::Vertex => "Vertex",
                SnippetHook::VertexTransform => "VertexTransform",
                SnippetHook::VertexGlobals => "VertexGlobals",
                SnippetHook::PointSize => "PointSize",
                SnippetHook::Fragment => "Fragment",
                SnippetHook::FragmentGlobals => "FragmentGlobals",
                SnippetHook::TextureCoordTransform => "TextureCoordTransform",
                SnippetHook::LayerFragment => "LayerFragment",
                SnippetHook::TextureLookup => "TextureLookup",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for SnippetHook {
    type GlibType = ffi::CoglSnippetHook;

    fn to_glib(&self) -> ffi::CoglSnippetHook {
        match *self {
            SnippetHook::Vertex => ffi::COGL_SNIPPET_HOOK_VERTEX,
            SnippetHook::VertexTransform => ffi::COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
            SnippetHook::VertexGlobals => ffi::COGL_SNIPPET_HOOK_VERTEX_GLOBALS,
            SnippetHook::PointSize => ffi::COGL_SNIPPET_HOOK_POINT_SIZE,
            SnippetHook::Fragment => ffi::COGL_SNIPPET_HOOK_FRAGMENT,
            SnippetHook::FragmentGlobals => ffi::COGL_SNIPPET_HOOK_FRAGMENT_GLOBALS,
            SnippetHook::TextureCoordTransform => ffi::COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM,
            SnippetHook::LayerFragment => ffi::COGL_SNIPPET_HOOK_LAYER_FRAGMENT,
            SnippetHook::TextureLookup => ffi::COGL_SNIPPET_HOOK_TEXTURE_LOOKUP,
            SnippetHook::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglSnippetHook> for SnippetHook {
    fn from_glib(value: ffi::CoglSnippetHook) -> Self {
        match value {
            0 => SnippetHook::Vertex,
            1 => SnippetHook::VertexTransform,
            2 => SnippetHook::VertexGlobals,
            3 => SnippetHook::PointSize,
            2048 => SnippetHook::Fragment,
            2049 => SnippetHook::FragmentGlobals,
            4096 => SnippetHook::TextureCoordTransform,
            6144 => SnippetHook::LayerFragment,
            6145 => SnippetHook::TextureLookup,
            value => SnippetHook::__Unknown(value),
        }
    }
}

/// Represents how draw should affect the two buffers
/// of a stereo framebuffer. See `Framebuffer::set_stereo_mode`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum StereoMode {
    /// draw to both stereo buffers
    Both,
    /// draw only to the left stereo buffer
    Left,
    /// draw only to the left stereo buffer
    Right,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for StereoMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "StereoMode::{}",
            match *self {
                StereoMode::Both => "Both",
                StereoMode::Left => "Left",
                StereoMode::Right => "Right",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for StereoMode {
    type GlibType = ffi::CoglStereoMode;

    fn to_glib(&self) -> ffi::CoglStereoMode {
        match *self {
            StereoMode::Both => ffi::COGL_STEREO_BOTH,
            StereoMode::Left => ffi::COGL_STEREO_LEFT,
            StereoMode::Right => ffi::COGL_STEREO_RIGHT,
            StereoMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglStereoMode> for StereoMode {
    fn from_glib(value: ffi::CoglStereoMode) -> Self {
        match value {
            0 => StereoMode::Both,
            1 => StereoMode::Left,
            2 => StereoMode::Right,
            value => StereoMode::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for StereoMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for StereoMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for StereoMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Some output devices (such as LCD panels) display colors
/// by making each pixel consist of smaller "subpixels"
/// that each have a particular color. By using knowledge
/// of the layout of this subpixel components, it is possible
/// to create image content with higher resolution than the
/// pixel grid.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum SubpixelOrder {
    /// the layout of subpixel
    ///  components for the device is unknown.
    Unknown,
    /// the device displays colors
    ///  without geometrically-separated subpixel components,
    ///  or the positioning or colors of the components do not
    ///  match any of the values in the enumeration.
    None,
    /// the device has
    ///  horizontally arranged components in the order
    ///  red-green-blue from left to right.
    HorizontalRgb,
    /// the device has
    ///  horizontally arranged components in the order
    ///  blue-green-red from left to right.
    HorizontalBgr,
    /// the device has
    ///  vertically arranged components in the order
    ///  red-green-blue from top to bottom.
    VerticalRgb,
    /// the device has
    ///  vertically arranged components in the order
    ///  blue-green-red from top to bottom.
    VerticalBgr,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for SubpixelOrder {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "SubpixelOrder::{}",
            match *self {
                SubpixelOrder::Unknown => "Unknown",
                SubpixelOrder::None => "None",
                SubpixelOrder::HorizontalRgb => "HorizontalRgb",
                SubpixelOrder::HorizontalBgr => "HorizontalBgr",
                SubpixelOrder::VerticalRgb => "VerticalRgb",
                SubpixelOrder::VerticalBgr => "VerticalBgr",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for SubpixelOrder {
    type GlibType = ffi::CoglSubpixelOrder;

    fn to_glib(&self) -> ffi::CoglSubpixelOrder {
        match *self {
            SubpixelOrder::Unknown => ffi::COGL_SUBPIXEL_ORDER_UNKNOWN,
            SubpixelOrder::None => ffi::COGL_SUBPIXEL_ORDER_NONE,
            SubpixelOrder::HorizontalRgb => ffi::COGL_SUBPIXEL_ORDER_HORIZONTAL_RGB,
            SubpixelOrder::HorizontalBgr => ffi::COGL_SUBPIXEL_ORDER_HORIZONTAL_BGR,
            SubpixelOrder::VerticalRgb => ffi::COGL_SUBPIXEL_ORDER_VERTICAL_RGB,
            SubpixelOrder::VerticalBgr => ffi::COGL_SUBPIXEL_ORDER_VERTICAL_BGR,
            SubpixelOrder::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglSubpixelOrder> for SubpixelOrder {
    fn from_glib(value: ffi::CoglSubpixelOrder) -> Self {
        match value {
            0 => SubpixelOrder::Unknown,
            1 => SubpixelOrder::None,
            2 => SubpixelOrder::HorizontalRgb,
            3 => SubpixelOrder::HorizontalBgr,
            4 => SubpixelOrder::VerticalRgb,
            5 => SubpixelOrder::VerticalBgr,
            value => SubpixelOrder::__Unknown(value),
        }
    }
}

/// Error enumeration for Cogl
///
/// The `SystemError::CoglSystemErrorUnsupported` error can be thrown for a
/// variety of reasons. For example:
///
/// `<itemizedlist>`
///  `<listitem>``<para>`You've tried to use a feature that is not
///  advertised by `cogl_has_feature`. This could happen if you create
///  a 2d texture with a non-power-of-two size when
///  `FeatureID::OglFeatureIdTextureNpot` is not advertised.`</para>``</listitem>`
///  `<listitem>``<para>`The GPU can not handle the configuration you have
///  requested. An example might be if you try to use too many texture
///  layers in a single `Pipeline``</para>``</listitem>`
///  `<listitem>``<para>`The driver does not support some
///  configuration.`</para>``</listiem>`
/// `</itemizedlist>`
///
/// Currently this is only used by Cogl API marked as experimental so
/// this enum should also be considered experimental.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum SystemError {
    /// You tried to use a feature or
    ///  configuration not currently available.
    CoglSystemErrorUnsupported,
    /// You tried to allocate a resource
    ///  such as a texture and there wasn't enough memory.
    CoglSystemErrorNoMemory,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for SystemError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "SystemError::{}",
            match *self {
                SystemError::CoglSystemErrorUnsupported => "CoglSystemErrorUnsupported",
                SystemError::CoglSystemErrorNoMemory => "CoglSystemErrorNoMemory",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for SystemError {
    type GlibType = ffi::CoglSystemError;

    fn to_glib(&self) -> ffi::CoglSystemError {
        match *self {
            SystemError::CoglSystemErrorUnsupported => ffi::COGL_SYSTEM_ERROR_UNSUPPORTED,
            SystemError::CoglSystemErrorNoMemory => ffi::COGL_SYSTEM_ERROR_NO_MEMORY,
            SystemError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglSystemError> for SystemError {
    fn from_glib(value: ffi::CoglSystemError) -> Self {
        match value {
            0 => SystemError::CoglSystemErrorUnsupported,
            1 => SystemError::CoglSystemErrorNoMemory,
            value => SystemError::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for SystemError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for SystemError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for SystemError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// See `Texture::set_components`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TextureComponents {
    /// Only the alpha component
    A,
    /// Red and green components. Note that
    ///  this can only be used if the `FeatureID::OglFeatureIdTextureRg` feature
    ///  is advertised.
    Rg,
    /// Red, green and blue components
    Rgb,
    /// Red, green, blue and alpha components
    Rgba,
    /// Only a depth component
    Depth,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for TextureComponents {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "TextureComponents::{}",
            match *self {
                TextureComponents::A => "A",
                TextureComponents::Rg => "Rg",
                TextureComponents::Rgb => "Rgb",
                TextureComponents::Rgba => "Rgba",
                TextureComponents::Depth => "Depth",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for TextureComponents {
    type GlibType = ffi::CoglTextureComponents;

    fn to_glib(&self) -> ffi::CoglTextureComponents {
        match *self {
            TextureComponents::A => ffi::COGL_TEXTURE_COMPONENTS_A,
            TextureComponents::Rg => ffi::COGL_TEXTURE_COMPONENTS_RG,
            TextureComponents::Rgb => ffi::COGL_TEXTURE_COMPONENTS_RGB,
            TextureComponents::Rgba => ffi::COGL_TEXTURE_COMPONENTS_RGBA,
            TextureComponents::Depth => ffi::COGL_TEXTURE_COMPONENTS_DEPTH,
            TextureComponents::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglTextureComponents> for TextureComponents {
    fn from_glib(value: ffi::CoglTextureComponents) -> Self {
        match value {
            1 => TextureComponents::A,
            2 => TextureComponents::Rg,
            3 => TextureComponents::Rgb,
            4 => TextureComponents::Rgba,
            5 => TextureComponents::Depth,
            value => TextureComponents::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for TextureComponents {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TextureComponents {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TextureComponents {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Error codes that can be thrown when allocating textures.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TextureError {
    /// Unsupported size
    Size,
    /// Unsupported format
    Format,
    BadParameter,
    /// A primitive texture type that is
    ///  unsupported by the driver was used
    Type,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for TextureError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "TextureError::{}",
            match *self {
                TextureError::Size => "Size",
                TextureError::Format => "Format",
                TextureError::BadParameter => "BadParameter",
                TextureError::Type => "Type",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for TextureError {
    type GlibType = ffi::CoglTextureError;

    fn to_glib(&self) -> ffi::CoglTextureError {
        match *self {
            TextureError::Size => ffi::COGL_TEXTURE_ERROR_SIZE,
            TextureError::Format => ffi::COGL_TEXTURE_ERROR_FORMAT,
            TextureError::BadParameter => ffi::COGL_TEXTURE_ERROR_BAD_PARAMETER,
            TextureError::Type => ffi::COGL_TEXTURE_ERROR_TYPE,
            TextureError::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglTextureError> for TextureError {
    fn from_glib(value: ffi::CoglTextureError) -> Self {
        match value {
            0 => TextureError::Size,
            1 => TextureError::Format,
            2 => TextureError::BadParameter,
            3 => TextureError::Type,
            value => TextureError::__Unknown(value),
        }
    }
}

impl ErrorDomain for TextureError {
    fn domain() -> Quark {
        unsafe { from_glib(ffi::cogl_texture_error_quark()) }
    }

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

    fn from(code: i32) -> Option<Self> {
        match code {
            0 => Some(TextureError::Size),
            1 => Some(TextureError::Format),
            2 => Some(TextureError::BadParameter),
            3 => Some(TextureError::Type),
            value => Some(TextureError::__Unknown(value)),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for TextureError {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TextureError {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TextureError {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Error codes that can be thrown when performing texture-pixmap-x11
/// operations.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TexturePixmapX11Error {
    /// An X11 protocol error
    TexturePixmapX11ErrorX11,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for TexturePixmapX11Error {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "TexturePixmapX11Error::{}",
            match *self {
                TexturePixmapX11Error::TexturePixmapX11ErrorX11 => "TexturePixmapX11ErrorX11",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for TexturePixmapX11Error {
    type GlibType = ffi::CoglTexturePixmapX11Error;

    fn to_glib(&self) -> ffi::CoglTexturePixmapX11Error {
        match *self {
            TexturePixmapX11Error::TexturePixmapX11ErrorX11 => {
                ffi::COGL_TEXTURE_PIXMAP_X11_ERROR_X11
            }
            TexturePixmapX11Error::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglTexturePixmapX11Error> for TexturePixmapX11Error {
    fn from_glib(value: ffi::CoglTexturePixmapX11Error) -> Self {
        match value {
            0 => TexturePixmapX11Error::TexturePixmapX11ErrorX11,
            value => TexturePixmapX11Error::__Unknown(value),
        }
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TexturePixmapX11ReportLevel {
    RawRectangles,
    DeltaRectangles,
    BoundingBox,
    NonEmpty,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for TexturePixmapX11ReportLevel {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "TexturePixmapX11ReportLevel::{}",
            match *self {
                TexturePixmapX11ReportLevel::RawRectangles => "RawRectangles",
                TexturePixmapX11ReportLevel::DeltaRectangles => "DeltaRectangles",
                TexturePixmapX11ReportLevel::BoundingBox => "BoundingBox",
                TexturePixmapX11ReportLevel::NonEmpty => "NonEmpty",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for TexturePixmapX11ReportLevel {
    type GlibType = ffi::CoglTexturePixmapX11ReportLevel;

    fn to_glib(&self) -> ffi::CoglTexturePixmapX11ReportLevel {
        match *self {
            TexturePixmapX11ReportLevel::RawRectangles => {
                ffi::COGL_TEXTURE_PIXMAP_X11_DAMAGE_RAW_RECTANGLES
            }
            TexturePixmapX11ReportLevel::DeltaRectangles => {
                ffi::COGL_TEXTURE_PIXMAP_X11_DAMAGE_DELTA_RECTANGLES
            }
            TexturePixmapX11ReportLevel::BoundingBox => {
                ffi::COGL_TEXTURE_PIXMAP_X11_DAMAGE_BOUNDING_BOX
            }
            TexturePixmapX11ReportLevel::NonEmpty => ffi::COGL_TEXTURE_PIXMAP_X11_DAMAGE_NON_EMPTY,
            TexturePixmapX11ReportLevel::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglTexturePixmapX11ReportLevel> for TexturePixmapX11ReportLevel {
    fn from_glib(value: ffi::CoglTexturePixmapX11ReportLevel) -> Self {
        match value {
            0 => TexturePixmapX11ReportLevel::RawRectangles,
            1 => TexturePixmapX11ReportLevel::DeltaRectangles,
            2 => TexturePixmapX11ReportLevel::BoundingBox,
            3 => TexturePixmapX11ReportLevel::NonEmpty,
            value => TexturePixmapX11ReportLevel::__Unknown(value),
        }
    }
}

/// Constants representing the underlying hardware texture type of a
/// `Texture`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum TextureType {
    _2d,
    _3d,
    /// A `TextureRectangle`
    Rectangle,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for TextureType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "TextureType::{}",
            match *self {
                TextureType::_2d => "_2d",
                TextureType::_3d => "_3d",
                TextureType::Rectangle => "Rectangle",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for TextureType {
    type GlibType = ffi::CoglTextureType;

    fn to_glib(&self) -> ffi::CoglTextureType {
        match *self {
            TextureType::_2d => ffi::COGL_TEXTURE_TYPE_2D,
            TextureType::_3d => ffi::COGL_TEXTURE_TYPE_3D,
            TextureType::Rectangle => ffi::COGL_TEXTURE_TYPE_RECTANGLE,
            TextureType::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglTextureType> for TextureType {
    fn from_glib(value: ffi::CoglTextureType) -> Self {
        match value {
            0 => TextureType::_2d,
            1 => TextureType::_3d,
            2 => TextureType::Rectangle,
            value => TextureType::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for TextureType {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for TextureType {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for TextureType {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Different ways of interpreting vertices when drawing.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum VerticesMode {
    /// FIXME, equivalent to
    /// `<constant>`GL_POINTS`</constant>`
    Points,
    /// FIXME, equivalent to `<constant>`GL_LINES`</constant>`
    Lines,
    /// FIXME, equivalent to
    /// `<constant>`GL_LINE_LOOP`</constant>`
    LineLoop,
    /// FIXME, equivalent to
    /// `<constant>`GL_LINE_STRIP`</constant>`
    LineStrip,
    /// FIXME, equivalent to
    /// `<constant>`GL_TRIANGLES`</constant>`
    Triangles,
    /// FIXME, equivalent to
    /// `<constant>`GL_TRIANGLE_STRIP`</constant>`
    TriangleStrip,
    /// FIXME, equivalent to `<constant>`GL_TRIANGLE_FAN`</constant>`
    TriangleFan,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for VerticesMode {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "VerticesMode::{}",
            match *self {
                VerticesMode::Points => "Points",
                VerticesMode::Lines => "Lines",
                VerticesMode::LineLoop => "LineLoop",
                VerticesMode::LineStrip => "LineStrip",
                VerticesMode::Triangles => "Triangles",
                VerticesMode::TriangleStrip => "TriangleStrip",
                VerticesMode::TriangleFan => "TriangleFan",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for VerticesMode {
    type GlibType = ffi::CoglVerticesMode;

    fn to_glib(&self) -> ffi::CoglVerticesMode {
        match *self {
            VerticesMode::Points => ffi::COGL_VERTICES_MODE_POINTS,
            VerticesMode::Lines => ffi::COGL_VERTICES_MODE_LINES,
            VerticesMode::LineLoop => ffi::COGL_VERTICES_MODE_LINE_LOOP,
            VerticesMode::LineStrip => ffi::COGL_VERTICES_MODE_LINE_STRIP,
            VerticesMode::Triangles => ffi::COGL_VERTICES_MODE_TRIANGLES,
            VerticesMode::TriangleStrip => ffi::COGL_VERTICES_MODE_TRIANGLE_STRIP,
            VerticesMode::TriangleFan => ffi::COGL_VERTICES_MODE_TRIANGLE_FAN,
            VerticesMode::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglVerticesMode> for VerticesMode {
    fn from_glib(value: ffi::CoglVerticesMode) -> Self {
        match value {
            0 => VerticesMode::Points,
            1 => VerticesMode::Lines,
            2 => VerticesMode::LineLoop,
            3 => VerticesMode::LineStrip,
            4 => VerticesMode::Triangles,
            5 => VerticesMode::TriangleStrip,
            6 => VerticesMode::TriangleFan,
            value => VerticesMode::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for VerticesMode {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for VerticesMode {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for VerticesMode {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Enum used to represent the two directions of rotation. This can be
/// used to set the front face for culling by calling
/// `Pipeline::set_front_face_winding`.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum Winding {
    /// Vertices are in a clockwise order
    Clockwise,
    /// Vertices are in a counter-clockwise order
    CounterClockwise,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for Winding {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "Winding::{}",
            match *self {
                Winding::Clockwise => "Clockwise",
                Winding::CounterClockwise => "CounterClockwise",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for Winding {
    type GlibType = ffi::CoglWinding;

    fn to_glib(&self) -> ffi::CoglWinding {
        match *self {
            Winding::Clockwise => ffi::COGL_WINDING_CLOCKWISE,
            Winding::CounterClockwise => ffi::COGL_WINDING_COUNTER_CLOCKWISE,
            Winding::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglWinding> for Winding {
    fn from_glib(value: ffi::CoglWinding) -> Self {
        match value {
            0 => Winding::Clockwise,
            1 => Winding::CounterClockwise,
            value => Winding::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for Winding {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for Winding {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for Winding {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum WinsysFeature {
    MultipleOnscreen,
    SwapThrottle,
    VblankCounter,
    VblankWait,
    TextureFromPixmap,
    SwapBuffersEvent,
    SwapRegion,
    SwapRegionThrottle,
    SwapRegionSynchronized,
    BufferAge,
    SyncAndCompleteEvent,
    NFeatures,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for WinsysFeature {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "WinsysFeature::{}",
            match *self {
                WinsysFeature::MultipleOnscreen => "MultipleOnscreen",
                WinsysFeature::SwapThrottle => "SwapThrottle",
                WinsysFeature::VblankCounter => "VblankCounter",
                WinsysFeature::VblankWait => "VblankWait",
                WinsysFeature::TextureFromPixmap => "TextureFromPixmap",
                WinsysFeature::SwapBuffersEvent => "SwapBuffersEvent",
                WinsysFeature::SwapRegion => "SwapRegion",
                WinsysFeature::SwapRegionThrottle => "SwapRegionThrottle",
                WinsysFeature::SwapRegionSynchronized => "SwapRegionSynchronized",
                WinsysFeature::BufferAge => "BufferAge",
                WinsysFeature::SyncAndCompleteEvent => "SyncAndCompleteEvent",
                WinsysFeature::NFeatures => "NFeatures",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for WinsysFeature {
    type GlibType = ffi::CoglWinsysFeature;

    fn to_glib(&self) -> ffi::CoglWinsysFeature {
        match *self {
            WinsysFeature::MultipleOnscreen => ffi::COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN,
            WinsysFeature::SwapThrottle => ffi::COGL_WINSYS_FEATURE_SWAP_THROTTLE,
            WinsysFeature::VblankCounter => ffi::COGL_WINSYS_FEATURE_VBLANK_COUNTER,
            WinsysFeature::VblankWait => ffi::COGL_WINSYS_FEATURE_VBLANK_WAIT,
            WinsysFeature::TextureFromPixmap => ffi::COGL_WINSYS_FEATURE_TEXTURE_FROM_PIXMAP,
            WinsysFeature::SwapBuffersEvent => ffi::COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT,
            WinsysFeature::SwapRegion => ffi::COGL_WINSYS_FEATURE_SWAP_REGION,
            WinsysFeature::SwapRegionThrottle => ffi::COGL_WINSYS_FEATURE_SWAP_REGION_THROTTLE,
            WinsysFeature::SwapRegionSynchronized => {
                ffi::COGL_WINSYS_FEATURE_SWAP_REGION_SYNCHRONIZED
            }
            WinsysFeature::BufferAge => ffi::COGL_WINSYS_FEATURE_BUFFER_AGE,
            WinsysFeature::SyncAndCompleteEvent => ffi::COGL_WINSYS_FEATURE_SYNC_AND_COMPLETE_EVENT,
            WinsysFeature::NFeatures => ffi::COGL_WINSYS_FEATURE_N_FEATURES,
            WinsysFeature::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglWinsysFeature> for WinsysFeature {
    fn from_glib(value: ffi::CoglWinsysFeature) -> Self {
        match value {
            0 => WinsysFeature::MultipleOnscreen,
            1 => WinsysFeature::SwapThrottle,
            2 => WinsysFeature::VblankCounter,
            3 => WinsysFeature::VblankWait,
            4 => WinsysFeature::TextureFromPixmap,
            5 => WinsysFeature::SwapBuffersEvent,
            6 => WinsysFeature::SwapRegion,
            7 => WinsysFeature::SwapRegionThrottle,
            8 => WinsysFeature::SwapRegionSynchronized,
            9 => WinsysFeature::BufferAge,
            10 => WinsysFeature::SyncAndCompleteEvent,
            11 => WinsysFeature::NFeatures,
            value => WinsysFeature::__Unknown(value),
        }
    }
}

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

impl<'a> FromValueOptional<'a> for WinsysFeature {
    unsafe fn from_value_optional(value: &Value) -> Option<Self> {
        Some(FromValue::from_value(value))
    }
}

impl<'a> FromValue<'a> for WinsysFeature {
    unsafe fn from_value(value: &Value) -> Self {
        from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
    }
}

impl SetValue for WinsysFeature {
    unsafe fn set_value(value: &mut Value, this: &Self) {
        gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
    }
}

/// Identifies specific window system backends that Cogl supports.
///
/// These can be used to query what backend Cogl is using or to try and
/// explicitly select a backend to use.
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
pub enum WinsysID {
    /// Implies no preference for which backend is used
    Any,
    /// Use the no-op stub backend
    Stub,
    /// Use the GLX window system binding API
    Glx,
    /// Use EGL with the X window system via XLib
    EglXlib,
    /// Use EGL with the PowerVR NULL window system
    EglNull,
    /// Use EGL with the GDL platform
    EglGdl,
    /// Use EGL with the Wayland window system
    EglWayland,
    /// Use EGL with the KMS platform
    EglKms,
    /// Use EGL with the Android platform
    EglAndroid,
    /// Use EGL with the Mir server
    EglMir,
    /// Use the Microsoft Windows WGL binding API
    Wgl,
    /// Use the SDL window system
    Sdl,
    #[doc(hidden)]
    __Unknown(i32),
}

impl fmt::Display for WinsysID {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(
            f,
            "WinsysID::{}",
            match *self {
                WinsysID::Any => "Any",
                WinsysID::Stub => "Stub",
                WinsysID::Glx => "Glx",
                WinsysID::EglXlib => "EglXlib",
                WinsysID::EglNull => "EglNull",
                WinsysID::EglGdl => "EglGdl",
                WinsysID::EglWayland => "EglWayland",
                WinsysID::EglKms => "EglKms",
                WinsysID::EglAndroid => "EglAndroid",
                WinsysID::EglMir => "EglMir",
                WinsysID::Wgl => "Wgl",
                WinsysID::Sdl => "Sdl",
                _ => "Unknown",
            }
        )
    }
}

#[doc(hidden)]
impl ToGlib for WinsysID {
    type GlibType = ffi::CoglWinsysID;

    fn to_glib(&self) -> ffi::CoglWinsysID {
        match *self {
            WinsysID::Any => ffi::COGL_WINSYS_ID_ANY,
            WinsysID::Stub => ffi::COGL_WINSYS_ID_STUB,
            WinsysID::Glx => ffi::COGL_WINSYS_ID_GLX,
            WinsysID::EglXlib => ffi::COGL_WINSYS_ID_EGL_XLIB,
            WinsysID::EglNull => ffi::COGL_WINSYS_ID_EGL_NULL,
            WinsysID::EglGdl => ffi::COGL_WINSYS_ID_EGL_GDL,
            WinsysID::EglWayland => ffi::COGL_WINSYS_ID_EGL_WAYLAND,
            WinsysID::EglKms => ffi::COGL_WINSYS_ID_EGL_KMS,
            WinsysID::EglAndroid => ffi::COGL_WINSYS_ID_EGL_ANDROID,
            WinsysID::EglMir => ffi::COGL_WINSYS_ID_EGL_MIR,
            WinsysID::Wgl => ffi::COGL_WINSYS_ID_WGL,
            WinsysID::Sdl => ffi::COGL_WINSYS_ID_SDL,
            WinsysID::__Unknown(value) => value,
        }
    }
}

#[doc(hidden)]
impl FromGlib<ffi::CoglWinsysID> for WinsysID {
    fn from_glib(value: ffi::CoglWinsysID) -> Self {
        match value {
            0 => WinsysID::Any,
            1 => WinsysID::Stub,
            2 => WinsysID::Glx,
            3 => WinsysID::EglXlib,
            4 => WinsysID::EglNull,
            5 => WinsysID::EglGdl,
            6 => WinsysID::EglWayland,
            7 => WinsysID::EglKms,
            8 => WinsysID::EglAndroid,
            9 => WinsysID::EglMir,
            10 => WinsysID::Wgl,
            11 => WinsysID::Sdl,
            value => WinsysID::__Unknown(value),
        }
    }
}