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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to BLTsville</title>
<style type="text/css">
.cmd_line {
background: #000;
color: #fff;
padding: 10px;
}
.inline_code {
font-family: "Courier New", Courier, monospace;
font-size: small;
}
.code_block {
margin-left: 40px;
font-family: "Courier New", Courier, monospace;
font-size: small;
}
.small_code_block_in_table {
font-family: "Courier New", Courier, monospace;
font-size: x-small;
}
.small_code_block {
font-family: "Courier New", Courier, monospace;
font-size: x-small;
margin-left: 40px;
}
.underline_code {
font-family: "Courier New", Courier, monospace;
font-size: small;
text-decoration: underline;
}
.Code_Header {
font-size: xx-large;
font-weight: bold;
text-align: left;
font-family: "Courier New", Courier, monospace;
}
.Code_Header_2 {
font-size: x-large;
font-weight: bold;
text-align: left;
font-family: "Courier New", Courier, monospace;
}
.Code_Header_3 {
font-size: large;
font-weight: bold;
text-align: left;
font-family: "Courier New", Courier, monospace;
}
.indent1 {
margin-left: 40px;
}
.center {
}
.Header1 {
margin: 0px 0 0 0;
font-size: xx-large;
font-weight: bold;
text-align: left;
line-height: normal;
background-color: #E0E0E0;
}
.Header2 {
font-size: xx-large;
font-weight: bold;
margin: 0px;
line-height: 100%;
}
.Header4 {
font-size: large;
font-weight: bold;
margin: 0px;
line-height: 100%;
}
.strong_emphasis {
text-decoration: underline;
font-weight: bold;
}
.filename {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
}
.underline {
text-decoration: underline;
}
.grn_left {
text-align: left;
color: #009900;
}
.left_topbord {
text-align: left;
border-top-style: solid;
border-top-width: 1px;
}
.center_topbord {
text-align: center;
border-top-style: solid;
border-top-width: 1px;
}
.blue_left_botbord {
text-align: left;
border-bottom-style: solid;
border-bottom-width: 1px;
color: #0000FF;
}
.blue_ctr_botbord {
text-align: center;
border-bottom-style: solid;
border-bottom-width: 1px;
color: #0000FF;
}
.red_ctr {
text-align: center;
color: #FF0000;
}
.red_left {
text-align: left;
color: #FF0000;
}
.grn_ctr {
text-align: center;
color: #009900;
}
.red_ctr_topbord {
text-align: center;
border-top-style: solid;
border-top-width: 1px;
color: #FF0000;
}
.blu_ctr_topbord {
text-align: center;
border-top-style: solid;
border-top-width: 1px;
color: #0000FF;
}
.indent_thick_bord {
border-color: #000000;
border-style: solid;
margin-left: 40px;
}
.thin_bord {
border: 1px solid #000000;
}
.thin_bord_dbl_botbord {
border-color: #000000;
border-left-style: solid;
border-left-width: 1px;
border-right-style: solid;
border-right-width: 1px;
border-top-style: solid;
border-top-width: 1px;
border-bottom-style: double;
border-bottom-width: 3px;
}
.dl_link {
float: right;
}
.note {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
margin-left: 40px;
}
.small_note {
font-size: xx-small;
line-height: 100%;
}
.ctr {
text-align: center;
}
.red {
color: #FF0000;
}
.glyph_cache {
font-family: "Courier New", Courier, monospace;
font-size: medium;
font-weight: normal;
font-style: normal;
margin-left: 40px;
}
</style>
</head>
<body>
<table style="width: 100%; line-height: 100%;">
<tr>
<td style="width: 484px">
<div style="background-position: center; background-image:url('bvlogo.png'); width: 484px; height: 400px; background-repeat: no-repeat;">
<div style="position: relative; left: 0; top: 0;">
<a href="http://graphics.github.com/ocd">
<img src="ocdtab.png" alt="Now With OCD" style="border-width: 0; position: absolute; top: 0; right: 0;" /></a>
</div>
</div>
</td>
<td>
<p>BLTsville is the open 2-D API designed to provide an abstract interface for both
hardware and software 2-D implementations.</p>
<p>BLTs (BLock Transfers) involve the moving around of blocks (rectangles) of pixels. BLTsville is the place to go
for BLTs.</p>
<hr />
<table style="width: 100%">
<tr>
<td>
<div class="dl_link"><img alt="CC BY-ND" longdesc="Creative Commons Attribution-NoDerivs 3.0 Unported License" src="http://i.creativecommons.org/l/by-nd/3.0/88x31.png" width="88" height="31" /></div>
<p class="Header2">License</p>
</td>
</tr>
<tr>
<td>
<div>
<p class="small_note">The API is designed and maintained by Texas Instruments, Inc., but anyone is free to use it with no
cost or obligation.</p>
<p>This project is licensed under the <a href="http://creativecommons.org/licenses/by-nd/3.0/">Creative Commons
Attribution-NoDerivs 3.0 Unported License</a>.</p>
</div>
</td>
</tr>
</table>
<hr />
<table style="width: 100%">
<tr>
<td>
<p class="Header2">Dependencies</p>
</td>
</tr>
<tr>
<td>
<p>This project is dependent on the <a href="http://graphics.github.com/ocd">Open Color format Defintions (OCD) project</a>.</p>
</td>
</tr>
</table>
<hr />
<table style="width: 100%">
<tr>
<td>
<p class="Header2">Source</p>
</td>
</tr>
<tr>
<td>
<div class="dl_link">
<a href="http://github.com/graphics/bltsville/zipball/master">
<img width="90" alt="download zip" src="http://github.com/images/modules/download/zip.png" border="0"/></a>
<a href="http://github.com/graphics/bltsville/tarball/master">
<img width="90" alt ="download tar" src="http://github.com/images/modules/download/tar.png" border="0"/></a>
</div>
<div>
Get the source code on GitHub at <a href="http://github.com/graphics/bltsville">graphics/bltsville</a>, or download this project in either
<a href="http://github.com/graphics/bltsville/zipball/master">zip</a> or
<a href="http://github.com/graphics/bltsville/tarball/master">tar</a> formats.</div>
<p>You can also clone the project with <a href="http://git-scm.com">Git</a> by running:</p>
<pre><a class="cmd_line">$ git clone git://github.com/graphics/bltsville</a></pre>
</td>
</tr>
<tr><td>
<hr />
<table style="width: 100%">
<tr>
<td class="Header2">Wiki</td>
</tr>
<tr>
<td><a href="https://github.com/graphics/bltsville/wiki">https://github.com/graphics/bltsville/wiki</a></td>
</tr>
</table>
</td></tr>
</table>
</td>
</tr>
</table>
<hr />
<p class="Header1">Points of Interest in BLTsville</p>
<table style="width: 100%">
<tr>
<td style="width: 50%" valign="top">
<ul>
<li>Solid fills</li>
<li>Pattern fills</li>
<li>Copies</li>
<li>Color format conversion<ul>
<li>Extensive color format support<ul>
<li>RGB, BGR</li>
<li>RGBA, ARGB, etc.</li>
<li>YCbCr (YUV)<ul>
<li>subsampling</li>
<li>packed</li>
<li>planar</li>
</ul>
</li>
<li>Monochrome</li>
<li>Alpha-only</li>
<li>Look-Up Table (LUT)</li>
</ul>
</li>
<li>Extensible color format</li>
</ul>
</li>
<li>ROP4<ul>
<li>Three inputs</li>
</ul>
</li>
<li>Blends<ul>
<li>Pre-defined Porter-Duff blends</li>
<li>Pre-defined DirectFB support</li>
<li>Extensible blends</li>
</ul>
</li>
<li>Multiple </li>
<li>Filters<ul>
<li>Extensible filters</li>
</ul>
</li>
<li>Independent horizontal and vertical <strong>flipping</strong></li>
<li>Independent <strong>scaling</strong> of all three inputs</li>
<li>Clipping</li>
<li>Independent <strong>rotation</strong> of all three inputs
(multiples of 90 degrees)</li>
</ul>
</td>
<td style="width: 50%" valign="top">
<ul>
<li>Choice of <strong>scaling</strong> type<ul>
<li>Quality based choice</li>
<li>Speed based choice</li>
<li>Image type based choice</li>
<li>Specific scale type choice</li>
<li>Extensible scale type</li>
</ul>
</li>
<li>Synchronous operations</li>
<li>Asynchronous operations<ul>
<li>Client notification of BLT completion</li>
</ul>
</li>
<li>Batching<ul>
<li>Combine multiple BLTs into group that can be
handled more efficiently by implementations<ul>
<li>Character BLTs</li>
<li>Multi-layer blending</li>
<li>ROP/Blend combination with
specified ordering</li>
<li>etc.</li>
</ul>
</li>
<li>Delta BLTs</li>
</ul>
</li>
<li>Dithering<ul>
<li>Quality based choice</li>
<li>Speed based choice</li>
<li>Image type based choice</li>
<li>Specific dither type choice</li>
<li>Extensible dither type</li>
</ul>
</li>
<li>Any implementation support<ul>
<li>CPU</li>
<li>2-D Accelerator</li>
</ul>
</li>
</ul>
</td>
</tr>
</table>
<ul>
<li>BLTsville does not dictate capabilities of the
implementations<ul>
<li>Operation specified either works or returns
a response indicating it's not supported</li>
</ul>
</li>
</ul>
<hr />
<p class="Header1">How to Get to BLTsville</p>
<p>BLTsville's API is defined in the BLTsville header files. A client must
include <span class="inline_code">bltsville.h</span> to access the
implementations.</p>
<p><em>Note that the </em> <span class="underline_code"><em>bvinternal.h</em></span><em><span class="underline"> header is for
implementations only</span> and should not be used by clients.</em></p>
<p class="indent1">BLTsville currently has a user mode interface, but kernel
mode is on the way.
<em>Obviously, the kernel mode interface will have more operating system
dependence, but as much as possible, the user mode itself is agnostic of
operating system. However, the kernel mode interface will be quite similar
to the user mode.</em></p>
<hr />
<p class="Header1">BLTsville Neighborhoods</p>
<p>For most BLTsville clients, only one or both of the two main implementations
will be used. These two implementations are the CPU and default 2-D hardware
implementations. Clients use the standard names below to access these
implementations. The specific
name decoration will be dictated by the host Operating System (O/S):</p>
<ul>
<li>CPU: <span class="filename">bltsville_cpu</span><ul>
<li>Linux/Android: <span class="filename">libbltsville_cpu.so</span></li>
<li>Windows: <span class="filename">bltsville_cpu.dll</span></li>
<li>etc.</li>
</ul>
</li>
<li>2-D hardware: <span class="filename">bltsville_2d</span><ul>
<li>Linux/Android: <span class="filename">libbltsville_2d.so</span></li>
<li>Windows: <span class="filename">bltsville_2d.dll</span></li>
<li>etc.</li>
</ul>
</li>
</ul>
<p>These entry points may represent the implementations themselves, or they may
be symbolic links. In most cases, system integration will will connect the
client
with the most capable 2-D hardware available in the system. For example,
<span class="filename">bltsville_2d</span> might be a symbolic link to
<span class="filename">bltsville_vivante2d</span>.</p>
<p>In addition, there may be more implementations co-existing in a given system.
These will have
additional unique names as determined by the vendors. For example:</p>
<ul>
<li>Reference CPU implementation: <span class="filename">bltsville_refcpu</span></li>
<li>System DMA: <span class="filename">bltsville_mydma</span></li>
</ul>
<hr />
<p class="Header1">Visiting BLTsville</p>
<p>More than one BLTsville implementation may be available. To facilitate this, BLTsville
implementation libraries are dynamically loaded by the client. Then the
BLTsville
entry points are imported. The specific procedure for this is dictated by the host
O/S.</p>
<hr />
<p class="Header1">Things To Do In BLTsville</p>
<p>BLTsville's interface consists of three functions per implementation,
which must be imported by the client at run time:</p>
<ul class="code_block">
<li><span class="inline_code"><a href="#bv_map">bv_map()</a></span></li>
<li><span class="inline_code"><a href="#bv_blt">bv_blt()</a></span></li>
<li><span class="inline_code"><a href="#bv_unmap">bv_unmap()</a></span></li>
</ul>
<a name="bv_map" class="Code_Header">bv_map()</a>
<p class="code_block">enum bverror bv_map(struct bvbuffdesc* buffdesc);</p>
<p><span class="strong_emphasis">BLTsville does not allocate buffers.</span>
Clients must provide a buffer description via the <span class="inline_code">
<a href="#bvbuffdesc">bvbuffdesc</a></span> structure so that BLTsville can
access the buffer.</p>
<p><span class="inline_code">bv_map()</span> is used to provide the
implementation an opportunity to associate hardware
resources with the specified buffer. Most hardware requires this type of
mapping, and there is usually appreciable overhead associated with it.</p>
<p>Client are provided with <span class="inline_code">bv_map()</span> so they can control exactly when the
mapping overhead is encountered. For a given buffer, the client can
call the <span class="inline_code">bv_map()</span> in each implementation to establish that mapping immediately.</p>
<p>As a special bonus, BLTsville clients are not required to call
<span class="inline_code">bv_map()</span> for each implementation being used.
One call to any implementation's <span class="inline_code">bv_map()</span> is
sufficient to indicate that the client can be trusted to make the corresponding
call to <span class="inline_code"><a href="#bv_unmap">bv_unmap()</a></span> upon
destruction of the buffer. As a result, the implementations can use
<em>lazy mapping</em> only as necessary. This way a client that
has multiple implementations available will not incur the overhead of the
mapping at all, unless a <span class="inline_code"><a href="#bv_blt">bv_blt()</a></span>
call to that implementation is made. But the mapping is maintained, so that the overhead
is avoided on subsequent <span class="inline_code"><a href="#bv_blt">bv_blt()</a></span>
calls.</p>
<p><em><strong>Calling </strong></em> <span class="inline_code">
<em><strong>bv_map()</strong></em></span><em><strong> is actually optional prior to calling
</strong></em>
<span class="inline_code"><a href="#bv_blt"><em><strong>bv_blt()</strong></em></a></span><em><strong>. However, if
it is not called at least once for a
given buffer, the necessary mapping must be done automatically when
</strong></em>
<span class="inline_code"><a href="#bv_blt"><em><strong>bv_blt()</strong></em></a></span><em><strong> is called, and
unmapping must be done when it is complete. This means the overhead will be incurred for every
</strong></em>
<a href="#bv_blt" class="inline_code"><em><strong>bv_blt()</strong></em></a><em><strong> call which uses that buffer.</strong></em></p>
<p><em>Normally, the lowest overhead </em><span class="inline_code"><em>bv_map()</em></span><em>
call will be in the CPU-based implementation. So most clients will want to
make a single, low overhead </em><span class="inline_code"><em>bv_map()</em></span><em>
call to the bltsville_cpu implementation to avoid the mapping/unmapping
overhead on each </em><span class="inline_code"><a href="#bv_blt"><em>bv_blt()</em></a></span><em>
call, while avoiding the mapping overhead when possible.</em></p>
<p><em>NOTE: Obviously any API cannot add capabilities beyond an implementation's
capabilities. So if the
implementation requires memory to be allocated from a special pool, that
responsibility falls upon the client. The </em> <span class="inline_code"><em>bv_map()</em></span><em>
function for that implementation will need to check the characteristics of the
memory and return an error if it does not meet the necessary criteria.</em></p>
<a name="bv_blt" class="Code_Header">bv_blt()</a>
<p class="code_block">enum bverror bv_blt(struct bvbltparams* bltparams);</p>
<p>The main function of BLTsville is <span class="inline_code">bv_blt()</span>.
A <span class="inline_code"><a href="#bvbltparams">bvbltparams</a></span> structure is passed into
<span class="inline_code">bv_blt()</span> to trigger the desired 2-D operation.</p>
<a name="bv_unmap" class="Code_Header">bv_unmap()</a>
<p class="code_block">enum bverror bv_unmap(struct bvbuffdesc* buffdesc);</p>
<p><span class="inline_code">bv_unmap()</span> is used to free implementation
resources associated with a buffer. If <span class="inline_code">
<a href="#bv_map">bv_map()</a></span> was called for a given buffer,
<span class="inline_code">bv_unmap()</span> must be called as well.</p>
<p>For convenience, only one <span class="inline_code">bv_unmap()</span> needs
to be called for each buffer, regardless of how many implementations were used,
including multiple calls to <span class="inline_code"><a href="#bv_map">bv_map()</a></span>.</p>
<p>Also for convenience, <span class="inline_code">bv_unmap()</span> may be
called multiple times on the same buffer. Note that only the first call
will actually free (all) associated resources. </p>
<hr />
<a name="bvbltparams" class="Code_Header">bvbltparams</a>
<p><span class="inline_code">bvbltparams</span> is the central structure in
BLTsville. This structure holds the details of the BLT being requested by
the client.</p>
<p class="small_code_block">struct bvbltparams {<br />
unsigned int <a href="#bvbltparams.structsize">structsize</a>;<br />
char *<a href="#errdesc">errdesc</a>;<br />
unsigned long <a href="#implementation">implementation</a>;<br />
unsigned long <a href="#flags">flags</a>;<br />
union {<br />
unsigned short <a href="#rop">rop</a>;<br />
enum bvblend <a href="#blend">blend</a>;<br />
struct bvfilter *<a href="#filter">filter</a>;<br />
} <a href="#op">op</a>;<br />
void *<a href="#colorkey">colorkey</a>;<br />
union bvalpha <a href="#globalalpha">globalalpha</a>;<br />
enum bvscalemode <a href="#scalemode">scalemode</a>;<br />
enum bvdithermode <a href="#dithermode">dithermode</a>;<br />
struct bvbuffdesc *<a href="#dstdesc">dstdesc</a>;<br />
struct bvsurfgeom *<a href="#dstgeom">dstgeom</a>;<br />
struct bvrect <a href="#dstrect">dstrect</a>;<br />
union {<br />
struct bvbuffdesc *<a href="#src1.desc">desc</a>;<br />
struct bvtileparams *<a href="#src1.tileparams">tileparams</a>;<br />
} <a href="#src1">src1</a>;<br />
struct bvsurfgeom *<a href="#src1geom">src1geom</a>;<br />
struct bvrect <a href="#src1rect">src1rect</a>;<br />
union {<br />
struct bvbuffdesc *<a href="#src2.desc">desc</a>;<br />
struct bvtileparams *<a href="#src2.tileparams">tileparams</a>;<br />
} <a href="#src2">src2</a>;<br />
struct bvsurfgeom *<a href="#src2geom">src2geom</a>;<br />
struct bvrect <a href="#src2rect">src2rect</a>;<br />
union {<br />
struct bvbuffdesc *<a href="#mask.desc">desc</a>;<br />
struct bvtileparams *<a href="#mask.tileparams">tileparams</a>;<br />
} <a href="#mask">mask</a>;<br />
struct bvsurfgeom *<a href="#maskgeom">maskgeom</a>;<br />
struct bvrect <a href="#maskrect">maskrect</a>;<br />
struct bvrect <a href="#cliprect">cliprect</a>;<br />
unsigned long <a href="#batchflags">batchflags</a>;<br />
struct bvbatch *<a href="#batch">batch</a>;<br />
void (*<a href="#callbackfn">callbackfn</a>)(struct
bvcallbackerror* err,<br />
unsigned long handle);<br />
unsigned long <a href="#callbackdata">callbackdata</a>;<br />
};</p>
<a name="bvbltparams.structsize" class="Code_Header_2">bvbltparams.structsize</a>
<p><span class="code_block">unsigned long structsize; /* input
*/</span></p>
<p>BLTsville is designed to be forwards and backwards compatible between client
and library versions. But this compatibility would be eliminated if
clients chose to check for a specific version of the BLTsville implementations
and fail if the specific version requested was not in place.</p>
<p>Instead, BLTsville structures use the <span class="inline_code">structsize</span>
member to indicate the number of bytes in the structure, which is used to
communicate between the client and implementation which portions of the
structure are current. This effectively bypasses the concept of a version
and focuses on the specifics of what changes need to be considered to maintain
compatibility.</p>
<ol>
<li>When an old client calls into a new implementation, that
implementation will realize if the client only provides a subset
of an updated structure. The implementation will handle
this and utilize only that information which has been provided.
New features will be disabled, but functionality will be
maintained.</li>
<li>When a new client calls into an old implementation, that
implementation will ignore the extra members of the structure
and operate in ignorance of them. If these members are
necessary for some new functionality, this will be evident from
other fields in the structure, so that the implementation can
gracefully fail.</li>
</ol>
<p>If <span class="inline_code">structsize</span> is set to a value that is too
small for an implementation, it may return a <span class="inline_code">
<a href="#BVERR_BLTPARAMS_VERS">BVERR_BLTPARAMS_VERS</a></span> error.</p>
<p class="Code_Header_2"><a name="bvbltparams.errdesc">bvbltparams.errdesc</a></p>
<p><span class="code_block">char* errdesc; /* output */</span></p>
<p><span class="inline_code">errdesc</span> is optionally used by
implementations to pass a 0-terminated string with additional debugging
information back to clients for debugging purposes.
<span class="inline_code">errdesc</span> is not localized or otherwise meant to
provide information that is displayed to users.</p>
<p class="Code_Header_2"><a name="bvbltparams.implementation">bvbltparams.implementation</a></p>
<p class="code_block">unsigned long implementation; /* input */</p>
<p>Multiple implementations of BLTsville can be combined under managers which
can distribute the BLT requests to the implementations based on whatever
criteria the manager chooses. This might include availability of the
operation, performance, loading, or power state. In such a scenario, the
client may need to override or augment the choice made by the manager.
This field allows that control.</p>
<p><strong><em>Note that this feature is extremely complicated, and more
detailed documentation needs to be created to allow creation of managers and
smooth integration by a client. There are serious issues that must be
understood before any manager can be put into place, such as CPU cache coherence
and multiple implementation operation interdependence. For now, this field
should be set to 0 by clients.</em></strong></p>
<p>If the implementation cannot respond to the <span class="inline_code">
implementation</span> flags set, it may return a <span class="inline_code">
<a href="#BVERR_IMPLEMENTATION">BVERR_IMPLEMENTATION</a></span> error.</p>
<p class="Code_Header_2"><a name="flags">bvbltparams.flags</a></p>
<p class="code_block">unsigned long flags; /* input */</p>
<p>The <span class="inline_code">flags</span> member provides the baseline of
information to <span class="inline_code"><a href="#bv_blt">bv_blt()</a></span>
about the type of BLT being requested.</p>
<p>To maintain compatibility, unused bits in the flags member should be set to
0.</p>
<p>If the flags set are not supported by the implementation, it may return
<span class="inline_code"><a href="#BVERR_FLAGS">BVERR_FLAGS</a></span>, or a
more specific <a href="#bverror">error code</a>.</p>
<p class="Code_Header_3"><a name="BVFLAG_OP_">bvbltparams.flags - BVFLAG_OP_*</a></p>
<p>The <span class="inline_code">op</span> field of the flags member specifies
the type of BLT operation to perform. Currently there are three types of
BLT operations defined:</p>
<table style="width: 100%">
<tr>
<td valign="top">1.</td>
<td><span class="inline_code"><strong><a name="BVFLAG_ROP">BVFLAG_ROP</a></strong></span><br />
<p>This flag indicates the operation being performed is a raster operation, and the
<span class="inline_code"><a href="#op">bvbltparams.op</a></span> union is treated as
<span class="inline_code"><a href="#rop">rop</a></span>. Raster OPerations are
binary operations performed on the bits of the inputs. See
<span class="inline_code"><a href="#rop">bvbltparams.op.rop</a></span> for details.<br />
</p>
<br />
</td>
</tr>
<tr>
<td valign="top">2.</td>
<td>
<p><span class="inline_code"><strong><a name="BVFLAG_BLEND">BVFLAG_BLEND</a></strong></span><br />
</p>
<p>This flag indicates the operation being performed is a blend, and the
<span class="inline_code"><a href="#op">bvbltparams.op</a></span> union is treated as
<span class="inline_code"><a href="#blend">blend</a></span>.
Blending involves mixing multiple layers of
pixels using the specified equations.
Surrounding pixels are not involved in blend
operations. See <span class="inline_code"><a href="#blend">bvbltparams.op.blend</a></span>
for details.</p>
<p> </p>
</td>
</tr>
<tr>
<td valign="top">3.</td>
<td><span class="inline_code"><strong><a name="BVFLAG_FILTER">BVFLAG_FILTER</a></strong></span><br />
<br />
This flag indicates the operation being performed is a filter, and the
<span class="inline_code"><a href="#op">bvbltparams.op</a></span> union is treated as
<span class="inline_code"><a href="#filter">filter</a></span>.
Filtering involves mixing multiple layers of
pixels. Surrounding pixels are involved in filter
operations. See <span class="inline_code"><a href="#filter">bvbltparams.op.filter</a></span>
for details.<br />
</td>
</tr>
</table>
<p class="Code_Header_3"><a name="BVFLAG_KEY_SRC">bvbltparams.flags - BVFLAG_KEY_SRC</a>/<a name="BVFLAG_KEY_DST">DST</a></p>
<p>The <span class="inline_code">BVFLAG_KEY_SRC</span> and <span class="inline_code">BVFLAG_KEY_DST</span> enable source
and destination color keying, respectively. When either flag is set, the <span class="inline_code"><a href="#colorkey">colorkey</a></span>
member of <span class="inline_code"><a href="#bvbltparams">bvbltparams</a></span> is used.</p>
<p><span class="inline_code">BVFLAG_KEY_SRC</span> and <span class="inline_code">BVFLAG_KEY_DST</span> are mutually
exclusive.</p>
<p>See <span class="inline_code"><a href="#colorkey">bvbltparams.colorkey</a></span> for details.</p>
<p class="Code_Header_3"><a name="BVFLAG_CLIP">bvbltparams.flags - BVFLAG_CLIP</a></p>
<p>When <span class="inline_code">BVFLAG_CLIP</span> is set, the <span class="inline_code"><a href="#cliprect">cliprect</a></span>
member of <span class="inline_code"><a href="#bvbltparams">bvbltparams</a></span> is used by the implementation as a
limiting rectangle on data written to the destination. See
<span class="inline_code"><a href="#cliprect">cliprect</a></span> for details.</p>
<p class="Code_Header_3"><a name="BVFLAG_SRCMASK">bvbltparams.flags - BVFLAG_SRCMASK</a></p>
<p>Normally, the mask is applied at the destination, after all scaling has been completed (including scaling the mask if
necessary). But some environments require that the mask be applied at the sources, before scaling occurs.
The <span class="inline_code">BVFLAG_SRCMASK</span> flag requests that the implementation use this method if supported.</p>
<p class="Code_Header_3">bvbltparams.flags - BVFLAG_TILE_*</p>
<p>Normally, when a source's size does not match the destination, the source is scaled to fill the destination.
But when the corresponding <span class="inline_code">BVFLAG_TILE_*</span> flag is set, this behavior is modified.</p>
<p>First, the source's size specifies a tile (or pattern, or brush) to be used to fill the destination. This tile
is replicated instead of scaled.</p>
<p>The origin of the source's rectangle is used to locate the tile within a larger surface. </p>
<p>Second, a <span class="inline_code"><a href="#bvbuffdesc">bvbuffdesc</a></span> object is no longer supplied by the
client in the bvbltparams structure. In its place is a <span class="inline_code"><a href="#bvtileparams">
bvtileparams</a></span> object.</p>
<p>Refer to the <span class="inline_code"><a href="#bvtileparams">bvtileparams</a></span> structure definition for
details.</p>
<p class="Code_Header_3">bvbltparams.flags - BVFLAG_HORZ/VERT_FLIP_*</p>
<p>These flags indicate that the corresponding image is flipped horizontally or vertically as it is used by the
operation.</p>
<p class="Code_Header_3">bvbltparams.flags - BVFLAG_SCALE/DITHER_RETURN</p>
<p>The scale and dither types can be specified with an implicit type. The implementation will then convert that
internally to an explicit scale or dither type. These flags request that the implementation return the explicit
type chosen to the client in the corresponding <span class="inline_code"><a href="#scalemode">bvbltparams.scalemode</a></span>
and <span class="inline_code"><a href="#dithermode">bvbltparams.dithermode</a></span> members.</p>
<p class="Code_Header_3">bvbltparams.flags - BVFLAG_ASYNC</p>
<p>This flag allows the client to inform the implementation that it can queue the requested BLT and return from
<span class="inline_code"><a href="#bv_blt">bv_blt()</a></span> before it has completed. If this bit is not set,
when the <span class="inline_code"><a href="#bv_blt">bv_blt()</a></span> returns, the operation is complete.</p>
<p>Normally, a client will also utilize the <span class="inline_code"><a href="#callbackfn">bvbltparams.callbackfn</a></span>
and <span class="inline_code"><a href="#callbackdata">bvbltparams.callbackdata</a></span> members to receive a
notification when the BLT has completed.</p>
<p class="Code_Header_3">bvbltparams.flags - BVFLAG_BATCH_BEGIN/CONTINUE/END</p>
<p>These flags are used to control batching of BLTs for two main reasons:</p>
<ol>
<li>To group small, similar BLTs to consolidate overhead. For example, the BLTs associated with
rendering each character in a word.</li>
<li>To group related BLTs, which may allow an implementation to perform a more efficient, but equivalent
set of operations.</li>
</ol>
<p>See <a href="#batching">Batching</a> for details.</p>
<p class="Code_Header_2"><a name="rop">bvbltparams.op.rop</a></p>
<p class="code_block">unsigned short rop; /* input */</p>
<p>When <span class="inline_code"><a href="#BVFLAG_ROP">BVFLAG_ROP</a></span> is set in
the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span> member, the
<span class="inline_code"><a href="#op">bvbltparams.op</a></span> union is treated as
<span class="inline_code">rop</span>. Raster OPerations are binary operations
performed on the bits of the inputs:</p>
<ul>
<li>ROP1s have one source:
the destination. Two bits
are sufficient to specify the
four possible (2<sup>2</sup>)
ROP1 operations.</li>
<li>ROP2s have two sources:
the destination and a source.
Four bits are used to specify
the sixteen (2<sup>2+2</sup>)
ROP2 operations.</li>
<li>ROP3s have three sources:
the destination, a source
(source 1), and a pattern
(a.k.a. brush), which we call
source 2 in BLTsville.
Eight bits are used to specify
the 256 (2<sup>2+2+2</sup>) ROP3
operations.</li>
<li>ROP4s have four sources:
the destination, two sources,
and a mask. Sixteen bits
are used to specify the 65,536
(2<sup>2+2+2+2</sup>) ROP4
operations.</li>
</ul>
<p>BLTsville's <span class="inline_code">rop</span>
element is used to specify a ROP4, but anything
from ROP1 up to ROP4 can be defined using this
member:</p>
<ul>
<li>To specify an 8-bit ROP3 as a 16-bit ROP4,
replicate the 8 bits twice:
0x2323.</li>
<li>To specify a 4-bit ROP2 as a 16-bit ROP4,
replicate the 4 bits four times:
0x2222.</li>
<li>To specify a 2-bit ROP1 as a 16-bit ROP4,
replicate the 2 bits eight
times: 0x5555.</li>
</ul>
<p>The table below is the magic decoder ring: </p>
<table class="indent1">
<tr>
<td>
Mask</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
1</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
<td class="ctr" style="width: 20px">
0</td>
</tr>
<tr>
<td class="red_left">
Source 2 </td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
1</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
0</td>
<td class="red_ctr" style="width: 20px">
0</td>
</tr>
<tr>
<td class="grn_left">
Source 1 </td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
1</td>
<td class="grn_ctr" style="width: 20px">
0</td>
<td class="grn_ctr" style="width: 20px">
0</td>
</tr>
<tr>
<td class="blue_left_botbord">
Destination </td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
<td class="blue_ctr_botbord" style="width: 20px">
1</td>
<td class="blue_ctr_botbord" style="width: 20px">
0</td>
</tr>
<tr>
<td class="left_topbord">
Raster
Operation </td>
<td class="center_topbord" style="width: 20px">
15</td>
<td class="center_topbord" style="width: 20px">
14</td>
<td class="center_topbord" style="width: 20px">
13</td>
<td class="center_topbord" style="width: 20px">
12</td>
<td class="center_topbord" style="width: 20px">
11</td>
<td class="center_topbord" style="width: 20px">
10</td>
<td class="center_topbord" style="width: 20px">
9</td>
<td class="center_topbord" style="width: 20px">
8</td>
<td class="center_topbord" style="width: 20px">
7</td>
<td class="center_topbord" style="width: 20px">
6</td>
<td class="center_topbord" style="width: 20px">
5</td>
<td class="center_topbord" style="width: 20px">
4</td>
<td class="center_topbord" style="width: 20px">
3</td>
<td class="center_topbord" style="width: 20px">
2</td>
<td class="center_topbord" style="width: 20px">
1</td>
<td class="center_topbord" style="width: 20px">
0</td>
</tr>
</table>
<br />
For example, to specify an operation that uses
the mask to choose between source 1 and
destination (source 1 when mask is 1,
destination when mask is 0), a client would
calculate the bottom line by parsing each
column:<br />
<br />
When mask is 1 (the first eight columns), the
<span class="inline_code">rop</span> matches the
source 1 row. When mask is 0 (the last
eight columns), the <span class="inline_code">
rop</span> matches the destination row.<br />
<br />
<table class="indent1">
<tr>
<td class="left_topbord">
Raster
Operation </td>
<td class="red_ctr_topbord" style="width: 20px">
1</td>
<td class="red_ctr_topbord" style="width: 20px">
1</td>
<td class="red_ctr_topbord" style="width: 20px">
1</td>
<td class="red_ctr_topbord" style="width: 20px">
1</td>
<td class="red_ctr_topbord" style="width: 20px">
0</td>
<td class="red_ctr_topbord" style="width: 20px">
0</td>
<td class="red_ctr_topbord" style="width: 20px">
0</td>
<td class="red_ctr_topbord" style="width: 20px">
0</td>
<td class="blu_ctr_topbord" style="width: 20px">
1</td>
<td class="blu_ctr_topbord" style="width: 20px">
0</td>
<td class="blu_ctr_topbord" style="width: 20px">
1</td>
<td class="blu_ctr_topbord" style="width: 20px">
0</td>
<td class="blu_ctr_topbord" style="width: 20px">
1</td>
<td class="blu_ctr_topbord" style="width: 20px">
0</td>
<td class="blu_ctr_topbord" style="width: 20px">
1</td>
<td class="blu_ctr_topbord" style="width: 20px">
0</td>
</tr>
</table>
<br />
So the <span class="inline_code">rop</span> for
this operation would be 0xF0AA.<br />
<br />
Here is a list of some commonly used raster
operations that have been given names:<br />
<table class="indent_thick_bord">
<tr>
<td class="thin_bord_dbl_botbord">
<strong>ROP </strong></td>
<td class="thin_bord_dbl_botbord">
<strong>Constant</strong></td>
<td class="thin_bord_dbl_botbord">
<strong>
Description</strong></td>
</tr>
<tr>
<td class="thin_bord">
BLACKNESS</td>
<td class="thin_bord">
0x0000</td>
<td class="thin_bord">
Set all
destination bits
to black (0).
Dest = 0</td>
</tr>
<tr>
<td class="thin_bord">
DSTINVERT</td>
<td class="thin_bord">
0x5555</td>
<td class="thin_bord">
Invert (NOT) the
destination
bits. Dest =
~Dest</td>
</tr>
<tr>
<td class="thin_bord">
MERGECOPY</td>
<td class="thin_bord">
0xC0C0</td>
<td class="thin_bord">
Dest = Src1 &
Src2</td>
</tr>
<tr>
<td class="thin_bord">
MERGEPAINT</td>
<td class="thin_bord">
0xBBBB</td>
<td class="thin_bord">
Dest = ~Src1 |
Dest</td>
</tr>
<tr>
<td class="thin_bord">
NOTSRCCOPY</td>
<td class="thin_bord">
0x3333</td>
<td class="thin_bord">
Dest = ~Src1</td>
</tr>
<tr>
<td class="thin_bord">
NOTSRCERASE</td>
<td class="thin_bord">
0x1111</td>
<td class="thin_bord">
Dest = ~Src1 & ~Dest
= ~(Src1 | Dest)</td>
</tr>
<tr>
<td class="thin_bord">
PATCOPY</td>
<td class="thin_bord">
0xF0F0</td>
<td class="thin_bord">
Copy source 2 to
destination.
Dest = Src2</td>
</tr>
<tr>
<td class="thin_bord">
PATINVERT</td>
<td class="thin_bord">
0x5A5A</td>
<td class="thin_bord">
XOR with Src2.
Dest = Src2 ^
Dest</td>
</tr>
<tr>
<td class="thin_bord">
PATPAINT</td>
<td class="thin_bord">
0xFBFB</td>
<td class="thin_bord">
Dest = ~Src1 |
Src2 | Dest</td>
</tr>
<tr>
<td class="thin_bord">
SRCAND</td>
<td class="thin_bord">
0x8888</td>
<td class="thin_bord">
Dest = Src1 &
Dest</td>
</tr>
<tr>
<td class="thin_bord">
SRCCOPY</td>
<td class="thin_bord">
0xCCCC</td>
<td class="thin_bord">
Dest = Src1</td>
</tr>
<tr>
<td class="thin_bord">
SRCERASE</td>
<td class="thin_bord">
0x4444</td>
<td class="thin_bord">
Dest = Src1 & ~Dest</td>
</tr>
<tr>
<td class="thin_bord">
SRCINVERT</td>
<td class="thin_bord">
0x6666</td>
<td class="thin_bord">
XOR with Src1.
Dest = Src1 ^
Dest</td>
</tr>
<tr>
<td class="thin_bord">
SRCPAINT</td>
<td class="thin_bord">
0xEEEE</td>
<td class="thin_bord">
OR with Src1.
Dest = Src1 |
Dest</td>
</tr>
<tr>
<td class="thin_bord">
WHITENESS</td>
<td class="thin_bord">
0xFFFF</td>
<td class="thin_bord">
Set all
destination bits
to white (1).
Dest = 1</td>
</tr>
</table>
<br />
<span class="Code_Header_2"><a name="blend">bvbltparams.op.blend</a></span>
<p class="code_block">enum bvblend blend; /* input */</p>
<p>When <span class="inline_code"><a href="#BVFLAG_BLEND">BVFLAG_BLEND</a></span> is set in the
<span class="inline_code"><a href="#flags">bvbltparams.flags</a></span> member, the <span class="inline_code">
<a href="#op">bvbltparams.op</a></span> union is treated as a <span class="inline_code">blend</span>.</p>
<p>To specify the blend, the client fills in <span class="inline_code">blend</span> with one of the
<span class="inline_code"><a href="#bvblend">bvblend</a></span> values.</p>
<p><span class="inline_code"><a href="#bvblend">bvblend</a></span> is an enumeration assembled from sets of fields.
The values specified may be extended beyond those that are explicitly defined using the definitions in the
<span class="filename">bvblend.h</span> header file.</p>
<p>The first 4 bits are the
format. Currently two format groups are defined, but others can be added.
The remainder of the bits are used as defined by the individual format:</p>
<table style="width: 100%">
<tr>
<td valign="top">
1.</td>
<td>
<span class="Code_Header_3">
BVBLENDDEF_FORMAT_CLASSIC</span><br />
<br />
The
<span class="inline_code">
BVBLENDDEF_FORMAT_CLASSIC</span>
is meant to
handle the
classic
Porter-Duff
equations. It
can also handle
the DirectFB
blending.<br />
<br />
<span class="inline_code">
BVBLENDDEF_FORMAT_CLASSIC</span>
is based on the
following
equations:<br />
<div>
<p class="indent1">C<sub>d</sub> = K<sub>1</sub>C<sub>1</sub> + K<sub>2</sub>C<sub>2</sub><br />
A<sub>d</sub> = K<sub>3</sub>A<sub>1</sub>
+ K<sub>4</sub>A<sub>2</sub></p>
</div>
where:<br />
<div>
<p class="indent1">C<sub>d</sub>: destination color<br />
C<sub>1</sub>: source 1 color<br />
C<sub>2</sub>: source 2 color<br />
A<sub>d</sub>: destination alpha<br />
A<sub>1</sub>: source 1 alpha<br />
A<sub>2</sub>: source 2 alpha<br />
K<sub>#</sub>: one of the constants defined using the
bitfields below</p>
</div>
The 28 bits for
<span class="inline_code">
BVBLENDDEF_FORMAT_CLASSIC</span>
are divided into
5 sections.<br />
<br />
The most
significant 4
bits are
modifiers, used
to include
additional alpha
values from
global or remote
sources.<br />
<br />
[27] The most
significant bit
indicates that a
remote alpha is
to be included
in the blend.
The format of
this is defined
by
<span class="inline_code">
<a href="#maskgeom">
bvbltparams.maskgeom.format</a></span>.<br />
<br />
[26] The next
bit is reserved.<br />
<br />
[25:24] The next
2 bits are used
to indicate that
a global alpha
is to be
included, and
what its format
is:<br />
<div>
<p class="indent1">00: no global included<br />
01: global included; bvbltparams.globalalpha.size8 is used (0 -> 255)<br />
10: this value is reserved<br />
11: global included; bvbltparams.flogalalpha.fp is used (0.0 -> 1.0) </p>
</div>
The remaining
bits are divided
into 4 sections,
one to define
each of the
constants:<br />
<br />
[23:18] - K1<br />
[17:12] - K2<br />
[11:6] - K3<br />
[5:0] - K4<br />
<br />
The format is
the same for all
4 constant
fields:<br />
<br />
[5:4] The first
2 bits of each
field indicates
the way in which
the other 2
fields are
interpreted:<br />
<div>
<p class="indent1">00: only As: the other two fields contain only As;
there should be
only one valid A
value between
the two fields<br />
01: minimum: the value of the constant is the minimum
of the two
fields<br />
10: maximum: the value of the constant is the maximum
of the two
fields<br />
11: only Cs: the other two fields contain only Cs;
there should be
only one valid C
value between
the two fields</p>
</div>
[3:2] The middle
2 bits of each
field contain
the inverse
field:<br />
<div>
<p class="indent1">00: 1-C1 ("don't care" for "only As")<br />
01: 1-A1 ("don't care" for "only Cs")<br />
10: 1-C2 ("don't care" for "only As")<br />
11: 1-A2 ("don't care" for "only Cs")</p>
</div>
[1:0] The last 2
bits if each
field contain
the normal
field:<br />
<div>
<p class="indent1">00: C1 ("don't care" for "only As")<br />
01: A1 ("don't care" for "only Cs")<br />
10: C2 ("don't care" for "only As")<br />
11: A2 ("don't care" for "only Cs")</p>
</div>
EXCEPTIONS:<br />
<br />
00 00 00 - The
value 00 00 00,
which normally
would indicate
"only As"
with two "don't
care" fields, is
interpreted as a constant of
0.<br />
<br />
11 11 11 - The
value 11 11 11,
which normally
would indicate
"only Cs"
with two "don't
care" fields, is
interpreted as a constant of
1.<br />
<br />
<span class="Header4">
Constants</span><br />
<br />
Put together,
these can define
portions of the
blend equations
that can be put
together in a
variety of ways:<br />
<div>
<p class="indent1">00 00 00: undefined -> zero<br />
00 00 01: A1 (preferred)<br />
00 00 10: undefined<br />
00 00 11: A2 (preferred)<br />
00 01 00: 1-A1 (preferred)<br />
00 01 01: undefined<br />
00 01 10: 1-A1 (use 00 01 00)<br />
00 01 11: undefined<br />
00 10 00: undefined<br />
00 10 01: A1 (use 00 00 01)<br />
00 10 10: undefined<br />
00 10 11: A2 (use 00 00 11)<br />
00 11 00: 1-A2 (preferred)<br />
00 11 01: undefined<br />
00 11 10: 1-A2 (use 00 11 00)<br />
00 11 11: undefined<br />
<br />
01 00 00: min(C1,1-C1)<br />
01 00 01: min(A1,1-C1)<br />
01 00 10: min(C2,1-C1)<br />
01 00 11: min(A2,1-C1)<br />
01 01 00: min(C1,1-A1)<br />
01 01 01: min(A1,1-A1)<br />
01 01 10: min(C2,1-A1)<br />
01 01 11: min(A2,1-A1)<br />
01 10 00: min(C1,1-C2)<br />
01 10 01: min(A1,1-C2)<br />
01 10 10: min(C2,1-C2)<br />
01 10 11: min(A2,1-C2)<br />
01 11 00: min(C1,1-A2)<br />
01 11 01: min(A1,1-A2)<br />
01 11 10: min(C2,1-A2)<br />
01 11 11: min(A2,1-A2)<br />
<br />
10 00 00:
max(C1,1-C1)<br />
10 00 01:
max(A1,1-C1)<br />
10 00 10:
max(C2,1-C1)<br />
10 00 11:
max(A2,1-C1)<br />
10 01 00:
max(C1,1-A1)<br />
10 01 01:
max(A1,1-A1)<br />
10 01 10:
max(C2,1-A1)<br />
10 01 11:
max(A2,1-A1)<br />
10 10 00:
max(C1,1-C2)<br />
10 10 01:
max(A1,1-C2)<br />
10 10 10:
max(C2,1-C2)<br />
10 10 11:
max(A2,1-C2)<br />
10 11 00:
max(C1,1-A2)<br />
10 11 01:
max(A1,1-A2)<br />
10 11 10:
max(C2,1-A2)<br />
10 11 11:
max(A2,1-A2)<br />
<br />
11 00 00:
undefined<br />
11 00 01: 1-C1
(use 11 00 11)<br />
11 00 10:
undefined<br />
11 00 11: 1-C1
(preferred)<br />
11 01 00: C1
(use 11 11 00)<br />
11 01 01:
undefined<br />
11 01 10: C2
(use 11 11 10)<br />
11 01 11:
undefined<br />
11 10 00:
undefined<br />
11 10 01: 1-C2
(use 11 10 11)<br />
11 10 10:
undefined<br />
11 10 11: 1-C2
(preferred)<br />
11 11 00: C1
(preferred)<br />
11 11 01:
undefined<br />
11 11 10: C2
(preferred)<br />
11 11 11:
undefined -> one</p>
</div>
<span class="Header4">DirectFB</span><br />
<br />
Putting these
together into
the proper
constants, the
blending
equations can be
built for
DirectFB as
well:<br />
<br />
For DirectFB,
the
<a href="http://directfb.org/docs/DirectFB_Reference_1_2/IDirectFBSurface_SetSrcBlendFunction.html" class="inline_code">
SetSrcBlendFunction()</a>
and
<a href="http://directfb.org/docs/DirectFB_Reference_1_2/IDirectFBSurface_SetDstBlendFunction.html" class="inline_code">
SetDstBlendFunction()</a>
can specify 121
combinations of
blends (11 x
11). It's
impractical to
specify these
combinations
individually.
Instead, the
settings
indicated by
each call should
be bitwise OR'd
to make the
proper single
value used in
BLTsville.<br />
<br />
binary value <-
<span class="inline_code">
<a href="http://directfb.org/docs/DirectFB_Reference_1_2/IDirectFBSurface_SetSrcBlendFunction.html">
SetSrcBlendFunction()</a><div>
<p class="indent1">
<span class="inline_code">
[--K1--]
[--K2--]
[--K3--]
[--K4--]<br />
0000 0000 00 00
00 xx xx xx 00
00 00 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_ZERO</a><br />
0000 0000 11 11
11 xx xx xx 11
11 11 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_ONE</a><br />
0000 0000 11 11
00 xx xx xx 00
00 01 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_SRCCOLOR</a><br />
0000 0000 11 00
11 xx xx xx 00
01 00 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_INVSRCCOLOR</a><br />
0000 0000 00 00
01 xx xx xx 00
00 01 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_SRCALPHA</a><br />
0000 0000 00 01
00 xx xx xx 00
01 00 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_INVSRCALPHA</a><br />
0000 0000 11 11
10 xx xx xx 00
00 11 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_DESTCOLOR</a><br />
0000 0000 11 10
11 xx xx xx 00
11 00 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_INVDESTCOLOR</a><br />
0000 0000 00 00
11 xx xx xx 00
00 11 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_DESTALPHA</a><br />
0000 0000 00 11
00 xx xx xx 00
11 00 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_INVDESTALPHA</a><br />
0000 0000 01 11
01 xx xx xx 11
11 11 xx xx xx
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_SRCALPHASAT</a></span></p>
</div>
</span>binary value <-
<span class="inline_code">
<a href="http://directfb.org/docs/DirectFB_Reference_1_2/IDirectFBSurface_SetDstBlendFunction.html">
SetDstBlendFunction()</a><div>
<p class="indent1">
[--K1--]
[--K2--]
[--K3--]
[--K4--]<br />
0000 0000 xx xx
xx 00 00 00 xx
xx xx 00 00 00
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_ZERO</a><br />
0000 0000 xx xx
xx 11 11 11 xx
xx xx 11 11 11
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_ONE</a><br />
0000 0000 xx xx
xx 11 11 00 xx
xx xx 00 00 01
<-
<a href="http://www.directfb.org/docs/DirectFB_Reference_1_5/types.html#DFBSurfaceBlendFunction">
DSBF_SRCCOLOR</a><br />
etc.</p>
</div>
</span><span class="Header4">Porter-Duff</span><br />
<br />
For Porter-Duff
blends,
the equations
can be more
specifically
defined. For
convenience,
these are
enumerated
in the <span class="inline_code">
bvblend.h</span>
header. These
enumerations
utilize only the
local alpha in
the equations as
indicated. To
use global or
remote alpha,
these
enumerations
need to be
modified. For
example, to
include the
global alpha in
the Porter-Duff
<span class="inline_code">BVBLEND_SRC1OVER</span> blend,
the blend could
be defined like
this:<span class="inline_code"><div>
<p class="indent1">params.op.blend
=
BVBLEND_SRC1OVER
+<br />
BVBLENDDEF_GLOBAL_UCHAR;</p>
</div>
</span>To include the
remote alpha,
the blend could
be defined like
this:<span class="inline_code"><div>
<p class="indent1"><span class="inline_code">params.op.blend
=
BVBLEND_SRC1OVER
+<br />
BVBLENDDEF_REMOTE;</span></p>
</div>
</span>And to include
both:<span class="inline_code"><div>
<p class="indent1">params.op.blend
=
BVBLEND_SRC1OVER
+<br />
BVBLENDDEF_GLOBAL_UCHAR
+<br />
BVBLENDDEF_REMOTE;</p>
</div>
</span>Note that if the
source color
formats include
local alphas,
the local
alphas, global
alpha, and
remote alpha
will be used
together.<br />
<br />
Note also that
the equations
assume the
surfaces are
premultiplied.
So
if the surface
formats indicate
that they are
not
premultiplied,
the
alpha
multiplication
of each color is
done prior to
using the
surface
values in the
equations.<br />
<br />
For example,
<span class="inline_code">BVBLEND_SRC1OVER</span>
specifies the
equations:<br />
<div>
<p class="indent1">C<sub>d</sub> = C<sub>1</sub> + (1 - A<sub>1</sub>)C<sub>2</sub><br />
A<sub>d</sub> = A<sub>1</sub> + (1 - A<sub>1</sub>)A<sub>2</sub></p>
</div>
If the format of
surface 1 is
non-premultiplied,
the equations
are modified to
include the
multiplication
explicitly:<br />
<div>
<p class="indent1">C<sub>d</sub> = A<sub>1</sub>C<sub>1</sub> + (1 - A<sub>1</sub>)C<sub>2</sub><br />
A<sub>d</sub> = A<sub>1</sub> + (1 - A<sub>1</sub>)A<sub>2</sub></p>
</div>
Likewise, if the
format of
surface 2 is
non-premultiplied,
the
equations are
modified for
this:<br />
<div>
<p class="indent1">C<sub>d</sub> = C<sub>1</sub> + (1 - A<sub>1</sub>)A<sub>2</sub>C<sub>2</sub><br />
A<sub>d</sub> = A<sub>1</sub> + (1 - A<sub>1</sub>)A<sub>2</sub></p>
</div>
When including
global or remote
alphas, these
values are used
to modify
the source 1
value values
before being
used in the
blend equation:<br />
<div>
<p class="indent1">C<sub>1</sub> = A<sub>g</sub>C<sub>1</sub><br />
A<sub>1</sub> = A<sub>g</sub>A<sub>1</sub><br />
-or-<br />
C<sub>1</sub> = A<sub>r</sub>C<sub>1</sub><br />
A<sub>1</sub> = A<sub>r</sub>A<sub>1</sub><br />
-or-<br />
C<sub>1</sub> = A<sub>r</sub>A<sub>g</sub>C<sub>1</sub><br />
A<sub>1</sub> = A<sub>r</sub>A<sub>g</sub>A<sub>1</sub></p>
<p class="indent1"> </p>
</div>
<sub> </sub></td>
</tr>
<tr>
<td valign="top">2.</td>
<td>
<span class="Code_Header_3">
<strong><a name="BVBLENDDEF_FORMAT_ESSENTIAL0">BVBLENDDEF_FORMAT_ESSENTIAL</a></strong></span><br />
<br />
The essential blending equations are based on the
blending equations in common image manipulation
programs.<pre class="indent1"><code>BVBLEND_LIGHTEN max(src1, src2)
BVBLEND_DARKEN min(src1, src2)
BVBLEND_MULTIPLY (src1 * src2) / 255
BVBLEND_AVERAGE (src1 + src2) / 2
BVBLEND_ADD src1 + src2 (saturated)
BVBLEND_SUBTRACT src1 + src2 - 255 (saturated)
BVBLEND_DIFFERENCE abs(src - src2)
BVBLEND_NEGATION 255 - abs(255 - src1 - src2)
BVBLEND_SCREEN 255 - (((255 - src1) * (255 - src2)) / 256)
BVBLEND_EXCLUSION src1 + src2 - ((2 * src1 * src2) / 255)
BVBLEND_OVERLAY (src2 < 128) ? (2 * src1 * src2 / 255) : (255 - 2 * (255 - src1) * (255 - src2) / 255)
BVBLEND_SOFT_LIGHT (src2 < 128) ? (2 * ((src1 >> 1) + 64)) * ((float)src2 / 255) : (255 - (2 * (255 - ((src1 >> 1) + 64)) * (float)(255 - src2) / 255))
BVBLEND_HARD_LIGHT (src1 < 128) ? (2 * src2 * src1 / 255) : (255 - 2 * (255 - src2) * (255 - src1) / 255)
BVBLEND_COLOR_DODGE (src2 == 255) ? src2 : min(255, ((src1 << 8) / (255 - src2))
BVBLEND_COLOR_BURN (src2 == 0) ? src2 : max(0, (255 - ((255 - src1) << 8 ) / src2))))
BVBLEND_LINEAR_DODGE same as BVBLEND_ADD
BVBLEND_LINEAR_BURN same as BVBLEND_SUBTRACT
BVBLEND_LINEAR_LIGHT (src2 < 128) ? LINEAR_BURN(src1,(2 * src2)) : LINEAR_DODGE(src1,(2 * (src2 - 128)))
BVBLEND_VIVIDL_IGHT (src2 < 128) ? COLOR_BURN(src1,(2 * src2)) : COLOR_DODGE(src1,(2 * (src2 - 128))))
BVBLEND_PIN_LIGHT (src2 < 128) ? DARKEN(src1,(2 * src2)) : LIGHTEN(src1,(2 * (src2 - 128)))
BVBLEND_HARD_MIX (VIVID_LIGHT(src1, src2) < 128) ? 0 : 255
BVBLEND_REFLECT (src2 == 255) ? src2 : min(255, (src1 * src1 / (255 - src2)))
BVBLEND_GLOW (src1 == 255) ? src1 : min(255, (src2 * src2 / (255 - src1)))
BVBLEND_PHOENIX min(src1, src2) - max(src1, src2) + 255)
BVBLEND_ALPHA alf * src1 + (1 - alf) * src2)
</code></pre>
</td>
</tr>
</table>
<a name="filter" class="Code_Header_2">bvbltparams.op.filter</a>
<p class="code_block">struct bvfilter *filter; /* input */</p>
<p>When <span class="inline_code"><a href="#BVFLAG_FILTER">BVFLAG_FILTER</a></span> is set in the
<span class="inline_code"><a href="#flags">bvbltparams.flags</a></span> member, the <span class="inline_code">
<a href="#op">bvbltparams.op</a></span> union is treated as a <span class="inline_code">filter</span>.</p>
<p>To specify the filter, the client fills in <span class="inline_code">filter</span> with one of the
<span class="inline_code">bvfilter</span> values.</p>
<p>These values will be extended as general filter types are requested.</p>
<a name="colorkey" class="Code_Header_2">bvbltparams.colorkey</a>
<p class="code_block">void *colorkey; /* input */</p>
<p>When either <span class="inline_code"><a href="#BVFLAG_KEY_SRC">BVFLAG_KEY_SRC</a></span> or
<span class="inline_code"><a href="#BVFLAG_KEY_DST">BVFLAG_KEY_DST</a></span> is set in the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span> member,
<span class="inline_code">colorkey</span> points to a single pixel used as the color key.</p>
<p>The format of this pixel matches the surface being keyed. i.e. <span class="inline_code"><a href="#bvsurfgeom">src1geom.format</a></span> is the format of the color key if
<span class="inline_code">BVFLAG_KEY_SRC</span> is set, or <span class="inline_code"><a href="#bvsurfgeom">dst.format</a></span>
is the format of the color key if <span class="inline_code">BVFLAG_KEY_DST</span> is set.</p>
<p><em>SSubsampled formats do not currently support color keying.</em></p>
<p class="Code_Header_2"><a name="globalalpha">bvbltparams.globalalpha</a></p>
<p class="code_block">union bvalpha globalalpha; /* input */</p>
<p>When <span class="inline_code"><a href="#BVFLAG_BLEND">BVFLAG_BLEND</a></span> is set in the
<span class="inline_code"><a href="#flags">bvbltparams.flags</a></span>, and when the <span class="inline_code">
<a href="#blend">blend</a></span> chosen requires it, <span class="inline_code">globalalpha</span> is used to provide an
alpha blending value for the entire operation. The type is also dependent on the <span class="inline_code">
<a href="#blend">blend</a></span> chosen.</p>
<p>For the <span class="inline_code">BVBLENDDEF_FORMAT_CLASSIC</span> blend types, if the <span class="inline_code">
BVBLENDDEF_GLOBAL_MASK</span> field is not 0, this field is used. Currently <span class="inline_code">
BVBLENDDEF_FORMAT_CLASSIC</span> provides for an 8-bit (unsigned character / byte) format designated by
<span class="inline_code">BVBLENDDEF_GLOBAL_UCHAR</span> as well as a 32-bit floating point format designated by
<span class="inline_code">BVBLENDDEF_GLOBAL_FLOAT</span>.</p>
<p class="Code_Header_2"><a name="scalemode">bvbltparams.scalemode</a></p>
<p class="code_block">enum bvscalemode scalemode; /* input/output */</p>
<p>This member allows the client to specify the type of scaling to be used. The enumeration
begins with 8 bits
indicating the vendor. The remaining bits are defined by the vendor. <span class="inline_code">
BVSCALEDEF_VENDOR_ALL</span> and <span class="inline_code">BVSCALEDEF_VENDOR_GENERAL</span>
are shared by all
implementations.</p>
<p><span class="inline_code">BVSCALEDEF_VENDOR_ALL</span> can be used to specify an implicit scale type. This type
is converted to an explicit type by the implementation:</p>
<div class="indent1">
<table>
<tr>
<td class="inline_code">BVSCALE_FASTEST</td>
<td>The fastest method of scaling available is used. This may include nearest
neighbor. The value of this enumeration is purposely 0, and is the default scale
type. No implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_FASTEST_NOT_NEAREST_NEIGHBOR</td>
<td>The fastest method of scaling available that is not nearest neighbor is used.
This may include an alternative point sample technique.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_FASTEST_POINT_SAMPLE</td>
<td>The fastest method of scaling using a point sample technique.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_FASTEST_INTERPOLATED</td>
<td>The fastest method of scaling using an interpolation technique.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_FASTEST_PHOTO</td>
<td>The fastest method of scaling appropriate for photographs is used.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_FASTEST_DRAWING</td>
<td>The fastest method of scaling appropriate for drawings is used.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_GOOD</td>
<td>A scaling technique is chosen that may be higher quality than the
<span class="inline_code">BVSCALE_FASTEST</span> choice.
This may include nearest neighbor. No implementation will
return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_GOOD_POINT_SAMPLE</td>
<td>A point sample scaling technique is chosen that may be higher quality than the
<span class="inline_code">BVSCALE_FASTEST_POINT_SAMPLE</span> choice.
This may include nearest neighbor.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_GOOD_INTERPOLATED</td>
<td>An interpolated scaling technique is chosen that may be higher quality than the
<span class="inline_code">BVSCALE_FASTEST_INTERPOLATED</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_GOOD_PHOTO</td>
<td>A scaling technique appropriate for photographs is chosen that may be higher quality
than the <span class="inline_code">BVSCALE_FASTEST_PHOTO</span> choice.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_GOOD_DRAWING</td>
<td>A scaling technique appropriate for drawings is chosen that may be higher quality
than the <span class="inline_code">BVSCALE_FASTEST_DRAWING</span> choice.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BETTER</td>
<td>A scaling technique is chosen that may be higher quality than the
<span class="inline_code">BVSCALE_GOOD</span> choice.
This may include nearest neighbor. No implementation will
return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BETTER_POINT_SAMPLE</td>
<td>A point sample scaling technique is chosen that may be higher quality than the
<span class="inline_code">BVSCALE_GOOD_POINT_SAMPLE</span> choice.
This may include nearest neighbor.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BETTER_INTERPOLATED</td>
<td>An interpolated scaling technique is chosen that may be higher quality than the
<span class="inline_code">BVSCALE_GOOD_INTERPOLATED</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BETTER_PHOTO</td>
<td>A scaling technique appropriate for photographs is chosen that may be higher quality
than the <span class="inline_code">BVSCALE_GOOD_PHOTO</span> choice.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BETTER_DRAWING</td>
<td>A scaling technique appropriate for drawings is chosen that may be higher quality
than the <span class="inline_code">BVSCALE_GOOD_DRAWING</span> choice.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BEST</td>
<td>The highest quality scaling technique is chosen.
This may include nearest neighbor. No implementation will return
an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BEST_POINT_SAMPLE</td>
<td>The highest quality point sample technique is chosen.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BEST_INTERPOLATED</td>
<td>The highest quality interpolated scaling technique is chosen.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BEST_PHOTO</td>
<td>The highest quality scaling technique appropriate for photographs is chosen.
This may include nearest neighbor.
No implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BEST_DRAWING</td>
<td>The highest quality scaling technique appropriate for drawings is chosen.
This may include nearest neighbor. No
implementation will return an error for this setting.</td>
</tr>
</table>
</div>
<br/>
<span class="inline_code">BVSCALEDEF_VENDOR_GENERAL</span> can be used to specify one of the shared explicit scale
types. At this point, only a limited number of explicit scale types are defined:
<br/>
<div class="indent1">
<table>
<tr>
<td class="inline_code">BVSCALE_NEAREST_NEIGHBOR</td>
<td>This is a point sample scaling technique where the resampled destination pixel is
set to the value of the closest source pixel.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BILINEAR</td>
<td>This is an interpolated scaling technique where the resampled destination pixel is
set to a value linearly interpolated in two dimensions from the four closest source
pixels.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_BICUBIC</td>
<td>This is an interpolated scaling technique where the resampled destination pixel is
set to a value calculated using cubic interpolation in two dimensions.</td>
</tr>
<tr>
<td class="inline_code">BVSCALE_3x3_TAP</td>
<td> </td>
</tr>
<tr>
<td class="inline_code">BVSCALE_5x5_TAP</td>
<td> </td>
</tr>
<tr>
<td class="inline_code">BVSCALE_7x7_TAP</td>
<td> </td>
</tr>
<tr>
<td class="inline_code">BVSCALE_9x9_TAP</td>
<td> </td>
</tr>
</table>
</div>
<p>If the client wants to know the explicit type chosen by a given implementation, it can set <span class="inline_code">
BVFLAG_SCALE_RETURN</span>
in the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span> member, and the explicit scale type is
returned in the <span class="inline_code">scalemode</span> member.</p>
<p>NOTE: Extending the <span class="inline_code">BVSCALEDEF_VENDOR_GENERAL</span> scale types or obtaining a
vendor ID can be accomplished by submitting a patch.</p>
<p class="Code_Header_2"><a name="dithermode">bvbltparams.dithermode</a></p>
<p class="code_block">enum bvdithermode dithermode; /* input/output */</p>
<p>This member allows the client to specify the type of dithering to be used,
when the output format has fewer bits of depth than the internal calculation.
The enumeration begins with 8 bits
indicating the vendor. The remaining bits are defined by the vendor. <span class="inline_code">
BVDITHERDEF_VENDOR_ALL</span> and <span class="inline_code">BVDITHERDEF_VENDOR_GENERAL</span>
are shared by all
implementations.</p>
<p><span class="inline_code">BVDITHERDEF_VENDOR_ALL</span> can be used to specify an implicit
dither type. This type
is converted to an explicit type by the implementation:</p>
<div class="indent1">
<table>
<tr>
<td class="inline_code">BVDITHER_FASTEST</td>
<td>The fastest method of dithering available is used. This may include
no dithering (truncation). The value of this enumeration is purposely 0, and is the default
dither
type. No implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_FASTEST_ON</td>
<td>The fastest method of dithering available is used.
This will not include no dithering.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_FASTEST_RANDOM</td>
<td>The fastest method of dithering using a
random technique.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_FASTEST_ORDERED</td>
<td>The fastest method of dithering using an
ordered diffusion technique.</td>
</tr>
<tr>
<td class="inline_code">
BVDITHER_FASTEST_DIFFUSED</td>
<td>The fastest method of dithering using an
error diffusion technique.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_FASTEST_PHOTO</td>
<td>The fastest method of dithering appropriate for photographs is used.
This may include no dithering. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_FASTEST_DRAWING</td>
<td>The fastest method of dithering appropriate for drawings is used.
This may include no dithering. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD</td>
<td>A dithering technique is chosen that may be higher quality than the
<span class="inline_code">BVDITHER_FASTEST</span> choice.
This may include no dithering. No implementation will
return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD_ON</td>
<td>Any dithering technique available is used. This will not include no dithering. This may be higher quality than <span class="inline_code">BVDITHER_FASTEST_ON</span>.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD_RANDOM</td>
<td>A random dithering technique is chosen that may be higher quality than the
<span class="inline_code">BVDITHER_FASTEST_RANDOM</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD_ORDERED</td>
<td>An ordered dithering technique is chosen that may be higher quality than the
<span class="inline_code">BVDITHER_FASTEST_ORDERED</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD_DIFFUSED</td>
<td>A diffused dithering technique is chosen
that may be higher quality than the
<span class="inline_code">
BVDITHER_FASTEST_DIFFUSED</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD_PHOTO</td>
<td>A dithering technique appropriate for photographs is chosen that may be higher quality
than the <span class="inline_code">BVDITHER_FASTEST_PHOTO</span> choice.
This may include no dithering. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_GOOD_DRAWING</td>
<td>A dithering technique appropriate for drawings is chosen that may be higher quality
than the <span class="inline_code">BVDITHER_FASTEST_DRAWING</span> choice.
This may include no dithering. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER</td>
<td>A dithering technique is chosen that may be higher quality than the
<span class="inline_code">BVDITHER_GOOD</span> choice.
This may include no dithering. No implementation will
return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER_ON</td>
<td>Any dithering technique available is used. This will not include no dithering. This may be higher quality than <span class="inline_code">BVDITHER_GOOD_ON</span>.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER_RANDOM</td>
<td>A random dithering technique is chosen that may be higher quality than the
<span class="inline_code">BVDITHER_GOOD_RANDOM</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER_ORDERED</td>
<td>An ordered dithering technique is chosen that may be higher quality than the
<span class="inline_code">BVDITHER_GOOD_ORDERED</span> choice.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER_DIFFUSED</td>
<td>A diffused dithering technique is chosen
that may be higher quality than the
<span class="inline_code">BVDITHER_GOOD_DIFFUSED</span>
choice.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER_PHOTO</td>
<td>A scaling technique appropriate for photographs is chosen that may be higher quality
than the <span class="inline_code">BVSCALE_GOOD_PHOTO</span> choice. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BETTER_DRAWING</td>
<td>A scaling technique appropriate for drawings is chosen that may be higher quality
than the <span class="inline_code">BVSCALE_GOOD_DRAWING</span> choice. No
implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST</td>
<td>The highest quality dithering technique is chosen.
This may include no dithering. No implementation will return
an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST_ON</td>
<td>Any dithering technique available is used. This will not include no dithering. This may be higher quality than <span class="inline_code">BVDITHER_BEST_ON</span>.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST_RANDOM</td>
<td>The highest quality random dithering technique is chosen.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST_ORDERED</td>
<td>The highest quality ordered dithering technique is chosen.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST_DIFFUSED</td>
<td>The highest quality diffused dithering
technique is chosen.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST_PHOTO</td>
<td>The highest quality dithering technique appropriate for photographs is chosen.
This may include no dithering.
No implementation will return an error for this setting.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_BEST_DRAWING</td>
<td>The highest quality dithering technique appropriate for drawings is chosen.
This may include no dithering. No
implementation will return an error for this setting.</td>
</tr>
</table>
</div>
<br/>
<span class="inline_code">BVDITHERDEF_VENDOR_GENERAL</span> can be used to specify one of the shared explicit
dithering types. At this point, only a limited number of explicit dither types are defined:<br />
<br/>
<div class="indent1">
<table>
<tr>
<td class="inline_code">BVDITHER_NONE</td>
<td>No dithering is performed. Internal
pixel component values are truncated to the
destination component bit depth.</td>
</tr>
<tr>
<td class="inline_code">BVDITHER_ORDERED_2x2</td>
<td> </td>
</tr>
<tr>
<td class="inline_code">BVDITHER_ORDERED_4x4</td>
<td> </td>
</tr>
<tr>
<td class="inline_code">BVDITHER_ORDERED_2x2_4x4</td>
<td>2x2 ordered dither is used for components
with the lowest bit reduction. 4x4 ordered
dither is used for the components with the
highest bit reduction. (E.g. RGB24 to
RGB565 will use 2x2 ordered dither for the green
component and 4x4 ordered dither for the red and
blue components.)</td>
</tr>
</table>
</div>
<p>If the client wants to know the explicit type chosen by a given implementation, it can set <span class="inline_code">
BVFLAG_DITHER_RETURN</span>
in the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span> member, and the explicit scale type is
returned in the <span class="inline_code">dithermode</span> member.</p>
<p>NOTE: Extending the <span class="inline_code">BVDITHERDEF_VENDOR_GENERAL</span> scale types or obtaining a
vendor ID can be accomplished by submitting a patch.</p>
<p class="Code_Header_2"><a name="dstdesc">bvbltparams.dstdesc</a></p>
<p class="code_block"><a href="#bvbuffdesc">struct bvbuffdesc</a> *dstdesc;</p>
<p><span class="inline_code">dstdesc</span> is used to specify the destination
buffer. If the buffer has not been mapped with a call to
<span class="inline_code"><a href="#bv_map">bv_map()</a></span>, <span class="inline_code"><a href="#bv_blt">bv_blt()</a></span> will map the
buffer as necessary to perform the BLT and then unmap afterwards. See
<span class="inline_code"><a href="#bvbuffdesc">bvbuffdesc</a></span> for
details.</p>
<p class="Code_Header_2"><a name="dstgeom">bvbltparams.dstgeom</a></p>
<p class="code_block"><a href="#bvsurfgeom">struct bvsurfgeom</a> *dstgeom;</p>
<p><span class="inline_code">dstgeom</span> is used to specify the geometry of
the surface contained in the destination buffer. See
<span class="inline_code"><a href="#bvsurfgeom">bvsurfgeom</a></span> for
details.</p>
<p class="Code_Header_2"><a name="dstrect">bvbltparams.dstrect</a></p>
<p class="code_block"><a href="#bvrect">struct bvrect</a> dstrect;</p>
<p><span class="inline_code">dstrect</span> is used to specify the destination
rectangle to receive the BLT. This rectangle is clipped by
<span class="inline_code"><a href="#cliprect">bvbltparams.cliprect</a></span>
when <span class="inline_code"><a href="#BVFLAG_CLIP">BVFLAG_CLIP</a></span> is
set in the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span>
member.</p>
<p class="Code_Header_2">bvbltparams.<a name="src1.desc">src1</a>/<a name="src2.desc">src2</a>/<a name="mask.desc">mask.desc</a></p>
<p class="code_block"><a href="#bvbuffdesc">struct bvbuffdesc</a> *src1.desc;<br />
<a href="#bvbuffdesc">struct bvbuffdesc</a> *src2.desc;<br />
<a href="#bvbuffdesc">struct bvbuffdesc</a> *mask.desc;</p>
<p>These members are used to identify the buffer for the source1, source2, and
mask surfaces when the associated <span class="inline_code">BVFLAG_TILE_*</span>
flag is not set. The buffer is the memory in which the surface lies.
See the <span class="inline_code"><a href="#src1geom">
bvbltparams.src1/src2/maskgeom</a></span> for the format and layout/geometry of
the surface.</p>
<p class="note">NOTE WELL: NEVER change the value of bvbuffdesc.virtptr
while a buffer is mapped.</p>
<p class="Code_Header_2">bvbltparams.<a name="src1.tileparams">src1</a>/<a name="src2.tileparams">src2</a>/<a name="mask.tileparams">mask.tileparams</a></p>
<p class="code_block"><a href="#bvtileparams">struct bvtileparams</a>
*src1.tileparams;<br />
<a href="#bvtileparams">struct bvtileparams</a> *src2.tileparams;<br />
<a href="#bvtileparams">struct bvtileparams</a> *mask.tileparams;</p>
<p>These members are used to identify the buffer for the source1, source2, and
mask surfaces when the associated <span class="inline_code">BVFLAG_TILE_*</span>
flag is set. The buffer is the memory in which the surface lies.
This differs from the <span class="inline_code"><a href="#src1.desc">
src1/src2/mask.desc</a></span> identity by providing more information needed for
tiling and by not requiring mapping (for hardware implementations that support
tiling, the tile data is usually moved into an on-chip cache).</p>
<p class="Code_Header_2">bvbltparams.<a name="src1geom">src1</a>/<a name="src2geom">src2</a>/<a name="maskgeom">maskgeom</a></p>
<p class="code_block"><a href="#bvsurfgeom">struct bvsurfgeom</a> src1geom;<br />
<a href="#bvsurfgeom">struct bvsurfgeom</a> src2geom;<br />
<a href="#bvsurfgeom">struct bvsurfgeom</a> maskgeom;</p>
<p>These members describe the format and layout/geometry of their respective
surfaces. Separating <span class="inline_code"><a href="#bvsurfgeom">
bvsurfgeom</a></span> from the <span class="inline_code"><a href="#bvbuffdesc">
bvbuffdesc</a></span> allows easy use of buffers for multiple geometries without
remapping. See <span class="inline_code"><a href="#bvsurfgeom">bvsurfgeom</a></span>
and <span class="inline_code"><a href="#bvbuffdesc">bvbuffdesc</a></span> for
details.</p>
<p class="Code_Header_2">bbvbltparams.src1/src2/maskrect</p>
<p class="code_block"><a href="#bvrect">struct bvrect</a> src1rect;<br />
<a href="#bvrect">struct bvrect</a> src2rect;<br />
<a href="#bvrect">struct bvrect</a> maskrect;</p>
<p>These members specify the
rectangle from which data is read for the BLT. These rectangles are clipped by
a scaled version of the
<span class="inline_code"><a href="#cliprect">bvbltparams.cliprect</a></span>
(scaling is based on the relationship between them and the
<span class="inline_code"><a href="#dstrect">bvbltparams.dstrect</a></span>)
when <span class="inline_code"><a href="#BVFLAG_CLIP">BVFLAG_CLIP</a></span> is
set in the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span>
member.</p>
<p>Example:</p>
<p class="code_block"><a href="#src1rect">src1rect</a> = (0, 0) - (400 x 200)<br />
<a href="#dstrect">dstrect</a> = (0, 0) - (800 x 600)<br />
<a href="#cliprect">cliprect</a> = (10, 30) - (300 x 300)</p>
<p>The scaling ratio of the <span class="inline_code"><a href="#dstrect">dstrect</a></span>
to the <span class="inline_code"><a href="#src1rect">src1rect</a></span> is
(800/400, 600/300) or (2, 3). Using this, the effective source 1
clipping rectangle becomes (10/2, 30/3) - (300/2 x 300/3) or (5, 10) - (150 x
100).</p>
<p>Note that this approach allows fractional clipping at the source using a
method which is simpler to implement than fractional coordinates.</p>
<p>The convention in BLTsville is that interpolated scaling (and filtering)
<span class="underline">can</span> fetch pixels outside of the source rectangle
if needed for the scaling algorithm, as long as no attempt is made to fetch
pixels outside of the surface boundaries. <span class="red"><em>Options
to allow the client to specify limiting the source region are being considered
at this time.</em></span></p>
<p class="Code_Header_2">bvbltparams.cliprect</p>
<p class="code_block"><a href="#bvrect">struct bvrect</a> cliprect;</p>
<p><span class="inline_code">cliprect</span> is used to specify a rectangle that limits what region of the
destination is written. This is most useful for scaling operations, where the
necessary scaling factor will not allow translation of the destination rectangle back to the source on an integer pixel
boundary.</p>
<p>For example, if the goal is to show a 640 x 480 video on a 1920 x 1080 screen, the video would be stretched to 1440 x
1080 to maintain the proper aspect ratio. So the relevant rectangles would be:</p>
<table class="indent1">
<tr>
<td class="thin_bord"><strong>src1rect</strong></td>
<td class="thin_bord"><strong>dstrect</strong></td>
</tr>
<tr>
<td class="thin_bord">(0, 0) - 640 x 480</td>
<td class="thin_bord">(240, 0) - 1440 x 1080</td>
</tr>
</table>
<p>However, to handle a 640 x 480 pop-up window that appears centered on the screen, in front of the video, the single
BLT may be broken into four smaller BLTs pieced around the popup. These rectangles would need to be:</p>
<table class="indent1">
<tr>
<td class="thin_bord"><strong>src1rect</strong></td>
<td class="thin_bord"><strong>dstrect</strong></td>
</tr>
<tr>
<td class="thin_bord">(0, 0) - 640 x 133.333...</td>
<td class="thin_bord">(240, 0) - 1440 x 300</td>
</tr>
<tr>
<td class="thin_bord">(0, 133.333...) - 284.444... x 213.333...</td>
<td class="thin_bord">(240, 300) - 400 x 480</td>
</tr>
<tr>
<td class="thin_bord">(568.888..., 133.333...) - 284.444... x 213.333...</td>
<td class="thin_bord">(1280, 300) - 400 x 480</td>
</tr>
<tr>
<td class="thin_bord">(0, 346.666...) - 640 x 133.333...</td>
<td class="thin_bord">(240, 780) - 1440 x 300</td>
</tr>
</table>
<p>Since this is a scaling factor of 2.25x, translating the required destination rectangles back to the source results
in non-integer coordinates and dimensions, as illustrated above. And adjusting the source rectangles to the
nearest integer values will result in visible discontinuities at the boundaries between the rectangles.</p>
<p>Instead, using the <span class="inline_code">cliprect</span>, this situation can be handled more easily:</p>
<table class="indent1">
<tr>
<td class="thin_bord"><strong>src1rect</strong></td>
<td class="thin_bord"><strong>dstrect</strong></td>
<td class="thin_bord"><strong>cliprect</strong></td>
</tr>
<tr>
<td class="thin_bord">(0, 0) - 640 x 480</td>
<td class="thin_bord">(240, 0) - 1440 x 1080</td>
<td class="thin_bord">(240, 0) - 1440 x 300</td>
</tr>
<tr>
<td class="thin_bord">(0, 0) - 640 x 480</td>
<td class="thin_bord">(240, 0) - 1440 x 1080</td>
<td class="thin_bord">(240, 300) - 400 x 480</td>
</tr>
<tr>
<td class="thin_bord">(0, 0) - 640 x 480</td>
<td class="thin_bord">(240, 0) - 1440 x 1080</td>
<td class="thin_bord">(1280, 300) - 400 x 480</td>
</tr>
<tr>
<td class="thin_bord">(0, 0) - 640 x 480</td>
<td class="thin_bord">(240, 0) - 1440 x 1080</td>
<td class="thin_bord">(240, 780) - 1440 x 300</td>
</tr>
</table>
<p class="Code_Header_2">bvbltparams.batchflags</p>
<p class="code_block">unsigned long batchflags;</p>
<p><span class="inline_code">batchflags</span> are used by the client to indicate to the implementation which
parameters are changing between successive BLTs of a batch. The flags are
used when the <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span>
has <span class="inline_code"><a href="#BVFLAG_BATCH_CONTINUE">
BVFLAG_BATCH_CONTINUE</a></span> or <span class="inline_code">
<a href="#BVFLAG_BATCH_END">BVFLAG_BATCH_END</a></span> set.</p>
<p><span class="inline_code"><a name="BVBATCH_OP">BVBATCH_OP</a></span>
indicates that the operation type (<span class="inline_code"><a href="#BVFLAG_ROP">BVFLAG_ROP</a></span>,
<span class="inline_code"><a href="#BVFLAG_BLEND">BVFLAG_BLEND</a></span>, <span class="inline_code">
<a href="#BVFLAG_FILTER">BVFLAG_FILTER</a></span>,
etc.) has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_KEY">BVBATCH_KEY</a></span>
indicates that the <span class="inline_code"><a href="#colorkey">
bvbltparams.colorkey</a></span> or the color key mode (<span class="inline_code"><a href="#BVFLAG_KEY_SRC">BVFLAG_KEY_SRC</a></span>/<span class="inline_code"><a href="#BVFLAG_KEY_DST">BVFLAG_KEY_DST</a></span>)
has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_MISCFLAGS">BVBATCH_MISCFLAGS</a></span>
indicates that <span class="inline_code"><a href="#flags">bvbltparams.flags</a></span>
other than the operation, color key, or clip flag have changes.</p>
<p><span class="inline_code"><a name="BVBATCH_ALPHA">BVBATCH_ALPHA</a></span>
indicates that <span class="inline_code"><a href="#globalalpha">
bvbltparams.globalalpha</a></span> or global alpha type has changed.</p>
<p><a name="BVBATCH_DITHER" class="inline_code">BVBATCH_DITHER</a> indicates
that <span class="inline_code"><a href="#dithermode">bvbltparams.dithermode</a></span>
has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_SCALE">BVBATCH_SCALE</a></span>
indicates that <span class="inline_code"><a href="#scalemode">
bvbltparams.scalemode</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_DST">BVBATCH_DST</a></span>
indicates that the destination surface (<span class="inline_code"><a href="#dstdesc">bvbltparams.dstdesc</a></span>,
<span class="inline_code"><a href="#dstgeom">bvbltparams.dstgeom</a></span> ,or
<span class="inline_code"><a href="#dstrect">bvbltparams.dstrect</a></span>) has
changed.</p>
<p><span class="inline_code">BVBATCH_SRC1</span> indicates that the source 1
surface (<span class="inline_code"><a href="#src1.desc">bvbltparams.src1.desc</a></span>
or <span class="inline_code"><a href="#src1.tileparams">
bvbltparams.src1.tileparams</a></span>, or <span class="inline_code">
<a href="#src1geom">bvbltparams.src1geom</a></span>)
has changed.</p>
<p><span class="inline_code">BVBATCH_SRC2</span> indicates that the source 2
surface (<span class="inline_code"><a href="#src2.desc">bvbltparams.src2.desc</a></span>
or <span class="inline_code"><a href="#src2.tileparams">
bvbltparams.src2.tileparams</a></span>, or <span class="inline_code">
<a href="#src2geom">bvbltparams.src2geom</a></span>)
has changed.</p>
<p><span class="inline_code">BVBATCH_MASK</span> indicates that the mask
surface (<span class="inline_code"><a href="#mask.desc">bvbltparams.mask.desc</a></span>
or <span class="inline_code"><a href="#mask.tileparams">
bvbltparams.mask.tileparams</a></span>, or <span class="inline_code">
<a href="#maskgeom">bvbltparams.maskgeom</a></span>)
has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_DSTRECT_ORIGIN">
BVBATCH_DSTRECT_ORIGIN</a></span> indicates that <span class="inline_code">
<a href="#dstrect">bvbltparams.dstrect.left</a></span> or
<span class="inline_code"><a href="#dstrect">top</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_DSTRECT_SIZE">BVBATCH_DSTRECT_SIZE</a></span>
indicates that the <span class="inline_code"><a href="#dstrect">
bvbltparams.dstrect.width</a></span> or <a href="#dstrect">height</a> has
changed.</p>
<p><span class="inline_code"><a name="BVBATCH_SRC1RECT_ORIGIN">
BVBATCH_SRC1RECT_ORIGIN</a></span> indicates that <span class="inline_code">
<a href="#src1rect">bvbltparams.src1rect.left</a></span> or
<span class="inline_code"><a href="#dstrect">top</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_SRC1RECT_SIZE">
BVBATCH_SRC1RECT_SIZE</a></span> indicates that the <span class="inline_code">
<a href="#src1rect">bvbltparams.src1rect.width</a></span> or <a href="#src1rect">
height</a> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_SRC2RECT_ORIGIN">
BVBATCH_SRC2RECT_ORIGIN</a></span> indicates that <span class="inline_code">
<a href="#src2rect">bvbltparams.src2rect.left</a></span> or
<span class="inline_code"><a href="#src2rect">top</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_SRC2RECT_SIZE">
BVBATCH_SRC2RECT_SIZE</a></span> indicates that the <span class="inline_code">
<a href="#src2rect">bvbltparams.src2rect.width</a></span> or <a href="#src2rect">
height</a> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_MASKRECT_ORIGIN">
BVBATCH_MASKRECT_ORIGIN</a></span> indicates that <span class="inline_code">
<a href="#maskrect">bvbltparams.maskrect.left</a></span> or
<span class="inline_code"><a href="#maskrect">top</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_MASKRECT_SIZE">
BVBATCH_MASKRECT_SIZE</a></span> indicates that the <span class="inline_code">
<a href="#maskrect">bvbltparams.maskrect.width</a></span> or <a href="#maskrect">
height</a> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_CLIPRECT_ORIGIN">
BVBATCH_CLIPRECT_ORIGIN</a></span> indicates that <span class="inline_code">
<a href="#cliprect">bvbltparams.cliprect.left</a></span> or
<span class="inline_code"><a href="#cliprect">top</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_CLIPRECT_SIZE">
BVBATCH_CLIPRECT_SIZE</a></span> indicates that the <span class="inline_code">
<a href="#cliprect">bvbltparams.cliprect.width</a></span> or <a href="#cliprect">
height</a> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_TILE_SRC1">BVBATCH_TILE_SRC1</a></span>
indicates that the <span class="inline_code"><a href="#src1.tileparams">
bvbltparams.src1.tileparams</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_TILE_SRC2">BVBATCH_TILE_SRC2</a></span>
indicates that the <span class="inline_code"><a href="#src2.tileparams">
bvbltparams.src2.tileparams</a></span>
has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_TILE_MASK">BVBATCH_TILE_MASK</a></span>
indicates that the <span class="inline_code"><a href="#mask.tileparams">
bvbltparams.mask.tileparams</a></span> has changed.</p>
<p><span class="inline_code"><a name="BVBATCH_ENDNOP">BVBATCH_ENDNOP</a></span>
is a special flag used with <span class="inline_code"><a href="#batch_end">
BVFLAG_BATCH_END</a></span>, for clients that do not have information that a batch is
ending until after the last BLT has been issued. When this flag is set, no
BLT is done, but the batch is ended.</p>
<p class="Code_Header_2"><a name="batch">bvbltparams.batch</a></p>
<p class="code_block"><a href="#bvbatch">struct bvbatch</a> *batch;</p>
<p>This member is used as a batch handle, so that multiple batches can be under
construction at the same time.</p>
<p class="Code_Header_2"><a name="callbackfn">bvbltparams.callbackfn</a></p>
<p class="code_block">void (*callbackfn)(<a href="#bvcallbackerror">struct
bvcallbackerror</a> *err, unsigned long <a href="#callbackdata">callbackdata</a>);</p>
<p>This member is a pointer to a client-supplied function which is called by the
implementation when <span class="inline_code"><a href="#BVFLAG_ASYNC">
BVFLAG_ASYNC</a></span> is set and the BLT is complete.</p>
<p class="note">NOTE: This function <span class="underline">can be called</span>
before the <span class="inline_code"><a href="#bv_blt">bv_blt()</a></span> call
has returned.</p>
<p class="Code_Header_2"><a name="callbackdata">bvbltparams.callbackdata</a></p>
<p class="code_block">unsigned long callbackdata;</p>
<p>This member is used as the parameter passed back by the
<span class="inline_code"><a href="#callbackfn">bvbltparams.callbackfn</a></span>.
This can be anything from an identifying index to a pointer used by the client.</p>
<hr />
<p class="Header1">Batching<a name="batching"></a></p>
<p>Batching is the single most powerful feature in BLTsville. It is used
for two major purposes:</p>
<ol>
<li>To group similar BLTs which use most of the same parameters so that they
can be handled more efficiently by the implementation.</li>
<li>To group BLTs that should go together so that implementations can use
special features that go beyond what seems to be expressed by the BLTsville
API.</li>
</ol>
<p class="note">NOTE: It is important to realize that BLTs batched
together may be done <span class="underline">in any order</span>, and in fact
may not even be done in the way specified. This includes the BLTs being
done as they are submitted, as well as no operations performed until the batch
submission is completed with <a href="#BVFLAG_BATCH_END" class="inline_code">
BVFLAG_BATCH_END</a>.</p>
<p class="Header2">Batches For Grouping Similar BLTs</p>
<p>Often, groups of similar BLTs are performed, with changes to only a few
parameters. Some implementations have the ability to re-use previous
settings, coupled with these changes, to perform new BLTs.</p>
<p>One good example of this in in rendering text, similar to that you are
reading now. In most systems, a glyph cache is maintained to hold the
characters of a given font, rasterized with the specific characteristics desired
(e.g. bold, italics, etc.). Each font in the glyph cache is normally
created using a font rasterization engine from a vector-based font, such as
FreeType. This technology allows fonts to be described in terms of curves
and lines instead of pixels, which means they can be created as needed, in any
size desirable.</p>
<table style="width: 100%" class="glyph_cache">
<tr>
<td class="glyph_cache"> !"#$%&'()*+'-./0123456789:;<=>?<br />
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_<br />
`abcdefghijklmnopqrstuvwxyz{|}~</td>
</tr>
</table>
<p>Then, when a character needs to be rendered, it is copied from the
pre-rendered glyph cache. This is much more efficient than performing the
font rasterization from the vector description each time a character is used.</p>
<p>With some hardware implementations, the setup to trigger the copy of these
characters from the glyph cache to the target surface can be quite significant,
when compared to the number of pixels actually affected. For example, each
character might consist of something on the order of 10 x 14, or about 140
pixels. Programming a typical hardware BLTer may require tens of commands
for each character.</p>
<p>But note that each of these BLTs differs by only a few parameters.
Specifically, once the source and destination surfaces have been specified, and
the operation described, only the source and destination rectangles change
between BLTs. To alleviate much of this overhead, most implementations will
allow the configuration of a previous BLT to be used again, with only those
parameters which change provided for the subsequent BLTs.</p>
<p>BLTsville provides access to this capability via the batch mechanism.</p>
<p>For rendering a word using a monospaced font like this, the client might
construct the batch like this:</p>
<p class="small_code_block">struct bvbuffdesc screendesc = {sizeof(struct
bvbuffdesc}, 0};<br />
struct bvsurfgeom screengeom = {sizeof(struct bvsurfgeom), 0};<br />
struct bvbuffdesc glyphcachedesc = {sizeof(struct bvbuffdesc), 0};<br />
struct bvsurfgeom glyphcachegeom = {sizeof(struct bvsurfgeom), 0};<br />
struct bvtileparams solidcolortileparams = {sizeof(struct bvtileparams), 0};<br />
struct bvbuffgeom solidcolorgeom = {sizeof(struct bvsurfgeom), 0};<br />
<br />
struct bvbltparams bltparams = {sizeof(struct
bvbltparams), 0};<br />
<br />
int charsperline = 32;<br />
int fontwidth = 10;<br />
int fontheight = 14;<br />
int i = 0;<br />
<br />
screendesc.virtaddr = screenaddr;<br />
screendesc.length = screenstride * screenheight;<br />
screengeom.format = OCDFMT_RGB24;<br />
screengeom.width = screenwidth;<br />
screengeom.height = screenheight;<br />
screengeom.virtstride = screenstride;<br />
<br />
glyphcachedesc.virtaddr = glyphcacheaddr;<br />
glyphcachedesc.length = glyphcachestride * glyphcacheheight;<br />
glyphcachegeom.format = OCDFMT_ALPHA8;<br />
glyphcachegeom.width = glyphcachewidth;<br />
glyphcachegeom.height = glyphcacheheight;<br />
glyphcachegeom.virtstride = glyphstride;<br />
<br />
solidcolortileparams.virtaddr = &solidcolor;<br />
solidcolortileparams.srcwidth = 1;<br />
solidcolortileparams.srcheight = 1;<br />
solidcolorgeom.format = OCDFMT_RGB24;<br />
<br />
bltparams.flags = BVFLAG_BLEND | BVFLAG_SRC1_TILED | BVFLAG_BATCH_BEGIN;<br />
bltparams.op.blend = BVBLEND_SRCOVER + BVBLENDDEF_REMOTE;<br />
bltparams.dstdesc = &screendesc;<br />
bltparams.dstgeom = &screengeom;<br />
bltparams.src1.tileparams = &solidcolortileparams;<br />
bltparams.src1geom = &solidcolorgeom;<br />
bltparams.src2.desc = &screendesc;<br />
bltparams.src2geom = &screengeom;<br />
bltparams.mask.desc = &glyphcachedesc;<br />
bltparams.maskgeom = &glyphcachegeom;<br />
<br />
bltparams.dstrect.left = bltparams.src2rect.left = screenrect.left;<br />
bltparams.dstrect.top = bltparams.src2rect.top = screenrect.top;<br />
<br />
bltparams.maskrect.width = bltparams.dstrect.width = bltparams.src2rect.width =
fontwidth;<br />
bltparams.maskrect.height = bltparams.dstrect.height = bltparams.src2rect.height
= fontheight;<br />
<br />
bltparams.maskrect.left = ((text[i] - ' ') % charsperline) * fontwidth;<br />
bltparams.maskrect.top = ((text[i] - ' ') / charsperline) * fontheight;<br />
<br />
bv_blt(&bltparams);<br />
<br />
i++;<br />
if(i < textlen)<br />
{<br />
bltparams.flags = (bltparams.flags & ~BVFLAG_BATCH_MASK) |
BVFLAG_BATCH_CONTINUE;<br />
bltparams.batch = BVBATCH_DSTRECT_ORIGIN | BVBATCH_SRC2RECT_ORIGIN |
BVBATCH_MASKRECT_ORIGIN;<br />
<br />
do<br />
{<br />
bltparams.dstrect.left += fontwidth;<br />
bltparams.src2rect.left = bltparams.dstrect.left;<br />
<br />
bltparams.maskrect.left = ((text[i] - ' ') % charsperline)
* fontwidth;<br />
bltparams.maskrect.top = ((text[i] - ' ') / charsperline)
* fontheight;<br />
<br />
bv_blt(&bltparams);<br />
<br />
i++;<br />
}while(i < textlen);<br />
}<br />
<br />
bltparams.flags = (bltparams.flags & ~BVFLAG_BATCH_MASK) | BVFLAG_BATCH_END;<br />
bltparams.batch = BVBATCH_ENDNOP;<br />
<br />
bv_blt(&bltparams);</p>
<p class="Header2">Batches For Special Feature BLTs</p>
<p>Enabling special features of some implementations is a special challenge.
But BLTsville is up the task.</p>
<p>For example, perhaps an implementation is capable of blending 4 layers at the
same time. But BLTsville only allows blending to be specified using 2
layers at a time. How can this be accomplished?</p>
<p>The most prevalent blending reference used is the Porter-Duff whitepaper,
which specifies blending of 2 sources. So any N-source blend would require
the blends to be specified as a grouping of 2 source blends in order to utilize
the Porter-Duff equations. That's how such a blend is specified in
BLTsville:</p>
<p class="small_code_block">bltparams.dstrect.width = bltparams.src1rect.width =
bltparams.src2rect.width = dstgeom.width;<br />
bltparams.dstrect.height = bltparams.src1rect.height = bltparams.src2rect.height
= dstgeom.height; <br />
<br />
bltparams.flags = BVFLAG_BLEND | BVFLAG_BATCH_BEGIN;<br />
bltparams.op.blend = BVBLEND_SRCOVER;<br />
bltparams.dstdesc = &dstdesc;<br />
bltparams.dstgeom = &dstgeom;<br />
bltparams.src1.desc = &src1desc;<br />
bltparams.src1geom = &src1geom;<br />
bltparams.src2.desc = &src2desc;<br />
bltparams.src2geom = &src2geom;<br />
<br />
bv_blt(&bltparams);<br />
<br />
bltparams.src1.desc = &src3desc;<br />
bltparams.src1geom = &src3geom;<br />
bltparams.dstdesc = &dstdesc;<br />
bltparams.dstgeom = &dstgeom;<br />
<br />
bltparams.flags = (bltparams.flags & ~BVFLAG_BATCH_MASK) |
BVFLAG_BATCH_CONTINUE;<br />
bltparams.batch = BVBATCH_SRC1 | BVBATCH_SRC2;<br />
<br />
bv_blt(&bltparams);<br />
<br />
bltparams.src1.desc = &src4desc;<br />
bltparams.src1geom = &src4geom;<br />
<br />
bltparams.flags = (bltparams.flags & ~BVFLAG_BATCH_MASK) | BVFLAG_BATCH_END;<br />
bltparams.batch = BVBATCH_SRC1;<br />
<br />
bv_blt(&bltparams);</p>
<p>The driver for an implementation that can perform this pair of operations as
one BLT would be tasked with recognizing that the batch contained BLTs which can
be linked.</p>
<p>The fantastic thing about this approach is that an implementation without the
ability to blend 4 sources would perform the 3 blends separately, with the
identical result.</p>
<p class="note">NOTE: A batch of BLTs may be serviced in any number of
ways. For example, one implementation may perform each BLT as it is
submitted, while another may take no action until the
<a href="#BVFLAG_BATCH_END" class="inline_code">BVFLAG_BATCH_END</a> BLT is
encountered. As a result, the client must be careful not to rely on any intermediate results. (In this
example, the destination buffer may be used for intermediate results, so it is
important that this buffer not be used during the batch--i.e. as a displayed
buffer.) </p>
<p class="note">NOTE: Failure during the performance of a batch (indicated by
the contents of the <a href="#bvcallbackerror" class="inline_code">
bvcallbackerror</a> structure) will result in
an unknown state for all destination buffers. Do not
assume that a given implementation's state in this case represents the state
which will be encountered for a different implementation.</p>
<p class="note">NOTE: Because of the indeterminate nature of the execution of a
batch of BLTs, a "batch abort" would not result in a known state either.
As stated above, a given implementation may have already performed earlier BLTs
in a batch as the batch is submitted. So errors encountered during the
submission of a batch must be handled by the client, and then the batch must be
terminated normally using <a href="#BVFLAG_BATCH_END" class="inline_code">
BVFLAG_BATCH_END</a>.</p>
<hr />
<p class="Code_Header"><a name="bvcallbackerror">bvcallbackerror</a></p>
<p class="code_block">struct bvcallbackerror {<br />
unsigned int structsize;<br />
<a href="#bverror">enum bverror</a>
error;<br />
char* errdesc;<br />
};</p>
<p class="Code_Header_2"><a name="bvcallbackerror.structsize">
bvcallbackerror.structsize</a></p>
<p> </p>
<p class="Code_Header_2"><a name="bvcallbackerror.error">bvcallbackerror.error</a></p>
<p> </p>
<p class="Code_Header_2"><a name="bvcallbackerror.errdesc">
bvcallbackerror.errdesc</a></p>
<p> </p>
<hr />
<p class="Header1"><a name="start">Where to Start</a></p>
<p><em>(Note that error checking is omitted in all the examples below for
clarity.)</em> </p>
<p>1. Clients begin by opening one or more BLTsville implementations
dynamically. The specific method of doing this is dependent on the
operating system. For example, Linux might do this like this:</p>
<p class="small_code_block">struct bltsvillelib<br />
{<br />
char* name;<br />
void* handle;<br />
BVFN_MAP bv_map;<br />
BVFN_BLT bv_blt;<br />
BVFN_UNMAP bv_unmap;<br />
}; <br />
<br />
struct bltsville bvlib[] =<br />
{<br />
{ "libbltsville_cpu.so", 0 },<br />
{ "libbltsville_2d.so", 0 }<br />
};<br />
const int NUMBVLIBS = sizeof(bvlib) / sizeof(struct bltsvillelib);<br />
<br />
for(int i = 0; i < NUMLIBS; i++)<br />
{<br />
bvlib[i].handle = dlopen(bvlib[i].name, RTLD_LOCAL | RTLD_LAZY);<br />
bvlib[i].bv_map = (BVFN_MAP)dlsym(bvlib[i].handle, "bv_map");<br />
bvlib[i].bv_blt = (BVFN_BLT)dlsym(bvlib[i].handle, "bv_blt");<br />
bvlib[i].bv_unmap = (BVFN_BLT)dlsym(bvlib[i].handle, "bv_unmap");<br />
}<br />
</p>
<p>2. Clients then need to create a <span class="inline_code">
<a href="#bvbuffdesc">bvbuffdesc</a></span> object for each buffer to be
accessed in BLTsville:</p>
<table class="indent1">
<tr>
<td valign="top">
<p class="small_code_block_in_table">struct
bvbuffdesc
buff =<br />
{sizeof(struct bvbuffdesc), 0};<br />
<br />
buff.virtaddr = buffptr;<br />
buff.length = bufflength;</p>
</td>
<td style="width: 30px" class="center">or</td>
<td valign="top">
<p class="inline_code">
<span class="small_code_block_in_table">struct
bvbuffdesc buff;<br />
<br />
memset(&buff, 0, sizeof(buff));<br />
buff.structsize = sizeof(buff);<br />
buff.virtaddr = buffptr;<br />
buff.length = bufflength;</span></p>
</td>
</tr>
</table>
<p class="strong_emphasis">Note that the client must ensure that the map element and any additional members
in <span class="inline_code"><a href="#bvbuffdesc">bvbuffdesc</a></span> are
initialized to 0.</p>
<p>3. Next the buffer can be mapped to give the hardware implementations
a chance to associate any necessary resources with the buffer:</p>
<table class="indent1">
<tr>
<td valign="top">
<p class="small_code_block_in_table">/* do
nothing */ </p>
</td>
<td style="width: 30px" class="center">or</td>
<td valign="top">
<p class="small_code_block_in_table">bvlib[0].bv_map(&buff); </p>
</td>
<td style="width: 30px" class="center">or</td>
<td valign="top">
<p class="small_code_block_in_table">for(int i =
0; i < NUMLIBS; i++)<br />
{<br />
if(bvlib[i].bv_map)<br />
bvlib[i].bv_map(&buff);<br />
}</p>
</td>
</tr>
</table>
<br/>
<table style="width: 100%">
<tr>
<td valign="top">a. </td>
<td>This step is actually optional, as indicated
above. However, if the client does not
explicitly call <span class="inline_code">
<a href="#bv_map">bv_map()</a></span>, the
mapping must be done by the implementation to
associate the necessary resources with the
buffer. So this mapping must be done
later, when <span class="inline_code">
<a href="#bv_blt">bv_blt()</a></span> is called.
Additionally, since the client did not call
<span class="inline_code"><a href="#bv_map">
bv_map()</a></span>, it is unlikely that the
client will call <span class="inline_code">
<a href="#bv_unmap">bv_unmap()</a></span> to
allow the implementation to free the resources
associated with the buffer. So the
implementation will internally unmap the
resources after completing the BLT. This
means that the mapping and unmapping overhead
will be encountered on every call to
<span class="inline_code"><a href="#bv_blt">
bv_blt()</a></span>.<br />
<em><br />
In general, the CPU implementations have
(almost) no overhead associated with mapping and
unmapping. So opting not to make the
<span class="inline_code"><a href="#bv_map">
bv_map()</a></span> call for CPU implementations
is likely to have negligible difference in
<span class="inline_code"><a href="#bv_blt">bv_blt()</a></span> performance.<br />
</em></td>
</tr>
<tr>
<td valign="top">b. </td>
<td>Calling <span class="inline_code">
<a href="#bv_map">bv_map()</a></span> once for each buffer is
enough to tell the implementations that the
client can be trusted to call
<span class="inline_code"><a href="#bv_unmap">bv_unmap()</a></span>
when work with the buffer is complete, as
indicated above. It does not matter which
implementation's <span class="inline_code">
<a href="#bv_map">bv_map()</a></span> is called.
However, that implementation is the only one
which will perform the mapping immediately.
All other implementations will perform a <em>
lazy mapping</em> only when their
<span class="inline_code"><a href="#bv_blt">
bv_blt()</a></span> call is invoked.<br />
<br />
This allows the client to avoid the overhead of
mapping and unmapping the buffers on each
<span class="inline_code"><a href="#bv_blt">
bv_blt()</a></span> call. It also avoids
the associated mapping and unmapping overhead if
a given implementation is never used.<br />
<br />
<em>As mentioned above, the CPU implementations
have (almost) no overhead associated with
mapping and unmapping, so they are a good choice
to use for the call to <span class="inline_code">
<a href="#bv_map">bv_map()</a></span>.<br />
</em></td>
</tr>
<tr>
<td valign="top">c. </td>
<td>If the client wants direct control over the
mapping and unmapping overhead, it can call the
<span class="inline_code"><a href="#bv_map">
bv_map()</a></span> function of each
implementation, as indicated above. Each
implementation will perform the mapping at that
time, so that the overhead will not appear on
subsequent calls to <span class="inline_code">
<a href="#bv_blt">bv_blt()</a></span>. </td>
</tr>
</table>
<p>4. Next the client must create <span class="inline_code">
<a href="#bvsurfgeom">bvsurfgeom</a></span> objects for each way in which a
buffer will be accessed. Often, there is only one way in which a buffer is
accessed, so there will be the same number of buffers, <span class="inline_code">
<a href="#bvbuffdesc">bvbuffdesc</a></span>, and <span class="inline_code">
<a href="#bvsurfgeom">bvsurfgeom</a></span> objects. If that's the case,
it may be convenient for the client to combine them into a parent structure.
It may even be possible to share a single bvbuffgeom structure among buffers.
Or there will be times when it is necessary to treat a buffer in different ways
for different BLTs. Having these two structures separated allows all of
these combinations.</p>
<table class="indent1">
<tr>
<td valign="top">
<p class="small_code_block_in_table">struct bvsurfgeom
geom =<br />
{sizeof(struct bvsurfgeom), 0};<br />
<br />
geom.format = OCDFMT_RGB24;<br />
geom.width = width;<br />
geom.height = height;<br />
geom.virtstride = stride;</p>
</td>
<td style="width: 30px" class="center">or</td>
<td valign="top">
<p class="inline_code">
<span class="small_code_block_in_table">struct
bvsurfgeom geom;<br />
<br />
memset(&geom, 0, sizeof(geom));<br />
geom.structsize = sizeof(geom);<br />
geom.width = width;<br />
geom.height = height;<br />
geom.virtstride = stride;</span></p>
</td>
</tr>
</table>
<p class="strong_emphasis">Note that the client must ensure that any additional members
in <span class="inline_code"><a href="#bvsurfgeom">bvsurfgeom</a></span> are
initialized to 0 for future compatibility.</p>
<p>5. Now the client is ready to fill in a bvbltparams structure to specify the
type of BLT requested. Here is an example of a simple copy from the lower
right corner of a surface to the upper left:</p>
<p class="small_code_block">struct bvbltparams bltparams = {sizeof(struct
bvbltparams), 0};<br />
<br />
bltparams.flags = BVFLAG_ROP;<br />
bltparams.op.rop = 0xCCCC; /* SRCCOPY */<br />
bltparams.dstdesc = &buff;<br />
bltparams.dstgeom = &geom;<br />
bltparams.dstrect.left = 0;<br />
bltparams.dstrect.top = 0;<br />
bltparams.dstwidth = width / 2;<br />
bltparams.dstheight = height / 2;<br />
bltparams.src1.desc = &buff;<br />
bltparams.src1geom = &geom;<br />
bltparams.src1rect.left = width / 2;<br />
bltparams.src1rect.top = height / 2;<br />
bltparams.src1rect.width = width / 2;<br />
bltparams.src1rect.height = height / 2;</p>
<p>6. And next the client can trigger the BLT by calling
<span class="inline_code"><a href="#bv_blt">bv_blt()</a></span>:</p>
<p class="small_code_block">bv_blt(&bltparams); </p>
<p><em>If the client cannot complete the requested BLT, it returns a </em>
<span class="inline_code"><a href="#bverror"><em>bverror</em></a></span><em>
indicating the issue. </em></p>
<p>7. Finally, the client should clean up:</p>
<p class="small_code_block">bv_unmap(&buff); </p>
</body>
</html>
|