aboutsummaryrefslogtreecommitdiff
path: root/docs/SkCanvas_Reference.bmh
blob: b2c70f547701c2f795d4828aae7205d443183eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
#Topic Canvas
#Alias Canvas_Reference

#Class SkCanvas

Canvas provides an interface for drawing, and how the drawing is clipped and transformed.
Canvas contains a stack of Matrix and Clip values.

Canvas and Paint together provide the state to draw into Surface or Device.
Each Canvas draw call transforms the geometry of the object by the concatenation of all
Matrix values in the stack. The transformed geometry is clipped by the intersection
of all of Clip values in the stack. The Canvas draw calls use Paint to supply drawing
state such as Color, Typeface, text size, stroke width, Shader and so on.

To draw to a pixel-based destination, create Raster_Surface or GPU_Surface. 
Request Canvas from Surface to obtain the interface to draw. 
Canvas generated by Raster_Surface draws to memory visible to the CPU. 
Canvas generated by GPU_Surface uses Vulkan or OpenGL to draw to the GPU.

To draw to a document, obtain Canvas from SVG_Canvas, Document_PDF, or Picture_Recorder.
Document based Canvas and other Canvas Subclasses reference Device describing the
destination.

Canvas can be constructed to draw to Bitmap without first creating Raster_Surface.
This approach may be deprecated in the future.  

#Topic Overview

#Subtopic Subtopics
#Table
#Legend
# topics                 # description                                 ##
#Legend ##
#ToDo generate a TOC here ##
#Table ##
#Subtopic ##

#Subtopic Constants
#Table
#Legend
# constants                      # description                                 ##
#Legend ##
# Lattice::Flags                 # Controls Lattice transparency. ##
# PointMode                      # Sets drawPoints options. ##
# SaveLayerFlags                 # Sets SaveLayerRec options. ##
# SrcRectConstraint              # Sets drawImageRect options. ##
#Table ##
#Subtopic ##

#Subtopic Structs
#Table
#Legend
# struct                         # description                                 ##
#Legend ##
# Lattice                        # Divides Bitmap, Image into a rectangular grid. ##
# SaveLayerRec                   # Contains state to create Layer. ##
#Table ##
#Subtopic ##

#Subtopic Constructors

Create the desired type of Surface to obtain its Canvas when possible. Constructors are useful
when no Surface is required, and some helpers implicitly create Raster_Surface.

#Table
#Legend
#                                                               # description                                     ##
#Legend ##
# SkCanvas()                                                    # No Surface, no dimensions.                      ##
# SkCanvas(int width, int height, const SkSurfaceProps* props = nullptr) # No Surface, set dimensions, Surface_Properties. ##
# SkCanvas(SkBaseDevice* device)                                # Existing Device. (SkBaseDevice is private.)     ##
# SkCanvas(const SkBitmap& bitmap)                              # Uses existing Bitmap.                           ##
# SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props) # Uses existing Bitmap and Surface_Properties.    ##
# MakeRasterDirect                                              # Creates from SkImageInfo and Pixel_Storage.     ##
# MakeRasterDirectN32                                           # Creates from image data and Pixel_Storage.      ##
#Table ##
#Subtopic ##

#Subtopic Member_Functions
#Table
#Legend
# function                         # description                                                   ##
#Legend ##
# accessTopLayerPixels             # Returns writable pixel access if available. ##
# accessTopRasterHandle            # Returns context that tracks Clip and Matrix. ##
# clear()                          # Fills Clip with Color. ##
# clipPath                         # Combines Clip with Path. ##
# clipRRect                        # Combines Clip with Round_Rect. ##
# clipRect                         # Combines Clip with Rect. ##
# clipRegion                       # Combines Clip with Region. ##
# concat()                         # Multiplies Matrix by Matrix. ##
# discard()                        # Makes Canvas contents undefined. ##
# drawAnnotation                   # Associates a Rect with a key-value pair.##
# drawArc                          # Draws Arc using Clip, Matrix, and Paint.##
# drawAtlas                        # Draws sprites using Clip, Matrix, and Paint.##
# drawBitmap                       # Draws Bitmap at (x, y) position. ##
# drawBitmapLattice                # Draws proportionally stretched Bitmap. ##
# drawBitmapNine                   # Draws Nine_Patch Bitmap. ##
# drawBitmapRect                   # Draws Bitmap, source Rect to destination Rect. ##
# drawCircle                       # Draws Circle using Clip, Matrix, and Paint. ##
# drawColor                        # Fills Clip with Color and Blend_Mode. ##
# drawDRRect                       # Draws double Round_Rect stroked or filled. ##
# drawDrawable                     # Draws Drawable, encapsulated drawing commands. ##
# drawIRect                        # Draws IRect using Clip, Matrix, and Paint. ##
# drawImage                        # Draws Image at (x, y) position. ##
# drawImageLattice                 # Draws proportionally stretched Image. ##
# drawImageNine                    # Draws Nine_Patch Image. ##
# drawImageRect                    # Draws Image, source Rect to destination Rect. ##
# drawLine                         # Draws line segment between two points.##
# drawOval                         # Draws Oval using Clip, Matrix, and Paint. ##
# drawPaint                        # Fills Clip with Paint. ##
# drawPatch                        # Draws Coons_Patch. ##
# drawPath                         # Draws Path using Clip, Matrix, and Paint. ##
# drawPicture                      # Draws Picture using Clip and Matrix. ##
# drawPoint                        # Draws point at (x, y) position. ##
# drawPoints                       # Draws array as points, lines, polygon. ##
# drawPosText                      # Draws text at array of (x, y) positions. ##
# drawPosTextH                     # Draws text at x positions with common baseline. ##
# drawRRect                        # Draws Round_Rect using Clip, Matrix, and Paint. ##
# drawRect                         # Draws Rect using Clip, Matrix, and Paint. ##
# drawRegion                       # Draws Region using Clip, Matrix, and Paint. ##
# drawRoundRect                    # Draws Round_Rect using Clip, Matrix, and Paint. ##
# drawText                         # Draws text at (x, y), using font advance. ##
# drawTextBlob                     # Draws text with arrays of positions and Paint. ##
# drawTextOnPath                   # Draws text following Path contour. ##
# drawTextOnPathHV                 # Draws text following Path with offsets. ##
# drawTextRSXform                  # Draws text with array of RSXform. ##
# drawString                       # Draws null terminated string at (x, y) using font advance. ##
# drawVertices                     # Draws Vertices, a triangle mesh. ##
# flush()                          # Triggers execution of all pending draw operations. ##
# getBaseLayerSize                 # Gets size of base Layer in global coordinates. ##
# getDeviceClipBounds              # Returns IRect bounds of Clip. ##
# getDrawFilter                    # Legacy; to be deprecated. ##
# getGrContext                     # Returns GPU_Context of the GPU_Surface. ##
# getLocalClipBounds               # Returns Clip bounds in source coordinates. ##
# getMetaData                      # Associates additional data with the canvas. ##
# getProps                         # Copies Surface_Properties if available. ##
# getSaveCount                     # Returns depth of stack containing Clip and Matrix. ##
# getTotalMatrix                   # Returns Matrix. ##
# imageInfo                        # Returns Image_Info for Canvas. ##
# isClipEmpty                      # Returns if Clip is empty. ##
# isClipRect                       # Returns if Clip is Rect and not empty. ##
# MakeRasterDirect                 # Creates Canvas from SkImageInfo and pixel data. ##
# MakeRasterDirectN32              # Creates Canvas from image specifications and pixel data. ##
# makeSurface                      # Creates Surface matching SkImageInfo and SkSurfaceProps. ##
# peekPixels                       # Returns if Canvas has direct access to its pixels. ##
# quickReject                      # Returns if Rect is outside Clip. ##
# readPixels                       # Copies and converts rectangle of pixels from Canvas. ##
# resetMatrix                      # Resets Matrix to identity. ##
# restore()                        # Restores changes to Clip and Matrix, pops save stack. ##
# restoreToCount                   # Restores changes to Clip and Matrix to given depth. ##
# rotate()                         # Rotates Matrix. ##
# save()                           # Saves Clip and Matrix on stack. ##
# saveLayer                        # Saves Clip and Matrix on stack; creates Layer. ##
# saveLayerAlpha                   # Saves Clip and Matrix on stack; creates Layer; sets opacity. ##
# saveLayerPreserveLCDTextRequests # Saves Clip and Matrix on stack; creates Layer for LCD text. ##
# scale()                          # Scales Matrix. ##
# setAllowSimplifyClip             # Experimental. ##
# setDrawFilter                    # Legacy; to be deprecated. ##
# setMatrix                        # Sets Matrix. ##
# skew()                           # Skews Matrix. #
# translate()                      # Translates Matrix. ##
# writePixels                      # Copies and converts rectangle of pixels to Canvas. ##
#Table ##
#Subtopic ##

#Topic Overview ##

# ------------------------------------------------------------------------------

#Method static std::unique_ptr<SkCanvas> MakeRasterDirect(const SkImageInfo& info, void* pixels,
                                                          size_t rowBytes,
                                                          const SkSurfaceProps* props = nullptr)

Allocates raster Canvas that will draw directly into pixels.

Canvas is returned if all parameters are valid.
Valid parameters include:
info dimensions are zero or positive;
info contains Image_Color_Type and Image_Alpha_Type supported by Raster_Surface;
pixels is not nullptr;
rowBytes is zero or large enough to contain info width pixels of Image_Color_Type.

Pass zero for rowBytes to compute rowBytes from info width and size of pixel. 
If rowBytes is greater than zero, it must be equal to or greater than
info width times bytes required for Image_Color_Type.

Pixel buffer size should be info height times computed rowBytes.
Pixels are not initialized.
To access pixels after drawing, call flush() or peekPixels.

#Param info  width, height, Image_Color_Type, Image_Alpha_Type, Color_Space, of Raster_Surface;
             width, or height, or both, may be zero
##
#Param pixels  pointer to destination pixels buffer
##
#Param rowBytes  interval from one Surface row to the next, or zero
##
#Param props  LCD striping orientation and setting for device independent fonts;
              may be nullptr
##

#Return  Canvas if all parameters are valid; otherwise, nullptr ##

#Example
    #Description
        Allocates a three by three bitmap, clears it to white, and draws a black pixel
        in the center.
    ##
void draw(SkCanvas* ) {
    SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3);  // device aligned, 32 bpp, Premultiplied
    const size_t minRowBytes = info.minRowBytes();  // bytes used by one bitmap row
    const size_t size = info.computeMinByteSize();  // bytes used by all rows
    SkAutoTMalloc<SkPMColor> storage(size);  // allocate storage for pixels
    SkPMColor* pixels = storage.get();  // get pointer to allocated storage
    // create a SkCanvas backed by a raster device, and delete it when the
    // function goes out of scope.
    std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirect(info, pixels, minRowBytes);
    canvas->clear(SK_ColorWHITE);  // white is Unpremultiplied, in ARGB order
    canvas->flush();  // ensure that pixels are cleared
    SkPMColor pmWhite = pixels[0];  // the Premultiplied format may vary
    SkPaint paint;  // by default, draws black
    canvas->drawPoint(1, 1, paint);  // draw in the center
    canvas->flush();  // ensure that point was drawn
    for (int y = 0; y < info.height(); ++y) {
        for (int x = 0; x < info.width(); ++x) {
            SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
        }
        SkDebugf("\n");
    }
}
    #StdOut
        ---
        -x-
        ---
    ##
##

#SeeAlso MakeRasterDirectN32 SkSurface::MakeRasterDirect

##

# ------------------------------------------------------------------------------

#Method static std::unique_ptr<SkCanvas> MakeRasterDirectN32(int width, int height, SkPMColor* pixels,
                                                         size_t rowBytes) 

Allocates raster Canvas specified by inline image specification. Subsequent Canvas
calls draw into pixels.
Image_Color_Type is set to kN32_SkColorType.
Image_Alpha_Type is set to kPremul_SkAlphaType.
To access pixels after drawing, call flush() or peekPixels.

Canvas is returned if all parameters are valid.
Valid parameters include:
width and height are zero or positive;
pixels is not nullptr;
rowBytes is zero or large enough to contain width pixels of kN32_SkColorType.

Pass zero for rowBytes to compute rowBytes from width and size of pixel. 
If rowBytes is greater than zero, it must be equal to or greater than
width times bytes required for Image_Color_Type.

Pixel buffer size should be height times rowBytes.

#Param width  pixel column count on Raster_Surface created; must be zero or greater ##
#Param height  pixel row count on Raster_Surface created; must be zero or greater ##
#Param pixels  pointer to destination pixels buffer; buffer size should be height
               times rowBytes
##
#Param rowBytes  interval from one Surface row to the next, or zero
##

#Return  Canvas if all parameters are valid; otherwise, nullptr ##

#Example
    #Description
        Allocates a three by three bitmap, clears it to white, and draws a black pixel
        in the center.
    ##
void draw(SkCanvas* ) {
    const int width = 3;
    const int height = 3;
    SkPMColor pixels[height][width];  // allocate a 3x3 Premultiplied bitmap on the stack
    // create a SkCanvas backed by a raster device, and delete it when the
    // function goes out of scope.
    std::unique_ptr<SkCanvas> canvas = SkCanvas::MakeRasterDirectN32(
            width,
            height,
            pixels[0],  // top-left of the bitmap
            sizeof(pixels[0]));  // byte width of the each row
    // write a premultiplied value for white into all pixels in the bitmap
    canvas->clear(SK_ColorWHITE);
    SkPMColor pmWhite = pixels[0][0];  // the Premultiplied format may vary
    SkPaint paint;  // by default, draws black
    canvas->drawPoint(1, 1, paint);  // draw in the center
    canvas->flush();  // ensure that pixels is ready to be read
    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < width; ++x) {
            SkDebugf("%c", pixels[y][x] == pmWhite ? '-' : 'x');
        }
        SkDebugf("\n");
    }
}
    #StdOut
        ---
        -x-
        ---
    ##
##

#SeeAlso MakeRasterDirect SkSurface::MakeRasterDirect SkImageInfo::MakeN32Premul

##

# ------------------------------------------------------------------------------

#Method SkCanvas()

Creates an empty Canvas with no backing device or pixels, with 
a width and height of zero.

#Return  empty Canvas ##

#Example

#Description
Passes a placeholder to a function that requires one.
##

#Function
// Returns true if either the canvas rotates the text by 90 degrees, or the paint does.
static void check_for_up_and_down_text(const SkCanvas* canvas, const SkPaint& paint) {
    bool paintHasVertical = paint.isVerticalText();
    const SkMatrix& matrix = canvas->getTotalMatrix();
    bool matrixIsVertical = matrix.preservesRightAngles() && !matrix.isScaleTranslate();
    SkDebugf("paint draws text %s\n", paintHasVertical != matrixIsVertical ?
            "top to bottom" : "left to right");
}

static void check_for_up_and_down_text(const SkPaint& paint) {
    SkCanvas canvas;  // placeholder only, does not have an associated device
    check_for_up_and_down_text(&canvas, paint);
}

##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    check_for_up_and_down_text(paint);  // paint draws text left to right
    paint.setVerticalText(true);
    check_for_up_and_down_text(paint);  // paint draws text top to bottom
    paint.setVerticalText(false);
    canvas->rotate(90);
    check_for_up_and_down_text(canvas, paint);  // paint draws text top to bottom
}

    #StdOut
        paint draws text left to right
        paint draws text top to bottom
        paint draws text top to bottom
    ##
##

#SeeAlso MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas

##

# ------------------------------------------------------------------------------

#Method SkCanvas(int width, int height, const SkSurfaceProps* props = nullptr)

Creates Canvas of the specified dimensions without a Surface.
Used by Subclasses with custom implementations for draw methods.

If props equals nullptr, Surface_Properties are created with
Surface_Properties_Legacy_Font_Host settings, which choose the pixel striping 
direction and order. Since a platform may dynamically change its direction when
the device is rotated, and since a platform may have multiple monitors with
different characteristics, it is best not to rely on this legacy behavior.

#Param width  zero or greater ##
#Param height zero or greater ##
#Param props  LCD striping orientation and setting for device independent fonts;
              may be nullptr
##

#Return       Canvas placeholder with dimensions ##

#Example
    SkCanvas canvas(10, 20);  // 10 units wide, 20 units high
    canvas.clipRect(SkRect::MakeXYWH(30, 40, 5, 10));  // clip is outside canvas' device
    SkDebugf("canvas %s empty\n", canvas.getDeviceClipBounds().isEmpty() ? "is" : "is not");

    #StdOut
        canvas is empty
    ##
##

#SeeAlso MakeRasterDirect SkSurfaceProps SkPixelGeometry SkCreateColorSpaceXformCanvas

##

# ------------------------------------------------------------------------------

#Method explicit SkCanvas(SkBaseDevice* device)

Construct a canvas that draws into device.
Used by child classes of SkCanvas.

#ToDo  Since SkBaseDevice is private, shouldn't this be private also? ##

#Param device   specifies a device for the canvas to draw into ##

#Return         Canvas that can be used to draw into device ##

#Example
#Error "Unsure how to create a meaningful example."
 SkPDFCanvas::SkPDFCanvas(const sk_sp<SkPDFDevice>& dev)
    : SkCanvas(dev.get()) {}
##

#ToDo either remove doc or figure out a way to fiddle it ##

#SeeAlso MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas

##

# ------------------------------------------------------------------------------

#Method explicit SkCanvas(const SkBitmap& bitmap)

Construct a canvas that draws into bitmap.
Sets SkSurfaceProps::kLegacyFontHost_InitType in constructed Surface. 

Bitmap is copied so that subsequently editing bitmap will not affect
constructed Canvas.

May be deprecated in the future.

#ToDo Should be deprecated? ##

#Param bitmap   width, height, Image_Color_Type, Image_Alpha_Type, and pixel
                storage of Raster_Surface
##

#Return         Canvas that can be used to draw into bitmap ##

#Example
#Description
The actual output depends on the installed fonts.
##
    SkBitmap bitmap;
    // create a bitmap 5 wide and 11 high
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(5, 11));
    SkCanvas canvas(bitmap);
    canvas.clear(SK_ColorWHITE);  // white is Unpremultiplied, in ARGB order
    SkPixmap pixmap;  // provides guaranteed access to the drawn pixels
    if (!canvas.peekPixels(&pixmap)) {
        SkDebugf("peekPixels should never fail.\n");
    }
    const SkPMColor* pixels = pixmap.addr32();  // points to top-left of bitmap
    SkPMColor pmWhite = pixels[0];  // the Premultiplied format may vary
    SkPaint paint;  // by default, draws black, 12 point text
    canvas.drawString("!", 1, 10, paint);  // 1 char at baseline (1, 10)
    for (int y = 0; y < bitmap.height(); ++y) {
        for (int x = 0; x < bitmap.width(); ++x) {
            SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
        }
        SkDebugf("\n");
    }

    #StdOut
    -----
    ---x-
    ---x-
    ---x-
    ---x-
    ---x-
    ---x-
    -----
    ---x-
    ---x-
    -----
    #StdOut ##
##

#SeeAlso MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas

##

#EnumClass ColorBehavior

#Private
Android framework only.
##

#Code
    enum class ColorBehavior {
        kLegacy,
    };
##
#Const kLegacy 0
    Is a placeholder to allow specialized constructor; has no meaning.
##
##

#Method SkCanvas(const SkBitmap& bitmap, ColorBehavior behavior)

#Private
Android framework only.
##

#Param bitmap    specifies a bitmap for the canvas to draw into ##
#Param behavior  specializes this constructor; value is unused ##
#Return          Canvas that can be used to draw into bitmap ##

#NoExample
##
##

# ------------------------------------------------------------------------------

#Method SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)

Construct a canvas that draws into bitmap.
Use props to match the device characteristics, like LCD striping.

bitmap is copied so that subsequently editing bitmap will not affect
constructed Canvas.

#Param bitmap   width, height, Image_Color_Type, Image_Alpha_Type,
                and pixel storage of Raster_Surface 
##
#Param props    order and orientation of RGB striping; and whether to use
                device independent fonts
##

#Return         Canvas that can be used to draw into bitmap ##

#Example
#Description
The actual output depends on the installed fonts.
##
    SkBitmap bitmap;
    // create a bitmap 5 wide and 11 high
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(5, 11));
    SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
    canvas.clear(SK_ColorWHITE);  // white is Unpremultiplied, in ARGB order
    SkPixmap pixmap;  // provides guaranteed access to the drawn pixels
    if (!canvas.peekPixels(&pixmap)) {
        SkDebugf("peekPixels should never fail.\n");
    }
    const SkPMColor* pixels = pixmap.addr32();  // points to top-left of bitmap
    SkPMColor pmWhite = pixels[0];  // the Premultiplied format may vary
    SkPaint paint;  // by default, draws black, 12 point text
    canvas.drawString("!", 1, 10, paint);  // 1 char at baseline (1, 10)
    for (int y = 0; y < bitmap.height(); ++y) {
        for (int x = 0; x < bitmap.width(); ++x) {
            SkDebugf("%c", *pixels++ == pmWhite ? '-' : 'x');
        }
        SkDebugf("\n");
    }

    #StdOut
    -----
    ---x-
    ---x-
    ---x-
    ---x-
    ---x-
    ---x-
    -----
    ---x-
    ---x-
    -----
    #StdOut ##
##

#SeeAlso MakeRasterDirect SkRasterHandleAllocator::MakeCanvas SkSurface::getCanvas SkCreateColorSpaceXformCanvas

##

# ------------------------------------------------------------------------------

#Method virtual ~SkCanvas()

Draw saved Layers, if any.
Free up resources used by Canvas.

#Example
#Description
Canvas Layer draws into bitmap. saveLayerAlpha sets up an additional
drawing surface that blends with the bitmap. When Layer goes out of
scope, Layer Destructor is called. The saved Layer is restored, drawing
transparent letters.
##
void draw(SkCanvas* canvas) {
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(200, 200));
    {
        SkCanvas offscreen(bitmap);
        SkPaint paint;
        paint.setTextSize(100);
        offscreen.drawString("ABC", 20, 160, paint);
        SkRect layerBounds = SkRect::MakeXYWH(32, 32, 192, 192);
        offscreen.saveLayerAlpha(&layerBounds, 128);
        offscreen.clear(SK_ColorWHITE);
        offscreen.drawString("DEF", 20, 160, paint);
    }
    canvas->drawBitmap(bitmap, 0, 0, nullptr);
}
##

#SeeAlso State_Stack

##

# ------------------------------------------------------------------------------

#Method SkMetaData& getMetaData()

Returns storage to associate additional data with the canvas.
The storage is freed when Canvas is deleted.

#Return  storage that can be read from and written to ##

#Example
    const char* kHelloMetaData = "HelloMetaData";
    SkCanvas canvas;
    SkMetaData& metaData = canvas.getMetaData();
    SkDebugf("before: %s\n", metaData.findString(kHelloMetaData));
    metaData.setString(kHelloMetaData, "Hello!");
    SkDebugf("during: %s\n", metaData.findString(kHelloMetaData));
    metaData.removeString(kHelloMetaData);
    SkDebugf("after: %s\n", metaData.findString(kHelloMetaData));

    #StdOut
        before: (null)
        during: Hello!
        after: (null)
    #StdOut ##
##

#SeeAlso SkMetaData

##

# ------------------------------------------------------------------------------

#Method SkImageInfo imageInfo() const

Returns Image_Info for Canvas. If Canvas is not associated with Raster_Surface or
GPU_Surface, returned Image_Color_Type is set to kUnknown_SkColorType.

#Return  dimensions and Image_Color_Type of Canvas ##

#Example
    SkCanvas emptyCanvas;
    SkImageInfo canvasInfo = emptyCanvas.imageInfo();
    SkImageInfo emptyInfo;
    SkDebugf("emptyInfo %c= canvasInfo\n", emptyInfo == canvasInfo ? '=' : '!');

    #StdOut
        emptyInfo == canvasInfo
    ##
##

#SeeAlso SkImageInfo MakeRasterDirect makeSurface

##

# ------------------------------------------------------------------------------

#Method bool getProps(SkSurfaceProps* props) const

If Canvas is associated with Raster_Surface or
GPU_Surface, copies Surface_Properties and returns true. Otherwise,
return false and leave props unchanged.

#Param props  storage for writable SkSurfaceProps ##

#Return  true if Surface_Properties was copied ##

#ToDo This seems old style. Deprecate? ##

#Example
    SkBitmap bitmap;
    SkCanvas canvas(bitmap, SkSurfaceProps(0, kRGB_V_SkPixelGeometry));
    SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry);
    SkDebugf("isRGB:%d\n", SkPixelGeometryIsRGB(surfaceProps.pixelGeometry()));
    if (!canvas.getProps(&surfaceProps)) {
        SkDebugf("getProps failed unexpectedly.\n");
    }
    SkDebugf("isRGB:%d\n", SkPixelGeometryIsRGB(surfaceProps.pixelGeometry()));

    #StdOut
        isRGB:0
        isRGB:1
    #StdOut ##
##

#SeeAlso SkSurfaceProps makeSurface

##

# ------------------------------------------------------------------------------

#Method void flush()

Triggers the immediate execution of all pending draw operations. 
If Canvas is associated with GPU_Surface, resolves all pending GPU operations.
If Canvas is associated with Raster_Surface, has no effect; raster draw
operations are never deferred.

#ToDo
In an overview section on managing the GPU, include:
- flush should never change what is drawn
- call to kick off gpu work
- calling too much impacts performance
- some calls (peekPixels, prepareForExternalIO) call it internally
- canvas call is local, GrContext::flush is global
- diffentiate between flush, flushAndSignalSemaphores
- normally never needs to be called
- call it when sharing gpu resources, feeling memory pressure, swapping out app, and before
  abandoning context
- also call to say "I'm finished drawing here", e.g., when drawing to a GPU-backed offscreen surface
  (created with SkSurface::MakeRenderTarget)

for posterity: this doesn't show a difference: fiddle.skia.org/c/@flushfail
##

#Example
#Error "haven't thought of a useful example to put here"
##

#SeeAlso peekPixels SkSurface::flush() GrContext::flush() SkSurface::prepareForExternalIO GrContext::abandonContext()

##

# ------------------------------------------------------------------------------

#Method virtual SkISize getBaseLayerSize() const

Gets the size of the base or root Layer in global canvas coordinates. The
origin of the base Layer is always (0,0). The area available for drawing may be
smaller (due to clipping or saveLayer).

#Return  integral width and height of base Layer ##

#Example
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(20, 30));
    SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
    canvas.clipRect(SkRect::MakeWH(10, 40));
    SkIRect clipDeviceBounds = canvas.getDeviceClipBounds();
    if (clipDeviceBounds.isEmpty()) {
        SkDebugf("Empty clip bounds is unexpected!\n");
    }
    SkDebugf("clip=%d,%d\n", clipDeviceBounds.width(), clipDeviceBounds.height());
    SkISize baseLayerSize = canvas.getBaseLayerSize();
    SkDebugf("size=%d,%d\n", baseLayerSize.width(), baseLayerSize.height());

    #StdOut
        clip=10,30
        size=20,30
    ##
##

#ToDo is this the same as the width and height of surface? ##

#SeeAlso getDeviceClipBounds

##

# ------------------------------------------------------------------------------

#Method sk_sp<SkSurface> makeSurface(const SkImageInfo& info, const SkSurfaceProps* props = nullptr)

Creates Surface matching info and props, and associates it with Canvas.
Returns nullptr if no match found.

If props is nullptr, matches Surface_Properties in Canvas. If props is nullptr and Canvas
does not have Surface_Properties, creates Surface with default Surface_Properties.

#Param info  width, height, Image_Color_Type, Image_Alpha_Type, and Color_Space ##
#Param props  Surface_Properties to match; may be nullptr to match Canvas ##

#Return  Surface matching info and props, or nullptr if no match is available ##

#Example
    sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(5, 6);
    SkCanvas* smallCanvas = surface->getCanvas();
    SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(3, 4);
    sk_sp<SkSurface> compatible = smallCanvas->makeSurface(imageInfo);
    SkDebugf("compatible %c= nullptr\n", compatible == nullptr ? '=' : '!');
    SkDebugf("size = %d, %d\n", compatible->width(), compatible->height());

    #StdOut
        compatible != nullptr
        size = 3, 4
    ##
##

#SeeAlso SkSurface SkSurface::makeSurface SkImageInfo SkSurfaceProps

##

# ------------------------------------------------------------------------------

#Method virtual GrContext* getGrContext()

Returns GPU_Context of the GPU_Surface associated with Canvas.

#Return GPU_Context, if available; nullptr otherwise ##

#Example
void draw(SkCanvas* canvas) {
    if (canvas->getGrContext()) {
         canvas->clear(SK_ColorRED);
    } else {
         canvas->clear(SK_ColorBLUE);
    }
}
##

#ToDo fiddle should show both CPU and GPU out ##

#SeeAlso GrContext 

##

# ------------------------------------------------------------------------------

#Method void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin = nullptr)

Returns the pixel base address, Image_Info, rowBytes, and origin if the pixels
can be read directly. The returned address is only valid
while Canvas is in scope and unchanged. Any Canvas call or Surface call
may invalidate the returned address and other returned values.

If pixels are inaccessible, info, rowBytes, and origin are unchanged.

#Param info      storage for writable pixels' Image_Info; may be nullptr ##
#Param rowBytes  storage for writable pixels' row bytes; may be nullptr ##
#Param origin    storage for Canvas top Layer origin, its top-left corner;
                 may be nullptr
##

#Return  address of pixels, or nullptr if inaccessible ##

#Example
void draw(SkCanvas* canvas) {
    if (canvas->accessTopLayerPixels(nullptr, nullptr)) {
         canvas->clear(SK_ColorRED);
    } else {
         canvas->clear(SK_ColorBLUE);
    }
}
##

#Example
#Description
Draws "ABC" on the device. Then draws "DEF" in Layer, and reads
Layer to add a large dotted "DEF". Finally blends Layer with the
device. 

The Layer and blended result appear on the CPU and GPU but the large dotted
"DEF" appear only on the CPU.
##
void draw(SkCanvas* canvas) {
  SkPaint paint;
  paint.setTextSize(100);
  canvas->drawString("ABC", 20, 160, paint);
  SkRect layerBounds = SkRect::MakeXYWH(32, 32, 192, 192);
  canvas->saveLayerAlpha(&layerBounds, 128);
  canvas->clear(SK_ColorWHITE);
  canvas->drawString("DEF", 20, 160, paint);
  SkImageInfo imageInfo;
  size_t rowBytes;
  SkIPoint origin;
  uint32_t* access = (uint32_t*) canvas->accessTopLayerPixels(&imageInfo, &rowBytes, &origin);
  if (access) {
    int h = imageInfo.height();
    int v = imageInfo.width();
    int rowWords = rowBytes / sizeof(uint32_t);
    for (int y = 0; y < h; ++y) {
        int newY = (y - h / 2) * 2 + h / 2;
        if (newY < 0 || newY >= h) {
            continue;
        }
        for (int x = 0; x < v; ++x) {
            int newX = (x - v / 2) * 2 + v / 2;
            if (newX < 0 || newX >= v) {
                continue;
            }
            if (access[y * rowWords + x] == SK_ColorBLACK) {
                access[newY * rowWords + newX] = SK_ColorGRAY;
            }
        }
    }

  }
  canvas->restore();
}
##

#ToDo there are no callers of this that I can find. Deprecate? ##
#ToDo fiddle should show both CPU and GPU out ##

#SeeAlso SkImageInfo SkPixmap

##

# ------------------------------------------------------------------------------

#Method SkRasterHandleAllocator::Handle accessTopRasterHandle() const

Returns custom context that tracks the Matrix and Clip.

Use Raster_Handle_Allocator to blend Skia drawing with custom drawing, typically performed
by the host platform user interface. The custom context returned is generated by
SkRasterHandleAllocator::MakeCanvas, which creates a custom canvas with raster storage for
the drawing destination.

#Return  context of custom allocation ##

#Example
#Description
#ToDo ##
##
#Function
    static void DeleteCallback(void*, void* context) {
        delete (char*) context;
    }

    class CustomAllocator : public SkRasterHandleAllocator {
    public:
        bool allocHandle(const SkImageInfo& info, Rec* rec) override {
            char* context = new char[4]{'s', 'k', 'i', 'a'};
            rec->fReleaseProc = DeleteCallback;
            rec->fReleaseCtx = context;
            rec->fHandle = context;
            rec->fPixels = context;
            rec->fRowBytes = 4;
            return true;
        }

        void updateHandle(Handle handle, const SkMatrix& ctm, const SkIRect& clip_bounds) override {
            // apply canvas matrix and clip to custom environment
        }
    };

##
    void draw(SkCanvas* canvas) {
        const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
        std::unique_ptr<SkCanvas> c2 =
                SkRasterHandleAllocator::MakeCanvas(std::unique_ptr<CustomAllocator>(
                new CustomAllocator()), info);
        char* context = (char*) c2->accessTopRasterHandle();
        SkDebugf("context = %.4s\n", context);

    }
    #StdOut
        context = skia
    ##
    #ToDo skstd::make_unique could not be used because def is private -- note to fix in c++14? ##
##

#SeeAlso SkRasterHandleAllocator

##

# ------------------------------------------------------------------------------

#Method bool peekPixels(SkPixmap* pixmap)

Returns true if Canvas has direct access to its pixels.

Pixels are readable when Device is raster. Pixels are not readable when Canvas
is returned from GPU_Surface, returned by SkDocument::beginPage, returned by
SkPictureRecorder::beginRecording, or Canvas is the base of a utility class
like SkDumpCanvas.

pixmap is valid only while Canvas is in scope and unchanged. Any
Canvas or Surface call may invalidate the pixmap values.

#Param pixmap  storage for pixel state if pixels are readable; otherwise, ignored ##

#Return  true if Canvas has direct access to pixels ##

#Example
    SkPixmap pixmap;
    if (canvas->peekPixels(&pixmap)) {
        SkDebugf("width=%d height=%d\n", pixmap.bounds().width(), pixmap.bounds().height());
    }
    #StdOut
        width=256 height=256
    ##
##

#SeeAlso readPixels SkBitmap::peekPixels SkImage::peekPixels SkSurface::peekPixels

##

# ------------------------------------------------------------------------------

#Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
                    int srcX, int srcY)

Copies Rect of pixels from Canvas into dstPixels. Matrix and Clip are
ignored. 

Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination Rect corners are (0, 0) and (dstInfo.width(), dstInfo.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to dstInfo.colorType() and dstInfo.alphaType() if required.

Pixels are readable when Device is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
class like SkDumpCanvas.

The destination pixel storage must be allocated by the caller.

Pixel values are converted only if Image_Color_Type and Image_Alpha_Type
do not match. Only pixels within both source and destination rectangles
are copied. dstPixels contents outside Rect intersection are unchanged.

Pass negative values for srcX or srcY to offset pixels across or down destination.

Does not copy, and returns false if:

#List
# Source and destination rectangles do not intersect. ##
# Canvas pixels could not be converted to dstInfo.colorType() or dstInfo.alphaType(). ##
# Canvas pixels are not readable; for instance, Canvas is document-based. ##
# dstRowBytes is too small to contain one row of pixels. ##
##

#Param dstInfo  width, height, Image_Color_Type, and Image_Alpha_Type of dstPixels ##
#Param dstPixels  storage for pixels; dstInfo.height() times dstRowBytes, or larger ##
#Param dstRowBytes  size of one destination row; dstInfo.width() times pixel size, or larger ##
#Param srcX  offset into readable pixels in x; may be negative ##
#Param srcY  offset into readable pixels in y; may be negative ##

#Return  true if pixels were copied ##

#Example
#Width 64
#Height 64
#Description
    A black circle drawn on a blue background provides an image to copy.
    readPixels copies one quarter of the canvas into each of the four corners.
    The copied quarter circles overdraw the original circle.
##
    canvas->clear(SK_ColorBLUE);
    SkPaint paint;
    canvas->drawCircle(32, 32, 28, paint);
    SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
    sk_sp<SkData> data(SkData::MakeUninitialized(info.minRowBytes() * info.height()));
    sk_bzero(data->writable_data(), info.minRowBytes() * info.height());
    for (int x : { 32, -32 } ) {
        for (int y : { 32, -32 } ) {
            canvas->readPixels(info, data->writable_data(), info.minRowBytes(), x, y);
        } 
    }
    sk_sp<SkImage> image = SkImage::MakeRasterData(info, data, info.minRowBytes());
    canvas->drawImage(image, 0, 0);
##

#Example
#Description
    Canvas returned by Raster_Surface has Premultiplied pixel values.
    clear() takes Unpremultiplied input with Color_Alpha equal 0x80
    and Color_RGB equal 0x55, 0xAA, 0xFF. Color_RGB is multiplied by Color_Alpha
    to generate Premultiplied value 0x802B5580. readPixels converts pixel back
    to Unpremultiplied value 0x8056A9FF, introducing error.
##
    canvas->clear(0x8055aaff);
    for (SkAlphaType alphaType : { kPremul_SkAlphaType, kUnpremul_SkAlphaType } ) {
        uint32_t pixel = 0;
        SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, alphaType);
        if (canvas->readPixels(info, &pixel, 4, 0, 0)) {
            SkDebugf("pixel = %08x\n", pixel);
        }
    }

    #StdOut
        pixel = 802b5580
        pixel = 8056a9ff
    ##
##

#SeeAlso peekPixels writePixels drawBitmap drawImage SkBitmap::readPixels SkPixmap::readPixels SkImage::readPixels SkSurface::readPixels

##

# ------------------------------------------------------------------------------

#Method bool readPixels(const SkPixmap& pixmap, int srcX, int srcY)

Copies Rect of pixels from Canvas into pixmap. Matrix and Clip are
ignored.

Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination Rect corners are (0, 0) and (pixmap.width(), pixmap.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to pixmap.colorType() and pixmap.alphaType() if required.

Pixels are readable when Device is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
class like SkDumpCanvas.

Caller must allocate pixel storage in pixmap if needed.

Pixel values are converted only if Image_Color_Type and Image_Alpha_Type
do not match. Only pixels within both source and destination Rects
are copied. pixmap pixels contents outside Rect intersection are unchanged.

Pass negative values for srcX or srcY to offset pixels across or down pixmap.

Does not copy, and returns false if:

#List
# Source and destination rectangles do not intersect. ##
# Canvas pixels could not be converted to pixmap.colorType() or pixmap.alphaType(). ##
# Canvas pixels are not readable; for instance, Canvas is document-based. ##
# Pixmap pixels could not be allocated. ##
# pixmap.rowBytes() is too small to contain one row of pixels. ##
##

#Param pixmap  storage for pixels copied from Canvas ##
#Param srcX    offset into readable pixels in x; may be negative ##
#Param srcY    offset into readable pixels in y; may be negative ##

#Return  true if pixels were copied ##

#Example
    #Description
        clear() takes Unpremultiplied input with Color_Alpha equal 0x80
        and Color_RGB equal 0x55, 0xAA, 0xFF. Color_RGB is multiplied by Color_Alpha
        to generate Premultiplied value 0x802B5580.
    ##
    void draw(SkCanvas* canvas) {
        canvas->clear(0x8055aaff);
        uint32_t pixels[1] = { 0 };
        SkPixmap pixmap(SkImageInfo::MakeN32Premul(1, 1), pixels, 4);
        canvas->readPixels(pixmap, 0, 0);
        SkDebugf("pixel = %08x\n", pixels[0]);
    }
    #StdOut
        pixel = 802b5580
    ##
##

#SeeAlso peekPixels writePixels drawBitmap drawImage SkBitmap::readPixels SkPixmap::readPixels SkImage::readPixels SkSurface::readPixels

##

# ------------------------------------------------------------------------------

#Method bool readPixels(const SkBitmap& bitmap, int srcX, int srcY)

Copies Rect of pixels from Canvas into bitmap. Matrix and Clip are
ignored.

Source Rect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
Destination Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to bitmap.colorType() and bitmap.alphaType() if required.

Pixels are readable when Device is raster, or backed by a GPU.
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
class like SkDumpCanvas.

Caller must allocate pixel storage in bitmap if needed.

Bitmap values are converted only if Image_Color_Type and Image_Alpha_Type
do not match. Only pixels within both source and destination rectangles
are copied. Bitmap pixels outside Rect intersection are unchanged.

Pass negative values for srcX or srcY to offset pixels across or down bitmap.

Does not copy, and returns false if:

#List
# Source and destination rectangles do not intersect. ##
# Canvas pixels could not be converted to bitmap.colorType() or bitmap.alphaType(). ##
# Canvas pixels are not readable; for instance, Canvas is document-based. ##
# bitmap pixels could not be allocated. ##
# bitmap.rowBytes() is too small to contain one row of pixels. ##
##

#Param bitmap  storage for pixels copied from Canvas ##
#Param srcX    offset into readable pixels in x; may be negative ##
#Param srcY    offset into readable pixels in y; may be negative ##

#Return  true if pixels were copied ##

#Example
    #Description
        clear() takes Unpremultiplied input with Color_Alpha equal 0x80
        and Color_RGB equal 0x55, 0xAA, 0xFF. Color_RGB is multiplied by Color_Alpha
        to generate Premultiplied value 0x802B5580.
    ##
void draw(SkCanvas* canvas) {
    canvas->clear(0x8055aaff);
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1));
    canvas->readPixels(bitmap, 0, 0);
    SkDebugf("pixel = %08x\n", bitmap.getAddr32(0, 0)[0]);
}
    #StdOut
        pixel = 802b5580
    ##
##

#SeeAlso peekPixels writePixels drawBitmap drawImage SkBitmap::readPixels SkPixmap::readPixels SkImage::readPixels SkSurface::readPixels

##

# ------------------------------------------------------------------------------

#Method bool writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y)

Copies Rect from pixels to Canvas. Matrix and Clip are ignored.
Source Rect corners are (0, 0) and (info.width(), info.height()).
Destination Rect corners are (x, y) and
(imageInfo().width(), imageInfo().height()).

Copies each readable pixel intersecting both rectangles, without scaling,
converting to imageInfo().colorType() and imageInfo().alphaType() if required.

Pixels are writable when Device is raster, or backed by a GPU.
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
class like SkDumpCanvas.

Pixel values are converted only if Image_Color_Type and Image_Alpha_Type
do not match. Only pixels within both source and destination rectangles
are copied. Canvas pixels outside Rect intersection are unchanged.

Pass negative values for x or y to offset pixels to the left or
above Canvas pixels.

Does not copy, and returns false if:

#List
# Source and destination rectangles do not intersect. ##
# pixels could not be converted to this->imageInfo().colorType() or
this->imageInfo().alphaType(). ##
# Canvas pixels are not writable; for instance, Canvas is document-based. ##
# rowBytes is too small to contain one row of pixels. ##
##

#Param info  width, height, Image_Color_Type, and Image_Alpha_Type of pixels ##
#Param pixels  pixels to copy, of size info.height() times rowBytes, or larger ##
#Param rowBytes  size of one row of pixels; info.width() times pixel size, or larger ##
#Param x  offset into Canvas writable pixels in x; may be negative ##
#Param y  offset into Canvas writable pixels in y; may be negative ##

#Return  true if pixels were written to Canvas ##

#Example
    SkImageInfo imageInfo = SkImageInfo::MakeN32(256, 1, kPremul_SkAlphaType);
    for (int y = 0; y < 256; ++y) {
        uint32_t pixels[256];
        for (int x = 0; x < 256; ++x) {
            pixels[x] = SkColorSetARGB(x, x + y, x, x - y);
        }
        canvas->writePixels(imageInfo, &pixels, sizeof(pixels), 0, y);
    }
##

#SeeAlso readPixels drawBitmap drawImage SkBitmap::writePixels

##

# ------------------------------------------------------------------------------

#Method bool writePixels(const SkBitmap& bitmap, int x, int y)

Copies Rect from pixels to Canvas. Matrix and Clip are ignored.
Source Rect corners are (0, 0) and (bitmap.width(), bitmap.height()).

Destination Rect corners are (x, y) and
(imageInfo().width(), imageInfo().height()).

Copies each readable pixel intersecting both rectangles, without scaling,
converting to imageInfo().colorType() and imageInfo().alphaType() if required.

Pixels are writable when Device is raster, or backed by a GPU.
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
returned by SkPictureRecorder::beginRecording, or Canvas is the base of a utility
class like SkDumpCanvas.

Pixel values are converted only if Image_Color_Type and Image_Alpha_Type
do not match. Only pixels within both source and destination rectangles
are copied. Canvas pixels outside Rect intersection are unchanged.

Pass negative values for x or y to offset pixels to the left or
above Canvas pixels.

Does not copy, and returns false if:

#List
# Source and destination rectangles do not intersect. ##
# bitmap does not have allocated pixels. ##
# bitmap pixels could not be converted to this->imageInfo().colorType() or
this->imageInfo().alphaType(). ##
# Canvas pixels are not writable; for instance, Canvas is document based. ##
# bitmap pixels are inaccessible; for instance, bitmap wraps a texture. ##
##

#Param bitmap  contains pixels copied to Canvas ##
#Param x       offset into Canvas writable pixels in x; may be negative ##
#Param y       offset into Canvas writable pixels in y; may be negative ##

#Return  true if pixels were written to Canvas ##

#Example
void draw(SkCanvas* canvas) {
    SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(2, 2);
    SkBitmap bitmap;
    bitmap.setInfo(imageInfo);
    uint32_t pixels[4];
    bitmap.setPixels(pixels);
    for (int y = 0; y < 256; y += 2) {
        for (int x = 0; x < 256;  x += 2) {
            pixels[0] = SkColorSetRGB(x, y, x | y);
            pixels[1] = SkColorSetRGB(x ^ y, y, x);
            pixels[2] = SkColorSetRGB(x, x & y, y);
            pixels[3] = SkColorSetRGB(~x, ~y, x);
            canvas->writePixels(bitmap, x, y);
        }
    }
}
##

#SeeAlso readPixels drawBitmap drawImage SkBitmap::writePixels

##

# ------------------------------------------------------------------------------
#Topic State_Stack

Canvas maintains a stack of state that allows hierarchical drawing, commonly used
to implement windows and views. The initial state has an identity matrix and and
an infinite clip. Even with a wide-open clip, drawing is constrained by the
bounds of the Canvas Surface or Device.

Canvas savable state consists of Clip, Matrix, and Draw_Filter.
Clip describes the area that may be drawn to.
Matrix transforms the geometry.
Draw_Filter (deprecated on most platforms) modifies the paint before drawing.

save(), saveLayer, saveLayerPreserveLCDTextRequests, and saveLayerAlpha
save state and return the depth of the stack.

restore(), restoreToCount, and ~SkCanvas() revert state to its value when saved.

Each state on the stack intersects Clip with the previous Clip,
and concatenates Matrix with the previous Matrix.
The intersected Clip makes the drawing area the same or smaller;
the concatenated Matrix may move the origin and potentially scale or rotate
the coordinate space.

Canvas does not require balancing the state stack but it is a good idea
to do so. Calling save() without restore() will eventually cause Skia to fail;
mismatched save() and restore() create hard to find bugs.

It is not possible to use state to draw outside of the clip defined by the
previous state.

#Example
#Description
Draw to ever smaller clips; then restore drawing to full canvas.
Note that the second clipRect is not permitted to enlarge Clip.
##
#Height 160
void draw(SkCanvas* canvas) {
    SkPaint paint;
    canvas->save();                             // records stack depth to restore  
    canvas->clipRect(SkRect::MakeWH(100, 100)); // constrains drawing to clip
    canvas->clear(SK_ColorRED);                 // draws to limit of clip
    canvas->save();                             // records stack depth to restore 
    canvas->clipRect(SkRect::MakeWH(50, 150));  // Rect below 100 is ignored
    canvas->clear(SK_ColorBLUE);                // draws to smaller clip
    canvas->restore();                          // enlarges clip
    canvas->drawLine(20, 20, 150, 150, paint);  // line below 100 is not drawn
    canvas->restore();                          // enlarges clip
    canvas->drawLine(150, 20, 50, 120, paint);  // line below 100 is drawn
}
## 

Each Clip uses the current Matrix for its coordinates.

#Example
#Description
While clipRect is given the same rectangle twice, Matrix makes the second
clipRect draw at half the size of the first.
##
#Height 128
void draw(SkCanvas* canvas) {
    canvas->clipRect(SkRect::MakeWH(100, 100));
    canvas->clear(SK_ColorRED);
    canvas->scale(.5, .5);
    canvas->clipRect(SkRect::MakeWH(100, 100));
    canvas->clear(SK_ColorBLUE);
}
##

#SeeAlso save() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha restore() restoreToCount

#Method int save()

Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms).
Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
restoring the Matrix, Clip, and Draw_Filter to their state when save() was called.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix,
and resetMatrix. Clip may be changed by clipRect, clipRRect, clipPath, clipRegion.

Saved Canvas state is put on a stack; multiple calls to save() should be balance
by an equal number of calls to restore().

Call restoreToCount with result to restore this and subsequent saves.

#Return depth of saved stack ##

#Example
#Description 
The black square is translated 50 pixels down and to the right.
Restoring Canvas state removes translate() from Canvas stack;
the red square is not translated, and is drawn at the origin.
##
#Height 100
void draw(SkCanvas* canvas) {
    SkPaint paint;
    SkRect rect = { 0, 0, 25, 25 };
    canvas->drawRect(rect, paint);
    canvas->save();
    canvas->translate(50, 50);
    canvas->drawRect(rect, paint);
    canvas->restore();
    paint.setColor(SK_ColorRED);
    canvas->drawRect(rect, paint);
}
##

#SeeAlso saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha restore() restoreToCount

##

# ------------------------------------------------------------------------------

#Method void restore()

Removes changes to Matrix, Clip, and Draw_Filter since Canvas state was
last saved. The state is removed from the stack. 

Does nothing if the stack is empty. 

#Example
void draw(SkCanvas* canvas) {
    SkCanvas simple;
    SkDebugf("depth = %d\n", simple.getSaveCount());
    simple.restore();
    SkDebugf("depth = %d\n", simple.getSaveCount());
}
##

#SeeAlso save() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha restoreToCount

##

# ------------------------------------------------------------------------------

#Method int getSaveCount() const

Returns the number of saved states, each containing: Matrix, Clip, and Draw_Filter.
Equals the number of save() calls less the number of restore() calls plus one. 
The save count of a new canvas is one.

#Return  depth of save state stack ##

#Example
void draw(SkCanvas* canvas) {
    SkCanvas simple;
    SkDebugf("depth = %d\n", simple.getSaveCount());
    simple.save();
    SkDebugf("depth = %d\n", simple.getSaveCount());
    simple.restore();
    SkDebugf("depth = %d\n", simple.getSaveCount());
}
#StdOut
depth = 1
depth = 2
depth = 1
##
##

#SeeAlso save() restore() restoreToCount

##

# ------------------------------------------------------------------------------

#Method void restoreToCount(int saveCount)

Restores state to Matrix, Clip, and Draw_Filter values when save(), saveLayer,
saveLayerPreserveLCDTextRequests, or saveLayerAlpha returned saveCount.

Does nothing if saveCount is greater than state stack count. 
Restores state to initial values if saveCount is less than or equal to one.

#Param saveCount    depth of state stack to restore ##

#Example
void draw(SkCanvas* canvas) {
    SkDebugf("depth = %d\n", canvas->getSaveCount());
    canvas->save();
    canvas->save();
    SkDebugf("depth = %d\n", canvas->getSaveCount());
    canvas->restoreToCount(0);
    SkDebugf("depth = %d\n", canvas->getSaveCount());
}
#StdOut
depth = 1
depth = 3
depth = 1
##
##

#SeeAlso restore() getSaveCount save() 

##

#Topic State_Stack ##

# ------------------------------------------------------------------------------

#Topic Layer
#Substitute layer
#Alias Layers

Layer allocates a temporary Bitmap to draw into. When the drawing is
complete, the Bitmap is drawn into the Canvas. 

Layer is saved in a stack along with other saved state. When state with a Layer
is restored, the Bitmap is drawn into the previous Layer.

Layer may be initialized with the contents of the previous Layer. When Layer is
restored, its Bitmap can be modified by Paint passed to Layer to apply
Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode.

#Method int saveLayer(const SkRect* bounds, const SkPaint* paint)

Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms),
and allocates a Bitmap for subsequent drawing.
Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
and draws the Bitmap.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect, 
clipPath, clipRegion.

Rect bounds suggests but does not define the Bitmap size. To clip drawing to
a specific rectangle, use clipRect.

Optional Paint paint applies Color_Alpha, Color_Filter, Image_Filter, and
Blend_Mode when restore() is called.

Call restoreToCount with returned value to restore this and subsequent saves.

#Param bounds  hint to limit the size of the Layer; may be nullptr ##
#Param paint   graphics state for Layer; may be nullptr ##

#Return        depth of saved stack ##

#Example
#Description
Rectangles are blurred by Image_Filter when restore() draws Layer to main
Canvas.
##
#Height 128
void draw(SkCanvas* canvas) {
    SkPaint paint, blur;
    blur.setImageFilter(SkBlurImageFilter::Make(3, 3, nullptr));
    canvas->saveLayer(nullptr, &blur);
    SkRect rect = { 25, 25, 50, 50};
    canvas->drawRect(rect, paint);
    canvas->translate(50, 50);
    paint.setColor(SK_ColorRED);
    canvas->drawRect(rect, paint);
    canvas->restore();
}
##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha SaveLayerRec

##

#Method int saveLayer(const SkRect& bounds, const SkPaint* paint) 

Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms),
and allocates a Bitmap for subsequent drawing.
Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
and draws the Bitmap.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
clipPath, clipRegion.

Rect bounds suggests but does not define the Layer size. To clip drawing to
a specific rectangle, use clipRect.

Optional Paint paint applies Color_Alpha, Color_Filter, Image_Filter, and
Blend_Mode when restore() is called.

Call restoreToCount with returned value to restore this and subsequent saves.

#Param bounds  hint to limit the size of Layer; may be nullptr ##
#Param paint   graphics state for Layer; may be nullptr ##

#Return        depth of saved stack ##

#Example
#Description
Rectangles are blurred by Image_Filter when restore() draws Layer to main Canvas.
The red rectangle is clipped; it does not fully fit on Layer. 
Image_Filter blurs past edge of Layer so red rectangle is blurred on all sides.
##
#Height 128
void draw(SkCanvas* canvas) {
    SkPaint paint, blur;
    blur.setImageFilter(SkBlurImageFilter::Make(3, 3, nullptr));
    canvas->saveLayer(SkRect::MakeWH(90, 90), &blur);
    SkRect rect = { 25, 25, 50, 50};
    canvas->drawRect(rect, paint);
    canvas->translate(50, 50);
    paint.setColor(SK_ColorRED);
    canvas->drawRect(rect, paint);
    canvas->restore();
}
##

#SeeAlso save() restore() saveLayerPreserveLCDTextRequests saveLayerAlpha SaveLayerRec

##

#Method int saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPaint* paint)

Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms),
and allocates a Bitmap for subsequent drawing.
LCD_Text is preserved when the Layer is drawn to the prior Layer.

Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
and draws Layer.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
clipPath, clipRegion.
  
Rect bounds suggests but does not define the Layer size. To clip drawing to
a specific rectangle, use clipRect.

Optional Paint paint applies Color_Alpha, Color_Filter, Image_Filter, and
Blend_Mode when restore() is called.

Call restoreToCount with returned value to restore this and subsequent saves.

Draw text on an opaque background so that LCD_Text blends correctly with the
prior Layer. LCD_Text drawn on a background with transparency may result in
incorrect blending.

#Param bounds  hint to limit the size of Layer; may be nullptr ##
#Param paint   graphics state for Layer; may be nullptr ##

#Return        depth of saved stack ##

#Example
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setLCDRenderText(true);
    paint.setTextSize(20);
    for (auto preserve : { false, true } ) {
        preserve ? canvas->saveLayerPreserveLCDTextRequests(nullptr, nullptr)
                 : canvas->saveLayer(nullptr, nullptr);
        SkPaint p;
        p.setColor(SK_ColorWHITE);
        // Comment out the next line to draw on a non-opaque background.
        canvas->drawRect(SkRect::MakeLTRB(25, 40, 200, 70), p);
        canvas->drawString("Hamburgefons", 30, 60, paint);

        p.setColor(0xFFCCCCCC);
        canvas->drawRect(SkRect::MakeLTRB(25, 70, 200, 100), p);
        canvas->drawString("Hamburgefons", 30, 90, paint);

        canvas->restore();
        canvas->translate(0, 80);
    }
    ##

#SeeAlso save() restore() saveLayer saveLayerAlpha SaveLayerRec

##

#Method int saveLayerAlpha(const SkRect* bounds, U8CPU alpha)

Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms),
and allocates Bitmap for subsequent drawing.

Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
and blends Layer with alpha opacity onto prior Layer.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
clipPath, clipRegion.

Rect bounds suggests but does not define Layer size. To clip drawing to
a specific rectangle, use clipRect.

alpha of zero is fully transparent, 255 is fully opaque.

Call restoreToCount with returned value to restore this and subsequent saves.

#Param bounds  hint to limit the size of Layer; may be nullptr ##
#Param alpha   opacity of Layer ##

#Return  depth of saved stack ##

#Example
    SkPaint paint;
    paint.setColor(SK_ColorRED);
    canvas->drawCircle(50, 50, 50, paint);
    canvas->saveLayerAlpha(nullptr, 128);
    paint.setColor(SK_ColorBLUE);
    canvas->drawCircle(100, 50, 50, paint);
    paint.setColor(SK_ColorGREEN);
    paint.setAlpha(128);
    canvas->drawCircle(75, 90, 50, paint);
    canvas->restore();
##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests SaveLayerRec

##

#Enum

#Code
    enum {
        kIsOpaque_SaveLayerFlag = 1 << 0,
        kPreserveLCDText_SaveLayerFlag = 1 << 1,
        kInitWithPrevious_SaveLayerFlag = 1 << 2,
        kDontClipToLayer_Legacy_SaveLayerFlag = kDontClipToLayer_PrivateSaveLayerFlag,
    };
##

SaveLayerFlags provides options that may be used in any combination in SaveLayerRec,
defining how Layer allocated by saveLayer operates.

#Const kIsOpaque_SaveLayerFlag 1
  Creates Layer without transparency. Flag is ignored if Layer Paint contains
  Image_Filter or Color_Filter.
##

#Const kPreserveLCDText_SaveLayerFlag 2
  Creates Layer for LCD text. Flag is ignored if Layer Paint contains
  Image_Filter or Color_Filter.
##

#Const kInitWithPrevious_SaveLayerFlag 4
  Initializes Layer with the contents of the previous Layer.
##

#Const kDontClipToLayer_Legacy_SaveLayerFlag 0x80000000
#Private
  to be deprecated: bug.skia.org/2440
##
  Only present on Android.
  Skips setting a clip to the Layer bounds. 
##

#Example
#Height 160
#Description
Canvas Layer captures red and blue circles scaled up by four.
scalePaint blends Layer back with transparency. 
##
void draw(SkCanvas* canvas) {
    SkPaint redPaint, bluePaint, scalePaint;
    redPaint.setColor(SK_ColorRED);
    canvas->drawCircle(21, 21, 8, redPaint);
    bluePaint.setColor(SK_ColorBLUE);
    canvas->drawCircle(31, 21, 8, bluePaint);
    SkMatrix matrix;
    matrix.setScale(4, 4);
    scalePaint.setAlpha(0x40);
    scalePaint.setImageFilter(
            SkImageFilter::MakeMatrixFilter(matrix, kNone_SkFilterQuality, nullptr));
    SkCanvas::SaveLayerRec saveLayerRec(nullptr, &scalePaint,
            SkCanvas::kInitWithPrevious_SaveLayerFlag); 
    canvas->saveLayer(saveLayerRec);
    canvas->restore();
}
##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha SaveLayerRec

#Enum ##

#Typedef uint32_t SaveLayerFlags

##

#Struct SaveLayerRec

#Code
    struct SaveLayerRec {
        SaveLayerRec*(...

        const SkRect*           fBounds;
        const SkPaint*          fPaint;
        const SkImageFilter*    fBackdrop;
        SaveLayerFlags          fSaveLayerFlags;
    };
##

SaveLayerRec contains the state used to create the Layer. 

#Member const SkRect*           fBounds
    fBounds is used as a hint to limit the size of Layer; may be nullptr.
    fBounds suggests but does not define Layer size. To clip drawing to
    a specific rectangle, use clipRect.
##

#Member const SkPaint*          fPaint
    fPaint modifies how Layer overlays the prior Layer; may be nullptr.
    Color_Alpha, Blend_Mode, Color_Filter, Draw_Looper, Image_Filter, and
    Mask_Filter affect Layer draw.
##

#Member const SkImageFilter*    fBackdrop
    fBackdrop applies Image_Filter to the prior Layer when copying to the Layer;
    may be nullptr. Use kInitWithPrevious_SaveLayerFlag to copy the
    prior Layer without an Image_Filter.
##

#Member const SkImage*          fClipMask
  restore() clips Layer by the Color_Alpha channel of fClipMask when
  Layer is copied to Device. fClipMask may be nullptr.    .
##

#Member const SkMatrix*         fClipMatrix
  fClipMatrix transforms fClipMask before it clips Layer. If 
  fClipMask describes a translucent gradient, it may be scaled and rotated
  without introducing artifacts. fClipMatrix may be nullptr.
##

#Member SaveLayerFlags          fSaveLayerFlags
    fSaveLayerFlags are used to create Layer without transparency,
    create Layer for LCD text, and to create Layer with the
    contents of the previous Layer.
##

#Example
#Height 160
#Description
Canvas Layer captures a red Anti-aliased circle and a blue Aliased circle scaled
up by four. After drawing another red circle without scaling on top, the Layer is
transferred to the main canvas. 
##
void draw(SkCanvas* canvas) {
    SkPaint redPaint, bluePaint;
    redPaint.setAntiAlias(true);
    redPaint.setColor(SK_ColorRED);
    canvas->drawCircle(21, 21, 8, redPaint);
    bluePaint.setColor(SK_ColorBLUE);
    canvas->drawCircle(31, 21, 8, bluePaint);
    SkMatrix matrix;
    matrix.setScale(4, 4);
    auto scaler = SkImageFilter::MakeMatrixFilter(matrix, kNone_SkFilterQuality, nullptr);
    SkCanvas::SaveLayerRec saveLayerRec(nullptr, nullptr, scaler.get(), 0); 
    canvas->saveLayer(saveLayerRec);
    canvas->drawCircle(125, 85, 8, redPaint);
    canvas->restore();
}
##

#Method SaveLayerRec()

Sets fBounds, fPaint, and fBackdrop to nullptr. Clears fSaveLayerFlags.

#Return  empty SaveLayerRec ##

#Example
    SkCanvas::SaveLayerRec rec1;
    rec1.fSaveLayerFlags = SkCanvas::kIsOpaque_SaveLayerFlag;
    SkCanvas::SaveLayerRec rec2(nullptr, nullptr, SkCanvas::kIsOpaque_SaveLayerFlag);
    SkDebugf("rec1 %c= rec2\n", rec1.fBounds == rec2.fBounds
            && rec1.fPaint == rec2.fPaint
            && rec1.fBackdrop == rec2.fBackdrop
            && rec1.fSaveLayerFlags == rec2.fSaveLayerFlags ? '=' : '!');
    #StdOut
        rec1 == rec2
    ##
##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha

##

#Method SaveLayerRec(const SkRect* bounds, const SkPaint* paint, SaveLayerFlags saveLayerFlags = 0)

Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr.

#Param bounds  Layer dimensions; may be nullptr ##
#Param paint  applied to Layer when overlaying prior Layer; may be nullptr ##
#Param saveLayerFlags  SaveLayerRec options to modify Layer ##

#Return  SaveLayerRec with empty backdrop ##

#Example
    SkCanvas::SaveLayerRec rec1;
    SkCanvas::SaveLayerRec rec2(nullptr, nullptr);
    SkDebugf("rec1 %c= rec2\n", rec1.fBounds == rec2.fBounds
            && rec1.fPaint == rec2.fPaint
            && rec1.fBackdrop == rec2.fBackdrop
            && rec1.fSaveLayerFlags == rec2.fSaveLayerFlags ? '=' : '!');
    #StdOut
        rec1 == rec2
    ##
##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha

##

#Method SaveLayerRec(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop,
                     SaveLayerFlags saveLayerFlags)

Sets fBounds, fPaint, fBackdrop, and fSaveLayerFlags.

#Param bounds          Layer dimensions; may be nullptr ##
#Param paint           applied to Layer when overlaying prior Layer;
                       may be nullptr
##
#Param backdrop        prior Layer copied with Image_Filter; may be nullptr
##
#Param saveLayerFlags  SaveLayerRec options to modify Layer ##

#Return  SaveLayerRec fully specified ##

#Example
    SkCanvas::SaveLayerRec rec1;
    SkCanvas::SaveLayerRec rec2(nullptr, nullptr, nullptr, 0);
    SkDebugf("rec1 %c= rec2\n", rec1.fBounds == rec2.fBounds
            && rec1.fPaint == rec2.fPaint
            && rec1.fBackdrop == rec2.fBackdrop
            && rec1.fSaveLayerFlags == rec2.fSaveLayerFlags ? '=' : '!');
    #StdOut
        rec1 == rec2
    ##
##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha

##

#Method SaveLayerRec(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop,
                     const SkImage* clipMask, const SkMatrix* clipMatrix,
                     SaveLayerFlags saveLayerFlags)

#Experimental
Not ready for general use.
##

Sets fBounds, fPaint, fBackdrop, fClipMask, fClipMatrix, and fSaveLayerFlags.
clipMatrix uses Color_Alpha channel of image, transformed by clipMatrix, to clip
Layer when drawn to Canvas.

Implementation is not complete; has no effect if Device is GPU-backed.

#Param bounds          Layer dimensions; may be nullptr ##
#Param paint           graphics state applied to Layer when overlaying prior
                       Layer; may be nullptr
##
#Param backdrop        prior Layer copied with Image_Filter;
                       may be nullptr
##
#Param clipMask        clip applied to Layer; may be nullptr ##
#Param clipMatrix      matrix applied to clipMask; may be nullptr to use
                       identity matrix 
##
#Param saveLayerFlags  SaveLayerRec options to modify Layer ##

#Return                SaveLayerRec fully specified ##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha

##

#Struct ##

#Method int saveLayer(const SaveLayerRec& layerRec)

Saves Matrix, Clip, and Draw_Filter (Draw_Filter deprecated on most platforms),
and allocates Bitmap for subsequent drawing.

Calling restore() discards changes to Matrix, Clip, and Draw_Filter,
and blends Bitmap with Color_Alpha opacity onto the prior Layer.

Matrix may be changed by translate(), scale(), rotate(), skew(), concat(),
setMatrix, and resetMatrix. Clip may be changed by clipRect, clipRRect,
clipPath, clipRegion.

SaveLayerRec contains the state used to create the Layer.

Call restoreToCount with returned value to restore this and subsequent saves.

#Param layerRec  Layer state ##

#Return          depth of save state stack ##

#Example
#Description
The example draws an image, and saves it into a Layer with kInitWithPrevious_SaveLayerFlag.
Next it punches a hole in Layer and restore with SkBlendMode::kPlus.
Where Layer was cleared, the original image will draw unchanged.
Outside of the circle the mandrill is brightened.
##
    #Image 3
    // sk_sp<SkImage> image = GetResourceAsImage("images/mandrill_256.png");
    canvas->drawImage(image, 0, 0, nullptr);
    SkCanvas::SaveLayerRec rec;
    SkPaint paint;
    paint.setBlendMode(SkBlendMode::kPlus);
    rec.fSaveLayerFlags = SkCanvas::kInitWithPrevious_SaveLayerFlag;
    rec.fPaint = &paint;
    canvas->saveLayer(rec);
    paint.setBlendMode(SkBlendMode::kClear);
    canvas->drawCircle(128, 128, 96, paint);
    canvas->restore();
##

#ToDo above example needs to replace GetResourceAsImage with way to select image in fiddle ##

#SeeAlso save() restore() saveLayer saveLayerPreserveLCDTextRequests saveLayerAlpha

##

#Topic Layer ##

# ------------------------------------------------------------------------------
#Topic Matrix

#Method void translate(SkScalar dx, SkScalar dy)

Translate Matrix by dx along the x-axis and dy along the y-axis.

Mathematically, replace Matrix with a translation matrix
Premultiplied with Matrix. 

This has the effect of moving the drawing by (dx, dy) before transforming
the result with Matrix.

#Param  dx   distance to translate in x ##
#Param  dy   distance to translate in y ##

#Example
#Height 128
#Description
scale() followed by translate() produces different results from translate() followed
by scale(). 

The blue stroke follows translate of (50, 50); a black
fill follows scale of (2, 1/2.f). After restoring the clip, which resets 
Matrix, a red frame follows the same scale of (2, 1/2.f); a gray fill
follows translate of (50, 50).
##
void draw(SkCanvas* canvas) {
    SkPaint filledPaint;
    SkPaint outlinePaint;
    outlinePaint.setStyle(SkPaint::kStroke_Style);
    outlinePaint.setColor(SK_ColorBLUE);
    canvas->save();
    canvas->translate(50, 50);
    canvas->drawCircle(28, 28, 15, outlinePaint);  // blue center: (50+28, 50+28)
    canvas->scale(2, 1/2.f);
    canvas->drawCircle(28, 28, 15, filledPaint);   // black center: (50+(28*2), 50+(28/2))
    canvas->restore();
    filledPaint.setColor(SK_ColorGRAY);
    outlinePaint.setColor(SK_ColorRED);
    canvas->scale(2, 1/2.f);
    canvas->drawCircle(28, 28, 15, outlinePaint);  // red center: (28*2, 28/2)
    canvas->translate(50, 50);
    canvas->drawCircle(28, 28, 15, filledPaint);   // gray center: ((50+28)*2, (50+28)/2)
}
##

#SeeAlso concat() scale() skew() rotate() setMatrix

##

# ------------------------------------------------------------------------------

#Method void scale(SkScalar sx, SkScalar sy)

Scale Matrix by sx on the x-axis and sy on the y-axis.

Mathematically, replace Matrix with a scale matrix
Premultiplied with Matrix. 

This has the effect of scaling the drawing by (sx, sy) before transforming
the result with Matrix.

#Param  sx   amount to scale in x ##
#Param  sy   amount to scale in y ##

#Example
#Height 160
void draw(SkCanvas* canvas) {
    SkPaint paint;
    SkRect rect = { 10, 20, 60, 120 };
    canvas->translate(20, 20);
    canvas->drawRect(rect, paint);
    canvas->scale(2, .5f);
    paint.setColor(SK_ColorGRAY);
    canvas->drawRect(rect, paint);
}
##

#SeeAlso concat() translate() skew() rotate() setMatrix

##

# ------------------------------------------------------------------------------

#Method void rotate(SkScalar degrees)

Rotate Matrix by degrees. Positive degrees rotates clockwise.

Mathematically, replace Matrix with a rotation matrix
Premultiplied with Matrix. 

This has the effect of rotating the drawing by degrees before transforming
the result with Matrix.

#Param  degrees  amount to rotate, in degrees ##

#Example
#Description
Draw clock hands at time 5:10. The hour hand and minute hand point up and
are rotated clockwise.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setStyle(SkPaint::kStroke_Style);
    canvas->translate(128, 128);
    canvas->drawCircle(0, 0, 60, paint);
    canvas->save();
    canvas->rotate(10 * 360 / 60);   // 10 minutes of 60 scaled to 360 degrees
    canvas->drawLine(0, 0, 0, -50, paint); 
    canvas->restore();
    canvas->rotate((5 + 10.f/60) * 360 / 12); // 5 and 10/60 hours of 12 scaled to 360 degrees
    canvas->drawLine(0, 0, 0, -30, paint);
}
##

#SeeAlso concat() translate() skew() scale() setMatrix

##

# ------------------------------------------------------------------------------

#Method void rotate(SkScalar degrees, SkScalar px, SkScalar py)

Rotate Matrix by degrees about a point at (px, py). Positive degrees rotates
clockwise.

Mathematically, construct a rotation matrix. Premultiply the rotation matrix by
a translation matrix, then replace Matrix with the resulting matrix
Premultiplied with Matrix. 

This has the effect of rotating the drawing about a given point before
transforming the result with Matrix.

#Param  degrees  amount to rotate, in degrees ##
#Param  px  x-coordinate of the point to rotate about ##
#Param  py  y-coordinate of the point to rotate about ##

#Example
#Height 192
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setTextSize(96);
    canvas->drawString("A1", 130, 100, paint);
    canvas->rotate(180, 130, 100);
    canvas->drawString("A1", 130, 100, paint);
}
##

#SeeAlso concat() translate() skew() scale() setMatrix

##

# ------------------------------------------------------------------------------

#Method void skew(SkScalar sx, SkScalar sy)

Skew Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx
skews the drawing right as y increases; a positive value of sy skews the drawing
down as x increases.

Mathematically, replace Matrix with a skew matrix Premultiplied with Matrix. 

This has the effect of skewing the drawing by (sx, sy) before transforming
the result with Matrix.

#Param  sx   amount to skew in x ##
#Param  sy   amount to skew in y ##

#Example
    #Description 
        Black text mimics an oblique text style by using a negative skew in x that
        shifts the geometry to the right as the y values decrease.
        Red text uses a positive skew in y to shift the geometry down as the x values
        increase.
        Blue text combines x and y skew to rotate and scale.
    ##
    SkPaint paint;
    paint.setTextSize(128);
    canvas->translate(30, 130);
    canvas->save();
    canvas->skew(-.5, 0);
    canvas->drawString("A1", 0, 0, paint);
    canvas->restore();
    canvas->save();
    canvas->skew(0, .5);
    paint.setColor(SK_ColorRED);
    canvas->drawString("A1", 0, 0, paint);
    canvas->restore();
    canvas->skew(-.5, .5);
    paint.setColor(SK_ColorBLUE);
    canvas->drawString("A1", 0, 0, paint);
##

#SeeAlso concat() translate() rotate() scale() setMatrix

##

# ------------------------------------------------------------------------------

#Method void concat(const SkMatrix& matrix)

Replace Matrix with matrix Premultiplied with existing Matrix.

This has the effect of transforming the drawn geometry by matrix, before
transforming the result with existing Matrix.

#Param  matrix   matrix to Premultiply with existing Matrix ##

#Example
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setTextSize(80);
    paint.setTextScaleX(.3);
    SkMatrix matrix;
    SkRect rect[2] = {{ 10, 20, 90, 110 }, { 40, 130, 140, 180 }};
    matrix.setRectToRect(rect[0], rect[1], SkMatrix::kFill_ScaleToFit);
    canvas->drawRect(rect[0], paint);
    canvas->drawRect(rect[1], paint);
    paint.setColor(SK_ColorWHITE);
    canvas->drawString("Here", rect[0].fLeft + 10, rect[0].fBottom - 10, paint);
    canvas->concat(matrix);
    canvas->drawString("There", rect[0].fLeft + 10, rect[0].fBottom - 10, paint);
}
##

#SeeAlso translate() rotate() scale() skew() setMatrix

##

# ------------------------------------------------------------------------------

#Method void setMatrix(const SkMatrix& matrix)

Replace Matrix with matrix.
Unlike concat(), any prior matrix state is overwritten.

#Param  matrix  matrix to copy, replacing existing Matrix ##

#Example
#Height 128
void draw(SkCanvas* canvas) {
    SkPaint paint;
    canvas->scale(4, 6);
    canvas->drawString("truth", 2, 10, paint);
    SkMatrix matrix;
    matrix.setScale(2.8f, 6);
    canvas->setMatrix(matrix);
    canvas->drawString("consequences", 2, 20, paint);
}
##

#SeeAlso resetMatrix concat() translate() rotate() scale() skew()

##

# ------------------------------------------------------------------------------

#Method void resetMatrix()

Sets Matrix to the identity matrix.
Any prior matrix state is overwritten.

#Example
#Height 128
void draw(SkCanvas* canvas) {
    SkPaint paint;
    canvas->scale(4, 6);
    canvas->drawString("truth", 2, 10, paint);
    canvas->resetMatrix();
    canvas->scale(2.8f, 6);
    canvas->drawString("consequences", 2, 20, paint);
}
##

#SeeAlso setMatrix concat() translate() rotate() scale() skew()

##

# ------------------------------------------------------------------------------

#Method const SkMatrix& getTotalMatrix() const

Returns Matrix.
This does not account for translation by Device or Surface.

#Return Matrix in Canvas ##

#Example
    SkDebugf("isIdentity %s\n", canvas->getTotalMatrix().isIdentity() ? "true" : "false");
    #StdOut
        isIdentity true
    ##
##

#SeeAlso setMatrix resetMatrix concat()

##

#Topic Matrix ##

# ------------------------------------------------------------------------------
#Topic Clip

Clip is built from a stack of clipping paths. Each Path in the
stack can be constructed from one or more Path_Contour elements. The 
Path_Contour may be composed of any number of Path_Verb segments. Each
Path_Contour forms a closed area; Path_Fill_Type defines the area enclosed
by Path_Contour.

Clip stack of Path elements successfully restrict the Path area. Each
Path is transformed by Matrix, then intersected with or subtracted from the 
prior Clip to form the replacement Clip. Use SkClipOp::kDifference
to subtract Path from Clip; use SkClipOp::kIntersect to intersect Path
with Clip.

A clipping Path may be Anti-aliased; if Path, after transformation, is
composed of horizontal and vertical lines, clearing Anti-alias allows whole pixels
to either be inside or outside the clip. The fastest drawing has a Aliased,
rectangular clip.

If clipping Path has Anti-alias set, clip may partially clip a pixel, requiring
that drawing blend partially with the destination along the edge. A rotated 
rectangular Anti-aliased clip looks smoother but draws slower.

Clip can combine with Rect and Round_Rect primitives; like
Path, these are transformed by Matrix before they are combined with Clip.

Clip can combine with Region. Region is assumed to be in Device coordinates
and is unaffected by Matrix.

#Example
#Height 90
    #Description
        Draw a red circle with an Aliased clip and an Anti-aliased clip.
        Use an image filter to zoom into the pixels drawn.
        The edge of the Aliased clip fully draws pixels in the red circle.
        The edge of the Anti-aliased clip partially draws pixels in the red circle.
    ##
    SkPaint redPaint, scalePaint;
    redPaint.setAntiAlias(true);
    redPaint.setColor(SK_ColorRED);
    canvas->save();
    for (bool antialias : { false, true } ) {
        canvas->save();
        canvas->clipRect(SkRect::MakeWH(19.5f, 11.5f), antialias);
        canvas->drawCircle(17, 11, 8, redPaint);
        canvas->restore();
        canvas->translate(16, 0);
    }
    canvas->restore();
    SkMatrix matrix;
    matrix.setScale(6, 6);
    scalePaint.setImageFilter(
            SkImageFilter::MakeMatrixFilter(matrix, kNone_SkFilterQuality, nullptr));
    SkCanvas::SaveLayerRec saveLayerRec(
            nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag); 
    canvas->saveLayer(saveLayerRec);
    canvas->restore();
##

#Method void clipRect(const SkRect& rect, SkClipOp op, bool doAntiAlias)

Replace Clip with the intersection or difference of Clip and rect,
with an Aliased or Anti-aliased clip edge. rect is transformed by Matrix
before it is combined with Clip.

#Param  rect  Rect to combine with Clip ##
#Param  op    Clip_Op to apply to Clip ##
#Param  doAntiAlias  true if Clip is to be Anti-aliased ##

#Example
#Height 128
void draw(SkCanvas* canvas) {
    canvas->rotate(10);
    SkPaint paint;
    paint.setAntiAlias(true);
    for (auto alias: { false, true } ) {
        canvas->save();
        canvas->clipRect(SkRect::MakeWH(90, 80), SkClipOp::kIntersect, alias);
        canvas->drawCircle(100, 60, 60, paint);
        canvas->restore();
        canvas->translate(80, 0);
    }
}
##

#SeeAlso clipRRect clipPath clipRegion

##

#Method void clipRect(const SkRect& rect, SkClipOp op) 

Replace Clip with the intersection or difference of Clip and rect.
Resulting Clip is Aliased; pixels are fully contained by the clip.
rect is transformed by Matrix before it is combined with Clip.

#Param  rect  Rect to combine with Clip ##
#Param  op    Clip_Op to apply to Clip ##

#Example
#Height 192
#Width 280
void draw(SkCanvas* canvas) {
    SkPaint paint;
    for (SkClipOp op: { SkClipOp::kIntersect, SkClipOp::kDifference } ) {
        canvas->save();
        canvas->clipRect(SkRect::MakeWH(90, 120), op, false);
        canvas->drawCircle(100, 100, 60, paint);
        canvas->restore();
        canvas->translate(80, 0);
    }
}
##

#SeeAlso clipRRect clipPath clipRegion

##

#Method void clipRect(const SkRect& rect, bool doAntiAlias = false) 

Replace Clip with the intersection of Clip and rect.
Resulting Clip is Aliased; pixels are fully contained by the clip.
rect is transformed by Matrix
before it is combined with Clip.

#Param  rect   Rect to combine with Clip ##
#Param  doAntiAlias  true if Clip is to be Anti-aliased ##

#Example
#Height 133
    #Description
        A circle drawn in pieces looks uniform when drawn Aliased.
        The same circle pieces blend with pixels more than once when Anti-aliased,
        visible as a thin pair of lines through the right circle.
    ##
void draw(SkCanvas* canvas) {
    canvas->clear(SK_ColorWHITE);
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setColor(0x8055aaff);
    SkRect clipRect = { 0, 0, 87.4f, 87.4f };
    for (auto alias: { false, true } ) {
        canvas->save();
        canvas->clipRect(clipRect, SkClipOp::kIntersect, alias);
        canvas->drawCircle(67, 67, 60, paint);
        canvas->restore();
        canvas->save();
        canvas->clipRect(clipRect, SkClipOp::kDifference, alias);
        canvas->drawCircle(67, 67, 60, paint);
        canvas->restore();
        canvas->translate(120, 0);
    }
}
##

#SeeAlso clipRRect clipPath clipRegion

##

#Method void androidFramework_setDeviceClipRestriction(const SkIRect& rect)

Sets the maximum clip rectangle, which can be set by clipRect, clipRRect and
clipPath and intersect the current clip with the specified rect.
The maximum clip affects only future clipping operations; it is not retroactive.
The clip restriction is not recorded in pictures.

Pass an empty rect to disable maximum clip. 

#Private
This is private API to be used only by Android framework.
##

#Param  rect   maximum allowed clip in device coordinates
#Param ##

##

#Method void clipRRect(const SkRRect& rrect, SkClipOp op, bool doAntiAlias)

Replace Clip with the intersection or difference of Clip and rrect,
with an Aliased or Anti-aliased clip edge.
rrect is transformed by Matrix
before it is combined with Clip.

#Param  rrect  Round_Rect to combine with Clip ##
#Param  op  Clip_Op to apply to Clip ##
#Param  doAntiAlias  true if Clip is to be Anti-aliased ##

#Example
#Height 128
void draw(SkCanvas* canvas) {
    canvas->clear(SK_ColorWHITE);
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setColor(0x8055aaff);
    SkRRect oval;
    oval.setOval({10, 20, 90, 100});
    canvas->clipRRect(oval, SkClipOp::kIntersect, true);
    canvas->drawCircle(70, 100, 60, paint);
}
##

#SeeAlso clipRect clipPath clipRegion

##

#Method void clipRRect(const SkRRect& rrect, SkClipOp op) 

Replace Clip with the intersection or difference of Clip and rrect.
Resulting Clip is Aliased; pixels are fully contained by the clip.
rrect is transformed by Matrix before it is combined with Clip.

#Param  rrect  Round_Rect to combine with Clip ##
#Param  op  Clip_Op to apply to Clip ##

#Example
#Height 128
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setColor(0x8055aaff);
    auto oval = SkRRect::MakeOval({10, 20, 90, 100});
    canvas->clipRRect(oval, SkClipOp::kIntersect);
    canvas->drawCircle(70, 100, 60, paint);
}
##

#SeeAlso clipRect clipPath clipRegion

##

#Method void clipRRect(const SkRRect& rrect, bool doAntiAlias = false) 

Replace Clip with the intersection of Clip and rrect,
with an Aliased or Anti-aliased clip edge.
rrect is transformed by Matrix before it is combined with Clip.

#Param  rrect  Round_Rect to combine with Clip ##
#Param  doAntiAlias  true if Clip is to be Anti-aliased ##

#Example
#Height 128
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    auto oval = SkRRect::MakeRectXY({10, 20, 90, 100}, 9, 13);
    canvas->clipRRect(oval, true);
    canvas->drawCircle(70, 100, 60, paint);
}
##

#SeeAlso clipRect clipPath clipRegion

##

#Method void clipPath(const SkPath& path, SkClipOp op, bool doAntiAlias)

Replace Clip with the intersection or difference of Clip and path,
with an Aliased or Anti-aliased clip edge. Path_Fill_Type determines if path
describes the area inside or outside its contours; and if Path_Contour overlaps
itself or another Path_Contour, whether the overlaps form part of the area.
path is transformed by Matrix before it is combined with Clip.

#Param  path  Path to combine with Clip ##
#Param  op  Clip_Op to apply to Clip ##
#Param  doAntiAlias  true if Clip is to be Anti-aliased ##

#Example
#Description
Top figure uses SkPath::kInverseWinding_FillType and SkClipOp::kDifference;
area outside clip is subtracted from circle.

Bottom figure uses SkPath::kWinding_FillType and SkClipOp::kIntersect;
area inside clip is intersected with circle.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPath path;
    path.addRect({20, 30, 100, 110});
    path.setFillType(SkPath::kInverseWinding_FillType);
    canvas->save();
    canvas->clipPath(path, SkClipOp::kDifference, false);
    canvas->drawCircle(70, 100, 60, paint);
    canvas->restore();
    canvas->translate(100, 100);
    path.setFillType(SkPath::kWinding_FillType);
    canvas->clipPath(path, SkClipOp::kIntersect, false);
    canvas->drawCircle(70, 100, 60, paint);
}
##

#SeeAlso clipRect clipRRect clipRegion

##

#Method void clipPath(const SkPath& path, SkClipOp op) 

Replace Clip with the intersection or difference of Clip and path.
Resulting Clip is Aliased; pixels are fully contained by the clip.
Path_Fill_Type determines if path
describes the area inside or outside its contours; and if Path_Contour overlaps
itself or another Path_Contour, whether the overlaps form part of the area.
path is transformed by Matrix
before it is combined with Clip.

#Param  path  Path to combine with Clip ##
#Param  op  Clip_Op to apply to Clip ##

#Example
#Description
Overlapping Rects form a clip. When clip Path_Fill_Type is set to
SkPath::kWinding_FillType, the overlap is included. Set to 
SkPath::kEvenOdd_FillType, the overlap is excluded and forms a hole.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPath path;
    path.addRect({20, 15, 100, 95});
    path.addRect({50, 65, 130, 135});
    path.setFillType(SkPath::kWinding_FillType);
    canvas->save();
    canvas->clipPath(path, SkClipOp::kIntersect);
    canvas->drawCircle(70, 85, 60, paint);
    canvas->restore();
    canvas->translate(100, 100);
    path.setFillType(SkPath::kEvenOdd_FillType);
    canvas->clipPath(path, SkClipOp::kIntersect);
    canvas->drawCircle(70, 85, 60, paint);
}
##

#SeeAlso clipRect clipRRect clipRegion

##

#Method void clipPath(const SkPath& path, bool doAntiAlias = false) 

Replace Clip with the intersection of Clip and path.
Resulting Clip is Aliased; pixels are fully contained by the clip.
Path_Fill_Type determines if path
describes the area inside or outside its contours; and if Path_Contour overlaps
itself or another Path_Contour, whether the overlaps form part of the area.
path is transformed by Matrix before it is combined with Clip.

#Param  path  Path to combine with Clip ##
#Param  doAntiAlias  true if Clip is to be Anti-aliased ##

#Example
#Height 212
#Description
Clip loops over itself covering its center twice. When clip Path_Fill_Type 
is set to SkPath::kWinding_FillType, the overlap is included. Set to 
SkPath::kEvenOdd_FillType, the overlap is excluded and forms a hole.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPath path;
    SkPoint poly[] = {{20, 20}, { 80, 20}, { 80,  80}, {40,  80},
                      {40, 40}, {100, 40}, {100, 100}, {20, 100}};
    path.addPoly(poly, SK_ARRAY_COUNT(poly), true);
    path.setFillType(SkPath::kWinding_FillType);
    canvas->save();
    canvas->clipPath(path, SkClipOp::kIntersect);
    canvas->drawCircle(50, 50, 45, paint);
    canvas->restore();
    canvas->translate(100, 100);
    path.setFillType(SkPath::kEvenOdd_FillType);
    canvas->clipPath(path, SkClipOp::kIntersect);
    canvas->drawCircle(50, 50, 45, paint);
}
##

#SeeAlso clipRect clipRRect clipRegion

##

# ------------------------------------------------------------------------------

#Method void setAllowSimplifyClip(bool allow) 

#Experimental
Only used for testing.
##

Set to simplify clip stack using PathOps.

##

# ------------------------------------------------------------------------------

#Method void clipRegion(const SkRegion& deviceRgn, SkClipOp op = SkClipOp::kIntersect)

Replace Clip with the intersection or difference of Clip and Region deviceRgn.
Resulting Clip is Aliased; pixels are fully contained by the clip.
deviceRgn is unaffected by Matrix.

#Param  deviceRgn    Region to combine with Clip ##
#Param  op  Clip_Op to apply to Clip ##

#Example
#Description
    region is unaffected by canvas rotation; iRect is affected by canvas rotation.
    Both clips are Aliased; this is not noticeable on Region clip because it
    aligns to pixel boundaries.
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkIRect iRect = {30, 40, 120, 130 };
    SkRegion region(iRect);
    canvas->rotate(10);
    canvas->save();
    canvas->clipRegion(region, SkClipOp::kIntersect);
    canvas->drawCircle(50, 50, 45, paint);
    canvas->restore();
    canvas->translate(100, 100);
    canvas->clipRect(SkRect::Make(iRect), SkClipOp::kIntersect);
    canvas->drawCircle(50, 50, 45, paint);
}
##

#SeeAlso clipRect clipRRect clipPath

##

#Method bool quickReject(const SkRect& rect) const

Return true if Rect rect, transformed by Matrix, can be quickly determined to be
outside of Clip. May return false even though rect is outside of Clip.

Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.

#Param  rect  Rect to compare with Clip ##

#Return  true if rect, transformed by Matrix, does not intersect Clip ##

#Example
void draw(SkCanvas* canvas) {
    SkRect testRect = {30, 30, 120, 129 }; 
    SkRect clipRect = {30, 130, 120, 230 }; 
    canvas->save();
    canvas->clipRect(clipRect);
    SkDebugf("quickReject %s\n", canvas->quickReject(testRect) ? "true" : "false");
    canvas->restore();
    canvas->rotate(10);
    canvas->clipRect(clipRect);
    SkDebugf("quickReject %s\n", canvas->quickReject(testRect) ? "true" : "false");
}
    #StdOut
        quickReject true
        quickReject false
    ##
##

#SeeAlso getLocalClipBounds getTotalMatrix SkBitmap::drawsNothing

##

#Method bool quickReject(const SkPath& path) const

Return true if path, transformed by Matrix, can be quickly determined to be
outside of Clip. May return false even though path is outside of Clip.

Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.

#Param path  Path to compare with Clip ##

#Return  true if path, transformed by Matrix, does not intersect Clip ##

#Example
void draw(SkCanvas* canvas) {
    SkPoint testPoints[] = {{30,  30}, {120,  30}, {120, 129} }; 
    SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} }; 
    SkPath testPath, clipPath;
    testPath.addPoly(testPoints, SK_ARRAY_COUNT(testPoints), true);
    clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
    canvas->save();
    canvas->clipPath(clipPath);
    SkDebugf("quickReject %s\n", canvas->quickReject(testPath) ? "true" : "false");
    canvas->restore();
    canvas->rotate(10);
    canvas->clipPath(clipPath);
    SkDebugf("quickReject %s\n", canvas->quickReject(testPath) ? "true" : "false");
    #StdOut
        quickReject true
        quickReject false
    ##
}
##

#SeeAlso getLocalClipBounds getTotalMatrix SkBitmap::drawsNothing

##

#Method SkRect getLocalClipBounds() const 

Return bounds of Clip, transformed by inverse of Matrix. If Clip is empty,
return SkRect::MakeEmpty, where all Rect sides equal zero.

Rect returned is outset by one to account for partial pixel coverage if Clip
is Anti-aliased.

#Return  bounds of Clip in local coordinates ##

#Example
    #Description 
        Initial bounds is device bounds outset by 1 on all sides.
        Clipped bounds is clipPath bounds outset by 1 on all sides.
        Scaling the canvas by two in x and y scales the local bounds by 1/2 in x and y.
    ##
    SkCanvas local(256, 256);
    canvas = &local;
    SkRect bounds = canvas->getLocalClipBounds();
    SkDebugf("left:%g  top:%g  right:%g  bottom:%g\n",
            bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
    SkPoint clipPoints[]  = {{30, 130}, {120, 130}, {120, 230} }; 
    SkPath clipPath;
    clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
    canvas->clipPath(clipPath);
    bounds = canvas->getLocalClipBounds();
    SkDebugf("left:%g  top:%g  right:%g  bottom:%g\n",
            bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
    canvas->scale(2, 2);
    bounds = canvas->getLocalClipBounds();
    SkDebugf("left:%g  top:%g  right:%g  bottom:%g\n",
            bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
    #StdOut
        left:-1  top:-1  right:257  bottom:257
        left:29  top:129  right:121  bottom:231
        left:14.5  top:64.5  right:60.5  bottom:115.5
    ##
##

# local canvas in example works around bug in fiddle ##
#Bug 6524  ##
#SeeAlso getDeviceClipBounds getBaseLayerSize quickReject

##

#Method bool getLocalClipBounds(SkRect* bounds) const 

Return bounds of Clip, transformed by inverse of Matrix. If Clip is empty,
return false, and set bounds to SkRect::MakeEmpty, where all Rect sides equal zero.

bounds is outset by one to account for partial pixel coverage if Clip
is Anti-aliased.

#Param bounds  Rect of Clip in local coordinates ##

#Return  true if Clip bounds is not empty ##

#Example
    void draw(SkCanvas* canvas) {
        SkCanvas local(256, 256);
        canvas = &local;
        SkRect bounds;
        SkDebugf("local bounds empty = %s\n", canvas->getLocalClipBounds(&bounds)
                 ? "false" : "true");
        SkPath path;
        canvas->clipPath(path);
        SkDebugf("local bounds empty = %s\n", canvas->getLocalClipBounds(&bounds)
                 ? "false" : "true");
    }
    #StdOut
        local bounds empty = false
        local bounds empty = true
    ##
##

# local canvas in example works around bug in fiddle ##
#Bug 6524  ##
#SeeAlso getDeviceClipBounds getBaseLayerSize quickReject

##

#Method SkIRect getDeviceClipBounds() const 

Return IRect bounds of Clip, unaffected by Matrix. If Clip is empty,
return SkRect::MakeEmpty, where all Rect sides equal zero.

Unlike getLocalClipBounds, returned IRect is not outset. 

#Return  bounds of Clip in Device coordinates ##

#Example
void draw(SkCanvas* canvas) {
    #Description
        Initial bounds is device bounds, not outset.
        Clipped bounds is clipPath bounds, not outset.
        Scaling the canvas by 1/2 in x and y scales the device bounds by 1/2 in x and y.
    ##
    SkCanvas device(256, 256);
    canvas = &device;
    SkIRect bounds = canvas->getDeviceClipBounds();
    SkDebugf("left:%d  top:%d  right:%d  bottom:%d\n",
            bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
    SkPoint clipPoints[]  = {{30, 130}, {120, 130}, {120, 230} }; 
    SkPath clipPath;
    clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
    canvas->save();
    canvas->clipPath(clipPath);
    bounds = canvas->getDeviceClipBounds();
    SkDebugf("left:%d  top:%d  right:%d  bottom:%d\n",
            bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
    canvas->restore();
    canvas->scale(1.f/2, 1.f/2);
    canvas->clipPath(clipPath);
    bounds = canvas->getDeviceClipBounds();
    SkDebugf("left:%d  top:%d  right:%d  bottom:%d\n",
            bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
    #StdOut
        left:0  top:0  right:256  bottom:256
        left:30  top:130  right:120  bottom:230
        left:15  top:65  right:60  bottom:115
    ##
}
##

#ToDo some confusion on why with an identity Matrix local and device are different ##
#SeeAlso getLocalClipBounds getBaseLayerSize quickReject

# device canvas in example works around bug in fiddle ##
#Bug 6524  ##

##

#Method bool getDeviceClipBounds(SkIRect* bounds) const 

Return IRect bounds of Clip, unaffected by Matrix. If Clip is empty,
return false, and set bounds to SkRect::MakeEmpty, where all Rect sides equal zero.

Unlike getLocalClipBounds, bounds is not outset. 

#Param bounds  Rect of Clip in device coordinates ##

#Return  true if Clip bounds is not empty ##

#Example
    void draw(SkCanvas* canvas) {
        SkIRect bounds;
        SkDebugf("device bounds empty = %s\n", canvas->getDeviceClipBounds(&bounds)
                 ? "false" : "true");
        SkPath path;
        canvas->clipPath(path);
        SkDebugf("device bounds empty = %s\n", canvas->getDeviceClipBounds(&bounds)
                 ? "false" : "true");
    }
    #StdOut
        device bounds empty = false
        device bounds empty = true
    ##
##

#SeeAlso getLocalClipBounds getBaseLayerSize quickReject

##

#Topic Clip ##

# ------------------------------------------------------------------------------

#Method void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver)

Fill Clip with Color color.
mode determines how Color_ARGB is combined with destination.

#Param color    Unpremultiplied Color_ARGB ##
#Param mode  SkBlendMode used to combine source color and destination ##

#Example
    canvas->drawColor(SK_ColorRED);
    canvas->clipRect(SkRect::MakeWH(150, 150));
    canvas->drawColor(SkColorSetARGB(0x80, 0x00, 0xFF, 0x00), SkBlendMode::kPlus);
    canvas->clipRect(SkRect::MakeWH(75, 75));
    canvas->drawColor(SkColorSetARGB(0x80, 0x00, 0x00, 0xFF), SkBlendMode::kPlus);
##

#SeeAlso clear SkBitmap::erase drawPaint

##

# ------------------------------------------------------------------------------

#Method void clear(SkColor color) 

Fill Clip with Color color using SkBlendMode::kSrc. 
This has the effect of replacing all pixels contained by Clip with color.

#Param color    Unpremultiplied Color_ARGB ##

#Example
void draw(SkCanvas* canvas) {
    canvas->save();
    canvas->clipRect(SkRect::MakeWH(256, 128));
    canvas->clear(SkColorSetARGB(0x80, 0xFF, 0x00, 0x00)); 
    canvas->restore();
    canvas->save();
    canvas->clipRect(SkRect::MakeWH(150, 192));
    canvas->clear(SkColorSetARGB(0x80, 0x00, 0xFF, 0x00));
    canvas->restore();
    canvas->clipRect(SkRect::MakeWH(75, 256));
    canvas->clear(SkColorSetARGB(0x80, 0x00, 0x00, 0xFF));
}
##

#SeeAlso drawColor SkBitmap::erase drawPaint

##

# ------------------------------------------------------------------------------

#Method void discard() 

Make Canvas contents undefined. Subsequent calls that read Canvas pixels,
such as drawing with SkBlendMode, return undefined results. discard() does
not change Clip or Matrix.

discard() may do nothing, depending on the implementation of Surface or Device
that created Canvas.

discard() allows optimized performance on subsequent draws by removing
cached data associated with Surface or Device.
It is not necessary to call discard() once done with Canvas;
any cached data is deleted when owning Surface or Device is deleted.

#ToDo example? not sure how to make this meaningful w/o more implementation detail ##
#SeeAlso flush() SkSurface::prepareForExternalIO GrContext::abandonContext

#NoExample 
##

##

# ------------------------------------------------------------------------------

#Method void drawPaint(const SkPaint& paint)

Fill Clip with Paint paint. Paint components Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Blend_Mode affect drawing;
Path_Effect in paint is ignored.

# can Path_Effect in paint ever alter drawPaint?

#Param  paint    graphics state used to fill Canvas ##

#Example
void draw(SkCanvas* canvas) {
    SkColor     colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
    SkScalar    pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
    SkPaint     paint;
    paint.setShader(SkGradientShader::MakeSweep(256, 256, colors, pos, SK_ARRAY_COUNT(colors)));
    canvas->drawPaint(paint);
}
##

#SeeAlso clear drawColor SkBitmap::erase

##

# ------------------------------------------------------------------------------

#Enum PointMode

#Code
    enum PointMode {
        kPoints_PointMode,
        kLines_PointMode,
        kPolygon_PointMode,
    };
##

Selects if an array of points are drawn as discrete points, as lines, or as
an open polygon.

#Const kPoints_PointMode 0
    Draw each point separately.
##

#Const kLines_PointMode 1
    Draw each pair of points as a line segment.
##

#Const kPolygon_PointMode 2
    Draw the array of points as a open polygon.
##

#Example
    #Description 
        The upper left corner shows three squares when drawn as points.
        The upper right corner shows one line; when drawn as lines, two points are required per line.
        The lower right corner shows two lines; when draw as polygon, no miter is drawn at the corner.
        The lower left corner shows two lines with a miter when path contains polygon.
    ##
void draw(SkCanvas* canvas) {
  SkPaint paint;
  paint.setStyle(SkPaint::kStroke_Style);
  paint.setStrokeWidth(10);
  SkPoint points[] = {{64, 32}, {96, 96}, {32, 96}};
  canvas->drawPoints(SkCanvas::kPoints_PointMode, 3, points, paint);
  canvas->translate(128, 0);
  canvas->drawPoints(SkCanvas::kLines_PointMode, 3, points, paint);
  canvas->translate(0, 128);
  canvas->drawPoints(SkCanvas::kPolygon_PointMode, 3, points, paint);
  SkPath path;
  path.addPoly(points, 3, false);
  canvas->translate(-128, 0);
  canvas->drawPath(path, paint);
}
##

#SeeAlso drawLine drawPoint drawPath

##

# ------------------------------------------------------------------------------

#Method void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint)

Draw pts using Clip, Matrix and Paint paint.
count is the number of points; if count is less than one, has no effect.
mode may be one of: kPoints_PointMode, kLines_PointMode, or kPolygon_PointMode.

If mode is kPoints_PointMode, the shape of point drawn depends on paint
Paint_Stroke_Cap. If paint is set to SkPaint::kRound_Cap, each point draws a
circle of diameter Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap
or SkPaint::kButt_Cap, each point draws a square of width and height
Paint_Stroke_Width.

If mode is kLines_PointMode, each pair of points draws a line segment.
One line is drawn for every two points; each point is used once. If count is odd,
the final point is ignored. 

If mode is kPolygon_PointMode, each adjacent pair of points draws a line segment.
count minus one lines are drawn; the first and last point are used once.

Each line segment respects paint Paint_Stroke_Cap and Paint_Stroke_Width.
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.

Always draws each element one at a time; is not affected by
Paint_Stroke_Join, and unlike drawPath, does not create a mask from all points
and lines before drawing. 

#Param  mode     whether pts draws points or lines ##
#Param  count    number of points in the array ##
#Param  pts      array of points to draw ##
#Param  paint    stroke, blend, color, and so on, used to draw ##

#Example
#Height 200
    #Description 
    #List
    # The first column draws points. ##
    # The second column draws points as lines. ##
    # The third column draws points as a polygon. ##
    # The fourth column draws points as a polygonal path. ##
    # The first row uses a round cap and round join. ##
    # The second row uses a square cap and a miter join. ##
    # The third row uses a butt cap and a bevel join. ##
    ##
    The transparent color makes multiple line draws visible;
    the path is drawn all at once.
    ##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(10);
    paint.setColor(0x80349a45);
    const SkPoint points[] = {{32, 16}, {48, 48}, {16, 32}};
    const SkPaint::Join join[] = { SkPaint::kRound_Join, 
                                   SkPaint::kMiter_Join,
                                   SkPaint::kBevel_Join };
    int joinIndex = 0;
    SkPath path;
    path.addPoly(points, 3, false);
    for (const auto cap : { SkPaint::kRound_Cap, SkPaint::kSquare_Cap, SkPaint::kButt_Cap } ) {
        paint.setStrokeCap(cap);
        paint.setStrokeJoin(join[joinIndex++]);
        for (const auto mode : { SkCanvas::kPoints_PointMode,
                                 SkCanvas::kLines_PointMode,
                                 SkCanvas::kPolygon_PointMode } ) {
            canvas->drawPoints(mode, 3, points, paint);
            canvas->translate(64, 0);
        }
        canvas->drawPath(path, paint);
        canvas->translate(-192, 64);
    }
}
##

#SeeAlso drawLine drawPoint drawPath

##

# ------------------------------------------------------------------------------

#Method void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint)

Draw point at (x, y) using Clip, Matrix and Paint paint.

The shape of point drawn depends on paint Paint_Stroke_Cap.
If paint is set to SkPaint::kRound_Cap, draw a circle of diameter
Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap, 
draw a square of width and height Paint_Stroke_Width.
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.

#Param  x        left edge of circle or square ##
#Param  y        top edge of circle or square ##
#Param  paint    stroke, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
  SkPaint paint;
  paint.setAntiAlias(true);
  paint.setColor(0x80349a45);
  paint.setStyle(SkPaint::kStroke_Style);
  paint.setStrokeWidth(100);
  paint.setStrokeCap(SkPaint::kRound_Cap);
  canvas->scale(1, 1.2f);
  canvas->drawPoint(64, 96, paint);
  canvas->scale(.6f, .8f);
  paint.setColor(SK_ColorWHITE);
  canvas->drawPoint(106, 120, paint);
}
##

#SeeAlso drawPoints drawCircle drawRect drawLine drawPath

##

#Method void drawPoint(SkPoint p, const SkPaint& paint)

Draw point p using Clip, Matrix and Paint paint.

The shape of point drawn depends on paint Paint_Stroke_Cap.
If paint is set to SkPaint::kRound_Cap, draw a circle of diameter
Paint_Stroke_Width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap, 
draw a square of width and height Paint_Stroke_Width.
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.

#Param  p        top-left edge of circle or square ##
#Param  paint    stroke, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
  SkPaint paint;
  paint.setAntiAlias(true);
  paint.setColor(0x80349a45);
  paint.setStyle(SkPaint::kStroke_Style);
  paint.setStrokeWidth(100);
  paint.setStrokeCap(SkPaint::kSquare_Cap);
  canvas->scale(1, 1.2f);
  canvas->drawPoint({64, 96}, paint);
  canvas->scale(.6f, .8f);
  paint.setColor(SK_ColorWHITE);
  canvas->drawPoint(106, 120, paint);
}
##

#SeeAlso drawPoints drawCircle drawRect drawLine drawPath

##

# ------------------------------------------------------------------------------

#Method void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint)

Draws line segment from (x0, y0) to (x1, y1) using Clip, Matrix, and Paint paint.
In paint: Paint_Stroke_Width describes the line thickness;
Paint_Stroke_Cap draws the end rounded or square;
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.

#Param  x0    start of line segment on x-axis ##
#Param  y0    start of line segment on y-axis ##
#Param  x1    end of line segment on x-axis ##
#Param  y1    end of line segment on y-axis ##
#Param  paint stroke, blend, color, and so on, used to draw ##

#Example
  SkPaint paint;
  paint.setAntiAlias(true);
  paint.setColor(0xFF9a67be);
  paint.setStrokeWidth(20);
  canvas->skew(1, 0);
  canvas->drawLine(32, 96, 32, 160, paint);
  canvas->skew(-2, 0);
  canvas->drawLine(288, 96, 288, 160, paint);
##

#SeeAlso drawPoint drawCircle drawRect drawPath

##

#Method void drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint)

Draws line segment from p0 to p1 using Clip, Matrix, and Paint paint.
In paint: Paint_Stroke_Width describes the line thickness;
Paint_Stroke_Cap draws the end rounded or square;
Paint_Style is ignored, as if were set to SkPaint::kStroke_Style.

#Param  p0    start of line segment ##
#Param  p1    end of line segment ##
#Param  paint  stroke, blend, color, and so on, used to draw ##

#Example
  SkPaint paint;
  paint.setAntiAlias(true);
  paint.setColor(0xFF9a67be);
  paint.setStrokeWidth(20);
  canvas->skew(1, 0);
  canvas->drawLine({32, 96}, {32, 160}, paint);
  canvas->skew(-2, 0);
  canvas->drawLine({288, 96}, {288, 160}, paint);
##

#SeeAlso drawPoint drawCircle drawRect drawPath

##

# ------------------------------------------------------------------------------

#Method void drawRect(const SkRect& rect, const SkPaint& paint)

Draw Rect rect using Clip, Matrix, and Paint paint.
In paint: Paint_Style determines if rectangle is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness, and
Paint_Stroke_Join draws the corners rounded or square.

#Param  rect     rectangle to draw ##
#Param  paint    stroke or fill, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
    SkPoint rectPts[] = { {64, 48}, {192, 160} };
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(20);
    paint.setStrokeJoin(SkPaint::kRound_Join);
    SkMatrix rotator;
    rotator.setRotate(30, 128, 128);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorMAGENTA } ) {
        paint.setColor(color);
        SkRect rect;
        rect.set(rectPts[0], rectPts[1]);
        canvas->drawRect(rect, paint);
        rotator.mapPoints(rectPts, 2);
    }
}
##

#SeeAlso drawIRect drawRRect drawRoundRect drawRegion drawPath drawLine 

##

# ------------------------------------------------------------------------------

#Method void drawIRect(const SkIRect& rect, const SkPaint& paint) 

Draw IRect rect using Clip, Matrix, and Paint paint.
In paint: Paint_Style determines if rectangle is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness, and
Paint_Stroke_Join draws the corners rounded or square.

#Param  rect     rectangle to draw ##
#Param  paint    stroke or fill, blend, color, and so on, used to draw ##

#Example
    SkIRect rect = { 64, 48, 192, 160 };
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(20);
    paint.setStrokeJoin(SkPaint::kRound_Join);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorMAGENTA } ) {
        paint.setColor(color);
        canvas->drawIRect(rect, paint);
        canvas->rotate(30, 128, 128);
    }
##

#SeeAlso drawRect drawRRect drawRoundRect drawRegion drawPath drawLine

##

# ------------------------------------------------------------------------------

#Method void drawRegion(const SkRegion& region, const SkPaint& paint)

Draw Region region using Clip, Matrix, and Paint paint.
In paint: Paint_Style determines if rectangle is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness, and
Paint_Stroke_Join draws the corners rounded or square.

#Param  region   region to draw ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
    SkRegion region;
    region.op( 10, 10, 50, 50, SkRegion::kUnion_Op);
    region.op( 10, 50, 90, 90, SkRegion::kUnion_Op);
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    paint.setStrokeWidth(20);
    paint.setStrokeJoin(SkPaint::kRound_Join);
    canvas->drawRegion(region, paint);
}
##

#SeeAlso drawRect drawIRect drawPath

##

# ------------------------------------------------------------------------------

#Method void drawOval(const SkRect& oval, const SkPaint& paint)

Draw Oval oval using Clip, Matrix, and Paint.
In paint: Paint_Style determines if Oval is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness.

#Param  oval     Rect bounds of Oval ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
    canvas->clear(0xFF3f5f9f);
    SkColor  kColor1 = SkColorSetARGB(0xff, 0xff, 0x7f, 0);
    SkColor  g1Colors[] = { kColor1, SkColorSetA(kColor1, 0x20) };
    SkPoint  g1Points[] = { { 0, 0 }, { 0, 100 } };
    SkScalar pos[] = { 0.2f, 1.0f };
    SkRect bounds = SkRect::MakeWH(80, 70);
    SkPaint paint;
    paint.setAntiAlias(true);
    paint.setShader(SkGradientShader::MakeLinear(g1Points, g1Colors, pos, SK_ARRAY_COUNT(g1Colors),
            SkShader::kClamp_TileMode));
    canvas->drawOval(bounds , paint);
}
##

#SeeAlso drawCircle drawPoint drawPath drawRRect drawRoundRect

##

# ------------------------------------------------------------------------------

#Method void drawRRect(const SkRRect& rrect, const SkPaint& paint)

Draw Round_Rect rrect using Clip, Matrix, and Paint paint.
In paint: Paint_Style determines if rrect is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness.

rrect may represent a rectangle, circle, oval, uniformly rounded rectangle, or
may have any combination of positive non-square radii for the four corners.

#Param  rrect    Round_Rect with up to eight corner radii to draw ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkRect outer = {30, 40, 210, 220};
    SkRect radii = {30, 50, 70, 90 };
    SkRRect rRect;
    rRect.setNinePatch(outer, radii.fLeft, radii.fTop, radii.fRight, radii.fBottom);
    canvas->drawRRect(rRect, paint);
    paint.setColor(SK_ColorWHITE);
    canvas->drawLine(outer.fLeft + radii.fLeft, outer.fTop,
                     outer.fLeft + radii.fLeft, outer.fBottom, paint);
    canvas->drawLine(outer.fRight - radii.fRight, outer.fTop, 
                     outer.fRight - radii.fRight, outer.fBottom, paint);
    canvas->drawLine(outer.fLeft,  outer.fTop + radii.fTop, 
                     outer.fRight, outer.fTop + radii.fTop, paint);
    canvas->drawLine(outer.fLeft,  outer.fBottom - radii.fBottom, 
                     outer.fRight, outer.fBottom - radii.fBottom, paint);
}
##

#SeeAlso drawRect drawRoundRect drawDRRect drawCircle drawOval drawPath

##

# ------------------------------------------------------------------------------

#Method void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint)

Draw Round_Rect outer and inner
using Clip, Matrix, and Paint paint. 
outer must contain inner or the drawing is undefined.
In paint: Paint_Style determines if Round_Rect is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness.
If stroked and Round_Rect corner has zero length radii, Paint_Stroke_Join can
draw corners rounded or square. 

GPU-backed platforms optimize drawing when both outer and inner are
concave and outer contains inner. These platforms may not be able to draw
Path built with identical data as fast. 

#Param  outer    Round_Rect outer bounds to draw ##
#Param  inner    Round_Rect inner bounds to draw ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {
   SkRRect outer = SkRRect::MakeRect({20, 40, 210, 200});
   SkRRect inner = SkRRect::MakeOval({60, 70, 170, 160});
   SkPaint paint;
   canvas->drawDRRect(outer, inner, paint);
}
##

#Example
#Description
    Outer Rect has no corner radii, but stroke join is rounded.
    Inner Round_Rect has corner radii; outset stroke increases radii of corners.
    Stroke join does not affect inner Round_Rect since it has no sharp corners.
##
void draw(SkCanvas* canvas) {
   SkRRect outer = SkRRect::MakeRect({20, 40, 210, 200});
   SkRRect inner = SkRRect::MakeRectXY({60, 70, 170, 160}, 10, 10);
   SkPaint paint;
   paint.setAntiAlias(true);
   paint.setStyle(SkPaint::kStroke_Style);
   paint.setStrokeWidth(20);
   paint.setStrokeJoin(SkPaint::kRound_Join);
   canvas->drawDRRect(outer, inner, paint);
   paint.setStrokeWidth(1);
   paint.setColor(SK_ColorWHITE);
   canvas->drawDRRect(outer, inner, paint);
}
##

#SeeAlso drawRect drawRoundRect drawRRect drawCircle drawOval drawPath

##

# ------------------------------------------------------------------------------

#Method void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint)

Draw Circle at (cx, cy) with radius using Clip, Matrix, and Paint paint.
If radius is zero or less, nothing is drawn.
In paint: Paint_Style determines if Circle is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness.

#Param  cx       Circle center on the x-axis ##
#Param  cy       Circle center on the y-axis ##
#Param  radius   half the diameter of Circle ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
    void draw(SkCanvas* canvas) {
        SkPaint paint;
        paint.setAntiAlias(true);
        canvas->drawCircle(128, 128, 90, paint);
        paint.setColor(SK_ColorWHITE);
        canvas->drawCircle(86, 86, 20, paint);
        canvas->drawCircle(160, 76, 20, paint);
        canvas->drawCircle(140, 150, 35, paint);
    }
##

#SeeAlso drawOval drawRRect drawRoundRect drawPath drawArc drawPoint drawLine

##

#Method void drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint)

Draw Circle at center with radius using Clip, Matrix, and Paint paint.
If radius is zero or less, nothing is drawn.
In paint: Paint_Style determines if Circle is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness.

#Param  center   Circle center ##
#Param  radius   half the diameter of Circle ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
    void draw(SkCanvas* canvas) {
        SkPaint paint;
        paint.setAntiAlias(true);
        canvas->drawCircle(128, 128, 90, paint);
        paint.setColor(SK_ColorWHITE);
        canvas->drawCircle({86, 86}, 20, paint);
        canvas->drawCircle({160, 76}, 20, paint);
        canvas->drawCircle({140, 150}, 35, paint);
    }
##

#SeeAlso drawOval drawRRect drawRoundRect drawPath drawArc drawPoint drawLine

##

# ------------------------------------------------------------------------------

#Method void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
                 bool useCenter, const SkPaint& paint)

Draw Arc using Clip, Matrix, and Paint paint.

Arc is part of Oval bounded by oval, sweeping from startAngle to startAngle plus
sweepAngle. startAngle and sweepAngle are in degrees.

startAngle of zero places start point at the right middle edge of oval.
A positive sweepAngle places Arc end point clockwise from start point;
a negative sweepAngle places Arc end point counterclockwise from start point.
sweepAngle may exceed 360 degrees, a full circle.
If useCenter is true, draw a wedge that includes lines from oval
center to Arc end points. If useCenter is false, draw Arc between end points.

If Rect oval is empty or sweepAngle is zero, nothing is drawn.

#Param  oval     Rect bounds of Oval containing Arc to draw ##
#Param  startAngle angle in degrees where Arc begins ##
#Param  sweepAngle sweep angle in degrees; positive is clockwise ##
#Param  useCenter if true, include the center of the oval ##
#Param  paint    Paint stroke or fill, blend, color, and so on, used to draw ##

#Example
    void draw(SkCanvas* canvas) {
        SkPaint paint;
        paint.setAntiAlias(true);
        SkRect oval = { 4, 4, 60, 60};
        for (auto useCenter : { false, true } ) {
            for (auto style : { SkPaint::kFill_Style, SkPaint::kStroke_Style } ) {
                paint.setStyle(style);
                for (auto degrees : { 45, 90, 180, 360} ) {
                    canvas->drawArc(oval, 0, degrees , useCenter, paint);
                    canvas->translate(64, 0);
                }
                canvas->translate(-256, 64);
            }
        }
    }
##

#Example
#Height 64
    void draw(SkCanvas* canvas) {
        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setStyle(SkPaint::kStroke_Style);
        paint.setStrokeWidth(4);
        SkRect oval = { 4, 4, 60, 60};
        float intervals[] = { 5, 5 };
        paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 2.5f));
        for (auto degrees : { 270, 360, 540, 720 } ) {
            canvas->drawArc(oval, 0, degrees, false, paint);
            canvas->translate(64, 0);
        }
    }
##

#SeeAlso SkPath::arcTo drawCircle drawOval drawPath

##

# ------------------------------------------------------------------------------

#Method void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, const SkPaint& paint)

Draw Round_Rect bounded by Rect rect, with corner radii (rx, ry) using Clip,
Matrix, and Paint paint.

In paint: Paint_Style determines if Round_Rect is stroked or filled; 
if stroked, Paint_Stroke_Width describes the line thickness.
If rx or ry are less than zero, they are treated as if they are zero.
If rx plus ry exceeds rect width or rect height, radii are scaled down to fit.
If rx and ry are zero, Round_Rect is drawn as Rect and if stroked is affected by
Paint_Stroke_Join.

#Param  rect     Rect bounds of Round_Rect to draw ##
#Param  rx       axis length in x of oval describing rounded corners ##
#Param  ry       axis length in y of oval describing rounded corners ##
#Param  paint    stroke, blend, color, and so on, used to draw ##

#Example
#Description
    Top row has a zero radius a generates a rectangle.
    Second row radii sum to less than sides.
    Third row radii sum equals sides.
    Fourth row radii sum exceeds sides; radii are scaled to fit.
##
    void draw(SkCanvas* canvas) {
        SkVector radii[] = { {0, 20}, {10, 10}, {10, 20}, {10, 40} };
        SkPaint paint;
        paint.setStrokeWidth(15);
        paint.setStrokeJoin(SkPaint::kRound_Join);
        paint.setAntiAlias(true);
        for (auto style : { SkPaint::kStroke_Style, SkPaint::kFill_Style  } ) {
            paint.setStyle(style );
            for (size_t i = 0; i < SK_ARRAY_COUNT(radii); ++i) {
               canvas->drawRoundRect({10, 10, 60, 40}, radii[i].fX, radii[i].fY, paint);
               canvas->translate(0, 60);
            }
            canvas->translate(80, -240);
        }
    }
##

#SeeAlso DrawRRect drawRect drawDRRect drawPath drawCircle drawOval drawPoint

##

# ------------------------------------------------------------------------------

#Method void drawPath(const SkPath& path, const SkPaint& paint)

Draw Path path using Clip, Matrix, and Paint paint.
Path contains an array of Path_Contour, each of which may be open or closed.

In paint: Paint_Style determines if Round_Rect is stroked or filled:
if filled, Path_Fill_Type determines whether Path_Contour describes inside or
outside of fill; if stroked, Paint_Stroke_Width describes the line thickness,
Paint_Stroke_Cap describes line ends, and Paint_Stroke_Join describes how
corners are drawn.

#Param  path     Path to draw ##
#Param  paint    stroke, blend, color, and so on, used to draw ##

#Example
#Description
    Top rows draw stroked path with combinations of joins and caps. The open contour
    is affected by caps; the closed contour is affected by joins.
    Bottom row draws fill the same for open and closed contour. 
    First bottom column shows winding fills overlap.
    Second bottom column shows even odd fills exclude overlap.
    Third bottom column shows inverse winding fills area outside both contours.
##
void draw(SkCanvas* canvas) {
    SkPath path;
    path.moveTo(20, 20);
    path.quadTo(60, 20, 60, 60);
    path.close();
    path.moveTo(60, 20);
    path.quadTo(60, 60, 20, 60);
    SkPaint paint;
    paint.setStrokeWidth(10);
    paint.setAntiAlias(true);
    paint.setStyle(SkPaint::kStroke_Style);
    for (auto join: { SkPaint::kBevel_Join, SkPaint::kRound_Join, SkPaint::kMiter_Join } ) {
        paint.setStrokeJoin(join);
        for (auto cap: { SkPaint::kButt_Cap, SkPaint::kSquare_Cap, SkPaint::kRound_Cap  } ) {
            paint.setStrokeCap(cap);
            canvas->drawPath(path, paint);
            canvas->translate(80, 0);
        }
        canvas->translate(-240, 60);
    }
    paint.setStyle(SkPaint::kFill_Style);
    for (auto fill : { SkPath::kWinding_FillType, 
                       SkPath::kEvenOdd_FillType, 
                       SkPath::kInverseWinding_FillType } ) {
        path.setFillType(fill);
        canvas->save();
        canvas->clipRect({0, 10, 80, 70});
        canvas->drawPath(path, paint);
        canvas->restore();
        canvas->translate(80, 0);
    }
}
##

#SeeAlso SkPath drawLine drawArc drawRect drawPoints

##

# ------------------------------------------------------------------------------
#Topic Draw_Image

drawImage, drawImageRect, and drawImageNine can be called with a bare pointer or
a smart pointer as a convenience. The pairs of calls are otherwise identical.

#Method void drawImage(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint = nullptr)

Draw Image image, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.

If paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter, Blend_Mode,
and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds. If generated
mask extends beyond image bounds, replicate image edge colors, just as Shader
made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the
image edge color when it samples outside of its bounds. 

#Param  image    uncompressed rectangular map of pixels ##
#Param  left     left side of image ##
#Param  top      top side of image ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##

#Example
#Height 64
#Image 4
void draw(SkCanvas* canvas) {
   // sk_sp<SkImage> image;
   SkImage* imagePtr = image.get();
   canvas->drawImage(imagePtr, 0, 0);
   SkPaint paint;
   canvas->drawImage(imagePtr, 80, 0, &paint);
   paint.setAlpha(0x80);
   canvas->drawImage(imagePtr, 160, 0, &paint);
}
##

#SeeAlso drawBitmap drawImageLattice drawImageNine drawImageRect SkPaint::setImageFilter

##

# ------------------------------------------------------------------------------

#Method void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top,
                   const SkPaint* paint = nullptr) 

Draw Image image, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds. If generated
mask extends beyond image bounds, replicate image edge colors, just as Shader
made from SkImage::makeShader with SkShader::kClamp_TileMode set replicates the
image edge color when it samples outside of its bounds. 

#Param  image    uncompressed rectangular map of pixels ##
#Param  left     left side of image ##
#Param  top      pop side of image ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##

#Example
#Height 64
#Image 4
void draw(SkCanvas* canvas) {
   // sk_sp<SkImage> image;
   canvas->drawImage(image, 0, 0);
   SkPaint paint;
   canvas->drawImage(image, 80, 0, &paint);
   paint.setAlpha(0x80);
   canvas->drawImage(image, 160, 0, &paint);
}
##

#SeeAlso drawBitmap drawImageLattice drawImageNine drawImageRect SkPaint::setImageFilter

##

# ------------------------------------------------------------------------------

#Enum SrcRectConstraint

#Code
    enum SrcRectConstraint {
        kStrict_SrcRectConstraint, 
        kFast_SrcRectConstraint, 
    };
##

SrcRectConstraint controls the behavior at the edge of source Rect,
provided to drawImageRect, trading off speed for precision.

Image_Filter in Paint may sample multiple pixels in the image. Source Rect
restricts the bounds of pixels that may be read. Image_Filter may slow down if
it cannot read outside the bounds, when sampling near the edge of source Rect. 
SrcRectConstraint specifies whether an Image_Filter is allowed to read pixels
outside source Rect.

#Const kStrict_SrcRectConstraint
    Requires Image_Filter to respect source Rect,
    sampling only inside of its bounds, possibly with a performance penalty.
##

#Const kFast_SrcRectConstraint
    Permits Image_Filter to sample outside of source Rect
    by half the width of Image_Filter, permitting it to run faster but with
    error at the image edges.
##

#Example
#Height 64
#Description
    redBorder contains a black and white checkerboard bordered by red.
    redBorder is drawn scaled by 16 on the left.
    The middle and right bitmaps are filtered checkerboards.
    Drawing the checkerboard with kStrict_SrcRectConstraint shows only a blur of black and white.
    Drawing the checkerboard with kFast_SrcRectConstraint allows red to bleed in the corners.
##
void draw(SkCanvas* canvas) {
    SkBitmap redBorder;
    redBorder.allocPixels(SkImageInfo::MakeN32Premul(4, 4));
    SkCanvas checkRed(redBorder);
    checkRed.clear(SK_ColorRED);
    uint32_t checkers[][2] = { { SK_ColorBLACK, SK_ColorWHITE },
                               { SK_ColorWHITE, SK_ColorBLACK } };
    checkRed.writePixels(
            SkImageInfo::MakeN32Premul(2, 2), (void*) checkers, sizeof(checkers[0]), 1, 1);
    canvas->scale(16, 16);
    canvas->drawBitmap(redBorder, 0, 0, nullptr);
    canvas->resetMatrix();
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(redBorder);
    SkPaint lowPaint;
    lowPaint.setFilterQuality(kLow_SkFilterQuality);
    for (auto constraint : { SkCanvas::kStrict_SrcRectConstraint,
                             SkCanvas::kFast_SrcRectConstraint } ) {
        canvas->translate(80, 0);
        canvas->drawImageRect(image.get(), SkRect::MakeLTRB(1, 1, 3, 3),
                SkRect::MakeLTRB(16, 16, 48, 48), &lowPaint, constraint);
    }
}
##

#SeeAlso drawImageRect drawImage SkPaint::setImageFilter

##

# ------------------------------------------------------------------------------

#Method void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
                       const SkPaint* paint,
                       SrcRectConstraint constraint = kStrict_SrcRectConstraint)

Draw Rect src of Image image, scaled and translated to fill Rect dst.
Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within src; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  src        source Rect of image to draw from ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##
#Param  constraint filter strictly within src or draw faster ##

#Example
#Height 64
#Description
    The left bitmap draws with Paint default kNone_SkFilterQuality, and stays within
    its bounds; there is no bleeding with kFast_SrcRectConstraint.
    the middle and right bitmaps draw with kLow_SkFilterQuality; with
    kStrict_SrcRectConstraint, the filter remains within the checkerboard, and
    with kFast_SrcRectConstraint red bleeds on the edges.
##
void draw(SkCanvas* canvas) {
    uint32_t pixels[][4] = { 
            { 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000 },
            { 0xFFFF0000, 0xFF000000, 0xFFFFFFFF, 0xFFFF0000 },
            { 0xFFFF0000, 0xFFFFFFFF, 0xFF000000, 0xFFFF0000 },
            { 0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000 } };
    SkBitmap redBorder;
    redBorder.installPixels(SkImageInfo::MakeN32Premul(4, 4), 
            (void*) pixels, sizeof(pixels[0]));
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(redBorder);
    SkPaint lowPaint;
    for (auto constraint : {
            SkCanvas::kFast_SrcRectConstraint,
            SkCanvas::kStrict_SrcRectConstraint,
            SkCanvas::kFast_SrcRectConstraint } ) {
        canvas->drawImageRect(image.get(), SkRect::MakeLTRB(1, 1, 3, 3),
                SkRect::MakeLTRB(16, 16, 48, 48), &lowPaint, constraint);
        lowPaint.setFilterQuality(kLow_SkFilterQuality);
        canvas->translate(80, 0);
    }
}
##

#SeeAlso SrcRectConstraint drawImage drawImageLattice drawImageNine

##

# ------------------------------------------------------------------------------

#Method void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
                       const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)

Draw IRect isrc of Image image, scaled and translated to fill Rect dst.
Note that isrc is on integer pixel boundaries; dst may include fractional
boundaries. Additionally transform draw using Clip, Matrix, and optional Paint
paint. 

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  isrc       source IRect of image to draw from ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##
#Param  constraint filter strictly within isrc or draw faster ##

#Example
#Image 4
void draw(SkCanvas* canvas) {
    // sk_sp<SkImage> image;
    for (auto i : { 1, 2, 4, 8 } ) {
        canvas->drawImageRect(image.get(), SkIRect::MakeLTRB(0, 0, 100, 100), 
                SkRect::MakeXYWH(i * 20, i * 20, i * 20, i * 20), nullptr);
    }
}
##

#SeeAlso SrcRectConstraint drawImage drawImageLattice drawImageNine

##

# ------------------------------------------------------------------------------

#Method void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint,
                       SrcRectConstraint constraint = kStrict_SrcRectConstraint)

Draw Image image, scaled and translated to fill Rect dst, using Clip, Matrix,
and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within image; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##
#Param  constraint filter strictly within image or draw faster ##

#Example
#Image 4
void draw(SkCanvas* canvas) {
    // sk_sp<SkImage> image;
    for (auto i : { 20, 40, 80, 160 } ) {
        canvas->drawImageRect(image.get(), SkRect::MakeXYWH(i, i, i, i), nullptr);
    }
}
##

#SeeAlso SrcRectConstraint drawImage drawImageLattice drawImageNine

##

# ------------------------------------------------------------------------------

#Method void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
                       const SkPaint* paint,
                       SrcRectConstraint constraint = kStrict_SrcRectConstraint) 

Draw Rect src of Image image, scaled and translated to fill Rect dst.
Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within src; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  src        source Rect of image to draw from ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##
#Param  constraint filter strictly within src or draw faster ##

#Example
#Height 64
#Description
    Canvas scales and translates; transformation from src to dst also scales.
    The two matrices are concatenated to create the final transformation.
##
void draw(SkCanvas* canvas) {
    uint32_t pixels[][2] = { { SK_ColorBLACK, SK_ColorWHITE },
                             { SK_ColorWHITE, SK_ColorBLACK } };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2), 
            (void*) pixels, sizeof(pixels[0]));
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
    SkPaint paint;
    canvas->scale(4, 4);
    for (auto alpha : { 50, 100, 150, 255 } ) {
        paint.setAlpha(alpha);
        canvas->drawImageRect(image, SkRect::MakeWH(2, 2), SkRect::MakeWH(8, 8), &paint);
        canvas->translate(8, 0);
    }
}
##

#SeeAlso SrcRectConstraint drawImage drawImageLattice drawImageNine

##

# ------------------------------------------------------------------------------

#Method void drawImageRect(const sk_sp<SkImage>& image, const SkIRect& isrc, const SkRect& dst,
                       const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint) 

Draw IRect isrc of Image image, scaled and translated to fill Rect dst.
isrc is on integer pixel boundaries; dst may include fractional boundaries.
Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within image; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  isrc       source IRect of image to draw from ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##
#Param  constraint filter strictly within image or draw faster ##

#Example
#Height 64
void draw(SkCanvas* canvas) {
    uint32_t pixels[][2] = { { 0x00000000, 0x55555555},
                             { 0xAAAAAAAA, 0xFFFFFFFF} };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2), 
            (void*) pixels, sizeof(pixels[0]));
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
    SkPaint paint;
    canvas->scale(4, 4);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
        paint.setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kPlus));
        canvas->drawImageRect(image, SkIRect::MakeWH(2, 2), SkRect::MakeWH(8, 8), &paint);
        canvas->translate(8, 0);
    }
}
##

#SeeAlso SrcRectConstraint drawImage drawImageLattice drawImageNine

##

# ------------------------------------------------------------------------------

#Method void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst, const SkPaint* paint,
                       SrcRectConstraint constraint = kStrict_SrcRectConstraint) 

Draw Image image, scaled and translated to fill Rect dst,
using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within image; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##
#Param  constraint filter strictly within image or draw faster ##

#Example
#Height 64
void draw(SkCanvas* canvas) {
    uint32_t pixels[][2] = { { 0x00000000, 0x55550000},
                             { 0xAAAA0000, 0xFFFF0000} };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2), 
            (void*) pixels, sizeof(pixels[0]));
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
    SkPaint paint;
    canvas->scale(4, 4);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
        paint.setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kPlus));
        canvas->drawImageRect(image, SkRect::MakeWH(8, 8), &paint);
        canvas->translate(8, 0);
    }
}
##

#SeeAlso SrcRectConstraint drawImage drawImageLattice drawImageNine

##

# ------------------------------------------------------------------------------

#Method void drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
                       const SkPaint* paint = nullptr)

Draw Image image stretched proportionally to fit into Rect dst.
IRect center divides the image into nine sections: four sides, four corners, and
the center. Corners are unmodified or scaled down proportionately if their sides
are larger than dst; center and four sides are scaled to fit remaining space, if any.

Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  center     IRect edge of image corners and sides ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##

#Example
#Height 128
#Description
    The leftmost image is smaller than center; only corners are drawn, all scaled to fit.
    The second image equals the size of center; only corners are drawn without scaling.
    The remaining images are larger than center. All corners draw without scaling.
    The sides and center are scaled if needed to take up the remaining space.
##
void draw(SkCanvas* canvas) {
    SkIRect center = { 20, 10, 50, 40 };
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(60, 60));
    SkCanvas bitCanvas(bitmap);
    SkPaint paint;
    SkColor gray = 0xFF000000;
    int left = 0;
    for (auto right: { center.fLeft, center.fRight, bitmap.width() } ) {
        int top = 0;
        for (auto bottom: { center.fTop, center.fBottom, bitmap.height() } ) {
            paint.setColor(gray);
            bitCanvas.drawIRect(SkIRect::MakeLTRB(left, top, right, bottom), paint);
            gray += 0x001f1f1f;
            top = bottom;
        }
        left = right; 
    }
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
    SkImage* imagePtr = image.get();
    for (auto dest: { 20, 30, 40, 60, 90 } ) {
        canvas->drawImageNine(imagePtr, center, SkRect::MakeWH(dest, dest), nullptr);
        canvas->translate(dest + 4, 0);
    }
}
##

#SeeAlso drawImage drawBitmapNine drawImageLattice drawImageRect

##

# ------------------------------------------------------------------------------

#Method void drawImageNine(const sk_sp<SkImage>& image, const SkIRect& center, const SkRect& dst,
                       const SkPaint* paint = nullptr) 

Draw Image image stretched proportionally to fit into Rect dst.
IRect center divides the image into nine sections: four sides, four corners, and
the center. Corners are not scaled, or scaled down proportionately if their sides
are larger than dst; center and four sides are scaled to fit remaining space, if any.

Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If image is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from image bounds.

If generated mask extends beyond image bounds, replicate image edge colors, just
as Shader made from SkImage::makeShader with SkShader::kClamp_TileMode set
replicates the image edge color when it samples outside of its bounds.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  center     IRect edge of image corners and sides ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint      Paint containing Blend_Mode, Color_Filter, Image_Filter,
                   and so on; or nullptr
##

#Example
#Height 128
#Description
    The two leftmost images has four corners and sides to the left and right of center.
    The leftmost image scales the width of corners proportionately to fit.
    The third and fourth image corners are not scaled; the sides and center are scaled to 
    fill the remaining space.
    The rightmost image has four corners scaled vertically to fit, and uses sides above
    and below center to fill the remaining space.
##
void draw(SkCanvas* canvas) {
    SkIRect center = { 20, 10, 50, 40 };
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(60, 60));
    SkCanvas bitCanvas(bitmap);
    SkPaint paint;
    SkColor gray = 0xFF000000;
    int left = 0;
    for (auto right: { center.fLeft, center.fRight, bitmap.width() } ) {
        int top = 0;
        for (auto bottom: { center.fTop, center.fBottom, bitmap.height() } ) {
            paint.setColor(gray);
            bitCanvas.drawIRect(SkIRect::MakeLTRB(left, top, right, bottom), paint);
            gray += 0x001f1f1f;
            top = bottom;
        }
        left = right; 
    }
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
    for (auto dest: { 20, 30, 40, 60, 90 } ) {
        canvas->drawImageNine(image, center, SkRect::MakeWH(dest, 110 - dest), nullptr);
        canvas->translate(dest + 4, 0);
    }
}
##

#SeeAlso drawImage drawBitmapNine drawImageLattice drawImageRect

##

# ------------------------------------------------------------------------------

#Method void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
                    const SkPaint* paint = nullptr)

Draw Bitmap bitmap, with its top-left corner at (left, top),
using Clip, Matrix, and optional Paint paint.

If Paint paint is not nullptr, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds. 

#Param  bitmap   Bitmap containing pixels, dimensions, and format ##
#Param  left     left side of bitmap ##
#Param  top      top side of bitmap ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##

#Example
#Height 64
void draw(SkCanvas* canvas) {
    uint8_t pixels[][8] = { { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00},
                            { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},
                            { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},
                            { 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF},
                            { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
                            { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00},
                            { 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00},
                            { 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF} };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeA8(8, 8), 
            (void*) pixels, sizeof(pixels[0]));
    SkPaint paint;
    canvas->scale(4, 4);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xFF007F00} ) {
        paint.setColor(color);
        canvas->drawBitmap(bitmap, 0, 0, &paint);
        canvas->translate(12, 0);
    }
}
##

#SeeAlso drawImage drawBitmapLattice drawBitmapNine drawBitmapRect SkBitmap::readPixels SkBitmap::writePixels

##

# ------------------------------------------------------------------------------

#Method void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
                        const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)

Draw Rect src of Bitmap bitmap, scaled and translated to fill Rect dst.
Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within src; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  bitmap   Bitmap containing pixels, dimensions, and format ##
#Param  src      source Rect of image to draw from ##
#Param  dst      destination Rect of image to draw to ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##
#Param  constraint filter strictly within src or draw faster ##

#Example
#Height 64
void draw(SkCanvas* canvas) {
    uint8_t pixels[][8] = { { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00},
                            { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},
                            { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00},
                            { 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF},
                            { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
                            { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00},
                            { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},
                            { 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00} };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeA8(8, 8), 
            (void*) pixels, sizeof(pixels[0]));
    SkPaint paint;
    paint.setMaskFilter(SkBlurMaskFilter::Make(kSolid_SkBlurStyle, 6));
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xFF007F00} ) {
        paint.setColor(color);
        canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint);
        canvas->translate(48, 0);
    }
}
##

#SeeAlso drawImageRect drawBitmap drawBitmapLattice drawBitmapNine

##

# ------------------------------------------------------------------------------

#Method void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
                        const SkPaint* paint, SrcRectConstraint constraint = kStrict_SrcRectConstraint)

Draw IRect isrc of Bitmap bitmap, scaled and translated to fill Rect dst.
isrc is on integer pixel boundaries; dst may include fractional boundaries.
Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  bitmap   Bitmap containing pixels, dimensions, and format ##
#Param  isrc     source IRect of image to draw from ##
#Param  dst      destination Rect of image to draw to ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##
#Param  constraint sample strictly within isrc, or draw faster ##

#Example
#Height 64
void draw(SkCanvas* canvas) {
    uint8_t pixels[][8] = { { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00},
                            { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},
                            { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF},
                            { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF},
                            { 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF},
                            { 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF},
                            { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00},
                            { 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00} };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeA8(8, 8), 
            (void*) pixels, sizeof(pixels[0]));
    SkPaint paint;
    paint.setFilterQuality(kHigh_SkFilterQuality);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xFF007F00, 0xFF7f007f} ) {
        paint.setColor(color);
        canvas->drawBitmapRect(bitmap, SkIRect::MakeWH(8, 8), SkRect::MakeWH(32, 32), &paint);
        canvas->translate(48.25f, 0);
    }
}
##

#SeeAlso drawImageRect drawBitmap drawBitmapLattice drawBitmapNine

##

# ------------------------------------------------------------------------------

#Method void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
                        SrcRectConstraint constraint = kStrict_SrcRectConstraint)

Draw Bitmap bitmap, scaled and translated to fill Rect dst.
bitmap bounds is on integer pixel boundaries; dst may include fractional boundaries.
Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds.

constraint set to kStrict_SrcRectConstraint limits Paint Filter_Quality to
sample within bitmap; set to kFast_SrcRectConstraint allows sampling outside to
improve performance.

#Param  bitmap   Bitmap containing pixels, dimensions, and format ##
#Param  dst      destination Rect of image to draw to ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##
#Param  constraint filter strictly within bitmap or draw faster ##

#Example
#Height 64
void draw(SkCanvas* canvas) {
    uint32_t pixels[][2] = { { 0x00000000, 0x55550000},
                             { 0xAAAA0000, 0xFFFF0000} };
    SkBitmap bitmap;
    bitmap.installPixels(SkImageInfo::MakeN32Premul(2, 2), 
            (void*) pixels, sizeof(pixels[0]));
    SkPaint paint;
    canvas->scale(4, 4);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN } ) {
        paint.setColorFilter(SkColorFilter::MakeModeFilter(color, SkBlendMode::kPlus));
        canvas->drawBitmapRect(bitmap, SkRect::MakeWH(8, 8), &paint);
        canvas->translate(8, 0);
    }
}
##

#SeeAlso drawImageRect drawBitmap drawBitmapLattice drawBitmapNine

##

# ------------------------------------------------------------------------------

#Method void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
                        const SkPaint* paint = nullptr)

Draw Bitmap bitmap stretched proportionally to fit into Rect dst.
IRect center divides the bitmap into nine sections: four sides, four corners,
and the center. Corners are not scaled, or scaled down proportionately if their
sides are larger than dst; center and four sides are scaled to fit remaining
space, if any.

Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds.

#Param  bitmap     Bitmap containing pixels, dimensions, and format ##
#Param  center     IRect edge of image corners and sides ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##

#Example
#Height 128
#Description
    The two leftmost bitmap draws has four corners and sides to the left and right of center.
    The leftmost bitmap draw scales the width of corners proportionately to fit.
    The third and fourth draw corners are not scaled; the sides and center are scaled to 
    fill the remaining space.
    The rightmost bitmap draw has four corners scaled vertically to fit, and uses sides above
    and below center to fill the remaining space.
##
void draw(SkCanvas* canvas) {
    SkIRect center = { 20, 10, 50, 40 };
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(60, 60));
    SkCanvas bitCanvas(bitmap);
    SkPaint paint;
    SkColor gray = 0xFF000000;
    int left = 0;
    for (auto right: { center.fLeft, center.fRight, bitmap.width() } ) {
        int top = 0;
        for (auto bottom: { center.fTop, center.fBottom, bitmap.height() } ) {
            paint.setColor(gray);
            bitCanvas.drawIRect(SkIRect::MakeLTRB(left, top, right, bottom), paint);
            gray += 0x001f1f1f;
            top = bottom;
        }
        left = right; 
    }
    for (auto dest: { 20, 30, 40, 60, 90 } ) {
        canvas->drawBitmapNine(bitmap, center, SkRect::MakeWH(dest, 110 - dest), nullptr);
        canvas->translate(dest + 4, 0);
    }
}
##

#SeeAlso drawImageNine drawBitmap drawBitmapLattice drawBitmapRect

##

# ------------------------------------------------------------------------------
#Struct Lattice

#Code
    struct Lattice {
        enum Flags {...

        const int*     fXDivs;
        const int*     fYDivs;
        const Flags*   fFlags;
        int            fXCount;
        int            fYCount;
        const SkIRect* fBounds;
    };
##

    Lattice divides Bitmap or Image into a rectangular grid.
    Grid entries on even columns and even rows are fixed; these entries are
    always drawn at their original size if the destination is large enough.
    If the destination side is too small to hold the fixed entries, all fixed
    entries are proportionately scaled down to fit.
    The grid entries not on even columns and rows are scaled to fit the
    remaining space, if any.

    #Enum Flags
        #Code
            enum Flags : uint8_t {
                kTransparent_Flags = 1 << 0,
            };
        ##

        Optional setting per rectangular grid entry to make it transparent.

        #Const kTransparent_Flags 1
            Set to skip lattice rectangle by making it transparent.
        ##
    ##

    #Member const int*   fXDivs
        Array of x-coordinates that divide the bitmap vertically.
        Array entries must be unique, increasing, greater than or equal to
        fBounds left edge, and less than fBounds right edge.
        Set the first element to fBounds left to collapse the left column of
        fixed grid entries.
    ##

    #Member const int*   fYDivs
        Array of y-coordinates that divide the bitmap horizontally.
        Array entries must be unique, increasing, greater than or equal to
        fBounds top edge, and less than fBounds bottom edge.
        Set the first element to fBounds top to collapse the top row of fixed
        grid entries.
    ##

    #Member const Flags*  fFlags
        Optional array of Flags, one per rectangular grid entry:
        array length must be
    #Formula
        (fXCount + 1) * (fYCount + 1)
    ##
        .

        Array entries correspond to the rectangular grid entries, ascending
        left to right and then top to bottom.
    ##

    #Member int   fXCount
        Number of entries in fXDivs array; one less than the number of
        horizontal divisions.
    ##

    #Member int   fYCount
        Number of entries in fYDivs array; one less than the number of vertical
        divisions.
    ##

    #Member const SkIRect*   fBounds
       Optional subset IRect source to draw from.
       If nullptr, source bounds is dimensions of Bitmap or Image.
    ##

#Struct Lattice ##

#Method void drawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice, const SkRect& dst,
                           const SkPaint* paint = nullptr)

Draw Bitmap bitmap stretched proportionally to fit into Rect dst.

Lattice lattice divides bitmap into a rectangular grid.
Each intersection of an even-numbered row and column is fixed; like the corners
of drawBitmapNine, fixed lattice elements never scale larger than their initial
size and shrink proportionately when all fixed elements exceed the bitmap
dimension. All other grid elements scale to fill the available space, if any.

Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds.

#Param  bitmap     Bitmap containing pixels, dimensions, and format ##
#Param  lattice    division of bitmap into fixed and variable rectangles ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##

#Example
#Height 128
#Description
    The two leftmost bitmap draws has four corners and sides to the left and right of center.
    The leftmost bitmap draw scales the width of corners proportionately to fit.
    The third and fourth draw corners are not scaled; the sides are scaled to 
    fill the remaining space; the center is transparent.
    The rightmost bitmap draw has four corners scaled vertically to fit, and uses sides above
    and below center to fill the remaining space.
##
void draw(SkCanvas* canvas) {
    SkIRect center = { 20, 10, 50, 40 };
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(60, 60));
    SkCanvas bitCanvas(bitmap);
    SkPaint paint;
    SkColor gray = 0xFF000000;
    int left = 0;
    for (auto right: { center.fLeft, center.fRight, bitmap.width() } ) {
        int top = 0;
        for (auto bottom: { center.fTop, center.fBottom, bitmap.height() } ) {
            paint.setColor(gray);
            bitCanvas.drawIRect(SkIRect::MakeLTRB(left, top, right, bottom), paint);
            gray += 0x001f1f1f;
            top = bottom;
        }
        left = right; 
    }
    const int xDivs[] = { center.fLeft, center.fRight };
    const int yDivs[] = { center.fTop, center.fBottom };
    SkCanvas::Lattice::Flags flags[3][3];
    memset(flags, 0, sizeof(flags));  
    flags[1][1] = SkCanvas::Lattice::kTransparent_Flags;
    SkCanvas::Lattice lattice = { xDivs, yDivs, flags[0], SK_ARRAY_COUNT(xDivs),
         SK_ARRAY_COUNT(yDivs), nullptr };
    for (auto dest: { 20, 30, 40, 60, 90 } ) {
        canvas->drawBitmapLattice(bitmap, lattice , SkRect::MakeWH(dest, 110 - dest), nullptr);
        canvas->translate(dest + 4, 0);
    }
}
##

#SeeAlso drawImageLattice drawBitmap drawBitmapNine Lattice

##

# ------------------------------------------------------------------------------

#Method void drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
                          const SkPaint* paint = nullptr)

Draw Image image stretched proportionally to fit into Rect dst.

Lattice lattice divides image into a rectangular grid.
Each intersection of an even-numbered row and column is fixed; like the corners
of drawBitmapNine, fixed lattice elements never scale larger than their initial
size and shrink proportionately when all fixed elements exceed the bitmap
dimension. All other grid elements scale to fill the available space, if any.

Additionally transform draw using Clip, Matrix, and optional Paint paint.

If Paint paint is supplied, apply Color_Filter, Color_Alpha, Image_Filter,
Blend_Mode, and Draw_Looper. If bitmap is kAlpha_8_SkColorType, apply Shader.
If paint contains Mask_Filter, generate mask from bitmap bounds.

If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
just as Shader made from SkShader::MakeBitmapShader with
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
outside of its bounds.

#Param  image      Image containing pixels, dimensions, and format ##
#Param  lattice    division of bitmap into fixed and variable rectangles ##
#Param  dst        destination Rect of image to draw to ##
#Param  paint    Paint containing Blend_Mode, Color_Filter, Image_Filter,
                 and so on; or nullptr
##

#Example
#Height 128
#Description
    The leftmost image is smaller than center; only corners are drawn, all scaled to fit.
    The second image equals the size of center; only corners are drawn without scaling.
    The remaining images are larger than center. All corners draw without scaling. The sides
    are scaled if needed to take up the remaining space; the center is transparent.
##
void draw(SkCanvas* canvas) {
    SkIRect center = { 20, 10, 50, 40 };
    SkBitmap bitmap;
    bitmap.allocPixels(SkImageInfo::MakeN32Premul(60, 60));
    SkCanvas bitCanvas(bitmap);
    SkPaint paint;
    SkColor gray = 0xFF000000;
    int left = 0;
    for (auto right: { center.fLeft, center.fRight, bitmap.width() } ) {
        int top = 0;
        for (auto bottom: { center.fTop, center.fBottom, bitmap.height() } ) {
            paint.setColor(gray);
            bitCanvas.drawIRect(SkIRect::MakeLTRB(left, top, right, bottom), paint);
            gray += 0x001f1f1f;
            top = bottom;
        }
        left = right; 
    }
    const int xDivs[] = { center.fLeft, center.fRight };
    const int yDivs[] = { center.fTop, center.fBottom };
    SkCanvas::Lattice::Flags flags[3][3];
    memset(flags, 0, sizeof(flags));  
    flags[1][1] = SkCanvas::Lattice::kTransparent_Flags;
    SkCanvas::Lattice lattice = { xDivs, yDivs, flags[0], SK_ARRAY_COUNT(xDivs),
         SK_ARRAY_COUNT(yDivs), nullptr };
    sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
    SkImage* imagePtr = image.get();
    for (auto dest: { 20, 30, 40, 60, 90 } ) {
        canvas->drawImageNine(imagePtr, center, SkRect::MakeWH(dest, dest), nullptr);
        canvas->translate(dest + 4, 0);
    }
}
##

#SeeAlso drawBitmapLattice drawImage drawImageNine Lattice

##

#Topic Draw_Image ##

# ------------------------------------------------------------------------------

#Method void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
                  const SkPaint& paint)

Draw text, with origin at (x, y), using Clip, Matrix, and Paint paint.

text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8.

x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
text draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

#Param  text     character code points or Glyphs drawn ##
#Param  byteLength   byte length of text array ##
#Param  x        start of text on x-axis ##
#Param  y        start of text on y-axis ##
#Param  paint    text size, blend, color, and so on, used to draw ##

#Example
#Height 200
#Description
    The same text is drawn varying Paint_Text_Size and varying
    Matrix. 
##
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    float textSizes[] = { 12, 18, 24, 36 };
    for (auto size: textSizes ) {
        paint.setTextSize(size);
        canvas->drawText("Aa", 2, 10, 20, paint);
        canvas->translate(0, size * 2);
    }
    paint.reset();
    paint.setAntiAlias(true);
    float yPos = 20;
    for (auto size: textSizes ) {
        float scale = size / 12.f;
        canvas->resetMatrix();
        canvas->translate(100, 0);
        canvas->scale(scale, scale);
        canvas->drawText("Aa", 2, 10 / scale, yPos / scale, paint);
        yPos += size * 2; 
    }
}
##

#SeeAlso drawString drawPosText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform

##

#Method void drawString(const char* string, SkScalar x, SkScalar y, const SkPaint& paint)

Draw null terminated string, with origin at (x, y), using Clip, Matrix, and
Paint paint.

string meaning depends on Paint_Text_Encoding; by default, strings are encoded
as UTF-8. Other values of Paint_Text_Encoding are unlikely to produce the desired
results, since zero bytes may be embedded in the string.

x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

#Param  string   character code points or Glyphs drawn,
                 ending with a char value of zero
##
#Param  x        start of string on x-axis ##
#Param  y        start of string on y-axis ##
#Param  paint    text size, blend, color, and so on, used to draw ##

#Example
   SkPaint paint;
   canvas->drawString("a small hello", 20, 20, paint);
##

#SeeAlso drawText drawPosText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform

##

#Method void drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint)

Draw null terminated string, with origin at (x, y), using Clip, Matrix, and
Paint paint.

string meaning depends on Paint_Text_Encoding; by default, strings are encoded
as UTF-8. Other values of Paint_Text_Encoding are unlikely to produce the desired
results, since zero bytes may be embedded in the string.

x and y meaning depends on Paint_Text_Align and Paint_Vertical_Text; by default
string draws left to right, positioning the first glyph left side bearing at x
and its baseline at y. Text size is affected by Matrix and Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

#Param  string   character code points or Glyphs drawn,
                 ending with a char value of zero
##
#Param  x        start of string on x-axis ##
#Param  y        start of string on y-axis ##
#Param  paint    text size, blend, color, and so on, used to draw ##

#Example
   SkPaint paint;
   SkString string("a small hello");
   canvas->drawString(string, 20, 20, paint);
##

#SeeAlso drawText drawPosText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform

##

# ------------------------------------------------------------------------------

#Method void drawPosText(const void* text, size_t byteLength, const SkPoint pos[],
                     const SkPaint& paint)

Draw each glyph in text with the origin in pos array, using Clip, Matrix, and
Paint paint. The number of entries in pos array must match the number of Glyphs
described by byteLength of text.

text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. pos elements' meaning depends on Paint_Text_Align and Paint_Vertical_Text;
by default each glyph left side bearing is positioned at x and its
baseline is positioned at y. Text size is affected by Matrix and
Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

Layout engines such as Harfbuzz typically position each glyph
rather than using the font advance widths.

#Param  text     character code points or Glyphs drawn ##
#Param  byteLength   byte length of text array ##
#Param  pos      array of glyph origins ##
#Param  paint    text size, blend, color, and so on, used to draw ##

#Example
#Height 120
void draw(SkCanvas* canvas) {
  const char hello[] = "HeLLo!";
  const SkPoint pos[] = { {40, 100}, {82, 95}, {115, 110}, {130, 95}, {145, 85},
    {172, 100} };
  SkPaint paint;
  paint.setTextSize(60);
  canvas->drawPosText(hello, strlen(hello), pos, paint);
}
##

#SeeAlso drawText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform

##

# ------------------------------------------------------------------------------

#Method void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY,
                      const SkPaint& paint)

Draw each glyph in text with its (x, y) origin composed from xpos array and
constY, using Clip, Matrix, and Paint paint. The number of entries in xpos array
must match the number of Glyphs described by byteLength of text.

text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. xpos elements' meaning depends on Paint_Text_Align and Paint_Vertical_Text;
by default each glyph left side bearing is positioned at an xpos element and
its baseline is positioned at constY. Text size is affected by Matrix and
Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

Layout engines such as Harfbuzz typically position each glyph
rather than using the font advance widths if all Glyphs share the same
baseline.

#Param  text     character code points or Glyphs drawn ##
#Param  byteLength   byte length of text array ##
#Param  xpos     array of x positions, used to position each glyph ##
#Param  constY   shared y coordinate for all of x positions ##
#Param  paint    text size, blend, color, and so on, used to draw ##

#Example
#Height 40
    void draw(SkCanvas* canvas) {
        SkScalar xpos[] = { 20, 40, 80, 160 };
        SkPaint paint;
        canvas->drawPosTextH("XXXX", 4, xpos, 20, paint);
    }
##

#SeeAlso drawText drawPosText drawTextBlob drawTextOnPath drawTextRSXform

##

# ------------------------------------------------------------------------------

#Method void drawTextOnPathHV(const void* text, size_t byteLength, const SkPath& path, SkScalar hOffset,
                          SkScalar vOffset, const SkPaint& paint)

Draw text on Path path, using Clip, Matrix, and Paint paint.

Origin of text is at distance hOffset along the path, offset by a perpendicular
vector of length vOffset. If the path section corresponding the glyph advance is
curved, the glyph is drawn curved to match; control points in the glyph are
mapped to projected points parallel to the path. If the text advance is larger
than the path length, the excess text is clipped.

text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by Matrix and Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

#Param  text         character code points or Glyphs drawn ##
#Param  byteLength   byte length of text array ##
#Param  path         Path providing text baseline ##
#Param  hOffset      distance along path to offset origin ##
#Param  vOffset      offset of text above (if negative) or below (if positive) the path ##
#Param  paint        text size, blend, color, and so on, used to draw ##

#Example
    void draw(SkCanvas* canvas) { 
        const char aero[] = "correo a" "\xC3" "\xA9" "reo";
        const size_t len = sizeof(aero) - 1;
        SkPath path;
        path.addOval({43-26, 43-26, 43+26, 43+26}, SkPath::kCW_Direction, 3);
        SkPaint paint;
        paint.setTextSize(24);
        for (auto offset : { 0, 10, 20 } ) {
            canvas->drawTextOnPathHV(aero, len, path, 0, -offset, paint);
            canvas->translate(70 + offset, 70 + offset);
        }
    }
##

#SeeAlso drawTextOnPath drawText drawPosTextH drawTextBlob drawTextRSXform

##

# ------------------------------------------------------------------------------

#Method void drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
                        const SkMatrix* matrix, const SkPaint& paint)

Draw text on Path path, using Clip, Matrix, and Paint paint.

Origin of text is at beginning of path offset by matrix, if provided, before it
is mapped to path. If the path section corresponding the glyph advance is
curved, the glyph is drawn curved to match; control points in the glyph are
mapped to projected points parallel to the path. If the text advance is larger
than the path length, the excess text is clipped.

text meaning depends on Paint_Text_Encoding; by default, text is encoded as
UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by
default text positions the first glyph left side bearing at origin x and its
baseline at origin y. Text size is affected by Matrix and Paint_Text_Size. 

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

#Param  text         character code points or Glyphs drawn ##
#Param  byteLength   byte length of text array ##
#Param  path         Path providing text baseline ##
#Param  matrix       transform of Glyphs before mapping to path; may be nullptr
                     to use identity Matrix
##
#Param  paint        text size, blend, color, and so on, used to draw ##

#Example
    void draw(SkCanvas* canvas) { 
        const char roller[] = "rollercoaster";
        const size_t len = sizeof(roller) - 1;
        SkPath path;
        path.cubicTo(40, -80, 120, 80, 160, -40);
        SkPaint paint;
        paint.setTextSize(32);
        paint.setStyle(SkPaint::kStroke_Style);
        SkMatrix matrix;
        matrix.setIdentity();
        for (int i = 0; i < 3; ++i) {
            canvas->translate(25, 60);
            canvas->drawPath(path, paint);
            canvas->drawTextOnPath(roller, len, path, &matrix, paint);
            matrix.preTranslate(0, 10);
        }
    }
##

#SeeAlso drawTextOnPathHV drawText drawPosTextH drawTextBlob drawTextRSXform

##

# ------------------------------------------------------------------------------

#Method void drawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
                         const SkRect* cullRect, const SkPaint& paint)

Draw text, transforming each glyph by the corresponding SkRSXform,
using Clip, Matrix, and Paint paint.

RSXform array specifies a separate square scale, rotation, and translation for 
each glyph.

Optional Rect cullRect is a conservative bounds of text, taking into account
RSXform and paint. If cullRect is outside of Clip, canvas can skip drawing.

All elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader,
Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws
filled 12 point black Glyphs.

#Param  text         character code points or Glyphs drawn ##
#Param  byteLength   byte length of text array ##
#Param  xform        RSXform rotates, scales, and translates each glyph individually ##
#Param  cullRect     Rect bounds of text for efficient clipping; or nullptr ##
#Param  paint        text size, blend, color, and so on, used to draw ##

#Example
void draw(SkCanvas* canvas) {  
    const int iterations = 26;
    SkRSXform transforms[iterations];
    char alphabet[iterations];
    SkScalar angle = 0;
    SkScalar scale = 1;
    for (size_t i = 0; i < SK_ARRAY_COUNT(transforms); ++i) {
        const SkScalar s = SkScalarSin(angle) * scale;
        const SkScalar c = SkScalarCos(angle) * scale;
        transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16);
        angle += .45;
        scale += .2;
        alphabet[i] = 'A' + i;
    }
    SkPaint paint;
    paint.setTextAlign(SkPaint::kCenter_Align);
    canvas->translate(110, 138);
    canvas->drawTextRSXform(alphabet, sizeof(alphabet), transforms, nullptr, paint);
}
##

#SeeAlso drawTextOnPath drawTextOnPathHV drawText drawPosText drawTextBlob

##

# ------------------------------------------------------------------------------

#Method void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)

Draw Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint.

blob contains Glyphs, their positions, and paint attributes specific to text:
Typeface, Paint_Text_Size, Paint_Text_Scale_X, Paint_Text_Skew_X,
Paint_Text_Align, Paint_Hinting, Anti-alias, Paint_Fake_Bold,
Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text,
Subpixel_Text, and Paint_Vertical_Text.

Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.

Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter, 
Image_Filter, and Draw_Looper; apply to blob.

#Param  blob     Glyphs, positions, and their paints' text size, typeface, and so on ##
#Param  x        horizontal offset applied to blob ##
#Param  y        vertical offset applied to blob ##
#Param  paint    blend, color, stroking, and so on, used to draw ##

#Example
#Height 120
    void draw(SkCanvas* canvas) {
        SkTextBlobBuilder textBlobBuilder;
        const char bunny[] = "/(^x^)\\";
        const int len = sizeof(bunny) - 1;
        uint16_t glyphs[len];
        SkPaint paint;
        paint.textToGlyphs(bunny, len, glyphs);
        paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
        int runs[] = { 3, 1, 3 };
        SkPoint textPos = { 20, 100 };
        int glyphIndex = 0;
        for (auto runLen : runs) {
            paint.setTextSize(1 == runLen ? 20 : 50);
            const SkTextBlobBuilder::RunBuffer& run = 
                    textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
            memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
            textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
            glyphIndex += runLen;
        }
        sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
        paint.reset();
        canvas->drawTextBlob(blob.get(), 0, 0, paint);
    }
##

#SeeAlso drawText drawPosText drawPosTextH

##

# ------------------------------------------------------------------------------

#Method void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) 

Draw Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint.

blob contains Glyphs, their positions, and paint attributes specific to text:
Typeface, Paint_Text_Size, Paint_Text_Scale_X, Paint_Text_Skew_X,
Paint_Text_Align, Paint_Hinting, Anti-alias, Paint_Fake_Bold,
Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text,
Subpixel_Text, and Paint_Vertical_Text.

Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding.

Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter, 
Image_Filter, and Draw_Looper; apply to blob.

#Param  blob     Glyphs, positions, and their paints' text size, typeface, and so on ##
#Param  x        horizontal offset applied to blob ##
#Param  y        vertical offset applied to blob ##
#Param  paint    blend, color, stroking, and so on, used to draw ##

#Example
#Height 120
#Description
Paint attributes unrelated to text, like color, have no effect on paint in allocated Text_Blob.
Paint attributes related to text, like text size, have no effect on paint passed to drawTextBlob.
##
    void draw(SkCanvas* canvas) {
        SkTextBlobBuilder textBlobBuilder;
        SkPaint paint;
        paint.setTextSize(50);
        paint.setColor(SK_ColorRED);
        paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
        const SkTextBlobBuilder::RunBuffer& run = 
                textBlobBuilder.allocRun(paint, 1, 20, 100);
        run.glyphs[0] = 20;
        sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
        paint.setTextSize(10);
        paint.setColor(SK_ColorBLUE);
        canvas->drawTextBlob(blob.get(), 0, 0, paint);
    }
##

#SeeAlso drawText drawPosText drawPosTextH

##

# ------------------------------------------------------------------------------

#Method void drawPicture(const SkPicture* picture) 

Draw Picture picture, using Clip and Matrix.
Clip and Matrix are unchanged by picture contents, as if
save() was called before and restore() was called after drawPicture.

Picture records a series of draw commands for later playback.

#Param  picture  recorded drawing commands to play ##

#Example
void draw(SkCanvas* canvas) {  
    SkPictureRecorder recorder;
    SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
        SkPaint paint;
        paint.setColor(color);
        recordingCanvas->drawRect({10, 10, 30, 40}, paint);
        recordingCanvas->translate(10, 10);
        recordingCanvas->scale(1.2f, 1.4f);
    }
    sk_sp<SkPicture> playback = recorder.finishRecordingAsPicture();
    const SkPicture* playbackPtr = playback.get();
    canvas->drawPicture(playback);
    canvas->scale(2, 2);
    canvas->translate(50, 0);
    canvas->drawPicture(playback);
}
##

#SeeAlso drawDrawable SkPicture SkPicture::playback

##

# ------------------------------------------------------------------------------

#Method void drawPicture(const sk_sp<SkPicture>& picture) 

Draw Picture picture, using Clip and Matrix.
Clip and Matrix are unchanged by picture contents, as if
save() was called before and restore() was called after drawPicture.

Picture records a series of draw commands for later playback.

#Param  picture  recorded drawing commands to play ##

#Example
void draw(SkCanvas* canvas) {  
    SkPictureRecorder recorder;
    SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
        SkPaint paint;
        paint.setColor(color);
        recordingCanvas->drawRect({10, 10, 30, 40}, paint);
        recordingCanvas->translate(10, 10);
        recordingCanvas->scale(1.2f, 1.4f);
    }
    sk_sp<SkPicture> playback = recorder.finishRecordingAsPicture();
    canvas->drawPicture(playback);
    canvas->scale(2, 2);
    canvas->translate(50, 0);
    canvas->drawPicture(playback);
}
##

#SeeAlso drawDrawable SkPicture SkPicture::playback

##

# ------------------------------------------------------------------------------

#Method void drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint)

Draw Picture picture, using Clip and Matrix; transforming picture with
Matrix matrix, if provided; and use Paint paint Color_Alpha, Color_Filter,
Image_Filter, and Blend_Mode, if provided.

matrix transformation is equivalent to: save(), concat(), drawPicture, restore().
paint use is equivalent to: saveLayer, drawPicture, restore().

#Param  picture  recorded drawing commands to play ##
#Param  matrix   Matrix to rotate, scale, translate, and so on; may be nullptr ##
#Param  paint    Paint to apply transparency, filtering, and so on; may be nullptr ##

#Example
void draw(SkCanvas* canvas) {  
    SkPaint paint;
    SkPictureRecorder recorder;
    SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
        paint.setColor(color);
        recordingCanvas->drawRect({10, 10, 30, 40}, paint);
        recordingCanvas->translate(10, 10);
        recordingCanvas->scale(1.2f, 1.4f);
    }
    sk_sp<SkPicture> playback = recorder.finishRecordingAsPicture();
    const SkPicture* playbackPtr = playback.get();
    SkMatrix matrix;
    matrix.reset();
    for (auto alpha : { 70, 140, 210 } ) {
    paint.setAlpha(alpha);
    canvas->drawPicture(playbackPtr, &matrix, &paint);
    matrix.preTranslate(70, 70);
    }
}
##

#SeeAlso drawDrawable SkPicture SkPicture::playback

##

# ------------------------------------------------------------------------------

#Method void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, const SkPaint* paint) 

Draw Picture picture, using Clip and Matrix; transforming picture with
Matrix matrix, if provided; and use Paint paint Color_Alpha, Color_Filter,
Image_Filter, and Blend_Mode, if provided.

matrix transformation is equivalent to: save(), concat(), drawPicture, restore().
paint use is equivalent to: saveLayer, drawPicture, restore().

#Param  picture  recorded drawing commands to play ##
#Param  matrix   Matrix to rotate, scale, translate, and so on; may be nullptr ##
#Param  paint    Paint to apply transparency, filtering, and so on; may be nullptr ##

#Example
void draw(SkCanvas* canvas) {  
    SkPaint paint;
    SkPictureRecorder recorder;
    SkCanvas* recordingCanvas = recorder.beginRecording(50, 50);
    for (auto color : { SK_ColorRED, SK_ColorBLUE, 0xff007f00 } ) {
        paint.setColor(color);
        recordingCanvas->drawRect({10, 10, 30, 40}, paint);
        recordingCanvas->translate(10, 10);
        recordingCanvas->scale(1.2f, 1.4f);
    }
    sk_sp<SkPicture> playback = recorder.finishRecordingAsPicture();
    SkMatrix matrix;
    matrix.reset();
    for (auto alpha : { 70, 140, 210 } ) {
    paint.setAlpha(alpha);
    canvas->drawPicture(playback, &matrix, &paint);
    matrix.preTranslate(70, 70);
    }
}
##

#SeeAlso drawDrawable SkPicture SkPicture::playback

##

# ------------------------------------------------------------------------------

#Method void drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint)

Draw Vertices vertices, a triangle mesh, using Clip and Matrix.
If Vertices_Texs and Vertices_Colors are defined in vertices, and Paint paint
contains Shader, Blend_Mode mode combines Vertices_Colors with Shader.

#Param  vertices  triangle mesh to draw ##
#Param  mode      combines Vertices_Colors with Shader, if both are present ##
#Param  paint     specifies the Shader, used as Vertices texture; may be nullptr ##

#Example
void draw(SkCanvas* canvas) {
    SkPaint paint;
    SkPoint points[] = { { 0, 0 }, { 250, 0 }, { 100, 100 }, { 0, 250 } };
    SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN };
    auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode,
            SK_ARRAY_COUNT(points), points, nullptr, colors);
    canvas->drawVertices(vertices.get(), SkBlendMode::kSrc, paint);
}
##

#SeeAlso drawPatch drawPicture

##

# ------------------------------------------------------------------------------

#Method void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint)

Draw Vertices vertices, a triangle mesh, using Clip and Matrix.
If Vertices_Texs and Vertices_Colors are defined in vertices, and Paint paint
contains Shader, Blend_Mode mode combines Vertices_Colors with Shader.

#Param  vertices  triangle mesh to draw ##
#Param  mode      combines Vertices_Colors with Shader, if both are present ##
#Param  paint     specifies the Shader, used as Vertices texture, may be nullptr ##

#Example
void draw(SkCanvas* canvas) {
    SkPaint paint;
    SkPoint points[] = { { 0, 0 }, { 250, 0 }, { 100, 100 }, { 0, 250 } };
    SkPoint texs[] = { { 0, 0 }, { 0, 250 }, { 250, 250 }, { 250, 0 } };
    SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN };
    paint.setShader(SkGradientShader::MakeLinear(points, colors, nullptr, 4,
            SkShader::kClamp_TileMode));
    auto vertices = SkVertices::MakeCopy(SkVertices::kTriangleFan_VertexMode,
            SK_ARRAY_COUNT(points), points, texs, colors);
    canvas->drawVertices(vertices.get(), SkBlendMode::kDarken, paint);
}
##

#SeeAlso drawPatch drawPicture

##

# ------------------------------------------------------------------------------

#Method void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
                   const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint)

Draws a Coons_Patch: the interpolation of four cubics with shared corners, 
associating a color, and optionally a texture coordinate, with each corner.

Coons_Patch uses Clip and Matrix, paint Shader, Color_Filter,
Color_Alpha, Image_Filter, and Blend_Mode. If Shader is provided it is treated
as Coons_Patch texture; Blend_Mode mode combines Color colors and Shader if
both are provided.

Point array cubics specifies four Cubics starting at the top-left corner, 
in clockwise order, sharing every fourth point. The last Cubic ends at the
first point.

Color array color associates colors with corners in top-left, top-right,
bottom-right, bottom-left order.

If paint contains Shader, Point array texCoords maps Shader as texture to
corners in top-left, top-right, bottom-right, bottom-left order.

#Param cubics     Path_Cubic array, sharing common points ##
#Param colors     Color array, one for each corner ##
#Param texCoords  Point array of texture coordinates, mapping Shader to corners;
                  may be nullptr 
#Param ##
#Param mode       Blend_Mode for colors, and for Shader if paint has one ##
#Param paint      Shader, Color_Filter, Blend_Mode, used to draw ##

#Example
#Image 5
void draw(SkCanvas* canvas) {
    // SkBitmap source = cmbkygk;
    SkPaint paint;
    paint.setFilterQuality(kLow_SkFilterQuality);
    paint.setAntiAlias(true);
    SkPoint cubics[] = { { 3, 1 },    { 4, 2 }, { 5, 1 },    { 7, 3 },
                      /* { 7, 3 }, */ { 6, 4 }, { 7, 5 },    { 5, 7 },
                      /* { 5, 7 }, */ { 4, 6 }, { 3, 7 },    { 1, 5 },
                      /* { 1, 5 }, */ { 2, 4 }, { 1, 3 }, /* { 3, 1 } */ };
    SkColor colors[] = { 0xbfff0000, 0xbf0000ff, 0xbfff00ff, 0xbf00ffff };
    SkPoint texCoords[] = { { -30, -30 }, { 162, -30}, { 162, 162}, { -30, 162} };
    paint.setShader(SkShader::MakeBitmapShader(source, SkShader::kClamp_TileMode,
                                                       SkShader::kClamp_TileMode, nullptr));
    canvas->scale(15, 15);
    for (auto blend : { SkBlendMode::kSrcOver, SkBlendMode::kModulate, SkBlendMode::kXor } ) {
        canvas->drawPatch(cubics, colors, texCoords, blend, paint);
        canvas->translate(4, 4);
    }
}
##

#ToDo can patch use image filter? ##
#SeeAlso SeeAlso drawVertices drawPicture

##

# ------------------------------------------------------------------------------

#Method void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
                   const SkPoint texCoords[4], const SkPaint& paint) 

Draws Cubic Coons_Patch: the interpolation of four cubics with shared corners, 
associating a color, and optionally a texture coordinate, with each corner.

Coons_Patch uses Clip and Matrix, paint Shader, Color_Filter,
Color_Alpha, Image_Filter, and Blend_Mode. If Shader is provided it is treated
as Coons_Patch texture; Blend_Mode mode combines Color colors and Shader if
both are provided.

Point array cubics specifies four Cubics starting at the top-left corner, 
in clockwise order, sharing every fourth point. The last Cubic ends at the
first point.

Color array color associates colors with corners in top-left, top-right,
bottom-right, bottom-left order.

If paint contains Shader, Point array texCoords maps Shader as texture to
corners in top-left, top-right, bottom-right, bottom-left order.

#Param cubics     Path_Cubic array, sharing common points ##
#Param colors     Color array, one for each corner ##
#Param texCoords  Point array of texture coordinates, mapping Shader to corners;
                  may be nullptr 
#Param ##
#Param paint      Shader, Color_Filter, Blend_Mode, used to draw ##

#Example
void draw(SkCanvas* canvas) {
    SkPaint paint;
    paint.setAntiAlias(true);
    SkPoint cubics[] = { { 3, 1 },    { 4, 2 }, { 5, 1 },    { 7, 3 },
                      /* { 7, 3 }, */ { 6, 4 }, { 7, 5 },    { 5, 7 },
                      /* { 5, 7 }, */ { 4, 6 }, { 3, 7 },    { 1, 5 },
                      /* { 1, 5 }, */ { 2, 4 }, { 1, 3 }, /* { 3, 1 } */ };
    SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorYELLOW, SK_ColorCYAN };
    canvas->scale(30, 30);
    canvas->drawPatch(cubics, colors, nullptr, paint);
    SkPoint text[] = { {3,0.9f}, {4,2.5f}, {5,0.9f}, {7.5f,3.2f}, {5.5f,4.2f},
            {7.5f,5.2f}, {5,7.5f}, {4,5.9f}, {3,7.5f}, {0.5f,5.2f}, {2.5f,4.2f},
            {0.5f,3.2f} };
    paint.setTextSize(18.f / 30);
    paint.setTextAlign(SkPaint::kCenter_Align);
    for (int i = 0; i< 10; ++i) {
       char digit = '0' + i;
       canvas->drawText(&digit, 1, text[i].fX, text[i].fY, paint);
    }
    canvas->drawString("10", text[10].fX, text[10].fY, paint);
    canvas->drawString("11", text[11].fX, text[11].fY, paint);
    paint.setStyle(SkPaint::kStroke_Style);
    canvas->drawPoints(SkCanvas::kPolygon_PointMode, 12, cubics, paint);
    canvas->drawLine(cubics[11].fX, cubics[11].fY, cubics[0].fX, cubics[0].fY, paint);
}
##

#Example
#Image 6
void draw(SkCanvas* canvas) {
    // SkBitmap source = checkerboard;
    SkPaint paint;
    paint.setFilterQuality(kLow_SkFilterQuality);
    paint.setAntiAlias(true);
    SkPoint cubics[] = { { 3, 1 },    { 4, 2 }, { 5, 1 },    { 7, 3 },
                      /* { 7, 3 }, */ { 6, 4 }, { 7, 5 },    { 5, 7 },
                      /* { 5, 7 }, */ { 4, 6 }, { 3, 7 },    { 1, 5 },
                      /* { 1, 5 }, */ { 2, 4 }, { 1, 3 }, /* { 3, 1 } */ };
    SkPoint texCoords[] = { { 0, 0 }, { 0, 62}, { 62, 62}, { 62, 0 } };
    paint.setShader(SkShader::MakeBitmapShader(source, SkShader::kClamp_TileMode,
                                                       SkShader::kClamp_TileMode, nullptr));
    canvas->scale(30, 30);
    canvas->drawPatch(cubics, nullptr, texCoords, paint);
}
##

#ToDo can patch use image filter? ##
#SeeAlso SeeAlso drawVertices drawPicture

##

# ------------------------------------------------------------------------------

#Method void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
                   const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
                   const SkPaint* paint)

Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.

xform, text, and colors if present, must contain count entries.
Optional colors are applied for each sprite using Blend_Mode.
Optional cullRect is a conservative bounds of all transformed sprites. 
If cullRect is outside of Clip, canvas can skip drawing.

#Param atlas  Image containing sprites ##
#Param xform  RSXform mappings for sprites in atlas ##
#Param tex    Rect locations of sprites in atlas ##
#Param colors  one per sprite, blended with sprite using Blend_Mode; may be nullptr ##
#Param count  number of sprites to draw ##
#Param mode   Blend_Mode combining colors and sprites ##
#Param cullRect  bounds of transformed sprites for efficient clipping; may be nullptr ##
#Param paint  Color_Filter, Image_Filter, Blend_Mode, and so on; may be nullptr ##

#Example
#Image 3
void draw(SkCanvas* canvas) {
  // SkBitmap source = mandrill;
  SkRSXform xforms[] = { { .5f, 0, 0, 0 }, {0, .5f, 200, 100 } };
  SkRect tex[] = { { 0, 0, 250, 250 }, { 0, 0, 250, 250 } };
  SkColor colors[] = { 0x7f55aa00, 0x7f3333bf };
  const SkImage* imagePtr = image.get();
  canvas->drawAtlas(imagePtr, xforms, tex, colors, 2, SkBlendMode::kSrcOver, nullptr, nullptr);
}
##

#SeeAlso drawBitmap drawImage

##

# ------------------------------------------------------------------------------

#Method void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
                   const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
                   const SkPaint* paint) 

Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.

xform, text, and colors if present, must contain count entries.
Optional colors is applied for each sprite using Blend_Mode.
Optional cullRect is a conservative bounds of all transformed sprites. 
If cullRect is outside of Clip, canvas can skip drawing.

#Param atlas  Image containing sprites ##
#Param xform  RSXform mappings for sprites in atlas ##
#Param tex    Rect locations of sprites in atlas ##
#Param colors  one per sprite, blended with sprite using Blend_Mode; may be nullptr ##
#Param count  number of sprites to draw ##
#Param mode   Blend_Mode combining colors and sprites ##
#Param cullRect  bounds of transformed sprites for efficient clipping; may be nullptr ##
#Param paint  Color_Filter, Image_Filter, Blend_Mode, and so on; may be nullptr ##

#Example
#Image 3
void draw(SkCanvas* canvas) {
  // SkBitmap source = mandrill;
  SkRSXform xforms[] = { { .5f, 0, 0, 0 }, {0, .5f, 200, 100 } };
  SkRect tex[] = { { 0, 0, 250, 250 }, { 0, 0, 250, 250 } };
  SkColor colors[] = { 0x7f55aa00, 0x7f3333bf };
  SkPaint paint;
  paint.setAlpha(127);
  canvas->drawAtlas(image, xforms, tex, colors, 2, SkBlendMode::kPlus, nullptr, &paint);
}
##

#ToDo bug in example on cpu side, gpu looks ok ##

#SeeAlso drawBitmap drawImage

##

# ------------------------------------------------------------------------------

#Method void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
                   const SkRect* cullRect, const SkPaint* paint) 

Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.

xform and text must contain count entries.
Optional cullRect is a conservative bounds of all transformed sprites. 
If cullRect is outside of Clip, canvas can skip drawing.

#Param atlas  Image containing sprites ##
#Param xform  RSXform mappings for sprites in atlas ##
#Param tex    Rect locations of sprites in atlas ##
#Param count  number of sprites to draw ##
#Param cullRect  bounds of transformed sprites for efficient clipping; may be nullptr ##
#Param paint  Color_Filter, Image_Filter, Blend_Mode, and so on; may be nullptr ##

#Example
#Image 3
void draw(SkCanvas* canvas) {
  // sk_sp<SkImage> image = mandrill;
  SkRSXform xforms[] = { { .5f, 0, 0, 0 }, {0, .5f, 200, 100 } };
  SkRect tex[] = { { 0, 0, 250, 250 }, { 0, 0, 250, 250 } };
  const SkImage* imagePtr = image.get();
  canvas->drawAtlas(imagePtr, xforms, tex, 2, nullptr, nullptr);
}
##

#SeeAlso drawBitmap drawImage

##

# ------------------------------------------------------------------------------

#Method void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
                   int count, const SkRect* cullRect, const SkPaint* paint) 

Draw a set of sprites from atlas, using Clip, Matrix, and optional Paint paint.
paint uses Anti-alias, Color_Alpha, Color_Filter, Image_Filter, and Blend_Mode
to draw, if present. For each entry in the array, Rect tex locates sprite in
atlas, and RSXform xform transforms it into destination space.

xform and text must contain count entries.
Optional cullRect is a conservative bounds of all transformed sprites. 
If cullRect is outside of Clip, canvas can skip drawing.

#Param atlas  Image containing sprites ##
#Param xform  RSXform mappings for sprites in atlas ##
#Param tex    Rect locations of sprites in atlas ##
#Param count  number of sprites to draw ##
#Param cullRect  bounds of transformed sprites for efficient clipping; may be nullptr ##
#Param paint  Color_Filter, Image_Filter, Blend_Mode, and so on; may be nullptr ##

#Example
#Image 3
void draw(SkCanvas* canvas) {
  // sk_sp<SkImage> image = mandrill;
  SkRSXform xforms[] = { { 1, 0, 0, 0 }, {0, 1, 300, 100 } };
  SkRect tex[] = { { 0, 0, 200, 200 }, { 200, 0, 400, 200 } };
  canvas->drawAtlas(image, xforms, tex, 2, nullptr, nullptr);
}
##

#SeeAlso drawBitmap drawImage

##

# ------------------------------------------------------------------------------

#Method void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr)

Draw Drawable drawable using Clip and Matrix, concatenated with 
optional matrix.

If Canvas has an asynchronous implementation, as is the case 
when it is recording into Picture, then drawable will be referenced,
so that SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.

#Param drawable  custom struct encapsulating drawing commands ##
#Param matrix    transformation applied to drawing; may be nullptr  ##

#Example
#Height 100
#Function
struct MyDrawable : public SkDrawable {
    SkRect onGetBounds() override { return SkRect::MakeWH(50, 100);  }

    void onDraw(SkCanvas* canvas) override {
       SkPath path;
       path.conicTo(10, 90, 50, 90, 0.9f);
       SkPaint paint;
       paint.setColor(SK_ColorBLUE);
       canvas->drawRect(path.getBounds(), paint);
       paint.setAntiAlias(true);
       paint.setColor(SK_ColorWHITE);
       canvas->drawPath(path, paint);
    }
};

#Function ##
void draw(SkCanvas* canvas) {
    sk_sp<SkDrawable> drawable(new MyDrawable);
  SkMatrix matrix;
  matrix.setTranslate(10, 10);
  canvas->drawDrawable(drawable.get(), &matrix);
}
##

#SeeAlso SkDrawable drawPicture

##

# ------------------------------------------------------------------------------

#Method void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y)

Draw Drawable drawable using Clip and Matrix, offset by (x, y).

If Canvas has an asynchronous implementation, as is the case 
when it is recording into Picture, then drawable will be referenced,
so that SkDrawable::draw() can be called when the operation is finalized. To force
immediate drawing, call SkDrawable::draw() instead.

#Param drawable  custom struct encapsulating drawing commands ##
#Param x  offset into Canvas writable pixels in x ##
#Param y  offset into Canvas writable pixels in y ##

#Example
#Height 100
#Function
struct MyDrawable : public SkDrawable {
    SkRect onGetBounds() override { return SkRect::MakeWH(50, 100);  }

    void onDraw(SkCanvas* canvas) override {
       SkPath path;
       path.conicTo(10, 90, 50, 90, 0.9f);
       SkPaint paint;
       paint.setColor(SK_ColorBLUE);
       canvas->drawRect(path.getBounds(), paint);
       paint.setAntiAlias(true);
       paint.setColor(SK_ColorWHITE);
       canvas->drawPath(path, paint);
    }
};

#Function ##
void draw(SkCanvas* canvas) {
    sk_sp<SkDrawable> drawable(new MyDrawable);
  canvas->drawDrawable(drawable.get(), 10, 10);
}
##

#SeeAlso SkDrawable drawPicture

##

# ------------------------------------------------------------------------------

#Method void drawAnnotation(const SkRect& rect, const char key[], SkData* value)

Associate Rect on Canvas when an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as Data.

Only some canvas implementations, such as recording to Picture, or drawing to 
Document_PDF, use annotations.

#Param rect    Rect extent of canvas to annotate ##
#Param key     string used for lookup ##
#Param value   data holding value stored in annotation ##

#Example
    #Height 1
    const char text[] = "Click this link!";
    SkRect bounds;
    SkPaint paint;
    paint.setTextSize(40);
    (void)paint.measureText(text, strlen(text), &bounds);
    const char url[] = "https://www.google.com/";
    sk_sp<SkData> urlData(SkData::MakeWithCString(url));
    canvas->drawAnnotation(bounds, "url_key", urlData.get());
##

#SeeAlso SkPicture SkDocument

##

# ------------------------------------------------------------------------------

#Method void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value) 

Associate Rect on Canvas when an annotation; a key-value pair, where the key is
a null-terminated utf8 string, and optional value is stored as Data.

Only some canvas implementations, such as recording to Picture, or drawing to 
Document_PDF, use annotations.

#Param rect    Rect extent of canvas to annotate ##
#Param key     string used for lookup ##
#Param value   data holding value stored in annotation ##

#Example
#Height 1
    const char text[] = "Click this link!";
    SkRect bounds;
    SkPaint paint;
    paint.setTextSize(40);
    (void)paint.measureText(text, strlen(text), &bounds);
    const char url[] = "https://www.google.com/";
    sk_sp<SkData> urlData(SkData::MakeWithCString(url));
    canvas->drawAnnotation(bounds, "url_key", urlData.get());
##

#SeeAlso SkPicture SkDocument

##

#Method SkDrawFilter* getDrawFilter() const

Legacy call to be deprecated.

#Deprecated 
##

##

#Method virtual SkDrawFilter* setDrawFilter(SkDrawFilter* filter)

Legacy call to be deprecated.

#Deprecated 
##

##

# ------------------------------------------------------------------------------

#Method virtual bool isClipEmpty() const

Returns true if Clip is empty; that is, nothing will draw.

May do work when called; it should not be called
more often than needed. However, once called, subsequent calls perform no
work until Clip changes.

#Return  true if Clip is empty ##

#Example
    void draw(SkCanvas* canvas) {
        SkDebugf("clip is%s empty\n", canvas->isClipEmpty() ? "" : " not");
        SkPath path;
        canvas->clipPath(path);
        SkDebugf("clip is%s empty\n", canvas->isClipEmpty() ? "" : " not");
    }
    #StdOut
        clip is not empty
        clip is empty
    ##
##

#SeeAlso isClipRect getLocalClipBounds getDeviceClipBounds

##

# ------------------------------------------------------------------------------

#Method virtual bool isClipRect() const

Returns true if Clip is Rect and not empty.
Returns false if the clip is empty, or if it is not Rect.

#Return  true if Clip is Rect and not empty ##

#Example
    void draw(SkCanvas* canvas) {
        SkDebugf("clip is%s rect\n", canvas->isClipRect() ? "" : " not");
        canvas->clipRect({0, 0, 0, 0});
        SkDebugf("clip is%s rect\n", canvas->isClipRect() ? "" : " not");
    }
    #StdOut
        clip is rect
        clip is not rect
    ##
##

#SeeAlso isClipEmpty getLocalClipBounds getDeviceClipBounds

##

#Class SkCanvas ##

#Class SkAutoCanvasRestore

Stack helper class calls SkCanvas::restoreToCount() when SkAutoCanvasRestore
goes out of scope. Use this to guarantee that the canvas is restored to a known
state.

#Method SkAutoCanvasRestore(SkCanvas* canvas, bool doSave)

Preserves Canvas save count. Optionally saves Canvas Clip and Matrix.

#Param canvas  Canvas to guard ##
#Param doSave  call SkCanvas::save() ##

#Return utility to restore Canvas state on destructor ##

#Example
#Height 128
    SkPaint p;
    p.setAntiAlias(true);
    p.setTextSize(64);
    for (SkScalar sx : { -1, 1 } ) {
        for (SkScalar sy : { -1, 1 } ) {
            SkAutoCanvasRestore autoRestore(canvas, true);
            SkMatrix m = SkMatrix::MakeAll(sx, 1, 96,    0, sy, 64,   0, 0, 1);
            canvas->concat(m);
            canvas->drawString("R", 0, 0, p);
        }
    }
##

#SeeAlso SkCanvas::save SkCanvas::restore

##

#Method ~SkAutoCanvasRestore()

Restores Canvas to saved state. Destructor is called when container goes out of
scope.

#NoExample
##

#SeeAlso SkCanvas::save SkCanvas::restore

##

#Method void restore()

Restores Canvas to saved state immediately. Subsequent calls and
~SkAutoCanvasRestore have no effect.

#Example
for (bool callRestore : { false, true } ) {
    for (bool saveCanvas : {false, true} ) {
        SkAutoCanvasRestore autoRestore(canvas, saveCanvas);
        if (!saveCanvas) {
            canvas->save();
        }
        SkDebugf("saveCanvas: %s  before restore: %d\n",
               saveCanvas ? "true" : "false", canvas->getSaveCount());
        if (callRestore) autoRestore.restore();
        SkDebugf("saveCanvas: %s  after restore: %d\n",
               saveCanvas ? "true" : "false", canvas->getSaveCount());
    }
}
SkDebugf("final count: %d\n", canvas->getSaveCount());
#StdOut
saveCanvas: false  before restore: 2
saveCanvas: false  after restore: 2
saveCanvas: true  before restore: 2
saveCanvas: true  after restore: 2
saveCanvas: false  before restore: 2
saveCanvas: false  after restore: 1
saveCanvas: true  before restore: 2
saveCanvas: true  after restore: 1
final count: 1
##
##

#SeeAlso SkCanvas::save SkCanvas::restore

##

#Class SkAutoCanvasRestore ##

#Topic Canvas ##