r_drw2d_api.h 172 KB
Newer Older
hu's avatar
hu committed
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 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618
/*
****************************************************************************
PROJECT : Drw2D driver
FILE    : $Id: r_drw2d_api.h 15479 2018-01-11 14:04:31Z florian.zimmermann $
============================================================================
DESCRIPTION
Driver for DRW2D
============================================================================
                            C O P Y R I G H T
============================================================================
                           Copyright (c) 2016
                                  by
                       Renesas Electronics (Europe) GmbH.
                           Arcadiastrasse 10
                          D-40472 Duesseldorf
                               Germany
                          All rights reserved.
============================================================================

DISCLAIMER

LICENSEE has read, understood and accepted the terms and conditions defined in
the license agreement, especially the usage rights. In any case, it is
LICENSEE's responsibility to make sure that any user of the software complies
with the terms and conditions of the signed license agreement.

****************************************************************************
*/

#ifndef R_DRW2D_API_H_
#define R_DRW2D_API_H_

#ifdef __cplusplus
extern "C" {
#endif


/*******************************************************************************
  Title: DRW2D API

  DRW2D (simple and slim 2D rendering) API.

  DRW2D controls DHD (DaveHD) driver and doesn't accesses H/W register directly. 
  DHD driver controls GPU2D H/W macro and accesses only register of GPU2D H/W macro.

  An application using DRW2D API with DaveHD port should include the following header files.

  * r_typedefs.h
  * r_drw2d_os.h
  * r_drw2d_api.h
  * r_config_drw2d.h
  * r_drw2d_ctx_dhd.h

*/


/***********************************************************
  Constant: API Version

  Major and minor version number and patchlevel

  - R_DRW2D_VERSION_MAJOR
  - R_DRW2D_VERSION_MINOR
  - R_DRW2D_VERSION_PATCH
*/

#define R_DRW2D_VERSION_MAJOR  1
#define R_DRW2D_VERSION_MINOR  8
#define R_DRW2D_VERSION_PATCH  0

/***************************************************************************
  Section: Global Types
*/

/***************************************************************************
  Group: Return codes
*/


/*******************************************************************************
  Enum: r_drw2d_Error_t

  Return codes used in almost all API functions.


  The lower 16 bits of an error code are used to encode detailed, possibly
  device-specific, error information.

  The <R_DRW2D_ERROR_CLASS> macro can be used to mask out the detailed error sub-code.


  Values:
    R_DRW2D_ERR_OK                        - No error occured.

    R_DRW2D_ERR_SYS                       - General system failure
    R_DRW2D_ERR_SYS_MUTEX_LOCK            - Failed to lock mutex
    R_DRW2D_ERR_SYS_MUTEX_UNLOCK          - Failed to unlock mutex
    R_DRW2D_ERR_SYS_MUTEX_CREATE          - Failed to create mutex
    R_DRW2D_ERR_SYS_MUTEX_DESTROY         - Failed to destroy mutex

    R_DRW2D_ERR_NOT_SUPPORTED             - Parameter/argument value or function not supported.

    R_DRW2D_ERR_INVALID_VALUE                                  - Parameter/argument value is out of range or undefined.
    R_DRW2D_ERR_INVALID_VALUE_NULLPTR                          - Parameter pointer argument is NULL
    R_DRW2D_ERR_INVALID_VALUE_FILLMODE                         - Invalid fill mode
    R_DRW2D_ERR_INVALID_VALUE_CULLMODE                         - Invalid cull mode
    R_DRW2D_ERR_INVALID_VALUE_LINEJOIN                         - Invalid LineJoin type
    R_DRW2D_ERR_INVALID_VALUE_LINECAP                          - Invalid LineCap type
    R_DRW2D_ERR_INVALID_VALUE_LINEWIDTH                        - Invalid line width (<= 0)
    R_DRW2D_ERR_INVALID_VALUE_MITERLIMIT                       - Invalid miter limit (<= 0)
    R_DRW2D_ERR_INVALID_VALUE_IMGQUALITY                       - Invalid image quality mode
    R_DRW2D_ERR_INVALID_VALUE_BLENDMODE                        - Invalid blend mode
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCRGB               - Invalid SrcRGB blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTRGB               - Invalid DstRGB blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCALPHA             - Invalid SrcAlpha blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTALPHA             - Invalid DstAlpha blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCRGB_UNSUPPORTED   - Unsupported SrcRGB blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTRGB_UNSUPPORTED   - Unsupported DstRGB blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCALPHA_UNSUPPORTED - Unsupported SrcAlpha blend factor
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTALPHA_UNSUPPORTED - Unsupported DstAlpha blend factor
    R_DRW2D_ERR_INVALID_VALUE_GPUFINISH                        - Invalid finish type (<R_DRW2D_GpuFinish>)
    R_DRW2D_ERR_INVALID_VALUE_TRANSFORMMODE                    - Invalid vertex matrix transform mode (<R_DRW2D_CtxTransformMode>)
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_X                       - Invalid viewport Pos.X
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_Y                       - Invalid viewport Pos.Y
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_W                       - Invalid viewport Size.Width
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_H                       - Invalid viewport Size.Height
    R_DRW2D_ERR_INVALID_VALUE_DRAWLINES_ODDPOINTCOUNT          - Odd number of points passed to <R_DRW2D_DrawLines>
    R_DRW2D_ERR_INVALID_VALUE_PERF_TYPE                        - Invalid performance counter type
    R_DRW2D_ERR_INVALID_VALUE_POLYLINE_COUNT                   - Invalid polyline point count (0 or 1)
    R_DRW2D_ERR_INVALID_VALUE_POLYBEZIER_COUNT                 - Invalid bezier curves point count (0, 1 or 2)
    R_DRW2D_ERR_INVALID_VALUE_CONVKERNELPRESET1D               - Invalid 1D convolution preset
    R_DRW2D_ERR_INVALID_VALUE_CONVKERNELPRESET2D               - Invalid 2D convolution preset

    R_DRW2D_ERR_UNIT                      - General unit error
    R_DRW2D_ERR_UNIT_OUTOFBOUNDS          - Invalid unit number

    R_DRW2D_ERR_DEVICE                    - General device error
    R_DRW2D_ERR_DEVICE_INIT               - Failed to initialize device context
    R_DRW2D_ERR_DEVICE_HANDLE             - Invalid device handle
    R_DRW2D_ERR_DEVICE_INTERNAL           - Internal device driver error
    R_DRW2D_ERR_DEVICE_INTERNAL_SWIZZLEVT - Internal device driver error (trying to mix swizzling + virtual tiling)
    R_DRW2D_ERR_DEVICE_INTERNAL_FINISH    - Internal device driver error (during finish)
    R_DRW2D_ERR_DEVICE_INTERNAL_SHUTDOWN  - Internal device driver error (during shutdown)
    R_DRW2D_ERR_DEVICE_INTERNAL_ALLOCCLUT - Internal device driver error (while allocating CLUT)
    R_DRW2D_ERR_DEVICE_INTERNAL_FLUSH     - Internal device driver error (during flush)
    R_DRW2D_ERR_DEVICE_INTERNAL_CMDLIST   - Internal device driver error (during cmdlist create/..)
    R_DRW2D_ERR_DEVICE_HWINSTANCENR       - Invalid instance (hw unit) nr
    R_DRW2D_ERR_DEVICE_PIXELFMT           - Pixel format not supported by device
    R_DRW2D_ERR_DEVICE_OUTOFVIDMEM        - Failed to allocate video memory
    R_DRW2D_ERR_DEVICE_NATIVEDRVHANDLE    - Failed to query native driver handle
    R_DRW2D_ERR_DEVICE_SAVESTATEALLOC     - Failed to create save state
    R_DRW2D_ERR_DEVICE_SAVESTATE          - Failed to backup low level driver state
    R_DRW2D_ERR_DEVICE_RESTORESTATE       - Failed to restore low level driver state

    R_DRW2D_ERR_CONTEXT                   - General render context error
    R_DRW2D_ERR_CONTEXT_NOTINUSE          - Context not in use.
                                            (while calling <R_DRW2D_ContextSelect>,
                                             <R_DRW2D_ContextInit> has to be called first.)

    R_DRW2D_ERR_FRAMEBUFFER               - General framebuffer error
    R_DRW2D_ERR_FRAMEBUFFER_HANDLE        - Invalid framebuffer handle
    R_DRW2D_ERR_FRAMEBUFFER_ADDR          - Invalid framebuffer address

    R_DRW2D_ERR_BUFFER                    - General (pixel-) buffer error (framebuffer or texture)
    R_DRW2D_ERR_BUFFER_PIXELFMT           - Invalid/unsupported pixel format
    R_DRW2D_ERR_BUFFER_WIDTH              - Invalid/unsupported width
    R_DRW2D_ERR_BUFFER_HEIGHT             - Invalid/unsupported height
    R_DRW2D_ERR_BUFFER_ALLINUSE           - All buffers in use
    R_DRW2D_ERR_BUFFER_ALIGNMENT          - Buffer alignment not correct (for framebuffer)

    R_DRW2D_ERR_TEXTURE                   - General texture error
    R_DRW2D_ERR_TEXTURE_ADDR              - Invalid texture buffer address
    R_DRW2D_ERR_TEXTURE_PIXELFMT          - Unsupported texel format
    R_DRW2D_ERR_TEXTURE_RLE_BPP           - Bits per texel not suitable for RLE decoder (DaveHD specific)
    R_DRW2D_ERR_TEXTURE_TRANSFORMMODE     - Invalid texture matrix transform mode (<R_DRW2D_CtxTextureTransformMode>)
    R_DRW2D_ERR_TEXTURE_WIDTH             - Invalid texture width
    R_DRW2D_ERR_TEXTURE_HEIGHT            - Invalid texture height
    R_DRW2D_ERR_TEXTURE_UNIT              - Invalid texture unit number

    R_DRW2D_ERR_DRAWING                   - Drawing error
    R_DRW2D_ERR_DRAWING_DRAWTRI           - Failed to draw triangle
    R_DRW2D_ERR_DRAWING_DRAWTRIUV         - Failed to draw UV texture mapped triangle
    R_DRW2D_ERR_DRAWING_DRAWRECT          - Failed to draw rectangle
    R_DRW2D_ERR_DRAWING_DRAWRECTUV        - Failed to draw UV texture mapped rectangle
    R_DRW2D_ERR_DRAWING_DRAWQUAD          - Failed to draw quad

    R_DRW2D_ERR_COMMANDLIST               - Commandlist error
    R_DRW2D_ERR_COMMANDLIST_RETHANDLE     - Invalid commandlist handle return address
    R_DRW2D_ERR_COMMANDLIST_HANDLE        - Invalid commandlist handle (not allocated, faulty, can not record, ..)
    R_DRW2D_ERR_COMMANDLIST_CBKNULLPTR    - Commandlist callback function null ptr

    R_DRW2D_ERR_PERF                      - Performance counter error
    R_DRW2D_ERR_PERF_ALLOC                - Failed to allocate performance counters (used by other ctx?)
    R_DRW2D_ERR_PERF_FREE                 - Failed to free performance counters
    R_DRW2D_ERR_PERF_NOTAVAIL             - Performance counter is not available (due to hw-limit or sw-config.)
    R_DRW2D_ERR_PERF_READ                 - Failed to query performance counter value.
    R_DRW2D_ERR_PERF_RESET                - Failed to reset performance counter.

    R_DRW2D_ERR_EFFECT                    - Effect API error
    R_DRW2D_ERR_EFFECT_INVALID_OPERAND    - Invalid Parameters provided for effects.
    R_DRW2D_ERR_EFFECT_OUT_OF_RESOURCES   - Combination of effects cannot be realized.
    R_DRW2D_ERR_EFFECT_INVALID_OPERATION  - Invalid Efefct Name.
    R_DRW2D_ERR_EFFECT_DIV_BY_ZERO        - Attempted Division by zero
                                            (Two identical points provided to Gradient Effect).
    R_DRW2D_ERR_EFFECT_INVALID_TEXTURE    - Invalid Texture Index.

    R_DRW2D_ERR_CONVOLUTION               - Convolution API error
    R_DRW2D_ERR_CONVOLUTION_ADDR          - Invalid coefficient array address.
    R_DRW2D_ERR_CONVOLUTION_DIMENSION     - Invalid kernel dimensions.
    R_DRW2D_ERR_CONVOLUTION_RES_CONFLICT  - Resource conflict. Color unit already in use by effect.
    R_DRW2D_ERR_CONVOLUTION_INVALID_PARAM - Invalid parameter.
*/
typedef enum
{
    R_DRW2D_ERR_OK                                             =  0,

    R_DRW2D_ERR_SYS                                            =  0x00010000,
    R_DRW2D_ERR_SYS_MUTEX_LOCK                                 =  0x00010010,
    R_DRW2D_ERR_SYS_MUTEX_UNLOCK                               =  0x00010011,
    R_DRW2D_ERR_SYS_MUTEX_CREATE                               =  0x00010012,
    R_DRW2D_ERR_SYS_MUTEX_DESTROY                              =  0x00010013,

    R_DRW2D_ERR_NOT_SUPPORTED                                  =  0x00020000,

    R_DRW2D_ERR_INVALID_VALUE                                  =  0x00030000,
    R_DRW2D_ERR_INVALID_VALUE_NULLPTR                          =  0x00030010,
    R_DRW2D_ERR_INVALID_VALUE_FILLMODE                         =  0x00030020,
    R_DRW2D_ERR_INVALID_VALUE_CULLMODE                         =  0x00030030,
    R_DRW2D_ERR_INVALID_VALUE_LINEJOIN                         =  0x00030040,
    R_DRW2D_ERR_INVALID_VALUE_LINECAP                          =  0x00030050,
    R_DRW2D_ERR_INVALID_VALUE_LINEWIDTH                        =  0x00030060,
    R_DRW2D_ERR_INVALID_VALUE_MITERLIMIT                       =  0x00030070,
    R_DRW2D_ERR_INVALID_VALUE_IMGQUALITY                       =  0x00030080,
    R_DRW2D_ERR_INVALID_VALUE_BLENDMODE                        =  0x00030090,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCRGB               =  0x000300A1,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTRGB               =  0x000300A2,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCALPHA             =  0x000300A3,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTALPHA             =  0x000300A4,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCRGB_UNSUPPORTED   =  0x000300A5,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTRGB_UNSUPPORTED   =  0x000300A6,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_SRCALPHA_UNSUPPORTED =  0x000300A7,
    R_DRW2D_ERR_INVALID_VALUE_BLENDFACTOR_DSTALPHA_UNSUPPORTED =  0x000300A8,
    R_DRW2D_ERR_INVALID_VALUE_GPUFINISH                        =  0x000300B0,
    R_DRW2D_ERR_INVALID_VALUE_TRANSFORMMODE                    =  0x000300C0,
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_X                       =  0x000300D1,
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_Y                       =  0x000300D2,
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_W                       =  0x000300D3,
    R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_H                       =  0x000300D4,
    R_DRW2D_ERR_INVALID_VALUE_DRAWLINES_ODDPOINTCOUNT          =  0x000300E0,
    R_DRW2D_ERR_INVALID_VALUE_PERF_TYPE                        =  0x000300F0,
    R_DRW2D_ERR_INVALID_VALUE_POLYLINE_COUNT                   =  0x00030100,
    R_DRW2D_ERR_INVALID_VALUE_POLYBEZIER_COUNT                 =  0x00030110,
    R_DRW2D_ERR_INVALID_VALUE_CONVKERNELPRESET1D               =  0x00030120,
    R_DRW2D_ERR_INVALID_VALUE_CONVKERNELPRESET2D               =  0x00030130,

    R_DRW2D_ERR_UNIT                                           =  0x00050000,
    R_DRW2D_ERR_UNIT_OUTOFBOUNDS                               =  0x00050010,

    R_DRW2D_ERR_DEVICE                                         =  0x00060000,
    R_DRW2D_ERR_DEVICE_INIT                                    =  0x00060010,
    R_DRW2D_ERR_DEVICE_HANDLE                                  =  0x00060020,
    R_DRW2D_ERR_DEVICE_INTERNAL                                =  0x00060030,
    R_DRW2D_ERR_DEVICE_INTERNAL_SWIZZLEVT                      =  0x00060031,
    R_DRW2D_ERR_DEVICE_INTERNAL_FINISH                         =  0x00060032,
    R_DRW2D_ERR_DEVICE_INTERNAL_SHUTDOWN                       =  0x00060033,
    R_DRW2D_ERR_DEVICE_INTERNAL_ALLOCCLUT                      =  0x00060034,

    R_DRW2D_ERR_DEVICE_INTERNAL_FLUSH                          =  0x00060037,
    R_DRW2D_ERR_DEVICE_INTERNAL_CMDLIST                        =  0x00060038,

    R_DRW2D_ERR_DEVICE_HWINSTANCENR                            =  0x00060100,
    R_DRW2D_ERR_DEVICE_PIXELFMT                                =  0x00060110,
    R_DRW2D_ERR_DEVICE_OUTOFVIDMEM                             =  0x00060120,
    R_DRW2D_ERR_DEVICE_NATIVEDRVHANDLE                         =  0x00060130,
    R_DRW2D_ERR_DEVICE_SAVESTATEALLOC                          =  0x00060140,
    R_DRW2D_ERR_DEVICE_SAVESTATE                               =  0x00060150,
    R_DRW2D_ERR_DEVICE_RESTORESTATE                            =  0x00060160,

    R_DRW2D_ERR_CONTEXT                                        =  0x00070000,
    R_DRW2D_ERR_CONTEXT_NOTINUSE                               =  0x00070010,

    R_DRW2D_ERR_FRAMEBUFFER                                    =  0x00080000,
    R_DRW2D_ERR_FRAMEBUFFER_HANDLE                             =  0x00080010,
    R_DRW2D_ERR_FRAMEBUFFER_ADDR                               =  0x00080020,

    R_DRW2D_ERR_BUFFER                                         =  0x00090000,
    R_DRW2D_ERR_BUFFER_PIXELFMT                                =  0x00090010,
    R_DRW2D_ERR_BUFFER_WIDTH                                   =  0x00090020,
    R_DRW2D_ERR_BUFFER_HEIGHT                                  =  0x00090030,
    R_DRW2D_ERR_BUFFER_ALLINUSE                                =  0x00090040,
    R_DRW2D_ERR_BUFFER_ALIGNMENT                               =  0x00090050,

    R_DRW2D_ERR_TEXTURE                                        =  0x000A0000,
    R_DRW2D_ERR_TEXTURE_ADDR                                   =  0x000A0020,
    R_DRW2D_ERR_TEXTURE_PIXELFMT                               =  0x000A0030,
    R_DRW2D_ERR_TEXTURE_RLE_BPP                                =  0x000A0040,
    R_DRW2D_ERR_TEXTURE_TRANSFORMMODE                          =  0x000A0060,
    R_DRW2D_ERR_TEXTURE_WIDTH                                  =  0x000A0070,
    R_DRW2D_ERR_TEXTURE_HEIGHT                                 =  0x000A0080,
    R_DRW2D_ERR_TEXTURE_UNIT                                   =  0x000A0090,

    R_DRW2D_ERR_DRAWING                                        =  0x000B0000,
    R_DRW2D_ERR_DRAWING_DRAWTRI                                =  0x000B0010,
    R_DRW2D_ERR_DRAWING_DRAWTRIUV                              =  0x000B0020,
    R_DRW2D_ERR_DRAWING_DRAWRECT                               =  0x000B0030,
    R_DRW2D_ERR_DRAWING_DRAWRECTUV                             =  0x000B0040,
    R_DRW2D_ERR_DRAWING_DRAWQUAD                               =  0x000B0050,
    R_DRW2D_ERR_DRAWING_TEXTUREBLIT                            =  0x000B0060,

    R_DRW2D_ERR_COMMANDLIST                                    =  0x000C0000,
    R_DRW2D_ERR_COMMANDLIST_RETHANDLE                          =  0x000C0010,
    R_DRW2D_ERR_COMMANDLIST_HANDLE                             =  0x000C0020,
    R_DRW2D_ERR_COMMANDLIST_CBKNULLPTR                         =  0x000C0030,

    R_DRW2D_ERR_PERF                                           =  0x000D0000,
    R_DRW2D_ERR_PERF_ALLOC                                     =  0x000D0010,
    R_DRW2D_ERR_PERF_FREE                                      =  0x000D0020,
    R_DRW2D_ERR_PERF_NOTAVAIL                                  =  0x000D0030,
    R_DRW2D_ERR_PERF_READ                                      =  0x000D0040,
    R_DRW2D_ERR_PERF_RESET                                     =  0x000D0050,

    R_DRW2D_ERR_EFFECT                                         =  0x000E0000,
    R_DRW2D_ERR_EFFECT_INVALID_OPERAND                         =  0x000E0010,
    R_DRW2D_ERR_EFFECT_OUT_OF_RESOURCES                        =  0x000E0020,
    R_DRW2D_ERR_EFFECT_INVALID_OPERATION                       =  0x000E0030,
    R_DRW2D_ERR_EFFECT_DIV_BY_ZERO                             =  0x000E0040,
    R_DRW2D_ERR_EFFECT_INVALID_TEXTURE                         =  0x000E0050,

    R_DRW2D_ERR_CONVOLUTION                                    =  0x000F0000,
    R_DRW2D_ERR_CONVOLUTION_ADDR                               =  0x000F0010,
    R_DRW2D_ERR_CONVOLUTION_DIMENSION                          =  0x000F0020,
    R_DRW2D_ERR_CONVOLUTION_RES_CONFLICT                       =  0x000F0030,
    R_DRW2D_ERR_CONVOLUTION_INVALID_PARAM                      =  0x000F0040,

    R_DRW2D_NUM_ERR_CODES
} r_drw2d_Error_t;


/***************************************************************************
  Group: Macros and Types
*/

/*******************************************************************************
  Macro: R_DRW2D_ERROR_CLASS

  Mask out error sub-code (lower 16bits of error code)

  Parameter:
    a - Error code

  Return value:
    Error class (lower 16bits of error code set to 0)

  See also:
   <r_drw2d_Error_t>
*/
#define R_DRW2D_ERROR_CLASS(a) ((a) & 0x7FFF0000)



/*******************************************************************************
  Type: r_drw2d_Device_t

  Device handle

  See also:
   <R_DRW2D_Init>
*/
typedef void *r_drw2d_Device_t;



/*******************************************************************************
  Type: r_drw2d_Context_t

  Opaque render context handle
*/
typedef void *r_drw2d_Context_t;



/*******************************************************************************
  Type: r_drw2d_FixedP_t

  A 1:15:16 fixed point number (signed 2s complement format. MSB=sign bit, 15 integer bits, 16 fractional bits).
*/
typedef int32_t r_drw2d_FixedP_t;



/*******************************************************************************
  Macro: R_DRW2D_2X

  Convert integer or float to fixed point.

  Parameter:
    v - Integer or float value

  Return value:
    Fixed point value.

  See also:
   <r_drw2d_FixedP_t>, <R_DRW2D_2I>, <R_DRW2D_2F>, <R_DRW2D_2U>
*/
#define R_DRW2D_2X(v) ((r_drw2d_FixedP_t)((v) * 65536))



/*******************************************************************************
  Macro: R_DRW2D_2I

  Convert fixed point to int.

  Parameter:
    x - Fixed point value

  Return value:
    Integer value

  See also:
   <r_drw2d_FixedP_t>, <R_DRW2D_2X>, <R_DRW2D_2F>
*/
#define R_DRW2D_2I(x)  (((int32_t)(x)) / 65536)



/*******************************************************************************
  Macro: R_DRW2D_2F

  Convert fixed point to float.

  Parameter:
    x - Fixed point value

  Return value:
    Float value

  See also:
   <r_drw2d_FixedP_t>, <R_DRW2D_2I>, <R_DRW2D_2X>
*/
#define R_DRW2D_2F(x)  (((float32_t)(x)) * (1.0f / 65536.0f))



/*******************************************************************************
  Macro: R_DRW2D_2U

  Convert integer or float to fixed point normalized texture U coordinate.

  (note) Texture coordinates are prescaled by 256.

  Parameter:
    v - Integer or float value

  Return value:
    Fixed point value.

  See also:
   <r_drw2d_FixedP_t>, <R_DRW2D_2I>, <R_DRW2D_2F>
*/
#define R_DRW2D_2U(v) ((r_drw2d_FixedP_t)((v) * (256 * 65536)))



/*******************************************************************************
  Macro: R_DRW2D_2V

  Convert integer or float to fixed point normalized texture V coordinate.

  (note) Texture coordinates are prescaled by 256.

  Parameter:
    v - Integer or float value

  Return value:
    Fixed point value.

  See also:
   <r_drw2d_FixedP_t>, <R_DRW2D_2I>, <R_DRW2D_2F>
*/
#define R_DRW2D_2V(v) ((r_drw2d_FixedP_t)((v) * (256 * 65536)))



/*******************************************************************************
  Type: r_drw2d_Boolean_t

  A boolean (R_TRUE or R_FALSE, 1 or 0).
*/
typedef int32_t r_drw2d_Boolean_t;



/*******************************************************************************
  Type: r_drw2d_ErrorCallback_t

  Device-context specific error callback function type.

  This callback function is used when a valid Device handle is available.

  Therefore, a different callback function can be set for each thread that
   uses the DRW2D API.

  Must return R_TRUE if the error was handled, or R_FALSE if the default
   error handler shall be run.

  See also:
    <r_drw2d_Error_t>, <R_DRW2D_ErrCallbackSet>
*/
typedef r_drw2d_Boolean_t (*r_drw2d_ErrorCallback_t) (r_drw2d_Device_t Device,
                                                      r_drw2d_Error_t  Error,
                                                      void *           UserData
                                                      );



/*******************************************************************************
  Type: r_drw2d_GlobalErrorCallback_t

  Global error callback function type.

  This callback function is used when no Device handle is available (e.g.
   when the application passed a NULL pointer handle).

  The callback is shared by all threads that use the DRW2D API.

  Must return R_TRUE if the error was handled, or R_FALSE if the default
   error handler shall be run.

  See also:
    <r_drw2d_Error_t>, <R_DRW2D_GlobalErrCallbackSet>
*/
typedef r_drw2d_Boolean_t (*r_drw2d_GlobalErrorCallback_t) (r_drw2d_Error_t  Error,
                                                            void *           UserData
                                                            );



/*******************************************************************************
  Type: r_drw2d_Unit_t

  Device enumeration type.
*/
typedef uint32_t r_drw2d_Unit_t;



/*******************************************************************************
  Type: r_drw2d_Color_t

  Packed 32bit ARGB color.

  See also:
   <R_DRW2D_CtxFgColor>, <R_DRW2D_CtxBgColor>
*/
typedef uint32_t r_drw2d_Color_t;



/*******************************************************************************
  Type: r_drw2d_GpuCmdList_t

  GPU command list handle/address.

  See also:
   <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListGenerate>, <R_DRW2D_GpuCmdListExec>, <R_DRW2D_GpuCmdListCopy>
*/
typedef void *r_drw2d_GpuCmdList_t;



/*******************************************************************************
  Type: r_drw2d_GpuCmdListCallback_t

  GPU command list callback used by <R_DRW2D_GpuCmdListGenerate>.

  See also:
   <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListGenerate>, <R_DRW2D_GpuCmdListExec>, <R_DRW2D_GpuCmdListCopy>
*/
typedef r_drw2d_Error_t (*r_drw2d_GpuCmdListCallback_t) (void *UserData);



/*******************************************************************************
  Type: r_drw2d_EdgeFlag_t

  Specifies which edge(s) of a triangle or quad will be antialiased.

    (note) Edge flags are currently only supported by the Dave HD port of DRW2D

  Values:
    R_DRW2D_EDGE_AB - Antialias edge between first and second vertex
    R_DRW2D_EDGE_BC - Antialias edge between second and third vertex
    R_DRW2D_EDGE_CA - Antialias edge between third and first triangle vertex (triangle only)
    R_DRW2D_EDGE_CD - Antialias edge between third and fourth vertex (quad only)
    R_DRW2D_EDGE_DA - Antialias edge between fourth and first vertex (quad only)
*/
typedef uint32_t r_drw2d_EdgeFlag_t;
#define R_DRW2D_EDGE_AB  ((r_drw2d_EdgeFlag_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)0))))
#define R_DRW2D_EDGE_BC  ((r_drw2d_EdgeFlag_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)1))))
#define R_DRW2D_EDGE_CA  ((r_drw2d_EdgeFlag_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)2))))
#define R_DRW2D_EDGE_CD  ((r_drw2d_EdgeFlag_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)3))))
#define R_DRW2D_EDGE_DA  ((r_drw2d_EdgeFlag_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)4))))





/***************************************************************************
  Group: Enumerations
*/

/*******************************************************************************
  Enum: r_drw2d_PixelFormat_t

  Describes the color model and pixel storage format of an <r_drw2d_Buffer_t>.


  Values:
    R_DRW2D_PIXELFORMAT_NONE     - Unspecified format (e.g. unallocated buffers)
    R_DRW2D_PIXELFORMAT_ALPHA8   - 8 alpha bits per pixel (only available as framebuffer format:
                                   input is read to all 4 channels, alpha channel is written out)
    R_DRW2D_PIXELFORMAT_LUM8     - 8 luminance bits per pixel (only available as framebuffer format:
                                   alpha channel set to 1.0 on read, blue channel is written out)
    R_DRW2D_PIXELFORMAT_AL17     - 1 alpha bit, 7 luminance bits per pixel
    R_DRW2D_PIXELFORMAT_AL44     - 4 alpha bits, 4 luminance bits per pixel
    R_DRW2D_PIXELFORMAT_AL88     - 8 alpha bits, 8 luminance bits per pixel
    R_DRW2D_PIXELFORMAT_AL1      - 1 alpha/luminance bit per pixel (only available as texture format)
    R_DRW2D_PIXELFORMAT_AL2      - 2 alpha/luminance bits per pixel (only available as texture format)
    R_DRW2D_PIXELFORMAT_AL4      - 4 alpha/luminance bits per pixel (only available as texture format)
    R_DRW2D_PIXELFORMAT_AL8      - 8 alpha/luminance bits per pixel (only available as texture format)
    R_DRW2D_PIXELFORMAT_RGB565   - 5 green, 6 red, 5 blue bits per pixel, packed into a 16bit word
    R_DRW2D_PIXELFORMAT_ARGB1555 - 1 alpha, 5 green, 5 red, 5 blue bits per pixel, packed into a 16bit word (alpha=MSB)
    R_DRW2D_PIXELFORMAT_RGBA5551 - 5 green, 5 red, 5 blue, 1 alpha bits per pixel, packed into a 16bit word (alpha=LSB)
    R_DRW2D_PIXELFORMAT_ARGB4444 - 4 alpha, 4 green, 4 red, 4 blue bits per pixel, packed into a 16bit word (alpha=MSB)
    R_DRW2D_PIXELFORMAT_RGBA4444 - 4 green, 4 red, 4 blue, 4 alpha bits per pixel, packed into a 16bit word (alpha=LSB)
    R_DRW2D_PIXELFORMAT_ARGB8888 - 8 alpha, 8 red, 8 green, 8 blue bits per pixel, packed into a 32bit word (alpha=MSB)
    R_DRW2D_PIXELFORMAT_RGBA8888 - 8 red, 8 green, 8 blue, 8 alpha bits per pixel, packed into a 32bit word (alpha=LSB)
    R_DRW2D_PIXELFORMAT_CLUT_8   - 8 bpp color lookup format (only available as texture format)
    R_DRW2D_PIXELFORMAT_CLUT_4   - 4 bpp color lookup format (only available as texture format)
    R_DRW2D_PIXELFORMAT_CLUT_2   - 2 bpp color lookup format (only available as texture format)
    R_DRW2D_PIXELFORMAT_CLUT_1   - 1 bpp color lookup format (only available as texture format)

  See also:
    <r_drw2d_Buffer_t>, <r_drw2d_Texture_t>, <R_DRW2D_FramebufferSet>, <R_DRW2D_CtxTextureSet>

*/
typedef enum
{
    R_DRW2D_PIXELFORMAT_NONE     =  0,
    R_DRW2D_PIXELFORMAT_ALPHA8   =  1,
    R_DRW2D_PIXELFORMAT_LUM8     =  2,
    R_DRW2D_PIXELFORMAT_AL17     =  3,
    R_DRW2D_PIXELFORMAT_AL44     =  4,
    R_DRW2D_PIXELFORMAT_AL88     =  5,
    R_DRW2D_PIXELFORMAT_AL1      =  6,
    R_DRW2D_PIXELFORMAT_AL2      =  7,
    R_DRW2D_PIXELFORMAT_AL4      =  8,
    R_DRW2D_PIXELFORMAT_AL8      =  9,
    R_DRW2D_PIXELFORMAT_RGB565   = 10,
    R_DRW2D_PIXELFORMAT_ARGB1555 = 11,
    R_DRW2D_PIXELFORMAT_RGBA5551 = 12,
    R_DRW2D_PIXELFORMAT_ARGB4444 = 13,
    R_DRW2D_PIXELFORMAT_RGBA4444 = 14,
    R_DRW2D_PIXELFORMAT_ARGB8888 = 15,
    R_DRW2D_PIXELFORMAT_RGBA8888 = 16,
    R_DRW2D_PIXELFORMAT_CLUT_8   = 17,
    R_DRW2D_PIXELFORMAT_CLUT_4   = 18,
    R_DRW2D_PIXELFORMAT_CLUT_2   = 19,
    R_DRW2D_PIXELFORMAT_CLUT_1   = 20,

    R_DRW2D_NUM_PIXELFORMATS
} r_drw2d_PixelFormat_t;



/*******************************************************************************
  Enum: r_drw2d_FramebufferFlags_t

  Flags used for <R_DRW2D_FramebufferSet> call.

  *reserved for future extensions*

  See also:
    <R_DRW2D_FramebufferSet>
*/
typedef enum
{
    __R_DRW2D_FRAMEBUFFERFLAGS_PLACEHOLDER__
} r_drw2d_FramebufferFlags_t;



/*******************************************************************************
  Enum: r_drw2d_TextureFlags_t

  Flags used for <R_DRW2D_CtxTextureSet> call.

  The upper 8 bits are reserved for internal purposes (texture lock flags).



  Values:
           R_DRW2D_TEX_NONE - No-op texture flag
          R_DRW2D_TEX_WRAPU - Wrap bitmap on U axis (x-direction)
          R_DRW2D_TEX_WRAPV - Wrap bitmap on V axis (y-direction)
       R_DRW2D_TEX_BILINEAR - Enable bilinear filtering
    R_DRW2D_TEX_PERSPECTIVE - Enable perspective texture mapping
            R_DRW2D_TEX_RLE - Enable run length encoding (RLE) texture compression.
                              The 'd3tc_swizzler' tool can be used to convert images to compressed RLE textures.
                              This feature is only available in the Dave HD port of DRW2D.
        R_DRW2D_TEX_SWIZZLE - Enable texture swizzling. This flag cannot be combined with <R_DRW2D_TEX_VT>.
                              The 'd3tc_swizzler' tool can be used to convert images to swizzled textures.
                              This feature is only available in the Dave HD port of DRW2D.
                              The textures' pitch & height have to be aligned to the swizzle mode value (by default it is 4x4
                              which means the pitch & height need to be aligned to 4).
             R_DRW2D_TEX_VT - Enable virtual tiling. This flag cannot be combined with <R_DRW2D_TEX_SWIZZLE>.
                              Virtual tiling settings can be configured in r_config_drw2d.h (R_DRW2D_DHD_VT_BPP_*).
                              This feature is only available in the Dave HD port of DRW2D and requires the texture pitch
                              to be a multiple of the virtual tile width.

  See also:
    <R_DRW2D_CtxTextureSet>
*/
typedef uint32_t r_drw2d_TextureFlags_t;
#define R_DRW2D_TEX_NONE         ((r_drw2d_TextureFlags_t)(0u))
#define R_DRW2D_TEX_WRAPU        ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)0))))
#define R_DRW2D_TEX_WRAPV        ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)1))))
#define R_DRW2D_TEX_BILINEAR     ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)2))))
#define R_DRW2D_TEX_PERSPECTIVE  ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)3))))
#define R_DRW2D_TEX_RLE          ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)4))))
#define R_DRW2D_TEX_SWIZZLE      ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)5))))
#define R_DRW2D_TEX_VT           ((r_drw2d_TextureFlags_t)((uint8_t)(((uint8_t)1u) << ((uint8_t)6))))



/*******************************************************************************
  Enum: r_drw2d_BlendMode_t

  Enumeration of preset blending equations.


  Values:
     R_DRW2D_BLENDMODE_CUSTOM - User defined blendmode specified by <R_DRW2D_CtxBlendFactors>.
       > dst_color = src_color*src_factor_color + dst_color*dst_factor_color
       > dst_alpha = src_alpha*src_factor_alpha + dst_alpha*dst_factor_alpha

     R_DRW2D_BLENDMODE_SRC - Porter-Duff Src
       > dst_color = src_color
       > dst_alpha = src_alpha

     R_DRW2D_BLENDMODE_SRC_OVER - Porter-Duff Src-over-Dst
       > dst_color = src_color + dst_color*(1-src_alpha)
       > dst_alpha = src_alpha + dst_alpha*(1-src_alpha)

     R_DRW2D_BLENDMODE_DST_OVER - Porter-Duff Dst-over-Src
       > dst_color = src_color*(1-dst_alpha) + dst_color
       > dst_alpha = src_alpha*(1-dst_alpha) + dst_alpha

     R_DRW2D_BLENDMODE_SRC_IN - Porter-Duff Src-in-Dst
       > dst_color = src_color*dst_alpha
       > dst_alpha = src_alpha*dst_alpha

     R_DRW2D_BLENDMODE_DST_IN - Porter-Duff Dst-in-Src
       > dst_color = dst_color*src_alpha
       > dst_alpha = dst_alpha*src_alpha

     R_DRW2D_BLENDMODE_MULTIPLY - Multiply the source and destination colors together, producing the effect of placing
                                  a transparent filter over a background.
       > dst_color = (src_alpha*src_color)*(1-dst_alpha) + (dst_alpha*dst_color)*(1-src_alpha)
       >              + (src_alpha*src_color*dst_alpha*dst_color)
       > dst_alpha = src_alpha + dst_alpha*(1-src_alpha)

     R_DRW2D_BLENDMODE_SCREEN - The opposite of multiplication, producing the effect of projecting a slide over a background.
       > dst_color = (src_alpha*src_color) + (dst_alpha*dst_color)
       >              - (src_alpha*src_color*dst_alpha*dst_color)
       > dst_alpha = src_alpha + dst_alpha*(1-src_alpha)

     R_DRW2D_BLENDMODE_DARKEN - Compute (Src over Dst) and (Dst over Src) and take the smaller (darker) value for each channel
       > dst_color = min(src_alpha*src_color + dst_alpha*dst_color *(1-src_alpha),
       >                 dst_alpha*dst_color + src_alpha*src_color *(1-dst_alpha))
       > dst_alpha = src_alpha + dst_alpha*(1-src_alpha)

     R_DRW2D_BLENDMODE_LIGHTEN - Compute (Src over Dst) and (Dst over Src) and take the larger (lighter) value for each channel
       > dst_color = max(src_alpha*src_color + dst_alpha*dst_color *(1-src_alpha),
       >                 dst_alpha*dst_color + src_alpha*src_color *(1-dst_alpha))
       > dst_alpha = src_alpha + dst_alpha*(1-src_alpha)

     R_DRW2D_BLENDMODE_ADDITIVE - Add alpha and color channels
       > dst_color = (src_alpha*src_color + dst_alpha*dst_color) / min(src_alpha + dst_alpha, 1)
       > dst_alpha = min(src_alpha+dst_alpha, 1)

  See also:
    <R_DRW2D_CtxBlendMode>, <R_DRW2D_CtxBlendFactors>, <r_drw2d_BlendFactor_t>
*/
typedef enum
{
    R_DRW2D_BLENDMODE_CUSTOM    =  0,
    R_DRW2D_BLENDMODE_SRC       =  1,
    R_DRW2D_BLENDMODE_SRC_OVER  =  2,
    R_DRW2D_BLENDMODE_DST_OVER  =  3,
    R_DRW2D_BLENDMODE_SRC_IN    =  4,
    R_DRW2D_BLENDMODE_DST_IN    =  5,
    R_DRW2D_BLENDMODE_MULTIPLY  =  6,
    R_DRW2D_BLENDMODE_SCREEN    =  7,
    R_DRW2D_BLENDMODE_DARKEN    =  8,
    R_DRW2D_BLENDMODE_LIGHTEN   =  9,
    R_DRW2D_BLENDMODE_ADDITIVE  = 10,

    R_DRW2D_NUM_BLENDMODES
} r_drw2d_BlendMode_t;



/*******************************************************************************
  Enum: r_drw2d_BlendFactor_t

  Source/destination blend factors used in <R_DRW2D_CtxBlendFactors>.


  When <R_DRW2D_BLENDMODE_CUSTOM> is selected, the effective color/alpha blend equation is
    > dst_color = src_color*src_factor_color + dst_color*dst_factor_color
    > dst_alpha = src_alpha*src_factor_alpha + dst_alpha*dst_factor_alpha


  Values:
    R_DRW2D_BLEND_ZERO                    - Multiply by 0 (discard)
    R_DRW2D_BLEND_ONE                     - Multiply by 1
    R_DRW2D_BLEND_SRC_COLOR               - Multiply by source color
    R_DRW2D_BLEND_ONE_MINUS_SRC_COLOR     - Multiply by inverse source color
    R_DRW2D_BLEND_DST_COLOR               - Multiply by destination color
    R_DRW2D_BLEND_ONE_MINUS_DST_COLOR     - Multiply by inverse destination color
    R_DRW2D_BLEND_SRC_ALPHA               - Multiply by source alpha
    R_DRW2D_BLEND_ONE_MINUS_SRC_ALPHA     - Multiply by inverse source alpha
    R_DRW2D_BLEND_DST_ALPHA               - Multiply by destination alpha
    R_DRW2D_BLEND_ONE_MINUS_DST_ALPHA     - Multiply by inverse destination alpha
    R_DRW2D_BLEND_CONSTANT_FGCOLOR        - (not supported currently) Multiply by foreground color
    R_DRW2D_BLEND_ONE_MINUS_CONST_FGCOLOR - (not supported currently) Multiply by inverse foreground color
    R_DRW2D_BLEND_CONSTANT_FGALPHA        - (not supported currently) Multiply by foreground alpha
    R_DRW2D_BLEND_ONE_MINUS_CONST_FGALPHA - (not supported currently) Multiply by inverse foreground alpha
    R_DRW2D_BLEND_CONSTANT_BGCOLOR        - (not supported currently) Multiply by background color
    R_DRW2D_BLEND_ONE_MINUS_CONST_BGCOLOR - (not supported currently) Multiply by inverse background color
    R_DRW2D_BLEND_CONSTANT_BGALPHA        - (not supported currently) Multiply by background alpha
    R_DRW2D_BLEND_ONE_MINUS_CONST_FGALPHA - (not supported currently) Multiply by inverse background alpha
    R_DRW2D_BLEND_SRC_ALPHA_SATURATE      - (not supported currently) Multiply by min(source alpha, inverse destination alpha)
    R_DRW2D_BLEND_SRC1_COLOR              - (to be specified)
    R_DRW2D_BLEND_ONE_MINUS_SRC1_COLOR    - (to be specified)
    R_DRW2D_BLEND_SRC1_ALPHA              - (to be specified)
    R_DRW2D_BLEND_ONE_MINUS_SRC1_ALPHA    - (to be specified)
    R_DRW2D_BLEND_SRC1_DST1               - (to be specified, D2D only?)

  See also:
    <R_DRW2D_CtxBlendFactors>, <R_DRW2D_CtxBlendMode>, <r_drw2d_BlendMode_t>

*/
typedef enum
{
    R_DRW2D_BLEND_ZERO                    =  0,
    R_DRW2D_BLEND_ONE                     =  1,
    R_DRW2D_BLEND_SRC_COLOR               =  2,
    R_DRW2D_BLEND_ONE_MINUS_SRC_COLOR     =  3,
    R_DRW2D_BLEND_DST_COLOR               =  4,
    R_DRW2D_BLEND_ONE_MINUS_DST_COLOR     =  5,
    R_DRW2D_BLEND_SRC_ALPHA               =  6,
    R_DRW2D_BLEND_ONE_MINUS_SRC_ALPHA     =  7,
    R_DRW2D_BLEND_DST_ALPHA               =  8,
    R_DRW2D_BLEND_ONE_MINUS_DST_ALPHA     =  9,
    R_DRW2D_BLEND_CONSTANT_FGCOLOR        = 10,
    R_DRW2D_BLEND_ONE_MINUS_CONST_FGCOLOR = 11,
    R_DRW2D_BLEND_CONSTANT_FGALPHA        = 12,
    R_DRW2D_BLEND_ONE_MINUS_CONST_FGALPHA = 13,
    R_DRW2D_BLEND_CONSTANT_BGCOLOR        = 14,
    R_DRW2D_BLEND_ONE_MINUS_CONST_BGCOLOR = 15,
    R_DRW2D_BLEND_CONSTANT_BGALPHA        = 16,
    R_DRW2D_BLEND_ONE_MINUS_CONST_BGALPHA = 17,
    R_DRW2D_BLEND_SRC_ALPHA_SATURATE      = 18,
    R_DRW2D_BLEND_SRC1_COLOR              = 19,
    R_DRW2D_BLEND_ONE_MINUS_SRC1_COLOR    = 20,
    R_DRW2D_BLEND_SRC1_ALPHA              = 21,
    R_DRW2D_BLEND_ONE_MINUS_SRC1_ALPHA    = 22,
    R_DRW2D_BLEND_SRC1_DST1               = 23
} r_drw2d_BlendFactor_t;



/*******************************************************************************
  Enum: r_drw2d_FillMode_t

  Enumeration of primitive fill modes.

  The fillmode influences the drawing mode of all render functions.

  The initial fillmode is <R_DRW2D_FILLMODE_SOLID>.


  Values:
    R_DRW2D_FILLMODE_SOLID   - Fill primitive with foreground color
    R_DRW2D_FILLMODE_TEXTURE - Fill primitive with current texture

  See also:
    <R_DRW2D_CtxFillMode>
*/
typedef enum
{
    R_DRW2D_FILLMODE_SOLID    = 1,
    R_DRW2D_FILLMODE_TEXTURE  = 2,

    R_DRW2D_NUM_FILLMODES
} r_drw2d_FillMode_t;



/*******************************************************************************
  Enum: r_drw2d_CullMode_t

  Enumeration of winding order culling modes.

  The initial cull mode is <R_DRW2D_CULLMODE_NONE>.


  Value:
    R_DRW2D_CULLMODE_NONE - Never cull primitives [default]
    R_DRW2D_CULLMODE_CCW - Cull primitives that have a counter clock wise winding order
    R_DRW2D_CULLMODE_CW  - Cull primitives that have a clock wise winding order
*/
typedef enum
{
    R_DRW2D_CULLMODE_NONE = 0,
    R_DRW2D_CULLMODE_CCW  = 1,
    R_DRW2D_CULLMODE_CW   = 2,

    R_DRW2D_NUM_CULLMODES
} r_drw2d_CullMode_t;



/*******************************************************************************
  Enum: r_drw2d_LineCap_t

  Enumeration of line start/end drawing styles.


  Values:
    R_DRW2D_LINECAP_ROUND  - Draw round line endings.
    R_DRW2D_LINECAP_SQUARE - Draw flat line ending, offset by half the line width.
    R_DRW2D_LINECAP_BUTT   - Draw flat line ending.

  See also:
    <R_DRW2D_CtxLineStyle>, <r_drw2d_LineJoin_t>, <r_drw2d_LineStyle_t>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>
*/

typedef enum
{
    R_DRW2D_LINECAP_ROUND   = 0,
    R_DRW2D_LINECAP_SQUARE  = 1,
    R_DRW2D_LINECAP_BUTT    = 2
} r_drw2d_LineCap_t;



/*******************************************************************************
  Enum: r_drw2d_LineJoin_t

  Enumeration of line connection drawing styles for multi-segment lines (see <R_DRW2D_DrawPolyline>).


  Values:
    R_DRW2D_LINEJOIN_NONE  - Do not connect lines (gaps may appear at sharp angles)
    R_DRW2D_LINEJOIN_MITER - Connect lines using sharp edges
    R_DRW2D_LINEJOIN_ROUND - Connect lines using round edges
    R_DRW2D_LINEJOIN_BEVEL - Connect lines using flat edges

  See also:
    <R_DRW2D_CtxLineStyle>,  <r_drw2d_LineCap_t>, <r_drw2d_LineStyle_t>, <R_DRW2D_DrawPolyline>
*/
typedef enum
{
    R_DRW2D_LINEJOIN_NONE  = 0,
    R_DRW2D_LINEJOIN_MITER = 1,
    R_DRW2D_LINEJOIN_ROUND = 2,
    R_DRW2D_LINEJOIN_BEVEL = 3,

    R_DRW2D_NUM_LINEJOIN_TYPES
} r_drw2d_LineJoin_t;



/*******************************************************************************
  Enum: r_drw2d_ImgQuality_t

  Enumeration of anti-aliasing / quality modes.


  Values:
    R_DRW2D_IMGQUALITY_LOW    - No antialiasing (default)
    R_DRW2D_IMGQUALITY_MEDIUM - Medium quality antialiasing
    R_DRW2D_IMGQUALITY_HIGH   - High quality antialiasing

  See also:
    <R_DRW2D_CtxImgQuality>
*/
typedef enum
{
    R_DRW2D_IMGQUALITY_LOW     = 0,
    R_DRW2D_IMGQUALITY_MEDIUM  = 1,
    R_DRW2D_IMGQUALITY_HIGH    = 2
} r_drw2d_ImgQuality_t;



/*******************************************************************************
  Enum: r_drw2d_TransformMode_t

  Vertex matrix transform mode.

  Values:
    R_DRW2D_TRANSFORM_NONE - No vertex transformation
    R_DRW2D_TRANSFORM_2D   - 2D vertex transformation (default)
    R_DRW2D_TRANSFORM_3D   - 3d vertex transformation and viewport projection

  See also:
    <R_DRW2D_CtxTransformMode>
*/
typedef enum
{
    R_DRW2D_TRANSFORM_NONE = 0,
    R_DRW2D_TRANSFORM_2D   = 1,
    R_DRW2D_TRANSFORM_3D   = 2
} r_drw2d_TransformMode_t;



/*******************************************************************************
  Enum: r_drw2d_TextureTransformMode_t

  Texture matrix transform mode.

  Values:
      R_DRW2D_TEX_TRANSFORM_NONE - No texture coordinate transformation
        R_DRW2D_TEX_TRANSFORM_2D - 2D texture transformation (default)
  See also:
    <R_DRW2D_CtxTextureTransformMode>
*/
typedef enum
{
    R_DRW2D_TEX_TRANSFORM_NONE    = 0,
    R_DRW2D_TEX_TRANSFORM_2D      = 2,
} r_drw2d_TextureTransformMode_t;



/*******************************************************************************
  Enum: r_drw2d_Performance_t

  Used in <R_DRW2D_PerfValueGet> and <R_DRW2D_PerfValueReset> to query/reset performance values.


  Values:
    R_DRW2D_PERF_GPU_TIME  - Total GPU time spent
    R_DRW2D_PERF_HW_READS  - Total GPU time spent for texture/framebuffer reads
    R_DRW2D_PERF_HW_WRITES - Total GPU time spent for texture/framebuffer writes
*/
typedef enum
{
    R_DRW2D_PERF_GPU_TIME   = 0,
    R_DRW2D_PERF_HW_READS   = 1,
    R_DRW2D_PERF_HW_WRITES  = 2
} r_drw2d_Performance_t;



/*******************************************************************************
  Enum: r_drw2d_Finish_t

  Whether <R_DRW2D_GpuFinish> will block or not can be specified with this option.
  Only when using R_DRW2D_FINISH_NOWAIT_MARK the sequence must be:
  1) (optional, n times possible) R_DRW2D_GpuFinish(dev, R_DRW2D_FINISH_NOWAIT)
  2) (mandatory, one time only)   R_DRW2D_GpuFinish(dev, R_DRW2D_FINISH_NOWAIT_MARK)
  3) (mandatory, one time only)   R_DRW2D_GpuFinished(dev, &finished)


  Values:
    R_DRW2D_FINISH_NOWAIT      - Send current command list to GPU and do not wait for completion.
    R_DRW2D_FINISH_NOWAIT_MARK - Send current command list to GPU non-waiting and mark this list
                                 to be queried with <R_DRW2D_GpuFinished>
    R_DRW2D_FINISH_WAIT        - Send current command list to GPU and wait for completion.

*/
typedef enum
{
    R_DRW2D_FINISH_NOWAIT      = 0,
    R_DRW2D_FINISH_WAIT        = 1,
    R_DRW2D_FINISH_NOWAIT_MARK = 2
} r_drw2d_Finish_t;



/***********************************************************
  Enum: r_drw2d_ConvolveMode_t

  Convolution filter mode (1d horizontal, 1d vertical, 2d)

  Values:
    R_DRW2D_SYS_CONVOLVEMODE_NONE - No convolution filter mode
    R_DRW2D_SYS_CONVOLVEMODE_1DX  - 1d horizontal convolution filter
    R_DRW2D_SYS_CONVOLVEMODE_1DY  - 1d vertical convolution filter
    R_DRW2D_SYS_CONVOLVEMODE_2D   - 2d convolution filter
    R_DRW2D_SYS_CONVOLVEMODE_USER - user defined convolution filter
*/
typedef enum
{
    R_DRW2D_SYS_CONVOLVEMODE_NONE = 0,
    R_DRW2D_SYS_CONVOLVEMODE_1DX  = 1,
    R_DRW2D_SYS_CONVOLVEMODE_1DY  = 2,
    R_DRW2D_SYS_CONVOLVEMODE_2D   = 3,
    R_DRW2D_SYS_CONVOLVEMODE_USER = 4
} r_drw2d_ConvolveMode_t;



/*******************************************************************************
  Enum: r_drw2d_ConvolutionKernelPreset1d_t

  1D convolution filter kernel presets. Also see <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawRectConvolve1dx>,
                                        <R_DRW2D_DrawRectConvolve1dy>

  Values:
    R_DRW2D_CONV1D_GAUSSIAN_BLUR_3 - 3 coefficient gaussian blur
    R_DRW2D_CONV1D_GAUSSIAN_BLUR_5 - 5 coefficient gaussian blur
    R_DRW2D_CONV1D_GAUSSIAN_BLUR_7 - 7 coefficient gaussian blur
    R_DRW2D_CONV1D_SOBEL_DIFF      - 3x1 Sobel differentiation (edge detection)
    R_DRW2D_CONV1D_SOBEL_AVG       - 3x1 Sobel averaging (edge detection)
*/
typedef enum
{
    R_DRW2D_CONV1D_GAUSSIAN_BLUR_3 = 1,
    R_DRW2D_CONV1D_GAUSSIAN_BLUR_5 = 2,
    R_DRW2D_CONV1D_GAUSSIAN_BLUR_7 = 3,
    R_DRW2D_CONV1D_SOBEL_DIFF      = 4,
    R_DRW2D_CONV1D_SOBEL_AVG       = 5,

    R_DRW2D_CONV1D_NUM_PRESETS     = 6

} r_drw2d_ConvolutionKernelPreset1d_t;



/*******************************************************************************
  Enum: r_drw2d_ConvolutionKernelPreset2d_t

  2D convolution filter kernel presets. Also see <R_DRW2D_CtxConvolutionKernelPreset2d>, <R_DRW2D_DrawRectConvolve2d>.

  Values:
    R_DRW2D_CONV2D_GAUSSIAN_BLUR_3x3 - 3x3 gaussian blur
    R_DRW2D_CONV2D_GAUSSIAN_BLUR_5x5 - 5x5 gaussian blur
    R_DRW2D_CONV2D_GAUSSIAN_BLUR_7x7 - 7x7 gaussian blur
    R_DRW2D_CONV2D_SOBEL_H_3x3       - 3x3 Sobel horizontal (edge detection)
    R_DRW2D_CONV2D_SOBEL_V_3x3       - 3x3 Sobel vertical (edge detection)
    R_DRW2D_CONV2D_SHARPEN_3x3       - 3x3 sharpen
    R_DRW2D_CONV2D_EMBOSS_3x3        - 3x3 emboss
*/
typedef enum
{
    R_DRW2D_CONV2D_GAUSSIAN_BLUR_3x3 = 1,
    R_DRW2D_CONV2D_GAUSSIAN_BLUR_5x5 = 2,
    R_DRW2D_CONV2D_GAUSSIAN_BLUR_7x7 = 3,
    R_DRW2D_CONV2D_SOBEL_H_3x3       = 4,
    R_DRW2D_CONV2D_SOBEL_V_3x3       = 5,
    R_DRW2D_CONV2D_SHARPEN_3x3       = 6,
    R_DRW2D_CONV2D_EMBOSS_3x3        = 7,

    R_DRW2D_CONV2D_NUM_PRESETS       = 8

} r_drw2d_ConvolutionKernelPreset2d_t;



/*******************************************************************************
  Enum: r_drw2d_NativeDrvFlags_t

  Flags that can be passed to <R_DRW2D_NativeDriverBegin>.

  Values:
    R_DRW2D_NATIVEDRV_APPCONTEXT - Application uses a different device context to access the low level driver. No DRW2D
                                   state flush or backup will be done. The device context has to be created/destroyed
                                   by the application by calling the respective low level driver functions.
    R_DRW2D_NATIVEDRV_SAVESTATE - Application uses the DRW2D device context to access the low level driver.
                                   All pending DRW2D state updates will be sent to the low level driver and the current
                                   driver state is backed up. It will automatically be restored when
                                   <R_DRW2D_NativeDriverEnd> is called.
    R_DRW2D_NATIVEDRV_KEEPSTATE - Application uses the DRW2D device context to access the low level driver. All pending
                                   DRW2D state updates will be sent to the low level driver. The current driver state will
                                   not be backed up so that state updates done using low level driver access will potentially
                                   have an effect on subsequent DRW2D render calls.
*/
typedef enum
{
    R_DRW2D_NATIVEDRV_APPCONTEXT  = 0,
    R_DRW2D_NATIVEDRV_SAVESTATE   = 1,
    R_DRW2D_NATIVEDRV_KEEPSTATE   = 2
} r_drw2d_NativeDrvFlags_t;


/*******************************************************************************
  Enum: r_drw2d_EffectName_t

  Available effects for the effect stage. Also see <R_DRW2D_CtxEffectsSet>.

  Values:
    R_DRW2D_EFFECT_REPLACE          - Replace by color value. (single 'Color' argument required)
    R_DRW2D_EFFECT_MODULATE         - Product of two color values (two 'Color' arguments required)
    R_DRW2D_EFFECT_ADD              - Sum of two color values (two 'Color' arguments required)
    R_DRW2D_EFFECT_ADD_SIGNED       - Sum of two color values minus 0.5 (two 'Color' arguments required)
    R_DRW2D_EFFECT_SUBTRACT         - Difference of two color values (two 'Color' arguments required)
    R_DRW2D_EFFECT_INTERPOLATE      - Interpolation of two color values by a third color value (three 'Color' arguments
                                      required)
    R_DRW2D_EFFECT_DOT3             - Dot product of two color values. Result is a scalar present in all color channels
                                      (two 'Color' arguments required)
    R_DRW2D_EFFECT_CONSTANT_ALPHA   - Blending by constant alpha (single 'Constant' argument required)
                                      requires <R_DRW2D_IMGQUALITY_MEDIUM> or <R_DRW2D_IMGQUALITY_HIGH>
    R_DRW2D_EFFECT_GRADIENT         - Blending by alpha gradient (two 'Point' and two 'Constant' arguments required)
                                      requires <R_DRW2D_IMGQUALITY_MEDIUM> or <R_DRW2D_IMGQUALITY_HIGH>
*/
typedef enum
{
    R_DRW2D_EFFECT_REPLACE,
    R_DRW2D_EFFECT_MODULATE,
    R_DRW2D_EFFECT_ADD,
    R_DRW2D_EFFECT_ADD_SIGNED,
    R_DRW2D_EFFECT_SUBTRACT,
    R_DRW2D_EFFECT_INTERPOLATE,
    R_DRW2D_EFFECT_DOT3,
    R_DRW2D_EFFECT_CONSTANT_ALPHA,
    R_DRW2D_EFFECT_GRADIENT
} r_drw2d_EffectName_t;



/*******************************************************************************
  Enum: r_drw2d_EffectParamSource_t

  Specifies where the type of the parameters are coming from.

  Values:
    R_DRW2D_EFFECT_SOURCE_TEXTURE_UNIT      - Texture unit: Set texture unit index via Param.Color.Source.TextureUnit
    R_DRW2D_EFFECT_SOURCE_CONSTANT_COLOR    - 32 bit constant color value: Set color value via
                                              Param.Color.Source.ConstantColor
    R_DRW2D_EFFECT_SOURCE_CONSTANT          - 16.16 signed fixpoint value (e.g. for constant alpha effect):
                                              Set value via Param.Constant
    R_DRW2D_EFFECT_SOURCE_POINT             - 2D position (e.g. for gradient effect): Set value via Param.Point
    R_DRW2D_EFFECT_SOURCE_PREV_STAGE        - The result of previous effects stage: Nothing in 'Param' is to be set.
*/
typedef enum
{
    R_DRW2D_EFFECT_SOURCE_TEXTURE_UNIT,
    R_DRW2D_EFFECT_SOURCE_CONSTANT_COLOR,
    R_DRW2D_EFFECT_SOURCE_CONSTANT,
    R_DRW2D_EFFECT_SOURCE_POINT,
    R_DRW2D_EFFECT_SOURCE_PREV_STAGE
} r_drw2d_EffectParamSource_t;



/*******************************************************************************
  Enum: r_drw2d_EffectColorParamOperand_t

  Specifies how the color source parameters shall be accessed.

  Values:
    R_DRW2D_EFFECT_COLOR_OPERAND_RGBA               - uses color channels directly
    R_DRW2D_EFFECT_COLOR_OPERAND_ONE_MINUS_RGBA     - uses inverted color channels
    R_DRW2D_EFFECT_COLOR_OPERAND_ALPHA              - uses alpha value for all color channels
    R_DRW2D_EFFECT_COLOR_OPERAND_ONE_MINUS_ALPHA    - uses inverted alpha value for all color channels
*/
typedef enum
{
    R_DRW2D_EFFECT_COLOR_OPERAND_RGBA,                /* RGB part is used*/
    R_DRW2D_EFFECT_COLOR_OPERAND_ONE_MINUS_RGBA,      /* (1 - RGB) is used*/
    R_DRW2D_EFFECT_COLOR_OPERAND_ALPHA,               /* alpha part is used for all channels */
    R_DRW2D_EFFECT_COLOR_OPERAND_ONE_MINUS_ALPHA,     /* (1 - alpha) part is used for all channels*/
    R_DRW2D_EFFECT_COLOR_OPERAND_111A,                /* alpha part is used, RGB part is set to 1 */
} r_drw2d_EffectColorParamOperand_t;



/*******************************************************************************
  Enum: r_drw2d_ConvKernelColorChannel_t

  Specifies the channels which are being processed by a convolution kernel.

  Values:
    R_DRW2D_CONVKERNEL_COLOR_CHANNEL_RGBA               - all color and alpha channels are being processed by the kernel
    R_DRW2D_CONVKERNEL_COLOR_CHANNEL_RGB                - only RGB channels are being processed by the kernel
*/
typedef enum
{
    R_DRW2D_CONVKERNEL_COLOR_CHANNEL_RGBA,                /* RGBA is processed*/
    R_DRW2D_CONVKERNEL_COLOR_CHANNEL_RGB,                 /* RGB is processed*/
} r_drw2d_ConvKernelColorChannel_t;



/*******************************************************************************
  Enum: r_drw2d_ConvMode_t

  Specifies how the texture is convoluted.

  Values:
    R_DRW2D_CONVMODE_TRIMMED               - Convolution is trimmed to the texture's size.
    R_DRW2D_CONVMODE_BLEEDING              - Convolution is also applied to pixels outside of the texture,
                                             which leads to a "bleeding" effect when using a blurr kernel.
                                             The number of pixels affected outside depends on the used
                                             kernel's size.
*/
typedef enum
{
    R_DRW2D_CONVMODE_TRIMMED,               /* Kernel applied to texture only.          */
    R_DRW2D_CONVMODE_BLEEDING,              /* Kernel applied also outside the texture. */
} r_drw2d_ConvMode_t;





/*******************************************************************************
  Section: Structures
*/

/*******************************************************************************
  Type: r_drw2d_LineStyle_t

  Describes the drawing style for (poly-)lines.


  Fields:
     LineJoin - Line join style. One of <R_DRW2D_LINEJOIN_NONE>, <R_DRW2D_LINEJOIN_MITER>, <R_DRW2D_LINEJOIN_BEVEL>,
                <R_DRW2D_LINEJOIN_ROUND>.
      LineCap - Line cap style. One of <R_DRW2D_LINECAP_ROUND>, <R_DRW2D_LINECAP_SQUARE>, <R_DRW2D_LINECAP_BUTT>.
        Width - Line width
   MiterLimit - Maximum distance between miter line join tip and line point. Value must be greater than zero.
                 If the miter limit is exceeded, a bevel joint will be drawn at the miter limit position.
     IsClosed - If true, draw closed polyline (last vertex is connected to first one)

  See also:
    <R_DRW2D_CtxLineStyle>, <r_drw2d_LineCap_t>, <r_drw2d_LineJoin_t>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>
*/
typedef struct
{
    r_drw2d_LineJoin_t  LineJoin;
    r_drw2d_LineCap_t   LineCap;
    r_drw2d_FixedP_t    Width;
    r_drw2d_FixedP_t    MiterLimit;
    r_drw2d_Boolean_t   IsClosed;
} r_drw2d_LineStyle_t;



/*******************************************************************************
  Type: r_drw2d_Point_t

  A 2D point / vertex (fixed point).

  The vertex matrix (see <R_DRW2D_CtxTransform>) can be used to setup custom coordinate systems.


  Fields:
    X - Horizontal position (see <r_drw2d_FixedP_t>)
    Y - Vertical position (see <r_drw2d_FixedP_t>)

  See also:
    <R_DRW2D_DrawRect>
*/
typedef struct
{
    r_drw2d_FixedP_t X;
    r_drw2d_FixedP_t Y;
} r_drw2d_Point_t;



/***********************************************************
  Type: r_drw2d_Vec4_t

  A 3D point / vertex (4 component fixed point vector).

  This vertex type is used for the assessment of vertex transformations (see <R_DRW2D_VtxTransform>).


  Fields:
    X - Horizontal position (see <r_drw2d_FixedP_t>)
    Y - Vertical position (see <r_drw2d_FixedP_t>)
    Z - 'Stacked' position (see <r_drw2d_FixedP_t>)
    W - Perspective information (see <r_drw2d_FixedP_t>)

  See also:
    <R_DRW2D_VtxTransform>
*/
typedef struct
{
    r_drw2d_FixedP_t X;
    r_drw2d_FixedP_t Y;
    r_drw2d_FixedP_t Z;
    r_drw2d_FixedP_t W;
} r_drw2d_Vec4_t;



/*******************************************************************************
  Type: r_drw2d_Size_t

  Specifies the size of a rectangle (fixed point).


  Fields:
     Width - Horizontal size (see <r_drw2d_FixedP_t>)
    Height - Vertical size (see <r_drw2d_FixedP_t>)

  See also:
    <R_DRW2D_DrawRect>
*/
typedef struct
{
    r_drw2d_FixedP_t Width;
    r_drw2d_FixedP_t Height;
} r_drw2d_Size_t;



/*******************************************************************************
  Type: r_drw2d_Rect_t

  A 2D rectangle, described by position and dimension (fixed point coordinates).


  Fields:
      Pos - Position (see <r_drw2d_Point_t>)
     Size - Size (see <r_drw2d_Size_t>)

  See also:
    <R_DRW2D_DrawRect>
*/
typedef struct
{
    r_drw2d_Point_t Pos;
    r_drw2d_Size_t  Size;
} r_drw2d_Rect_t;



/*******************************************************************************
  Type: r_drw2d_IntPoint_t

  A 2D point (integer).


  Fields:
    X - Horizontal position
    Y - Vertical position

  See also:
    <r_drw2d_IntRect_t>
*/
typedef struct
{
    int32_t X;
    int32_t Y;
} r_drw2d_IntPoint_t;



/*******************************************************************************
  Type: r_drw2d_IntSize_t

  Specifies the size of a rectangle (integer coordinates).


  Fields:
     Width - Horizontal size
    Height - Vertical size

  See also:
    <r_drw2d_IntRect_t>, <r_drw2d_Buffer_t>
*/
typedef struct
{
    int32_t Width;
    int32_t Height;
} r_drw2d_IntSize_t;



/*******************************************************************************
  Type: r_drw2d_IntRect_t

  A 2D rectangle, described by position and dimension (integer coordinates).


  Fields:
       Pos - Position (see <r_drw2d_IntPoint_t>)
      Size - Size (see <r_drw2d_IntSize_t>)

  See also:
    <R_DRW2D_CtxClipRect>
*/
typedef struct
{
    r_drw2d_IntPoint_t Pos;
    r_drw2d_IntSize_t  Size;
} r_drw2d_IntRect_t;



/*******************************************************************************
  Type: r_drw2d_UVCoord_t

  A 2D, normalized U/V coordinate (fixed point).

  (note) U/V are prescaled by 256, i.e. (256.0; 256.0) always maps to the bottom right texture corner.

  The texture matrix (see <R_DRW2D_CtxTextureTransform>) can be used to setup custom texture coordinate systems.


  Fields:
    U - Normalized horizontal texel position, scaled by 256 (see <r_drw2d_FixedP_t>)
    V - Normalized vertical texel position, scaled by 256 (see <r_drw2d_FixedP_t>)

  See also:
    <R_DRW2D_DrawRectUV>, <R_DRW2D_DrawTrianglesUV>
*/
typedef struct
{
    r_drw2d_FixedP_t U;
    r_drw2d_FixedP_t V;
} r_drw2d_UVCoord_t;



/*******************************************************************************
  Type: r_drw2d_Buffer_t

  Buffers are used with <R_DRW2D_FramebufferSet> and textures (<R_DRW2D_CtxTextureSet>).

  The buffer starts at the top/left corner.

  (note) Please consult target-specific documentation regarding alignment rules
         (4bits-per-pixel, scanlines, start address)


  Fields:
          Data - Reference to pixel data (GPU address. CPU address while buffer is locked)
         Pitch - Total number of pixels per line (including alignment/padding)
          Size - Buffer width and height
   PixelFormat - Pixel storage format. See <r_drw2d_PixelFormat_t>.
*/
typedef struct
{
    void                 *Data;
    int32_t               Pitch;
    r_drw2d_IntSize_t     Size;
    r_drw2d_PixelFormat_t PixelFormat;
} r_drw2d_Buffer_t;



/*******************************************************************************
  Type: r_drw2d_Framebuffer_t

  Framebuffer handle and attributes.


  Fields:
    Handle - Internal framebuffer handle (must not be modified by application)
    Buffer - Stores framebuffer geometry and pixel format
     Flags - reserved for future extensions (see <r_drw2d_FramebufferFlags_t>)

  See also:
    <R_DRW2D_FramebufferAlloc>, <R_DRW2D_FramebufferSet>, <R_DRW2D_FramebufferFree>
*/
/* [Golo] Disable MISRA checks here  */
/* Rule 5.3 is violated, because
   Integrity defines a Buffer type, and we cannot change either GHS nor this code */
#if defined (__ghs__)
#pragma ghs startnomisra
#endif

typedef struct
{
    void                      *Handle;
    r_drw2d_Buffer_t           Buffer;
    r_drw2d_FramebufferFlags_t Flags;
} r_drw2d_Framebuffer_t;



/*******************************************************************************
  Type: r_drw2d_Texture_t

  Texture handle and attributes.


  Fields:
    Handle - Internal texture handle (must not be modified by application)
    Buffer - Stores texture geometry and pixel format.
     Flags - Texture flags, see <r_drw2d_TextureFlags_t>

  See also:
    <r_drw2d_Buffer_t>, <R_DRW2D_CtxTextureSet>
*/

typedef struct
{
    void                  *Handle;
    r_drw2d_Buffer_t       Buffer;
    r_drw2d_TextureFlags_t Flags;
} r_drw2d_Texture_t;

#if defined (__ghs__)
#pragma ghs endnomisra
#endif



/*******************************************************************************
  Type: r_drw2d_EffectParam_t

  Effect parameter contains parameter information for one parameter of one effect.


  Fields:
    Source - Source of the parameter (type <r_drw2d_EffectParamSource_t>), declares what 'Param' is.
    Param - The parameter itself as a union. Can be .Color, .Constant or .Point, as indicated by 'Source'.
    See below for details.
    Param.Color - A struct with the fields .Operand and .Source. See below for details.
    Param.Color.Operand - Defines how the color value is to be used,
    e.g. inverted or not (type <r_drw2d_EffectColorParamOperand_t>)
    Param.Color.Source - A union, either .TextureUnit or .ConstantColor, as indicated by 'Source' above.
    Param.Color.Source.TextureUnit - Index of a texture unit
    Param.Color.Source.ConstantColor - 32bit ARGB8888 color value (type <r_drw2d_Color_t>)
    Param.Constant - 16.16 signed fixed point constant value (type <r_drw2d_FixedP_t>)
    Param.Point - 16.16 signed 2D fixed point coordinate (type <r_drw2d_Point_t>).

  See also:
    <r_drw2d_EffectName_t>, <r_drw2d_EffectParam_t>, <R_DRW2D_CtxEffectsSet>, <R_DRW2D_CtxEffectsDelete>,
    <R_DRW2D_CtxEffectsUpdate>
*/
typedef struct
{
    r_drw2d_EffectParamSource_t Source;
    union
    {
        struct
        {
            union
            {
                uint32_t        TextureUnit;   /* 0 or 1, see CtxTextureSet on how to set a texture in a desired texture unit*/
                r_drw2d_Color_t ConstantColor;
            } Source;
            r_drw2d_EffectColorParamOperand_t Operand;
        } Color;
        r_drw2d_FixedP_t Constant;      /* used for example with constant alpha*/
        r_drw2d_Point_t  Point;         /* used for example with gradients*/
    } Param;
} r_drw2d_EffectParam_t;



/*******************************************************************************
  Type: r_drw2d_EffectStage_t

  Effect stage contains information about one effect.


  Fields:
    Name - Name of the effect, type <r_drw2d_EffectName_t>
    Args - Parameters of the effect, array of type <r_drw2d_EffectParam_t> (used length of this array depends on
    'Name' of the effect, maximum is 4)

  See also:
    <r_drw2d_EffectName_t>, <r_drw2d_EffectParam_t>, <R_DRW2D_CtxEffectsSet>, <R_DRW2D_CtxEffectsDelete>,
    <R_DRW2D_CtxEffectsUpdate>
*/
typedef struct
{
    r_drw2d_EffectName_t  Name;
    r_drw2d_EffectParam_t Args[4];
} r_drw2d_EffectStage_t;



/*******************************************************************************
  Type: r_drw2d_ConvKernel_t

  Convolution kernel containing dimensions and coefficients of a kernel.


  Fields:
    Coeff   - The coefficients of the kernel (row by row).
    Channel - The color channels being processed by the kernel.
    Width   - Width of the kernel.
    Height  - Height of the kernel.
    Bias    - Bias value that is added to the resulting color channel values (range: -1.0 to 1.0).

  See also:
    <R_DRW2D_CtxConvolutionKernel>, <R_DRW2D_DrawRectConvolve2d>
*/
typedef struct
{
    const r_drw2d_FixedP_t           *Coeff;
    r_drw2d_ConvKernelColorChannel_t Channel;
    int32_t                          Width;
    int32_t                          Height;
    r_drw2d_FixedP_t                 Bias;
} r_drw2d_ConvKernel_t;



/***********************************************************
  Type: r_drw2d_DeviceBase_t

  Common base class type for all DRW2D-internal device contexts.
*/
struct r_drw2d_DeviceBase_s;
typedef struct r_drw2d_DeviceBase_s r_drw2d_DeviceBase_t;



/***********************************************************
  Type: r_drw2d_RenderContext_s

  Render context attributes.


  Fields:
       DeviceBase - Parent device context or NULL if render context is unused

         ClipRect - Clipping rectangle (not clipped to current framebuffer)
         Viewport - View port.
          FgColor - Foreground color (ARGB32)
          BgColor - Background color (ARGB32)
         FillMode - Fill mode
        LineStyle - Line join/cap style, line width, miterlimit and "closed" flag
       ImgQuality - Current image quality (antialiasing mode)
    TransformMode       - Vertex transform mode (see <r_drw2d_TransformMode_t>)
  TextureTransformMode  - Texture transform mode (See <r_drw2d_TextureTransformMode_t>)
        BlendMode       - Blendmode
        CullMode        - Cull mode (See <r_drw2d_CullMode_t>)
    EnableStriping      - Enable stripping.
    ConvKernelPreset1d  - 1D convolution filter kernel presets
    ConvKernelPreset2d  - 2D convolution filter kernel presets
    EffectStages        - Effect stages
    NumberOfStages      - Number of effect stages.
     BlendFactors - Used when BlendMode is set to <R_DRW2D_BLENDMODE_CUSTOM>
    TextureMatrix - Current texture matrix
     VertexMatrix - Current vertex matrix
          Texture - Current texture

  See also:
    <r_drw2d_RenderContext_t>
*/
struct r_drw2d_RenderContext_s
{
    r_drw2d_DeviceBase_t *DeviceBase;

    r_drw2d_IntRect_t                   ClipRect;
    r_drw2d_IntRect_t                   Viewport; /* (0,0),(0,0) == use current framebuffer size */
    r_drw2d_Color_t                     FgColor;
    r_drw2d_Color_t                     BgColor;
    r_drw2d_FillMode_t                  FillMode;
    r_drw2d_LineStyle_t                 LineStyle;
    r_drw2d_ImgQuality_t                ImgQuality;
    r_drw2d_TransformMode_t             TransformMode;
    r_drw2d_TextureTransformMode_t      TextureTransformMode;
    r_drw2d_BlendMode_t                 BlendMode;
    r_drw2d_CullMode_t                  CullMode;
    r_drw2d_Boolean_t                   EnableStriping;
    r_drw2d_ConvolutionKernelPreset1d_t ConvKernelPreset1d;
    r_drw2d_ConvolutionKernelPreset2d_t ConvKernelPreset2d;
    const r_drw2d_ConvKernel_t*         ConvKernel;
    r_drw2d_ConvMode_t                  ConvMode;

    r_drw2d_EffectStage_t              *EffectStages;
    uint32_t                            NumberOfStages;

    uint32_t                            ClutBase;
    struct
    {
        r_drw2d_BlendFactor_t           SrcRGB;
        r_drw2d_BlendFactor_t           DstRGB;
        r_drw2d_BlendFactor_t           SrcAlpha;
        r_drw2d_BlendFactor_t           DstAlpha;
    } BlendFactors;

    r_drw2d_FixedP_t                    TextureMatrix[3*2];
    r_drw2d_FixedP_t                    VertexMatrix[4*4];
    r_drw2d_Texture_t                   Texture[2];
};



/***********************************************************
  Type: r_drw2d_RenderContext_t

  Structure type for the render context.

  See also:
    <r_drw2d_RenderContext_s>
*/
typedef struct r_drw2d_RenderContext_s r_drw2d_RenderContext_t;



/***********************************************************
  Type: r_drw2d_DeviceBase_s

  Description:
    Common base class for all DRW2D-internal device contexts.

    This structure must be the first field of all driver-specific device context structures.


  Fields:
                 NumBytes - Total size (in bytes) of driver specific device context
                            (including DeviceBase structure)
                     Unit - Parent unit# of device context (DRW2D unit nr.)
                    Mutex - Used to synchronize access to this device context
                    Error - Error callback function pointer and user data (see <R_DRW2D_ErrCallbackSet>,
                            <r_drw2d_ErrorCallback_t>)
     DefaultRenderContext - Default render context.
     CurrentRenderContext - Reference to the current render context. Points whether to the DefaultRenderContext
                            or a user-set context.
       CurrentFramebuffer - Reference to the current framebuffer.
                            Points whether to the default FB or a user-set FB.
            APIDirtyFlags - Bitmask that indicates what to update on API-side when a Draw*() function is called.
                            See R_DRW2D_API_DIRTY_*.
            SysDirtyFlags - Bitmask that indicates what to update on Sys-side when a Draw*() function is called.
                            See R_DRW2D_SYS_DIRTY_*.
        EffectiveClipRect - Current clipping rectangle
           TexCoordsTrans - Transformed texture coordinate cache for static texture mapping
             ConvolveMode - Convolution filter mode (1d horizontal, 1d vertical, 2d)

  See also:
    <r_drw2d_Device_t>, <r_drw2d_DeviceBase_t>

*/
/* [Golo] Disable MISRA checks here  */
/* Rules 5.4 and 5.3 are violated, and we cannot change either GHS nor this code */
#if defined (__ghs__)
#pragma ghs startnomisra
#endif

struct r_drw2d_DeviceBase_s
{
    uint32_t                     NumBytes;
    r_drw2d_Unit_t               Unit;
    r_drw2d_OS_Mutex_t           Mutex;

    struct
    {
        void                    *UserData;
        r_drw2d_ErrorCallback_t  Callback;
    } Error;

    r_drw2d_FixedP_t             DepthRangeNear;
    r_drw2d_FixedP_t             DepthRangeFar;

    r_drw2d_RenderContext_t      DefaultRenderContext;

    struct
    {
        r_drw2d_RenderContext_t *CurrentRenderContext;
        r_drw2d_Framebuffer_t    CurrentFramebuffer;
        uint32_t                 APIDirtyFlags;
        uint32_t                 SysDirtyFlags;
        r_drw2d_IntRect_t        EffectiveClipRect;
        r_drw2d_Point_t          TexCoordsTrans[3];
        r_drw2d_ConvolveMode_t   ConvolveMode;
    } State;
};

#if defined (__ghs__)
#pragma ghs endnomisra
#endif




/*******************************************************************************
  Section: Global functions
*/


/*******************************************************************************
  Group: Basic functions
*/

/*******************************************************************************
  Function: R_DRW2D_Init

  Initialize DRW2D API and initialize global DRW2D resources.

  Must be called during system startup.

  Not threadsafe - The application must ensure that only one thread calls this function.

  All graphics driver specific global initializations must be done by the application during
  system startup (e.g. init DaveHD kernel mode driver).


  Parameter:
    void

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_Init(void);



/*******************************************************************************
  Function: R_DRW2D_Open

  Initialize DRW2D unit and driver-dependent graphics engine and return device handle.

  This function initializes the driver-dependent graphics engine to its default configuration.
  It initializes the internal device structure and returns an opaque handle to that structure.

  A default render context is created implicitly.

  <R_DRW2D_Open> must be called before any drawing function can take place.

  The application must ensure that the RetDevice is not used in more than one thread at a time.
  Ensure that you provide a real structure pointer as DeviceInternal, not a void pointer!
  Also ensure that the DeviceInternal structure members are initialised with 0.


  Parameter:
              Unit - Unit number (see <r_drw2d_Unit_t>)
                     When using DaveHD port, this parameter can only be set to 0.
        DriverUnit - Driver unit number
                     When using DaveHD port, this parameter can only be set to 0.
    DeviceInternal - Pointer to the gfx driver handle,
                     When using DaveHD port, set <r_drw2d_DeviceDHD_t>. defined in r_drw2d_ctx_dhd.h.
                     Normally, this variable is never used by user,1
                     but it must be kept until <R_DRW2D_Close> is called.
         RetDevice - Returns the (opaque) Drw2d device handle

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_Open(r_drw2d_Unit_t    Unit,
                             int32_t           DriverUnit,
                             void             *DeviceInternal,
                             r_drw2d_Device_t *RetDevice
                             );



/*******************************************************************************
  Function: R_DRW2D_Exit

  Shutdown DRW2D API and de-initialize global DRW2D resources.

  Must be called during system shutdown.

  Must not be called when <R_DRW2D_Init> has failed.

  Not threadsafe - The application must ensure that all DRW2D units have been closed and
  only one thread calls this function.


  Parameter:
    void

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_Exit(void);



/*******************************************************************************
  Function: R_DRW2D_Close

  Shutdown DRW2D unit, de-initialize driver-dependent graphics engine and cleans up its internally used resources.


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_Close(r_drw2d_Device_t Device);



/*******************************************************************************
  Function: R_DRW2D_VersionString

  Returns the version string of the DRW2D API.


  Parameter:
    void

  Return value:
   Version string
*/
const char_t *R_DRW2D_VersionString(void);





/*******************************************************************************
  Group: Native driver interface

   The following functions can be used to bypass the DRW2D API and access the low level, hardware-specific driver directly.
*/

/*******************************************************************************
  Function: R_DRW2D_NativeDriverHandleGet

  Returns a handle to the low level driver instance.

  DRW2D must have been initialized using <R_DRW2D_Init> prior to calling this function.


  Parameter:
                Device - Device handle (see <r_drw2d_Device_t>)
    RetNativeDrvHandle - Returns Native driver handle

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
   <R_DRW2D_NativeDriverBegin>, <R_DRW2D_NativeDriverEnd>, <r_drw2d_NativeDrvFlags_t>
*/
r_drw2d_Error_t R_DRW2D_NativeDriverHandleGet(r_drw2d_Device_t   Device,
                                              void             **RetNativeDrvHandle
                                              );



/*******************************************************************************
  Function: R_DRW2D_NativeDriverBegin

  Notify DRW2D that the application wants to access the low level, hardware-specific driver directly.


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    Flags - One of <R_DRW2D_NATIVEDRV_SAVESTATE>, <R_DRW2D_NATIVEDRV_KEEPSTATE>, <R_DRW2D_NATIVEDRV_APPCONTEXT>. The upper 16bits of this parameter are reserved for driver-specific extensions.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
   <R_DRW2D_NativeDriverHandleGet>, <R_DRW2D_NativeDriverEnd>, <r_drw2d_NativeDrvFlags_t>
*/
r_drw2d_Error_t R_DRW2D_NativeDriverBegin(r_drw2d_Device_t Device,
                                          uint32_t         Flags
                                          );



/*******************************************************************************
  Function: R_DRW2D_NativeDriverEnd

  Notify DRW2D that the application has finished accessing the low level, hardware-specific driver directly.


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    Flags - Reserved for future extensions. Pass 0 for now.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
   <R_DRW2D_NativeDriverHandleGet>, <R_DRW2D_NativeDriverBegin>, <r_drw2d_NativeDrvFlags_t>
*/
r_drw2d_Error_t R_DRW2D_NativeDriverEnd(r_drw2d_Device_t Device,
                                        uint32_t         Flags
                                        );





/*******************************************************************************
  Group: Context management functions

  The application can initialize and select render contexts with this API.

  A context stores the following settings:
    - Clipping rectangle (see <R_DRW2D_CtxClipRect>)
    - View port (see <R_DRW2D_CtxViewport>)
    - Foreground color and alpha (see <R_DRW2D_CtxFgColor>)
    - Background color and alpha (see <R_DRW2D_CtxBgColor>)
    - Cull mode (see <R_DRW2D_CtxCullMode>)
    - Striping (see <R_DRW2D_CtxStripingEnable>, <R_DRW2D_CtxStripingDisable>)
    - 1D convolution filter kernel presets (see <R_DRW2D_CtxConvolutionKernelPreset1d>)
    - 2D convolution filter kernel presets (see <R_DRW2D_CtxConvolutionKernelPreset2d>)
    - Convolution filter kernel (see <R_DRW2D_CtxConvolutionKernel>)
    - Effect stages (see <R_DRW2D_CtxEffectsSet>, <R_DRW2D_CtxEffectsDelete> , <R_DRW2D_CtxEffectsUpdate>)
    - Number of effect stages (see <R_DRW2D_CtxEffectsSet>, <R_DRW2D_CtxEffectsDelete> , <R_DRW2D_CtxEffectsUpdate>)
    - Fill mode (see <R_DRW2D_CtxFillMode>, <r_drw2d_FillMode_t>)
    - Blend mode (see <R_DRW2D_CtxBlendMode>, <r_drw2d_BlendMode_t>)
    - Blend factors (see <R_DRW2D_CtxBlendFactors>, <r_drw2d_BlendFactor_t>)
    - Transformation matrix (see <R_DRW2D_CtxTransform>, <R_DRW2D_CtxTranslate>, <R_DRW2D_CtxRotate>,
      <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>)
    - Texture matrix (see <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureTranslate>, <R_DRW2D_CtxTextureRotate>,
      <R_DRW2D_CtxTextureScale>)
    - Line style (see <R_DRW2D_CtxLineStyle>, <r_drw2d_LineCap_t>, <r_drw2d_LineJoin_t>, <r_drw2d_LineStyle_t>)
    - Image quality / antialiasing mode (see <R_DRW2D_CtxImgQuality>, <r_drw2d_ImgQuality_t>)
    - Transform mode (see <R_DRW2D_CtxTransformMode>, <r_drw2d_TransformMode_t>)
    - Source texture (see <R_DRW2D_CtxTextureSet>, <r_drw2d_Texture_t>)

  The context state can be changed by calling one of the R_DRW2D_Ctx*() functions.

  The DRW2D API provides one default context by default, which is initialized in <R_DRW2D_Open>.

  Custom render contexts can be setup using <R_DRW2D_ContextInit> and selected with <R_DRW2D_ContextSelect>.

*/

/*******************************************************************************
  Function: R_DRW2D_ContextInit

  Initialize a render context with default settings.


  Parameter:
           Device - Device handle (see <r_drw2d_Device_t>)
    RenderContext - Reference to uninitialized render context structure (see <r_drw2d_RenderContext_s>)
       RetContext - The context pointer that is initialized

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_ContextSelect>
*/
r_drw2d_Error_t R_DRW2D_ContextInit(r_drw2d_Device_t                Device,
                                    struct r_drw2d_RenderContext_s *RenderContext,
                                    r_drw2d_Context_t              *RetContext
                                    );



/*******************************************************************************
  Function: R_DRW2D_ContextSelect

  Sets the given context as the current one. Passing Context handle NULL will select the default context.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
    Context - Render context handle (see <r_drw2d_Context_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_ContextInit>

*/
r_drw2d_Error_t R_DRW2D_ContextSelect(r_drw2d_Device_t  Device,
                                      r_drw2d_Context_t Context
                                      );





/*******************************************************************************
  Group: Context control functions

  All of the functions in this section operate globally on the currently selected context
  (statemachine-like in OpenGL/OpenVG). That means they influence primitive drawing.

  Resetting values or setting back to default is the responsibility of the application/framework above Drw2D.
*/

/*******************************************************************************
  Function: R_DRW2D_CtxFgColor

  Set the foreground color to be used for drawing primitives.

  The foreground color can be used in custom blend modes by specifying
  <R_DRW2D_BLEND_CONSTANT_FGCOLOR>.

  The alpha component of the foreground color can be used in custom blend modes
  by specifying <R_DRW2D_BLEND_CONSTANT_FGALPHA>.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
      Color - The color value (32bit packed ARGB)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxBgColor>, <R_DRW2D_CtxBlendFactors>, <r_drw2d_BlendFactor_t>
*/
r_drw2d_Error_t R_DRW2D_CtxFgColor(r_drw2d_Device_t Device,
                                   r_drw2d_Color_t  Color
                                   );



/*******************************************************************************
  Function: R_DRW2D_CtxBgColor

  Set the background color to be used for drawing primitives.

  The background color can be used in custom blend modes by specifying
   <R_DRW2D_BLEND_CONSTANT_BGCOLOR>.

  The alpha component of the background color can be used in custom blend modes
   by specifying <R_DRW2D_BLEND_CONSTANT_BGALPHA>.

  The <R_DRW2D_FramebufferClear> function always uses the current background color.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
      Color - The color value (32bit packed ARGB)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxFgColor>, <R_DRW2D_CtxBlendFactors>, <r_drw2d_BlendFactor_t>
*/
r_drw2d_Error_t R_DRW2D_CtxBgColor(r_drw2d_Device_t Device,
                                   r_drw2d_Color_t  Color
                                   );



/*******************************************************************************
  Function: R_DRW2D_CtxClipRect

  Sets a global clipping rectangle for subsequent drawing operations.
  Multiple clip-rects can be set by calling this function before each R_DRW2D_Draw* API.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Rect - Rectangular clipping area (window coordinates) (see <r_drw2d_IntRect_t>).
              All elements must be positive numbers (or 0).

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Clipping rectangle is outside the framebuffer boundaries.
*/
r_drw2d_Error_t R_DRW2D_CtxClipRect(r_drw2d_Device_t   Device,
                              const r_drw2d_IntRect_t *Rect
                                    );



/*******************************************************************************
  Function: R_DRW2D_CtxFillMode

  Set the filling mode for drawing with primitives.

  This is used for placing e.g. a texture on top of any primitive.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Mode - The fill mode to be used. See <r_drw2d_FillMode_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported fill mode
*/
r_drw2d_Error_t R_DRW2D_CtxFillMode(r_drw2d_Device_t   Device,
                                    r_drw2d_FillMode_t Mode
                                    );



/*******************************************************************************
  Function: R_DRW2D_CtxCullMode

  Set the culling mode for drawing with primitives.

  This is used to discard triangles or rectangles depending on their winding order.

  The default cull mode is <R_DRW2D_CULLMODE_NONE>.


  Parameter:
      Device - Device handle (see <r_drw2d_Device_t>)
    CullMode - The cull mode to be used. See <r_drw2d_CullMode_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported cull mode
*/
r_drw2d_Error_t R_DRW2D_CtxCullMode(r_drw2d_Device_t   Device,
                                    r_drw2d_CullMode_t CullMode
                                    );



/*******************************************************************************
  Function: R_DRW2D_CtxLineStyle

  Set the line drawing style (e.g. line caps, line width, ..).


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
      Style - Pointer to line style struct (see <r_drw2d_LineStyle_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_LineCap_t>, <r_drw2d_LineJoin_t>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawPolyline>
*/
r_drw2d_Error_t R_DRW2D_CtxLineStyle(r_drw2d_Device_t     Device,
                               const r_drw2d_LineStyle_t *Style
                                     );



/*******************************************************************************
  Function: R_DRW2D_CtxBlendMode

  Set preset color/alpha source/destination blending equations.

  When <R_DRW2D_BLENDMODE_CUSTOM> is selected, the color/alpha blending equations
  are determined by the blend factors set by <R_DRW2D_CtxBlendFactors>.


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
    BlendMode - The blendmode mode to be used. See <r_drw2d_BlendMode_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported blend mode

  See also:
    <r_drw2d_BlendMode_t>, <R_DRW2D_CtxBlendFactors>, <r_drw2d_BlendFactor_t>
*/
r_drw2d_Error_t R_DRW2D_CtxBlendMode(r_drw2d_Device_t    Device,
                                     r_drw2d_BlendMode_t BlendMode
                                     );



/*******************************************************************************
  Function: R_DRW2D_CtxBlendFactors

  Set color/alpha source/destination blending factors.

  In order for these to have an effect, the <R_DRW2D_BLENDMODE_CUSTOM>
  blendmode must be selected (see <R_DRW2D_CtxBlendMode>).

  The effective color/alpha blend equation is determined by
    > dst_color = src_color*src_factor_color + dst_color*dst_factor_color
    > dst_alpha = src_alpha*src_factor_alpha + dst_alpha*dst_factor_alpha


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
       SrcRGB - The blendfactor to be used for source RGB values (see <r_drw2d_BlendFactor_t>)
       DstRGB - The blendfactor to be used for destination RGB values (see <r_drw2d_BlendFactor_t>)
     SrcAlpha - The blendfactor to be used for source alpha values (see <r_drw2d_BlendFactor_t>)
     DstAlpha - The blendfactor to be used for destination alpha values (see <r_drw2d_BlendFactor_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported blend mode

  See also:
    <r_drw2d_BlendFactor_t>, <R_DRW2D_CtxBlendMode>, <r_drw2d_BlendMode_t>

*/
r_drw2d_Error_t R_DRW2D_CtxBlendFactors(r_drw2d_Device_t      Device,
                                        r_drw2d_BlendFactor_t SrcRGB,
                                        r_drw2d_BlendFactor_t DstRGB,
                                        r_drw2d_BlendFactor_t SrcAlpha,
                                        r_drw2d_BlendFactor_t DstAlpha
                                        );



/*******************************************************************************
  Function: R_DRW2D_CtxImgQuality

  Sets for the current context a global quality value used for graphics primitives.
  (For texture quality please check the texture flags, e.g. R_DRW2D_TEX_BILINEAR)

  Note that the DHD platform is limited to an edge width/height of max. 2048 when
  using non antialiased (R_DRW2D_IMGQUALITY_LOW) edges.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
    Quality - Image quality/antialiasing mode. See <r_drw2d_ImgQuality_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported image quality mode

  See also:
    <r_drw2d_ImgQuality_t>
*/
r_drw2d_Error_t R_DRW2D_CtxImgQuality(r_drw2d_Device_t     Device,
                                      r_drw2d_ImgQuality_t Quality
                                      );



/*******************************************************************************
  Function: R_DRW2D_CtxTransformMode

  Set the vertex transform/projection mode.

  The default is <R_DRW2D_TRANSFORM_2D> (2D vertex matrix transformation).

  When set to <R_DRW2D_TRANSFORM_NONE>, vertices will be used as-is, i.e. they
  will not be transformed by the vertex matrix. This mode can be used as a
  performance optimization.

  When set to <R_DRW2D_TRANSFORM_3D>, vertices will be transformed by the
  4x4 vertex matrix and projected onto the current viewport.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Mode - The transform mode to be used. See <r_drw2d_TransformMode_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported fill mode
*/
r_drw2d_Error_t R_DRW2D_CtxTransformMode(r_drw2d_Device_t        Device,
                                         r_drw2d_TransformMode_t Mode
                                         );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureTransformMode

  Set the texture coordinate transformation mode.

  The default is <R_DRW2D_TEX_TRANSFORM_2D> (2D texture matrix transformation).

  When set to <R_DRW2D_TEX_TRANSFORM_NONE>, texture coordinates will be used as-is,
  i.e. they will not be transformed by the texture matrix. This mode can be used as a
  performance optimization. When no explicit UV coordinates are given, the texture
  is mapped to the screen 1:1.

  When set to <R_DRW2D_TEX_TRANSFORM_2D>, texture coordinates will be transformed by the 3x2 texture matrix.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Mode - The transform mode to be used. See <r_drw2d_TextureTransformMode_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported fill mode
*/
r_drw2d_Error_t R_DRW2D_CtxTextureTransformMode(r_drw2d_Device_t               Device,
                                                r_drw2d_TextureTransformMode_t Mode
                                                );



/*******************************************************************************
  Function: R_DRW2D_CtxViewport

  Set viewport for 3D vertex transformation/projection.

  The default is to use the current framebuffer width/height, offset by (0; 0).

  After setting a custom viewport, set the Rect.Size to (0; 0) to revert to the default behaviour.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Rect - The viewport rectangle. See <r_drw2d_IntRect_t>.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_INVALID_VALUE> - Unsupported fill mode
      - <R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_X> - Invalid viewport Pos.X
      - <R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_Y> - Invalid viewport Pos.Y
      - <R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_W> - Invalid viewport Size.Width
      - <R_DRW2D_ERR_INVALID_VALUE_VIEWPORT_H> - Invalid viewport Size.Height
*/
r_drw2d_Error_t R_DRW2D_CtxViewport(r_drw2d_Device_t   Device,
                              const r_drw2d_IntRect_t *Rect
                                    );



/*******************************************************************************
  Function: R_DRW2D_CtxStripingEnable

  Enable striped pixel enumeration (for performance reasons).

  This should only be enabled if texture mapping is used and larger triangles/quads are being rendered.

  The actual stripe settings are determined per-primitive.

  This function is only available in the Dave HD port of DRW2D.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxStripingDisable>
*/
r_drw2d_Error_t R_DRW2D_CtxStripingEnable(r_drw2d_Device_t Device);



/*******************************************************************************
  Function: R_DRW2D_CtxStripingDisable

  Disable striped pixel enumeration.

  This function is only available in the Dave HD port of DRW2D.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxStripingEnable>
*/
r_drw2d_Error_t R_DRW2D_CtxStripingDisable(r_drw2d_Device_t Device);





/*******************************************************************************
  Group: Effect functions

  For more information, help and examples concerning the Drw2D Effects API, see <Effects API Usage>.

*/

/*******************************************************************************
  Function: R_DRW2D_CtxEffectsSet

  Sets an array of effects to be used for colorization and blending.
  The data in the array must be readable/writeable until a call to <R_DRW2D_CtxEffectsDelete>.

  The content of the array will be modified by <R_DRW2D_CtxEffectsUpdate>.

  Between calls to <R_DRW2D_CtxEffectsSet> and <R_DRW2D_CtxEffectsDelete> any calls to functions
  <R_DRW2D_CtxFgColor>, <R_DRW2D_CtxBgColor>, and <R_DRW2D_CtxFillMode> are invalid and an error
  will be returned.

  The effects <R_DRW2D_EFFECT_REPLACE>, <R_DRW2D_EFFECT_MODULATE>, <R_DRW2D_EFFECT_ADD>, <R_DRW2D_EFFECT_SUBTRACT>,
  <R_DRW2D_EFFECT_ADD_SIGNED>, <R_DRW2D_EFFECT_INTERPOLATE>, and <R_DRW2D_EFFECT_DOT3> can be combined to calculate
  a final color.  If the input source is specified as <R_DRW2D_EFFECT_SOURCE_PREV_STAGE>, the result of the previous
  stage will be used.

  If the combination of effects can not be realized, an error will be returned by the drawing call.

  The effects <R_DRW2D_EFFECT_CONSTANT_ALPHA> and <R_DRW2D_EFFECT_GRADIENT> provide a final alpha blending.
  It is necessary to set the image quality to <R_DRW2D_IMGQUALITY_MEDIUM> or <R_DRW2D_IMGQUALITY_HIGH>
  (see <R_DRW2D_CtxImgQuality>) for these effects to work:
  In the case of <R_DRW2D_EFFECT_CONSTANT_ALPHA> the result will be blended with a constant alpha.
  The <R_DRW2D_EFFECT_GRADIENT> can be used to specify two points and two alpha values to calculate a linear gradient,
  which will be used to blend the final color. The effects <R_DRW2D_EFFECT_GRADIENT> and <R_DRW2D_EFFECT_CONSTANT_ALPHA>
  can be combined.

  See <Effects API Usage> for more information on how to use effects.


  Parameter:
     Device  - Device handle (see <r_drw2d_Device_t>)
     Effects - Array with effects (see <r_drw2d_EffectStage_t>)
     Count   - Number of effects in the array

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxEffectsUpdate>, <R_DRW2D_CtxEffectsDelete>
*/
r_drw2d_Error_t R_DRW2D_CtxEffectsSet(r_drw2d_Device_t       Device,
                                      r_drw2d_EffectStage_t *Effects,
                                      uint32_t               Count
                                      );



/*******************************************************************************
  Function: R_DRW2D_CtxEffectsUpdate

  updates effect at stage Stage.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Name - Effect (see <r_drw2d_EffectName_t>)
     Stage - Stage of effect to be updated
     NumParams - Number of parameters to be passed
     Params - Array of parameters (see <r_drw2d_EffectParam_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxEffectsSet>, <R_DRW2D_CtxEffectsDelete>
*/
r_drw2d_Error_t R_DRW2D_CtxEffectsUpdate(r_drw2d_Device_t Device,
                                         r_drw2d_EffectName_t Name,
                                         uint32_t Stage,
                                         uint32_t NumParams,
                                   const r_drw2d_EffectParam_t *Params
                                         );



/*******************************************************************************
  Function: R_DRW2D_CtxEffectsDelete

  Deletes all effects.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxEffectsSet>, <R_DRW2D_CtxEffectsUpdate>
*/
r_drw2d_Error_t R_DRW2D_CtxEffectsDelete(r_drw2d_Device_t Device);





/*******************************************************************************
  Group: Texture functions

*/

/*******************************************************************************
  Function: R_DRW2D_CtxTextureSet

  Set source texture.

  The DaveHD port of DRW2D supports the direct / zero-copy use of an application provided texture address.

  The texture is used when the fill mode is set to <R_DRW2D_FILLMODE_TEXTURE>.


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    TextureUnit - Texture Unit Number.
    Texture - Reference to texture structure (see <r_drw2d_Texture_t>). NULL to deselect current texture.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_TEXTURE>            - Failed to set source texture (e.g. invalid texture handle)
      - <R_DRW2D_ERR_DEVICE_OUTOFVIDMEM> - Failed to allocate texture video memory. This error can only occur with
                                           implementations of DRW2D that do not support user-provided
                                           zero-copy texture buffers.

  See also:
    <r_drw2d_Texture_t>, <r_drw2d_TextureFlags_t>, <r_drw2d_Buffer_t>, <R_DRW2D_CtxFillMode>, <R_DRW2D_TextureBlit>
*/
r_drw2d_Error_t R_DRW2D_CtxTextureSet(r_drw2d_Device_t   Device,
                                      uint32_t           TextureUnit,
                                const r_drw2d_Texture_t *Texture
                                      );



/*******************************************************************************
  Function: R_DRW2D_TextureBlit

  Blit texture from Src to Dest.

  Src can be NULL, in that case the blit origin is 0,0 inside of the texture and dimensions are taken from the DstRect.


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    SrcRect - Source rectangle.
    DstRect - Destination rectangle.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Texture_t>, <r_drw2d_TextureFlags_t>, <r_drw2d_Buffer_t>, <R_DRW2D_CtxFillMode>, <R_DRW2D_CtxTextureSet>
*/
r_drw2d_Error_t R_DRW2D_TextureBlit(r_drw2d_Device_t  Device,
                              const r_drw2d_Rect_t   *SrcRect,
                              const r_drw2d_Rect_t   *DstRect
                                    );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureColorKeyEnable

  Enables Color Keying for the provided RGB color.
  The color of ColorKey will be set as fully transparent by the GPU driver.


  Parameter:
    Device   - Device handle (see <r_drw2d_Device_t>)
    ColorKey - The color in RGB (alpha component is ignored)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_CtxTextureColorKeyEnable(r_drw2d_Device_t Device,
                                                 r_drw2d_Color_t  ColorKey
                                                 );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureColorKeyDisable

  Disabled a previously set color keying in the GPU driver


  Parameter:
    Device   - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_CtxTextureColorKeyDisable(r_drw2d_Device_t Device);





/*******************************************************************************
  Group: Matrix transformation functions

*/

/*******************************************************************************
  Function: R_DRW2D_CtxIdentity

  Reset vertex transformation matrix.

  The identity matrix maps the vertex at (0; 0) to the top/left screen/framebuffer position.

  The vertex at (framebuffer_width-1, framebuffer_height-1) is mapped to the bottom/right
  screen/framebuffer position.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxIdentity(r_drw2d_Device_t Device);



/*******************************************************************************
  Function: R_DRW2D_CtxTextureIdentity

  Reset texture matrix.

  If both texture and vertex matrices are set to identity, vertices and texture coordinates will use the
  same coordinate system.

  I.e. drawing a textured rectangle at (10;10) with size (40;30) will result in a 1:1 mapping of the respective texture area.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>, <R_DRW2D_CtxTextureTranslate>,
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>,
    <R_DRW2D_CtxTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxTextureIdentity(r_drw2d_Device_t Device);



/*******************************************************************************
  Function: R_DRW2D_CtxTransform

  Set 4x4 vertex transformation matrix.

  Can be used for 3D perspective mapping or affine transformations (scale, translate, rotate).


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Matrix - Reference to 4x4 transformation matrix. The matrix is expected to be in column-major format
     and use the following element order:
  > [ 0 4  8 12 ]
  > [ 1 5  9 13 ]
  > [ 2 6 10 14 ]
  > [ 3 7 11 15 ]
  (the translation vector is stored in elements 12, 13, and 14)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxTransform(r_drw2d_Device_t  Device,
                               const r_drw2d_FixedP_t *Matrix
                                     );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureTransform

  Set 3x2 texture transformation matrix.

  Can be used for e.g. affine transformations (scale, translate, rotate).


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Matrix - Reference to 3x2 transformation matrix. The matrix is expected to be in column-major format and use the
     following element order:
  > [ 0 2 4 ]
  > [ 1 3 5 ]
  (the translation vector is stored in elements 4 and 5)

  When performing the same transformation as <R_DRW2D_CtxScale>,
  texture matrix should be inverse matrix of vertex matrix.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>, <R_DRW2D_CtxTextureTranslate>,
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>,
    <R_DRW2D_CtxTranslate>

*/
r_drw2d_Error_t R_DRW2D_CtxTextureTransform(r_drw2d_Device_t  Device,
                                      const r_drw2d_FixedP_t *Matrix
                                            );



/*******************************************************************************
  Function: R_DRW2D_CtxRotate

  Multiply current vertex matrix by rotation matrix.

  > [ cos(Angle), -sin(Angle), 0, 0 ]
  > [ sin(Angle),  cos(Angle), 0, 0 ]
  > [          0,           0, 1, 0 ]
  > [          0,           0, 0, 1 ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)

     Angle - Angle of rotation around z axis (0..360 degrees)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxRotate(r_drw2d_Device_t Device,
                                  r_drw2d_FixedP_t Angle
                                  );



/*******************************************************************************
  Function: R_DRW2D_CtxRotate3d

  Multiply current vertex matrix by 3d rotation matrix.

   > [ xx(1-c)+c    xy(1-c)-zs   xz(1-c)+ys   0 ]
   > [ yx(1-c)+zs   yy(1-c)+c    yz(1-c)-xs   0 ]
   > [ xz(1-c)-ys   yz(1-c)+xs   zz(1-c)+c    0 ]
   > [ 0            0            0            1 ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
         X - Coordinate of vector starting in origin (0,0,0)
         Y - Coordinate of vector starting in origin (0,0,0)
         Z - Coordinate of vector starting in origin (0,0,0)
     Angle - Angle of rotation around axis of vector defined by (X,Y,Z) in (0..360 degrees)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxRotate3d(r_drw2d_Device_t Device,
                                    r_drw2d_FixedP_t X,
                                    r_drw2d_FixedP_t Y,
                                    r_drw2d_FixedP_t Z,
                                    r_drw2d_FixedP_t Angle
                                    );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureRotate

  Multiply current texture matrix by rotation matrix.

  > [ cos(Angle), -sin(Angle), 0 ]
  > [ sin(Angle),  cos(Angle), 0 ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
     Angle - Angle of rotation about z axis (0..360 degrees)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>, <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>,
    <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxTextureRotate(r_drw2d_Device_t Device,
                                         r_drw2d_FixedP_t Angle
                                         );



/*******************************************************************************
  Function: R_DRW2D_CtxScale

  Multiply current vertex matrix by scaling matrix.

  > [ ScaleX, 0     , 0,      0 ]
  > [      0, ScaleY, 0,      0 ]
  > [      0, 0     , ScaleZ, 0 ]
  > [      0, 0     , 0,      1 ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    ScaleX - Scale factor for the X axis (1.0 means no scaling)
    ScaleY - Scale factor for the Y axis (1.0 means no scaling)
    ScaleZ - Scale factor for the Z axis (1.0 means no scaling)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxTranslate>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxScale(r_drw2d_Device_t Device,
                                 r_drw2d_FixedP_t ScaleX,
                                 r_drw2d_FixedP_t ScaleY,
                                 r_drw2d_FixedP_t ScaleZ
                                 );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureScale

  Multiply current texture matrix by scaling matrix.

  > [ ScaleX, 0     , 0 ]
  > [      0, ScaleY, 0 ]

  When performing the same transformation as <R_DRW2D_CtxScale>,
  texture matrix should be inverse matrix of vertex matrix.


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    ScaleX - Scale factor for the X axis (1.0 means no scaling)
    ScaleY - Scale factor for the Y axis (1.0 means no scaling)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>,
    <R_DRW2D_CtxTextureTranslate>, <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>,
    <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxTextureScale(r_drw2d_Device_t Device,
                                        r_drw2d_FixedP_t ScaleX,
                                        r_drw2d_FixedP_t ScaleY
                                        );



/*******************************************************************************
  Function: R_DRW2D_CtxTranslate

  Multiply current vertex matrix by translation matrix.

  > [ 1, 0, 0, X ]
  > [ 0, 1, 0, Y ]
  > [ 0, 0, 1, Z ]
  > [ 0, 0, 0, 1 ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    TransX - X axis translation
    TransY - Y axis translation
    TransZ - Z axis translation

  See also:
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxTranslate(r_drw2d_Device_t Device,
                                     r_drw2d_FixedP_t TransX,
                                     r_drw2d_FixedP_t TransY,
                                     r_drw2d_FixedP_t TransZ
                                     );



/*******************************************************************************
  Function: R_DRW2D_CtxTextureTranslate

  Multiply current texture matrix by translation matrix.

  > [ 1, 0  X ]
  > [ 0, 1, Y ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
    TransX - X axis translation
    TransY - Y axis translation

  See also:
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>,
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxTransform>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>,
    <R_DRW2D_CtxTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxTextureTranslate(r_drw2d_Device_t Device,
                                            r_drw2d_FixedP_t TransX,
                                            r_drw2d_FixedP_t TransY
                                            );



/***********************************************************
  Function: R_DRW2D_CtxFrustum

  Multiply current vertex matrix by perspective matrix.

  > [ (2*near) / (right-left), 0                      , (right+left) / (right-left)  , 0                               ]
  > [ 0                      , (2*near) / (top-bottom), (top-bottom) / (top-bottom)  , 0                               ]
  > [ 0                      , 0                      , - ( (far+near) / (far-near) ), - ( (2*far*near) / (far-near) ) ]
  > [ 0                      , 0                      , -1                           , 0                               ]


  Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
      Left - Left vertical clipping plane
     Right - Right vertical clipping plane
    Bottom - Bottom horizontal clipping plane
       Top - Top horizontal clipping plane
     ZNear - Distance to near clipping plane
      ZFar - Distance to far clipping plane
*/
r_drw2d_Error_t R_DRW2D_CtxFrustum(r_drw2d_Device_t Device,
                                   r_drw2d_FixedP_t Left,
                                   r_drw2d_FixedP_t Right,
                                   r_drw2d_FixedP_t Bottom,
                                   r_drw2d_FixedP_t Top,
                                   r_drw2d_FixedP_t ZNear,
                                   r_drw2d_FixedP_t ZFar
                                   );



/***********************************************************
  Function: R_DRW2D_VtxTransform

  Transform a list of vertices by the current vertex transformation matrix.

  This function applies the current transformation matrix to an arbitrary number of
  points supplied via the parameters Vec and NumVertices.

  This function can be used to get the scope of the next drawing operation before executing it.
  This information can be used to allocate buffers with as small as possible size,
  as the target scope of the drawing operation is already known.


  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
       Vertices - Pointer to vertices
    NumVertices - Number of vertices provided by "Vertices" parameter
*/
r_drw2d_Error_t R_DRW2D_VtxTransform(r_drw2d_Device_t  Device,
                                     r_drw2d_Vec4_t   *Vertices,
                                     uint32_t          NumVertices
                                     );



/*******************************************************************************
  Function: R_DRW2D_CtxMatrix

  Get the 4x4 vertex transformation matrix and the 3x2 texture transformation matrix.

  Can be used to save and restore (<R_DRW2D_CtxTransform>, <R_DRW2D_CtxTextureTransform>)
  the current transformation matrices.
  This may reduce the CPU overhead of repeatedly calling almost identical transformation
  operations for several similar drawing operations.
  If just one of the matrices is required, set the other pointer to zero.


  Parameter:
            Device - Device handle (see <r_drw2d_Device_t>)
      VertexMatrix - Reference to 4x4 transformation matrix. The matrix is expected to be in column-major format and use the following element order:
 > [ 0 4  8 12 ]
 > [ 1 5  9 13 ]
 > [ 2 6 10 14 ]
 > [ 3 7 11 15 ]
          (the translation vector is stored in elements 12, 13, and 14)
     TextureMatrix - Reference to 3x2 transformation matrix. The matrix is expected to be in column-major format and use the following element order:
 > [ 0 2 4 ]
 > [ 1 3 5 ]
          (the translation vector is stored in elements 4 and 5)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxIdentity>, <R_DRW2D_CtxRotate>, <R_DRW2D_CtxRotate3d>, <R_DRW2D_CtxScale>, <R_DRW2D_CtxTranslate>,
    <R_DRW2D_CtxTextureIdentity>, <R_DRW2D_CtxTextureTransform>, <R_DRW2D_CtxTextureRotate>, <R_DRW2D_CtxTextureScale>, <R_DRW2D_CtxTextureTranslate>
*/
r_drw2d_Error_t R_DRW2D_CtxMatrix(r_drw2d_Device_t        Device,
                                  r_drw2d_FixedP_t *const VertexMatrix,
                                  r_drw2d_FixedP_t *const TextureMatrix
                                  );



/***********************************************************
  Function: R_DRW2D_ClutAlloc

  Allocates space for a CLUT used by <R_DRW2D_ClutSet> and <R_DRW2D_CtxClutSet>


  Parameter:
    Device   - Device handle (see <r_drw2d_Device_t>)
    Size     - Size of CLUT in bytes
    ClutBase - Function will write the CLUTs' base in ClutBase

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_ClutAlloc(r_drw2d_Device_t  Device,
                                  uint32_t          Size,
                                  uint32_t         *ClutBase
                                  );



/***********************************************************
  Function: R_DRW2D_ClutFree

  Frees CLUT memory previously allocated with <R_DRW2D_ClutAlloc>


  Parameter:
    Device   - Device handle (see <r_drw2d_Device_t>)
    Size     - Size of CLUT in bytes
    ClutBase - ClutBase

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_ClutFree(r_drw2d_Device_t Device,
                                 uint32_t         Size,
                                 uint32_t         ClutBase
                                 );



/***********************************************************
  Function: R_DRW2D_CtxClutSet

  Assign a previously created CLUT with the Offset ClutBase (as returned by R_DRW2D_ClutAlloc)
  to the texture.


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
     ClutBase - Address of clut table
*/
r_drw2d_Error_t R_DRW2D_CtxClutSet(r_drw2d_Device_t Device,
                                   uint32_t         ClutBase
                                   );



/***********************************************************
  Function: R_DRW2D_ClutSet

  Create and set a CLUT that was previously allocated with <R_DRW2D_ClutAlloc>


  Parameter:
    Device   - Device handle (see <r_drw2d_Device_t>)
    Data     - Pointer to the CLUT table
    Start    - Start address
    Size     - Size of CLUT elements

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
*/
r_drw2d_Error_t R_DRW2D_ClutSet(r_drw2d_Device_t  Device,
                                uint32_t         *Data,
                                uint32_t          Start,
                                uint32_t          Size
                                );





/*******************************************************************************
  Group: Framebuffer functions
*/

/*******************************************************************************
  Function: R_DRW2D_FramebufferSet

  Set current destination framebuffer.
  Allocation of the framebuffer is the responsibility of the application.

  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
    Framebuffer - Reference to framebuffer structure (see <r_drw2d_Framebuffer_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_FRAMEBUFFER> - Invalid framebuffer handle

  See also:
    <r_drw2d_Framebuffer_t>, <r_drw2d_Buffer_t>

*/
r_drw2d_Error_t R_DRW2D_FramebufferSet(r_drw2d_Device_t       Device,
                                       r_drw2d_Framebuffer_t *Framebuffer
                                       );



/*******************************************************************************
  Function: R_DRW2D_FramebufferClear

  Clears the current clip rectangle with the current background color (can be set with <R_DRW2D_CtxBgColor>)

  <R_DRW2D_FramebufferClear> will always use the SOLID fillmode and ignore current blendmode/factor settings.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Framebuffer_t>, <r_drw2d_Buffer_t>,
    <R_DRW2D_FramebufferSet>
*/
r_drw2d_Error_t R_DRW2D_FramebufferClear(r_drw2d_Device_t Device);





/*******************************************************************************
  Group: Render functions

  All following render functions take the current context settings (fillmode, fg/bg colors, texture, ..) into account.
*/

/*******************************************************************************
  Function: R_DRW2D_DrawTriangles

  Render an array of triangles.

  Each triangle vertex will be transformed by the current vertex transformation matrix.

  If texture mapping is enabled, the texture will be applied according to the current texture transformation matrix.

  Note that the Dave HD platform is limited to an edge width/height of max. 2048 when
  using non antialiased edges (Edge flag set to 0).


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
       Points - Array of vertices (see <r_drw2d_Point_t>)
        Count - Number of vertices. Count/3 triangles will be drawn.
    EdgeFlags - Specifies which triangles edge will be antialiased. One byte per triangle. See <r_drw2d_EdgeFlag_t>.
                If NULL, do not use antialiasing. The EdgeFlags parameter is currently only supported by
                the Dave HD port of DRW2D.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_DrawRect>,
    <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawTriangles(r_drw2d_Device_t  Device,
                                const r_drw2d_Point_t  *Points,
                                      uint32_t          Count,
                                const uint8_t          *EdgeFlags
                                      );



/*******************************************************************************
  Function: R_DRW2D_DrawTrianglesUV

  Render an array of UV texture mapped triangles.

  Each triangle vertex will be transformed by the current vertex transformation matrix.

  Each UV coordinate will be transformed by the current texture transformation matrix if the texture transform mode
  (<R_DRW2D_CtxTextureTransformMode>) is set to <R_DRW2D_TEX_TRANSFORM_2D>.

  If the fillmode is set to <R_DRW2D_FILLMODE_SOLID>, this function behaves like <R_DRW2D_DrawTriangles> and
  the UV coordinate array is ignored.

  Note that the Dave HD platform is limited to an edge width/height of max. 2048 when
  using non antialiased edges (Edge flag set to 0).


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
       Points - Array of vertices (see <r_drw2d_Point_t>)
        Count - Number of vertices. Count/3 triangles will be drawn.
    EdgeFlags - Specifies which triangles edge will be antialiased. One byte per triangle. See <r_drw2d_EdgeFlag_t>.
                If NULL, do not use antialiasing. The EdgeFlags parameter is currently only supported by the
                Dave HD port of DRW2D.
     UVCoords - Array of UV coordinates (one per vertex, 3 per triangle) (see <r_drw2d_UVCoord_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_DrawRect>,
    <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawTrianglesUV(r_drw2d_Device_t   Device,
                                  const r_drw2d_Point_t   *Points,
                                        uint32_t           Count,
                                  const uint8_t           *EdgeFlags,
                                  const r_drw2d_UVCoord_t *UVCoords
                                        );



/*******************************************************************************
  Function: R_DRW2D_DrawRect

  Render a rectangle.

  The *Pos* and *Size* fields of the Rect argument are used to construct a quad which will
  then be transformed by the current vertex matrix.

  If texture mapping is enabled, the texture will be applied according to the current texture transformation matrix.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Rect - Rectangle x, y, w, h

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>,
    <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawRect(r_drw2d_Device_t  Device,
                           const r_drw2d_Rect_t   *Rect
                                 );



/*******************************************************************************
  Function: R_DRW2D_DrawRectUV

  Render a UV texture mapped rectangle.

  The *Pos* and *Size* fields of the Rect argument are used to construct a quad which will
  then be transformed by the current vertex matrix.

  Each UV coordinate will be transformed by the current texture transformation matrix if the texture transform mode
  (<R_DRW2D_CtxTextureTransformMode>) is set to <R_DRW2D_TEX_TRANSFORM_2D>.

  If the fillmode is set to <R_DRW2D_FILLMODE_SOLID>, this function behaves like <R_DRW2D_DrawRect> and
  the UV coordinate array is ignored.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Rect - Rectangle x, y, w, h
   UVCoords - Reference to an array of 4 UV coordinates (left/top, right/top, right/bottom, left/bottom order)
              (see <r_drw2d_UVCoord_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>,
    <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawRectUV(r_drw2d_Device_t   Device,
                             const r_drw2d_Rect_t    *Rect,
                             const r_drw2d_UVCoord_t *UVCoords
                                   );



/*******************************************************************************
  Function: R_DRW2D_DrawQuads

  Renders an array of quadrilaterals.

  Each vertex will be transformed by the current vertex matrix.

  If texture mapping is enabled, the texture will be applied according to the current texture transformation matrix.

  Note that the Dave HD platform is limited to an edge width/height of max. 2048 when
  using non antialiased edges (Edge flag set to 0).


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
       Points - Array of vertices (see <r_drw2d_Point_t>)
        Count - Number of vertices. Count/4 quads will be drawn.
    EdgeFlags - Specifies which quad edges will be antialiased. One byte per quad. See <r_drw2d_EdgeFlag_t>.
                If NULL, do not use antialiasing. The EdgeFlags parameter is currently only supported by
                the Dave HD port of DRW2D.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawQuadsUV>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>,
    <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawQuads(r_drw2d_Device_t  Device,
                            const r_drw2d_Point_t  *Points,
                                  uint32_t          Count,
                            const uint8_t          *EdgeFlags
                                  );



/*******************************************************************************
  Function: R_DRW2D_DrawQuadsUV

  Renders an array of UV texture mapped quadrilaterals.

  Each vertex will be transformed by the current vertex matrix.

  Each UV coordinate will be transformed by the current texture transformation matrix if the texture transform mode
  (<R_DRW2D_CtxTextureTransformMode>) is set to <R_DRW2D_TEX_TRANSFORM_2D>.

  If the fillmode is set to <R_DRW2D_FILLMODE_SOLID>, this function behaves like <R_DRW2D_DrawQuads> and
  the UV coordinate array is ignored.

  Note that the Dave HD platform is limited to an edge width/height of max. 2048 when
  using non antialiased edges (Edge flag set to 0).


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
       Points - Array of vertices (see <r_drw2d_Point_t>)
        Count - Number of vertices. Count/4 quads will be drawn.
    EdgeFlags - Specifies which quad edges will be antialiased. One byte per quad. See <r_drw2d_EdgeFlag_t>.
                If NULL, do not use antialiasing.  The EdgeFlags parameter is currently only supported by
                the Dave HD port of DRW2D.
     UVCoords - Array of UV coordinates (one per vertex, 4 per quad) (see <r_drw2d_UVCoord_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawQuads>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>,
    <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawQuadsUV(r_drw2d_Device_t   Device,
                              const r_drw2d_Point_t   *Points,
                                    uint32_t           Count,
                                    uint8_t           *EdgeFlags,
                              const r_drw2d_UVCoord_t *UVCoords
                                    );



/*******************************************************************************
  Function: R_DRW2D_DrawQuads3dUV

  Renders an array of UV texture mapped 3D-quadrilaterals.

  Each vertex will be transformed by the current vertex matrix.

  Each UV coordinate will be transformed by the current texture transformation matrix if the texture transform mode
  (<R_DRW2D_CtxTextureTransformMode>) is set to <R_DRW2D_TEX_TRANSFORM_2D>.

  If the fillmode is set to <R_DRW2D_FILLMODE_SOLID>, this function behaves like <R_DRW2D_DrawQuads> and
  the UV coordinate array is ignored.

  Note that the Dave HD platform is limited to an edge width/height of max. 2048 when
  using non antialiased edges (Edge flag set to 0).


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
       Points - Array of 3D vertices (see <r_drw2d_Vec4_t>)
        Count - Number of vertices. Count/4 quads will be drawn.
    EdgeFlags - Specifies which quad edges will be antialiased. One byte per quad. See <r_drw2d_EdgeFlag_t>.
                If NULL, do not use antialiasing.  The EdgeFlags parameter is currently only supported by
                the Dave HD port of DRW2D.
     UVCoords - Array of UV coordinates (one per vertex, 4 per quad) (see <r_drw2d_UVCoord_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawQuads>, <R_DRW2D_DrawQuadsUV>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>,
    <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawQuads3dUV(r_drw2d_Device_t   Device,
                                const r_drw2d_Vec4_t    *Points,
                                      uint32_t           Count,
                                      uint8_t           *EdgeFlags,
                                const r_drw2d_UVCoord_t *UVCoords
                                      );



/*******************************************************************************
  Function: R_DRW2D_DrawEllipse

  Render an ellipse at Point with the specified x and y radius.

  The center point will be transformed by the current vertex matrix.

  In order to draw a circle, use the same values for RadiusX and RadiusY.

  If texture mapping is enabled, the texture will be applied according to the current texture transformation matrix.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
      Point - Center point
    RadiusX - Horizontal radius
    RadiusY - Vertical radius

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>,
    <R_DRW2D_DrawRect>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawEllipse(r_drw2d_Device_t Device,
                                    r_drw2d_Point_t  Point,
                                    r_drw2d_FixedP_t RadiusX,
                                    r_drw2d_FixedP_t RadiusY
                                    );



/*******************************************************************************
  Function: R_DRW2D_DrawLines

  Render an array of lines. The rendered lines include the start and end points.

  Each line point will be transformed by the current transformation matrix.

  The *Width* field of <r_drw2d_LineStyle_t> specifies the line width.

  The *LineCap* field of <r_drw2d_LineStyle_t> specifies how to render the line starts/ends (see <r_drw2d_LineCap_t>).

  If texture mapping is enabled, the texture will be applied according to the current texture transformation matrix.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Points - Line start/end vertices
      Count - Number of vertices. Count/2 lines will be drawn.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawEllipse>,
    <R_DRW2D_DrawRect>, <R_DRW2D_FramebufferClear>

*/
r_drw2d_Error_t R_DRW2D_DrawLines(r_drw2d_Device_t Device,
                            const r_drw2d_Point_t *Points,
                                  uint32_t         Count
                                  );



/*******************************************************************************
  Function: R_DRW2D_DrawPolyline

  Render a polyline consisting of one or many line segments.

  Each line point will be transformed by the current transformation matrix.

  The *Width* field of <r_drw2d_LineStyle_t> specifies the line width.

  If the *IsClosed* field of <r_drw2d_LineStyle_t> is set to 1 (true), the last segment will be connected
  to the first segment.

  The line segments will be connected as specified by the *LineJoin* field of <r_drw2d_LineStyle_t>
  (see <R_DRW2D_CtxLineStyle>, <r_drw2d_LineStyle_t>, <r_drw2d_LineJoin_t>).

  If the <R_DRW2D_LINEJOIN_MITER> join type is selected, the *MiterLimit* field of <r_drw2d_LineStyle_t>
  specifies the maximum distance between the line join tip and line point.
  If the miter limit is exceeded, a bevel joint will be drawn at the miter limit position.

  If the polyline is not closed, the *LineCap* field of <r_drw2d_LineStyle_t> specifies how to render
  the polyline start/end (see <r_drw2d_LineCap_t>).

  If texture mapping is enabled, the texture will be applied according to the current texture transformation matrix.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Points - Array of vertices
      Count - Number of vertices.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>,
    <R_DRW2D_DrawRect>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawPolyline(r_drw2d_Device_t  Device,
                               const r_drw2d_Point_t  *Points,
                                     uint32_t          Count
                                     );



/*******************************************************************************
  Function: R_DRW2D_DrawBezierCurves

  Render a bezier curve consisting of one or more quadratic bezier segments.

  Each curve point will be transformed by the current transformation matrix.

  The *Width* field of <r_drw2d_LineStyle_t> specifies the line width. The value must be less than 16.

  If the *IsClosed* field of <r_drw2d_LineStyle_t> is set to 1 (true), the last segment will be connected
  to the first segment by a straight line.

  The bezier segments will be connected by round joints.  The ends of the curve will be flat.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Points - Array of vertices
      Count - Number of vertices.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>,
    <R_DRW2D_DrawRect>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawBezierCurves(r_drw2d_Device_t  Device,
                                   const r_drw2d_Point_t  *Points,
                                         uint32_t          Count
                                         );





/*******************************************************************************
  Group: Convolution filter functions

  The convolution filter render functions take the following context settings into account:
    - source texture (see <R_DRW2D_CtxTextureSet>)
    - destination framebuffer (see <R_DRW2D_FramebufferSet>)
    - convolution filter kernel (see <R_DRW2D_CtxConvolutionKernel>, <R_DRW2D_CtxConvolutionKernelPreset1d>,
      <R_DRW2D_CtxConvolutionKernelPreset2d>)
    - clipping rectangle (see <R_DRW2D_CtxClipRect>)
*/

/*******************************************************************************
  Function: R_DRW2D_DrawRectConvolve1dx

  Apply one dimensional convolution filter to texture and store result in framebuffer.

  The currently selected 1D convolution kernel is applied in the horizontal direction, i.e. the kernel coefficients
  determine the weights of the pixel(s) to the left and right of the current texel while the source texture is
  being traversed.

  The *Pos* field of the Rect argument is used to select the framebuffer destination position.

  The *Size* field of the Rect argument is used to select the width and height of the convoluted area.

  The *TextureOffX* and *TextureOffY* arguments are used to select the left/top texel of the convolution source area.

  Unless the R_DRW2D_TEX_WRAPU flag is used, the texture width must be equal or greater than the kernel size.

  This function does not regard the vertex and texture transformation matrices.

  The fill mode must be set to <R_DRW2D_FILLMODE_TEXTURE>.

  Note that using textures with an improper pitch or height on Drw2D's DaveHD port will lead to *severe performance loss*.
  The texture's pitch should be a multiple of 256 / BPP, where BPP is the current texture format's number of bits per
  pixel. The texture's height should be a multiple of 4. Furthermore, the texture's start address should be 8 byte aligned.


  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
           Rect - Rectangle x, y, w, h (see <r_drw2d_Rect_t>)
    TextureOffX - Horizontal texture offset (number of texels)
    TextureOffY - Vertical texture offset (number of texels)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawRectConvolve1dy>, <R_DRW2D_DrawRectConvolve2d>, <R_DRW2D_CtxConvolutionKernelPreset1d>,
    <R_DRW2D_CtxConvolutionKernelPreset2d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>,
    <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawRectConvolve1dx(r_drw2d_Device_t   Device,
                                      const r_drw2d_IntRect_t *Rect,
                                            uint16_t           TextureOffX,
                                            uint16_t           TextureOffY
                                            );



/*******************************************************************************
  Function: R_DRW2D_DrawRectConvolve1dy

  Apply one dimensional convolution filter to texture and store result in framebuffer.

  The currently selected 1D convolution kernel is applied in the vertical direction, i.e. the kernel coefficients
  determine the weights of the pixel(s) above and below the current texel while the source texture is being traversed.

  The *Pos* field of the Rect argument is used to select the framebuffer destination position.

  The *Size* field of the Rect argument is used to select the width and height of the convoluted area.

  The *TextureOffX* and *TextureOffY* arguments are used to select the left/top texel of the convolution source area.

  Unless the <R_DRW2D_TEX_WRAPV> flag is used, the texture height must be equal or greater than the kernel size.

  This function does not regard the vertex and texture transformation matrices.

  The fill mode must be set to <R_DRW2D_FILLMODE_TEXTURE>.

  Note that using textures with an improper pitch or height on Drw2D's DaveHD port will lead to *severe performance
  loss*. The texture's pitch should be a multiple of 256 / BPP, where BPP is the current texture format's number of
  bits per pixel. The texture's height should be a multiple of 4. Furthermore, the texture's start address should
  be 8 byte aligned.


  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
           Rect - Rectangle x, y, w, h (see <r_drw2d_Rect_t>)
    TextureOffX - Horizontal texture offset (number of texels)
    TextureOffY - Vertical texture offset (number of texels)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawRectConvolve2d>,
    <R_DRW2D_CtxConvolutionKernelPreset2d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>,
    <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawRectConvolve1dy(r_drw2d_Device_t   Device,
                                      const r_drw2d_IntRect_t *Rect,
                                            uint16_t           TextureOffX,
                                            uint16_t           TextureOffY
                                            );



/*******************************************************************************
  Function: R_DRW2D_DrawRectConvolve2d

  Apply two dimensional convolution filter to texture and store result in framebuffer.

  The currently selected 2D convolution kernel is applied in both x and y directions, i.e. the kernel coefficients
  determine the weights of the pixel(s) above and below resp. to the left and right of the current texel while the
  source texture is being traversed.

  The *Pos* field of the Rect argument is used to select the framebuffer destination position.

  The *Size* field of the Rect argument is used to select the width and height of the convoluted area.

  The *TextureOffX* and *TextureOffY* arguments are used to select the left/top texel of the convolution source area.

  Unless the <R_DRW2D_TEX_WRAPU> flag is used, the texture width must be equal or greater than the kernel width.

  Unless the <R_DRW2D_TEX_WRAPV> flag is used, the texture height must be equal or greater than the kernel height.

  This function does not regard the vertex and texture transformation matrices.

  If the selected convolution kernel is separable, i.e. if the 2d kernel matrix can be expressed as a product of a row
  and column vector (e.g. Gaussian blur), applications should convolute the texture in two passes using
  <R_DRW2D_DrawRectConvolve1dx> and <R_DRW2D_DrawRectConvolve1dy>. Doing so will decrease computational complexity
  from O(n^2) to O(n). The drawback of this approach is that a temporary buffer is required to store the result
  of the first pass.

  Due to HW restrictions, not all separable kernels can be implemented using aforementioned two-pass rendering technique.
  In particular, the DaveHD port of DRW2D can not process separable kernels that contain negative weights
  (e.g. Sobel edge detect), since the result pixels are clamped to the 0..255 range after the first pass.

  The fill mode must be set to <R_DRW2D_FILLMODE_TEXTURE>.

  Note that using textures with an improper pitch or height on Drw2D's DaveHD port will lead to *severe performance loss*.
  The texture's pitch should be a multiple of 256 / BPP, where BPP is the current texture format's number of bits
  per pixel. The texture's height should be a multiple of 4. Furthermore, the texture's start address should be 8 byte
  aligned.


  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
           Rect - Rectangle x, y, w, h (see <r_drw2d_Rect_t>)
    TextureOffX - Horizontal texture offset (number of texels)
    TextureOffY - Vertical texture offset (number of texels)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernelPreset2d>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>,
    <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawRectConvolve2d(r_drw2d_Device_t   Device,
                                     const r_drw2d_IntRect_t *Rect,
                                           uint16_t           TextureOffX,
                                           uint16_t           TextureOffY
                                           );



/*******************************************************************************
  Function: R_DRW2D_DrawRectConvolve

  Apply two dimensional convolution filter to texture and store result in framebuffer.

  The currently selected 2D convolution kernel is applied in both x and y directions, i.e. the kernel coefficients
  determine the weights of the pixel(s) above and below resp. to the left and right of the current texel while the
  source texture is being traversed.

  The *Pos* field of the Rect argument is used to select the framebuffer destination position.

  The *Size* field of the Rect argument is used to select the width and height of the convoluted area.

  The *TextureOffX* and *TextureOffY* arguments are used to select the left/top texel of the convolution source area.

  Unless the <R_DRW2D_TEX_WRAPU> flag is used, the texture width must be equal or greater than the kernel width.

  Unless the <R_DRW2D_TEX_WRAPV> flag is used, the texture height must be equal or greater than the kernel height.

  This function does not regard the vertex and texture transformation matrices.

  If the selected convolution kernel is separable, i.e. if the 2d kernel matrix can be expressed as a product of a row
  and column vector (e.g. Gaussian blur), applications should convolute the texture in two passes
  using <R_DRW2D_DrawRectConvolve1dx> and <R_DRW2D_DrawRectConvolve1dy>. Doing so will decrease computational complexity
  from O(n^2) to O(n). The drawback of this approach is that a temporary buffer is required to store the result of the
  first pass.

  Due to HW restrictions, not all separable kernels can be implemented using aforementioned two-pass rendering technique.
  In particular, the DaveHD port of DRW2D can not process separable kernels that contain negative weights
  (e.g. Sobel edge detect), since the result pixels are clamped to the 0..255 range after the first pass.

  The fill mode must be set to <R_DRW2D_FILLMODE_TEXTURE>.

  Note that using textures with an improper pitch or height on Drw2D's DaveHD port will lead to *severe performance loss*.
  The texture's pitch should be a multiple of 256 / BPP, where BPP is the current texture format's number of bits
  per pixel. The texture's height should be a multiple of 4. Furthermore, the texture's start address should be 8 byte
  aligned.


  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
           Rect - Rectangle x, y, w, h (see <r_drw2d_Rect_t>)
    TextureOffX - Horizontal texture offset (number of texels)
    TextureOffY - Vertical texture offset (number of texels)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernelPreset2d>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>,
    <R_DRW2D_DrawPolyline>, <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_DrawRectConvolve(r_drw2d_Device_t   Device,
                                   const r_drw2d_IntRect_t *Rect,
                                         uint16_t           TextureOffX,
                                         uint16_t           TextureOffY
                                         );



/*******************************************************************************
  Function: R_DRW2D_CtxConvolutionKernelPreset1d

  Select 1d convolution kernel size and weights.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Preset - Kernel preset (see <r_drw2d_ConvolutionKernelPreset1d_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernelPreset2d>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_DrawRectConvolve2d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>,
    <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_CtxConvolutionKernelPreset1d(r_drw2d_Device_t                    Device,
                                                     r_drw2d_ConvolutionKernelPreset1d_t Preset
                                                     );



/*******************************************************************************
  Function: R_DRW2D_CtxConvolutionKernelPreset2d

  Select 2d convolution kernel size and weights.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Preset - Kernel preset (see <r_drw2d_ConvolutionKernelPreset2d_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_DrawRectConvolve2d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>,
    <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_CtxConvolutionKernelPreset2d(r_drw2d_Device_t                    Device,
                                                     r_drw2d_ConvolutionKernelPreset2d_t Preset
                                                     );



/*******************************************************************************
  Function: R_DRW2D_GetGaussKernel

  Computes a gauss gernel with the given size and sigma.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Kernel - Pointer to an array that has a size of (Width*Height)
     Width  - Width of the kernel (needs to be an odd value!).
     Height - Height of the kernel (needs to be an odd value!).
     Sigma  - The sigma used to compute the gauss coefficients.

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernel>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_DrawRectConvolve2d>, <R_DRW2D_DrawRectConvolve>
*/
r_drw2d_Error_t R_DRW2D_GetGaussKernel(r_drw2d_Device_t  Device,
                                       r_drw2d_FixedP_t *Kernel,
                                       int32_t           Width,
                                       int32_t           Height,
                                       r_drw2d_FixedP_t  Sigma
                                       );



/*******************************************************************************
  Function: R_DRW2D_CtxConvolutionKernel

  Select 2d convolution kernel size and weights.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Kernel - Convolution kernel (see <r_drw2d_ConvKernel_t>) - kernel width and height needs to be an odd value

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_DrawRectConvolve2d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>,
    <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_CtxConvolutionKernel(r_drw2d_Device_t      Device,
                                       const r_drw2d_ConvKernel_t *Kernel
                                             );



/*******************************************************************************
  Function: R_DRW2D_CtxConvolutionMode

  Sets the convolution mode.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
     Mode   - Convolution mode (see <r_drw2d_ConvMode_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_CtxConvolutionKernelPreset1d>, <R_DRW2D_DrawRectConvolve1dx>, <R_DRW2D_DrawRectConvolve1dy>,
    <R_DRW2D_DrawRectConvolve2d>, <R_DRW2D_DrawTriangles>, <R_DRW2D_DrawTrianglesUV>, <R_DRW2D_DrawPolyline>,
    <R_DRW2D_DrawLines>, <R_DRW2D_DrawEllipse>, <R_DRW2D_FramebufferClear>
*/
r_drw2d_Error_t R_DRW2D_CtxConvolutionMode(r_drw2d_Device_t   Device,
                                           r_drw2d_ConvMode_t Mode
                                           );





/*******************************************************************************
  Group: Display list control functions
*/

/*******************************************************************************
  Function: R_DRW2D_GpuFinish

  Tell the driver to explicitly trigger the finishing of the current drawing scene operation (display list execution).

  This function can block. i.e. wait for all commands in the GPU to be processed if the Finish parameter is
  <R_DRW2D_FINISH_WAIT> or return immediately if the parameter is <R_DRW2D_FINISH_NOWAIT>. Alternatively a non-blocking
  approach can be used: Call once R_DRW2D_FINISH_NOWAIT_MARK and later query with <R_DRW2D_GpuFinished>


 Parameter:
    Device - Device handle (see <r_drw2d_Device_t>)
     Block - Specify to wait for execution or not (see <r_drw2d_Finish_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_GpuFinished>, <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListDelete>, <R_DRW2D_GpuCmdListGenerate>,
    <R_DRW2D_GpuCmdListExec>, <R_DRW2D_GpuCmdListCopy>, <R_DRW2D_GpuCmdListDelete>
*/
r_drw2d_Error_t R_DRW2D_GpuFinish(r_drw2d_Device_t Device,
                                  r_drw2d_Finish_t Block
                                  );



/*******************************************************************************
  Function: R_DRW2D_GpuFinished

  Queries the driver for a yes/no whether there are still pending jobs in its pipeline.

  Can be used for single-threaded non-blocking use cases.
  <R_DRW2D_GpuFinish> with R_DRW2D_FINISH_NOWAIT_MARK must be be called once before this function.
  If this function is called before <R_DRW2D_GpuFinish>, the return value is R_DRW2D_ERR_OK
  and R_FALSE is returned in "RetFinished".


  Parameter:
    Device      - Device handle (see <r_drw2d_Device_t>)
    RetFinished - Result whether the GPU is finished (yes/no)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_GpuFinish>
*/
r_drw2d_Error_t R_DRW2D_GpuFinished(r_drw2d_Device_t Device, r_drw2d_Boolean_t *RetFinished);


/*******************************************************************************
  Function: R_DRW2D_GpuCmdListCreate

  Allocate empty command list.

  The application must call <R_DRW2D_GpuCmdListDelete> to delete the command list when it is no longer used.


  Parameter:
         Device - Device handle (see <r_drw2d_Device_t>)
     RetCmdList - Receives the allocated command list address (see <r_drw2d_GpuCmdList_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_COMMANDLIST> - Failed to allocate commandlist (all ids in use)
      - <R_DRW2D_ERR_NOT_SUPPORTED> - Command list recording not supported by low-level driver.

  See also:
    <R_DRW2D_GpuFinish>, <R_DRW2D_GpuCmdListDelete>, <R_DRW2D_GpuCmdListGenerate>, <R_DRW2D_GpuCmdListExec>,
    <R_DRW2D_GpuCmdListCopy>, <R_DRW2D_GpuCmdListDelete>
*/
r_drw2d_Error_t R_DRW2D_GpuCmdListCreate(r_drw2d_Device_t      Device,
                                         r_drw2d_GpuCmdList_t *RetCmdList
                                         );



/*******************************************************************************
  Function: R_DRW2D_GpuCmdListGenerate

  Record command list by calling an application provided function that invokes render commands.

  Any previously recorded command list data will be discarded.

  The command list must have been created using <R_DRW2D_GpuCmdListCreate>.

  Please notice that not all API functions may be called in the callback functions. Drawing API functions
  are supported.


  Parameter:
      Device - Device handle (see <r_drw2d_Device_t>)
     CmdList - Command list handle (see <r_drw2d_GpuCmdList_t>)
         Cbk - Callback function (see <r_drw2d_GpuCmdListCallback_t>)
    UserData - Arbitrary user data which will be passed to the callback function

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_COMMANDLIST> - Command list can not be recorded (e.g. because it is located in flash memory).

  See also:
    <R_DRW2D_GpuFinish>, <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListExec>, <R_DRW2D_GpuCmdListCopy>,
    <R_DRW2D_GpuCmdListDelete>
*/
r_drw2d_Error_t R_DRW2D_GpuCmdListGenerate(r_drw2d_Device_t              Device,
                                           r_drw2d_GpuCmdList_t          CmdList,
                                           r_drw2d_GpuCmdListCallback_t  Cbk,
                                           void                         *UserData
                                           );



/*******************************************************************************
  Function: R_DRW2D_GpuCmdListExec

  Execute previously recorded command list.


  Parameter:
      Device - Device handle (see <r_drw2d_Device_t>)
     CmdList - Command list handle (see <r_drw2d_GpuCmdList_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_COMMANDLIST> - Command list can not be executed (corrupted list or still recording)
      - <R_DRW2D_ERR_NOT_SUPPORTED> - Low-level driver does not support command lists.

  See also:
    <R_DRW2D_GpuFinish>, <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListDelete>, <R_DRW2D_GpuCmdListGenerate>,
    <R_DRW2D_GpuCmdListCopy>, <R_DRW2D_GpuCmdListDelete>
*/
r_drw2d_Error_t R_DRW2D_GpuCmdListExec(r_drw2d_Device_t     Device,
                                       r_drw2d_GpuCmdList_t CmdList
                                       );



/*******************************************************************************
  Function: R_DRW2D_GpuCmdListCopy

  Copy command list data to memory area.

  If DestAddr is NULL, Size returns the required size (in bytes) and no command list data is copied.

  If RelocBaseAddr is != NULL, relocate jump commands so that the command list can later be
  executed from the given address (e.g. in flash memory).

  The copied command list may not be re-recorded or deleted using <R_DRW2D_GpuCmdListDelete>.


  Parameter:
    Device          - Device handle (see <r_drw2d_Device_t>)
    CmdList         - Command list handle (see <r_drw2d_GpuCmdList_t>)
    DestAddr        - Where to copy the commandlist. NULL to query required size.
    Size            - If DestAddr is null, returns the required size. Otherwise this parameters determines
                      the maximum number of bytes that DestAddr can hold.
    RelocBaseAddr   - If not null, specifies the start address from where the command list can be executed
                      later on (e.g. a flash memory address).

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_COMMANDLIST> - Command list can not be copied (corrupted list or still recording)
      - <R_DRW2D_ERR_NOT_SUPPORTED> - Low-level driver does not support copying of command lists.

  See also:
    <R_DRW2D_GpuFinish>, <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListDelete>, <R_DRW2D_GpuCmdListGenerate>,
    <R_DRW2D_GpuCmdListExec>, <R_DRW2D_GpuCmdListDelete>
*/
r_drw2d_Error_t R_DRW2D_GpuCmdListCopy(r_drw2d_Device_t      Device,
                                       r_drw2d_GpuCmdList_t  CmdList,
                                       void                 *DestAddr,
                                       uint32_t             *Size,
                                       void                 *RelocBaseAddr
                                       );



/*******************************************************************************
  Function: R_DRW2D_GpuCmdListDelete

  Delete command list.

  The command list must have been created using <R_DRW2D_GpuCmdListCreate>.


  Parameter:
      Device - Device handle (see <r_drw2d_Device_t>)
     CmdList - Command list handle (see <r_drw2d_GpuCmdList_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.
      - <R_DRW2D_ERR_COMMANDLIST> - The given command list was not allocated by <R_DRW2D_GpuCmdListCreate>

  See also:
    <R_DRW2D_GpuFinish>, <R_DRW2D_GpuCmdListCreate>, <R_DRW2D_GpuCmdListGenerate>, <R_DRW2D_GpuCmdListExec>,
    <R_DRW2D_GpuCmdListCopy>
*/
r_drw2d_Error_t R_DRW2D_GpuCmdListDelete(r_drw2d_Device_t     Device,
                                         r_drw2d_GpuCmdList_t CmdList
                                         );





/*******************************************************************************
  Group: Performance counter functions
*/

/*******************************************************************************
  Function: R_DRW2D_PerfCountersAlloc

  Allocate hardware performance counter resources for this device context.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Performance_t>, <R_DRW2D_PerfCountersFree>, <R_DRW2D_PerfValueGet>, <R_DRW2D_PerfValueReset>
*/
r_drw2d_Error_t R_DRW2D_PerfCountersAlloc(r_drw2d_Device_t Device);



/*******************************************************************************
  Function: R_DRW2D_PerfCountersFree

  Free hardware performance counter resources for this device context.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Performance_t>, <R_DRW2D_PerfCountersAlloc>, <R_DRW2D_PerfValueGet>, <R_DRW2D_PerfValueReset>
*/
r_drw2d_Error_t R_DRW2D_PerfCountersFree(r_drw2d_Device_t Device);



/*******************************************************************************
  Function: R_DRW2D_PerfValueGet

  Query the driver for HW cycles of type Type and return the value in RetValue.

  The cycle counts are reset when <R_DRW2D_PerfValueReset> is called.

  <R_DRW2D_PerfCountersAlloc> must have been called to allocate the hardware performance counters
   for the DRW2D device context.


  Parameter:
       Device - Device handle (see <r_drw2d_Device_t>)
         Type - Performance type to query (see <r_drw2d_Performance_t>)
     RetValue - Cycle count is stored here (must not be NULL).

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Performance_t>, <R_DRW2D_PerfValueReset>
*/
r_drw2d_Error_t R_DRW2D_PerfValueGet(r_drw2d_Device_t      Device,
                                     r_drw2d_Performance_t Type,
                                     uint32_t *            RetValue
                                     );



/*******************************************************************************
  Function: R_DRW2D_PerfValueReset

  Reset the HW cycles of the given performance type to 0.


  Parameter:
     Device - Device handle (see <r_drw2d_Device_t>)
       Type - Performance type to query (see <r_drw2d_Performance_t>)

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <R_DRW2D_PerfValueGet>
*/
r_drw2d_Error_t R_DRW2D_PerfValueReset(r_drw2d_Device_t      Device,
                                       r_drw2d_Performance_t Type
                                       );





/*******************************************************************************
  Group: Error handling functions

  If the driver detects any fatal error, it will call the driver internal error handler function
  set by <R_DRW2D_ErrCallbackSet>.

  The error handler itself is not part of the API and must not be called by an application.
*/

/*******************************************************************************
  Function: R_DRW2D_ErrCallbackSet

  Install a device context / thread specific application error handler for the driver.

  If ErrorCb is zero, no callback function will be used.

  If the application has set an error handler callback function, the central error handler will call it and
  then return to its caller.

  To uninstall a device context / thread specific error handler, ErrorCb should be set to NULL.


  Parameter:
      Device - Device handle (see <r_drw2d_Device_t>)
     ErrorCb - Reference to error handler callback function (see <r_drw2d_ErrorCallback_t>)
    UserData - Arbitrary user data that is passed on to the error callback function

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Error_t>, <r_drw2d_ErrorCallback_t>
*/
r_drw2d_Error_t R_DRW2D_ErrCallbackSet(r_drw2d_Device_t        Device,
                                       r_drw2d_ErrorCallback_t ErrorCb,
                                       void *                  UserData
                                       );



/*******************************************************************************
  Function: R_DRW2D_GlobalErrCallbackSet

  Install a global error handler for the driver.

  If GlobalErrorCb is zero, no callback function will be used.

  If a valid device context (<r_drw2d_Device_t>) is available when an error occurs,
  and the application has set an error callback for that device context, the device context
  error handler will have precedence over the global error handler.

  If no valid device context is available, only the global error handler will be called.

  If the application has set an error handler callback function, the central error handler will call it and
  then return to its caller.

  To uninstall the global error handler, GlobalErrorCb should be set to NULL.


  Parameter:
            Device - Device handle (see <r_drw2d_Device_t>)
     GlobalErrorCb - Reference to error handler callback function (see <r_drw2d_GlobalErrorCallback_t>)
          UserData - Arbitrary user data that is passed on to the error callback function

  Return value:
    Errorcode (<R_DRW2D_ERR_OK> if successful). See <r_drw2d_Error_t> for the list of error codes.

  See also:
    <r_drw2d_Error_t>, <r_drw2d_GlobalErrorCallback_t>, <R_DRW2D_ErrCallbackSet>, <r_drw2d_ErrorCallback_t>
*/
r_drw2d_Error_t R_DRW2D_GlobalErrCallbackSet(r_drw2d_GlobalErrorCallback_t GlobalErrorCb,
                                             void *                        UserData
                                             );





/*******************************************************************************
  Group: Math Utility Functions

*/

/*******************************************************************************
  Function: R_DRW2D_FixMul

  Multiply two fixed point values.
*/
R_INLINE r_drw2d_FixedP_t R_DRW2D_FixMul(r_drw2d_FixedP_t A, r_drw2d_FixedP_t B);

R_INLINE r_drw2d_FixedP_t R_DRW2D_FixMul(r_drw2d_FixedP_t A, r_drw2d_FixedP_t B)
{
    union { uint32_t lh[2]; int64_t ll;} c;
    c.ll = A;
    c.ll *= B;
    return (c.lh[0] >> 16) | (c.lh[1] << 16);
}



/*******************************************************************************
  Function: R_DRW2D_FixDiv

  Divide fixed point value "a" by value "b".
*/
R_INLINE r_drw2d_FixedP_t R_DRW2D_FixDiv(r_drw2d_FixedP_t A, r_drw2d_FixedP_t B);

R_INLINE r_drw2d_FixedP_t R_DRW2D_FixDiv(r_drw2d_FixedP_t A, r_drw2d_FixedP_t B)
{
#if defined(__ghs__)
#pragma ghs startnomisra
#endif
    int64_t a64 = A;
    return (r_drw2d_FixedP_t) ((a64 << 16) / B);
#if defined(__ghs__)
#pragma ghs endnomisra
#endif
}



/*******************************************************************************
  Function: R_DRW2D_FixAbs

  Returns the absolute value of parameter A. Not defined for X == INT_MIN.
*/
R_INLINE r_drw2d_FixedP_t R_DRW2D_FixAbs(r_drw2d_FixedP_t A);

R_INLINE r_drw2d_FixedP_t R_DRW2D_FixAbs(r_drw2d_FixedP_t A)
{
    uint32_t result;

    if(A < 0)
    {
        result = ~((uint32_t) A);
        result++;
    }
    else
    {
        result = (uint32_t) A;
    }

    return (int32_t) result;
}



/*******************************************************************************
  Function: R_DRW2D_FixSin

  Calculate sine function for Angle (in radian measure)

  Parameter:
    Angle - Angle, in radian measure

  Return value:
    sin(Angle)
*/
r_drw2d_FixedP_t R_DRW2D_FixSin(r_drw2d_FixedP_t Angle);



/*******************************************************************************
  Function: R_DRW2D_FixCos

  Calculate cosine function for Angle (in radian measure)

  Parameter:
    Angle - Angle, in radian measure

  Return value:
    cos(Angle)
*/
r_drw2d_FixedP_t R_DRW2D_FixCos(r_drw2d_FixedP_t Angle);



/*******************************************************************************
  Function: R_DRW2D_FixTan

  Calculate tangens function for Angle (in radian measure)

  Parameter:
    Angle - Angle, in radian measure

  Return value:
    tan(Angle)
*/
r_drw2d_FixedP_t R_DRW2D_FixTan(r_drw2d_FixedP_t Angle);



/*******************************************************************************
  Function: R_DRW2D_FixSqrt

  Calculate square root of fixed point value

  Parameter:
    FixValue - Fixed point value

  Return value:
    sqrt(Value)
*/
r_drw2d_FixedP_t R_DRW2D_FixSqrt(r_drw2d_FixedP_t FixValue);



#ifdef __cplusplus
}
#endif

#endif /* R_DRW2D_API_H_ */