# all files / ol/render/canvas/ canvasreplay.js

75.25% Statements 675/897
56.61% Branches 167/295
78.72% Functions 37/47
75.33% Lines 675/896

    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

    1×
    1×
    1×
    1×
    1×
    1×

    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×
    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    44×

    1×

    1×

    73×
    73×
    73×
    73×
    73×

    73×
    73×
    179×
    179×
    179×
    179×
    60×
    59×
    59×

    60×
    60×
    60×
    119×
    117×
    117×
    117×

    2×

    179×
    179×
    179×

    73×
    14×
    14×

    73×
    53×
    53×

    73×

    1×
    65×

    65×
    65×

    65×

    1×

    41×
    41×
    3×

    38×

    38×
    38×

    41×
    41×
    41×
    41×
    41×
    41×
    41×
    610×
    610×
    610×
    610×

    90×
    90×
    90×

    90×

    90×

    90×

    67×
    67×
    67×

    67×
    67×
    67×

    19×

    19×
    19×

    19×
    19×

    19×
    19×
    19×
    19×
    19×
    19×
    19×
    19×
    19×
    19×
    19×
    19×

    19×
    19×
    19×
    19×
    19×
    19×

    19×

    19×
    19×

    19×
    19×
    19×

    19×

    19×

    19×
    19×

    4×

    4×
    4×

    4×
    4×

    4×
    4×

    4×
    4×

    4×
    4×

    4×
    4×

    4×
    4×

    4×
    4×

    4×
    4×
    4×
    4×
    4×

    4×

    4×
    4×

    4×

    4×
    4×

    90×
    25×

    25×
    25×
    10×

    80×
    80×

    67×
    67×
    67×

    67×

    67×
    67×

    67×
    67×
    67×
    67×
    67×
    67×
    34×
    34×
    34×

    67×
    277×
    277×
    277×
    277×
    277×
    277×
    277×
    277×

    67×
    67×

    36×

    36×
    36×
    36×

    34×

    34×

    34×

    34×

    34×

    34×

    34×

    34×
    34×
    34×
    34×
    34×
    34×
    34×

    34×
    34×
    34×
    34×

    2×

    2×

    2×

    2×
    2×
    2×
    2×
    2×

    67×
    67×
    67×

    31×

    31×

    1×

    27×
    27×

    1×

    14×
    14×

    1×

    25×

    25×

    25×
    25×
    25×
    25×
    25×
    25×
    501×
    501×
    501×
    61×
    61×
    440×
    61×
    61×

    61×
    61×

    1×
    65×

    65×
    65×
    65×

    65×
    65×
    65×

    65×
    65×

    1×

    1×
    20×

    1×
    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    7×

    1×

    1×

    8×

    1×

    8×

    8×

    8×

    8×

    8×

    8×

    8×

    8×

    8×

    8×

    8×

    8×
    8×
    8×
    8×
    8×

    8×

    8×

    8×

    1×

    1×
    5×

    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×
    5×

    1×
    8×
    8×
    8×
    8×
    8×
    8×
    8×

    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×
    8×

    1×

    3×

    3×

    1×

    1×

    1×
    1×
    1×
    1×
    1×
    1×

    1×

    1×

    1×

    1×

    1×

    1×

    3×
    3×
    3×
    3×
    3×

    3×
    3×

    3×
    3×

    3×
    3×

    3×
    3×

    3×
    3×

    3×
    3×

    3×

    1×

    23×

    23×

    1×

    1×

    53×
    53×
    53×
    53×
    53×
    53×
    53×
    53×
    53×

    53×

    53×
    53×
    53×

    53×

    53×
    53×
    53×
    53×

    53×
    53×

    53×
    53×
    53×

    53×

    1×

    1×

    53×
    53×
    53×
    53×
    53×

    53×
    53×

    53×
    53×

    53×

    53×
    53×

    53×
    53×
    53×
    53×
    53×

    1×

    1×
    20×
    20×
    20×

    20×
    20×
    20×
    20×
    20×
    548×

    1×
    54×
    21×
    21×
    21×
    21×

    54×

    1×

    56×
    56×

    56×
    56×
    55×
    55×

    1×

    56×
    56×
    56×

    56×
    56×

    56×
    56×

    56×
    56×

    56×
    56×

    56×
    56×

    56×
    23×

    23×

    1×
    53×
    53×
    53×
    53×
    53×
    53×
    53×
    53×
    53×
    20×

    20×

    53×
    53×
    53×
    53×
    53×
    53×

    53×

    20×

    20×
    20×
    20×
    20×
    20×
    20×

    1×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    2×

    1×

    1×

    4×

    4×
    4×

    4×

    4×
    4×
    4×
    4×

    4×
    4×
    4×

    4×
    4×
    4×

    1×

    4×
    4×

    2×

    2×

    2×
    2×
    2×
    2×

    1×

    1×

    4×
    4×

    2×

    2×

    2×
    2×
    2×
    2×

    1×
    4×

    4×
    4×

    4×
    4×

    4×
    2×

    2×
    2×

    4×
    4×
    4×

    4×
    4×
    4×
    4×
    4×
    4×
    4×
    4×
    4×

    4×

    4×

    4×
    2×

    2×
    2×
    2×
    2×

    4×
    4×
    4×
    4×
    4×

    1×

    77×

    77×

    77×

    77×

    77×

    77×

    77×

    1×
    70×
    70×
    27×
    27×
    27×
    27×

    1×

    14×
    14×

    14×
    14×

    14×
    14×
    14×
    14×
    14×

    14×

    25×
    25×
    20×
    20×
    10×

    10×

    1×

    75×
    75×
    75×
    33×
    33×

    75×
    75×
    33×
    33×

    33×

    33×

    75×

    1×
    65×

    1×

    27×
    27×

    27×
    27×
    27×
    27×
    27×
    27×
    27×

    27×
    27×
    27×
    27×
    27×
    27×
    27×
    27×

    27×
    27×
    27×
    27×
    108×
    108×
    27×

    27×

    1×

    14×
    14×

    14×
    14×
    14×
    14×
    46×
    46×
    14×

    14×
    10×

    4×

    1×

     // FIXME add option to apply snapToPixel to all coordinates?
    // FIXME can eliminate empty set styles and strokes (when all geoms skipped)

    goog.provide('ol.render.canvas.ImageReplay');
    goog.provide('ol.render.canvas.LineStringReplay');
    goog.provide('ol.render.canvas.PolygonReplay');
    goog.provide('ol.render.canvas.Replay');
    goog.provide('ol.render.canvas.ReplayGroup');
    goog.provide('ol.render.canvas.TextReplay');

    goog.require('goog.array');
    goog.require('goog.asserts');
    goog.require('goog.object');
    goog.require('goog.vec.Mat4');
    goog.require('ol');
    goog.require('ol.array');
    goog.require('ol.color');
    goog.require('ol.dom');
    goog.require('ol.extent');
    goog.require('ol.extent.Relationship');
    goog.require('ol.geom.flat.simplify');
    goog.require('ol.geom.flat.transform');
    goog.require('ol.has');
    goog.require('ol.render.IReplayGroup');
    goog.require('ol.render.VectorContext');
    goog.require('ol.render.canvas');
    goog.require('ol.vec.Mat4');

    /**
     * @enum {number}
     */
    ol.render.canvas.Instruction = {
      BEGIN_GEOMETRY: 0,
      BEGIN_PATH: 1,
      CIRCLE: 2,
      CLOSE_PATH: 3,
      DRAW_IMAGE: 4,
      DRAW_TEXT: 5,
      END_GEOMETRY: 6,
      FILL: 7,
      MOVE_TO_LINE_TO: 8,
      SET_FILL_STYLE: 9,
      SET_STROKE_STYLE: 10,
      SET_TEXT_STYLE: 11,
      STROKE: 12
    };

    /**
     * @constructor
     * @extends {ol.render.VectorContext}
     * @param {number} tolerance Tolerance.
     * @param {ol.Extent} maxExtent Maximum extent.
     * @param {number} resolution Resolution.
     * @protected
     * @struct
     */
    ol.render.canvas.Replay = function(tolerance, maxExtent, resolution) {
      goog.base(this);

      /**
       * @protected
       * @type {number}
       */
      this.tolerance = tolerance;

      /**
       * @protected
       * @const
       * @type {ol.Extent}
       */
      this.maxExtent = maxExtent;

      /**
       * @private
       * @type {ol.Extent}
       */
      this.bufferedMaxExtent_ = null;

      /**
       * @protected
       * @type {number}
       */
      this.maxLineWidth = 0;

      /**
       * @protected
       * @const
       * @type {number}
       */
      this.resolution = resolution;

      /**
       * @private
       * @type {Array.<*>}
       */
      this.beginGeometryInstruction1_ = null;

      /**
       * @private
       * @type {Array.<*>}
       */
      this.beginGeometryInstruction2_ = null;

      /**
       * @protected
       * @type {Array.<*>}
       */
      this.instructions = [];

      /**
       * @protected
       * @type {Array.<number>}
       */
      this.coordinates = [];

      /**
       * @private
       * @type {goog.vec.Mat4.Number}
       */
      this.renderedTransform_ = goog.vec.Mat4.createNumber();

      /**
       * @protected
       * @type {Array.<*>}
       */
      this.hitDetectionInstructions = [];

      /**
       * @private
       * @type {Array.<number>}
       */
      this.pixelCoordinates_ = [];

      /**
       * @private
       * @type {!goog.vec.Mat4.Number}
       */
      this.tmpLocalTransform_ = goog.vec.Mat4.createNumber();
    };
    goog.inherits(ol.render.canvas.Replay, ol.render.VectorContext);

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {number} end End.
     * @param {number} stride Stride.
     * @param {boolean} close Close.
     * @protected
     * @return {number} My end.
     */
    ol.render.canvas.Replay.prototype.appendFlatCoordinates =
        function(flatCoordinates, offset, end, stride, close) {

      var myEnd = this.coordinates.length;
      var extent = this.getBufferedMaxExtent();
      var lastCoord = [flatCoordinates[offset], flatCoordinates[offset + 1]];
      var nextCoord = [NaN, NaN];
      var skipped = true;

      var i, lastRel, nextRel;
      for (i = offset + stride; i < end; i += stride) {
        nextCoord[0] = flatCoordinates[i];
        nextCoord[1] = flatCoordinates[i + 1];
        nextRel = ol.extent.coordinateRelationship(extent, nextCoord);
        if (nextRel !== lastRel) {
          if (skipped) {
            this.coordinates[myEnd++] = lastCoord[0];
            this.coordinates[myEnd++] = lastCoord[1];
          }
          this.coordinates[myEnd++] = nextCoord[0];
          this.coordinates[myEnd++] = nextCoord[1];
          skipped = false;
        } else if (nextRel === ol.extent.Relationship.INTERSECTING) {
          this.coordinates[myEnd++] = nextCoord[0];
          this.coordinates[myEnd++] = nextCoord[1];
          skipped = false;
        } else {
          skipped = true;
        }
        lastCoord[0] = nextCoord[0];
        lastCoord[1] = nextCoord[1];
        lastRel = nextRel;
      }

      // handle case where there is only one point to append
      if (i === offset + stride) {
        this.coordinates[myEnd++] = lastCoord[0];
        this.coordinates[myEnd++] = lastCoord[1];
      }

      if (close) {
        this.coordinates[myEnd++] = flatCoordinates[offset];
        this.coordinates[myEnd++] = flatCoordinates[offset + 1];
      }
      return myEnd;
    };

    /**
     * @protected
     * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
     * @param {ol.Feature|ol.render.Feature} feature Feature.
     */
    ol.render.canvas.Replay.prototype.beginGeometry = function(geometry, feature) {
      this.beginGeometryInstruction1_ =
          [ol.render.canvas.Instruction.BEGIN_GEOMETRY, feature, 0];
      this.instructions.push(this.beginGeometryInstruction1_);
      this.beginGeometryInstruction2_ =
          [ol.render.canvas.Instruction.BEGIN_GEOMETRY, feature, 0];
      this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
    };

    /**
     * @private
     * @param {CanvasRenderingContext2D} context Context.
     * @param {number} pixelRatio Pixel ratio.
     * @param {goog.vec.Mat4.Number} transform Transform.
     * @param {number} viewRotation View rotation.
     * @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
     *     to skip.
     * @param {Array.<*>} instructions Instructions array.
     * @param {function((ol.Feature|ol.render.Feature)): T|undefined}
     *     featureCallback Feature callback.
     * @param {ol.Extent=} opt_hitExtent Only check features that intersect this
     *     extent.
     * @return {T|undefined} Callback result.
     * @template T
     */
    ol.render.canvas.Replay.prototype.replay_ = function(
        context, pixelRatio, transform, viewRotation, skippedFeaturesHash,
        instructions, featureCallback, opt_hitExtent) {
      /** @type {Array.<number>} */
      var pixelCoordinates;
      if (ol.vec.Mat4.equals2D(transform, this.renderedTransform_)) {
        pixelCoordinates = this.pixelCoordinates_;
      } else {
        pixelCoordinates = ol.geom.flat.transform.transform2D(
            this.coordinates, 0, this.coordinates.length, 2,
            transform, this.pixelCoordinates_);
        goog.vec.Mat4.setFromArray(this.renderedTransform_, transform);
        goog.asserts.assert(pixelCoordinates === this.pixelCoordinates_,
            'pixelCoordinates should be the same as this.pixelCoordinates_');
      }
      var i = 0; // instruction index
      var ii = instructions.length; // end of instructions
      var d = 0; // data index
      var dd; // end of per-instruction data
      var localTransform = this.tmpLocalTransform_;
      var prevX, prevY, roundX, roundY;
      while (i < ii) {
        var instruction = instructions[i];
        var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
        var feature, fill, stroke, text, x, y;
        switch (type) {
          case ol.render.canvas.Instruction.BEGIN_GEOMETRY:
            feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
            var featureUid = goog.getUid(feature).toString();
            Iif (skippedFeaturesHash[featureUid] !== undefined ||
                !feature.getGeometry()) {
              i = /** @type {number} */ (instruction[2]);
            } else Iif (opt_hitExtent !== undefined && !ol.extent.intersects(
                /** @type {Array<number>} */ (opt_hitExtent),
                feature.getGeometry().getExtent())) {
              i = /** @type {number} */ (instruction[2]);
            } else {
              ++i;
            }
            break;
          case ol.render.canvas.Instruction.BEGIN_PATH:
            context.beginPath();
            ++i;
            break;
          case ol.render.canvas.Instruction.CIRCLE:
            goog.asserts.assert(goog.isNumber(instruction[1]),
                'second instruction should be a number');
            d = /** @type {number} */ (instruction[1]);
            var x1 = pixelCoordinates[d];
            var y1 = pixelCoordinates[d + 1];
            var x2 = pixelCoordinates[d + 2];
            var y2 = pixelCoordinates[d + 3];
            var dx = x2 - x1;
            var dy = y2 - y1;
            var r = Math.sqrt(dx * dx + dy * dy);
            context.arc(x1, y1, r, 0, 2 * Math.PI, true);
            ++i;
            break;
          case ol.render.canvas.Instruction.CLOSE_PATH:
            context.closePath();
            ++i;
            break;
          case ol.render.canvas.Instruction.DRAW_IMAGE:
            goog.asserts.assert(goog.isNumber(instruction[1]),
                'second instruction should be a number');
            d = /** @type {number} */ (instruction[1]);
            goog.asserts.assert(goog.isNumber(instruction[2]),
                'third instruction should be a number');
            dd = /** @type {number} */ (instruction[2]);
            var image =  /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
                (instruction[3]);
            // Remaining arguments in DRAW_IMAGE are in alphabetical order
            var anchorX = /** @type {number} */ (instruction[4]) * pixelRatio;
            var anchorY = /** @type {number} */ (instruction[5]) * pixelRatio;
            var height = /** @type {number} */ (instruction[6]);
            var opacity = /** @type {number} */ (instruction[7]);
            var originX = /** @type {number} */ (instruction[8]);
            var originY = /** @type {number} */ (instruction[9]);
            var rotateWithView = /** @type {boolean} */ (instruction[10]);
            var rotation = /** @type {number} */ (instruction[11]);
            var scale = /** @type {number} */ (instruction[12]);
            var snapToPixel = /** @type {boolean} */ (instruction[13]);
            var width = /** @type {number} */ (instruction[14]);
            Iif (rotateWithView) {
              rotation += viewRotation;
            }
            for (; d < dd; d += 2) {
              x = pixelCoordinates[d] - anchorX;
              y = pixelCoordinates[d + 1] - anchorY;
              Eif (snapToPixel) {
                x = (x + 0.5) | 0;
                y = (y + 0.5) | 0;
              }
              Iif (scale != 1 || rotation !== 0) {
                var centerX = x + anchorX;
                var centerY = y + anchorY;
                ol.vec.Mat4.makeTransform2D(
                    localTransform, centerX, centerY, scale, scale,
                    rotation, -centerX, -centerY);
                context.setTransform(
                    goog.vec.Mat4.getElement(localTransform, 0, 0),
                    goog.vec.Mat4.getElement(localTransform, 1, 0),
                    goog.vec.Mat4.getElement(localTransform, 0, 1),
                    goog.vec.Mat4.getElement(localTransform, 1, 1),
                    goog.vec.Mat4.getElement(localTransform, 0, 3),
                    goog.vec.Mat4.getElement(localTransform, 1, 3));
              }
              var alpha = context.globalAlpha;
              Iif (opacity != 1) {
                context.globalAlpha = alpha * opacity;
              }

              var w = width - originX;
              var h = height - originY;
              context.drawImage(image, originX, originY, w, h, x, y,
                  w * pixelRatio, h * pixelRatio);

              Iif (opacity != 1) {
                context.globalAlpha = alpha;
              }
              Iif (scale != 1 || rotation !== 0) {
                context.setTransform(1, 0, 0, 1, 0, 0);
              }
            }
            ++i;
            break;
          case ol.render.canvas.Instruction.DRAW_TEXT:
            goog.asserts.assert(goog.isNumber(instruction[1]),
                '2nd instruction should be a number');
            d = /** @type {number} */ (instruction[1]);
            goog.asserts.assert(goog.isNumber(instruction[2]),
                '3rd instruction should be a number');
            dd = /** @type {number} */ (instruction[2]);
            goog.asserts.assert(goog.isString(instruction[3]),
                '4th instruction should be a string');
            text = /** @type {string} */ (instruction[3]);
            goog.asserts.assert(goog.isNumber(instruction[4]),
                '5th instruction should be a number');
            var offsetX = /** @type {number} */ (instruction[4]) * pixelRatio;
            goog.asserts.assert(goog.isNumber(instruction[5]),
                '6th instruction should be a number');
            var offsetY = /** @type {number} */ (instruction[5]) * pixelRatio;
            goog.asserts.assert(goog.isNumber(instruction[6]),
                '7th instruction should be a number');
            rotation = /** @type {number} */ (instruction[6]);
            goog.asserts.assert(goog.isNumber(instruction[7]),
                '8th instruction should be a number');
            scale = /** @type {number} */ (instruction[7]) * pixelRatio;
            goog.asserts.assert(goog.isBoolean(instruction[8]),
                '9th instruction should be a boolean');
            fill = /** @type {boolean} */ (instruction[8]);
            goog.asserts.assert(goog.isBoolean(instruction[9]),
                '10th instruction should be a boolean');
            stroke = /** @type {boolean} */ (instruction[9]);
            for (; d < dd; d += 2) {
              x = pixelCoordinates[d] + offsetX;
              y = pixelCoordinates[d + 1] + offsetY;
              Iif (scale != 1 || rotation !== 0) {
                ol.vec.Mat4.makeTransform2D(
                    localTransform, x, y, scale, scale, rotation, -x, -y);
                context.setTransform(
                    goog.vec.Mat4.getElement(localTransform, 0, 0),
                    goog.vec.Mat4.getElement(localTransform, 1, 0),
                    goog.vec.Mat4.getElement(localTransform, 0, 1),
                    goog.vec.Mat4.getElement(localTransform, 1, 1),
                    goog.vec.Mat4.getElement(localTransform, 0, 3),
                    goog.vec.Mat4.getElement(localTransform, 1, 3));
              }
              Iif (stroke) {
                context.strokeText(text, x, y);
              }
              Eif (fill) {
                context.fillText(text, x, y);
              }
              Iif (scale != 1 || rotation !== 0) {
                context.setTransform(1, 0, 0, 1, 0, 0);
              }
            }
            ++i;
            break;
          case ol.render.canvas.Instruction.END_GEOMETRY:
            if (featureCallback !== undefined) {
              feature =
                  /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
              var result = featureCallback(feature);
              if (result) {
                return result;
              }
            }
            ++i;
            break;
          case ol.render.canvas.Instruction.FILL:
            context.fill();
            ++i;
            break;
          case ol.render.canvas.Instruction.MOVE_TO_LINE_TO:
            goog.asserts.assert(goog.isNumber(instruction[1]),
                '2nd instruction should be a number');
            d = /** @type {number} */ (instruction[1]);
            goog.asserts.assert(goog.isNumber(instruction[2]),
                '3rd instruction should be a number');
            dd = /** @type {number} */ (instruction[2]);
            x = pixelCoordinates[d];
            y = pixelCoordinates[d + 1];
            roundX = (x + 0.5) | 0;
            roundY = (y + 0.5) | 0;
            if (roundX !== prevX || roundY !== prevY) {
              context.moveTo(x, y);
              prevX = roundX;
              prevY = roundY;
            }
            for (d += 2; d < dd; d += 2) {
              x = pixelCoordinates[d];
              y = pixelCoordinates[d + 1];
              roundX = (x + 0.5) | 0;
              roundY = (y + 0.5) | 0;
              Eif (roundX !== prevX || roundY !== prevY) {
                context.lineTo(x, y);
                prevX = roundX;
                prevY = roundY;
              }
            }
            ++i;
            break;
          case ol.render.canvas.Instruction.SET_FILL_STYLE:
            goog.asserts.assert(goog.isString(instruction[1]),
                '2nd instruction should be a string');
            context.fillStyle = /** @type {string} */ (instruction[1]);
            ++i;
            break;
          case ol.render.canvas.Instruction.SET_STROKE_STYLE:
            goog.asserts.assert(goog.isString(instruction[1]),
                '2nd instruction should be a string');
            goog.asserts.assert(goog.isNumber(instruction[2]),
                '3rd instruction should be a number');
            goog.asserts.assert(goog.isString(instruction[3]),
                '4rd instruction should be a string');
            goog.asserts.assert(goog.isString(instruction[4]),
                '5th instruction should be a string');
            goog.asserts.assert(goog.isNumber(instruction[5]),
                '6th instruction should be a number');
            goog.asserts.assert(instruction[6],
                '7th instruction should not be null');
            var usePixelRatio = instruction[7] !== undefined ?
                instruction[7] : true;
            var lineWidth = /** @type {number} */ (instruction[2]);
            context.strokeStyle = /** @type {string} */ (instruction[1]);
            context.lineWidth = usePixelRatio ? lineWidth * pixelRatio : lineWidth;
            context.lineCap = /** @type {string} */ (instruction[3]);
            context.lineJoin = /** @type {string} */ (instruction[4]);
            context.miterLimit = /** @type {number} */ (instruction[5]);
            Iif (ol.has.CANVAS_LINE_DASH) {
              context.setLineDash(/** @type {Array.<number>} */ (instruction[6]));
            }
            prevX = NaN;
            prevY = NaN;
            ++i;
            break;
          case ol.render.canvas.Instruction.SET_TEXT_STYLE:
            goog.asserts.assert(goog.isString(instruction[1]),
                '2nd instruction should be a string');
            goog.asserts.assert(goog.isString(instruction[2]),
                '3rd instruction should be a string');
            goog.asserts.assert(goog.isString(instruction[3]),
                '4th instruction should be a string');
            context.font = /** @type {string} */ (instruction[1]);
            context.textAlign = /** @type {string} */ (instruction[2]);
            context.textBaseline = /** @type {string} */ (instruction[3]);
            ++i;
            break;
          case ol.render.canvas.Instruction.STROKE:
            context.stroke();
            ++i;
            break;
          default:
            goog.asserts.fail('Unknown canvas render instruction');
            ++i; // consume the instruction anyway, to avoid an infinite loop
            break;
        }
      }
      // assert that all instructions were consumed
      goog.asserts.assert(i == instructions.length,
          'all instructions should be consumed');
      return undefined;
    };

    /**
     * @param {CanvasRenderingContext2D} context Context.
     * @param {number} pixelRatio Pixel ratio.
     * @param {goog.vec.Mat4.Number} transform Transform.
     * @param {number} viewRotation View rotation.
     * @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
     *     to skip.
     */
    ol.render.canvas.Replay.prototype.replay = function(
        context, pixelRatio, transform, viewRotation, skippedFeaturesHash) {
      var instructions = this.instructions;
      this.replay_(context, pixelRatio, transform, viewRotation,
          skippedFeaturesHash, instructions, undefined);
    };

    /**
     * @param {CanvasRenderingContext2D} context Context.
     * @param {goog.vec.Mat4.Number} transform Transform.
     * @param {number} viewRotation View rotation.
     * @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
     *     to skip.
     * @param {function((ol.Feature|ol.render.Feature)): T=} opt_featureCallback
     *     Feature callback.
     * @param {ol.Extent=} opt_hitExtent Only check features that intersect this
     *     extent.
     * @return {T|undefined} Callback result.
     * @template T
     */
    ol.render.canvas.Replay.prototype.replayHitDetection = function(
        context, transform, viewRotation, skippedFeaturesHash,
        opt_featureCallback, opt_hitExtent) {
      var instructions = this.hitDetectionInstructions;
      return this.replay_(context, 1, transform, viewRotation,
          skippedFeaturesHash, instructions, opt_featureCallback, opt_hitExtent);
    };

    /**
     * @private
     */
    ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions_ =
        function() {
      var hitDetectionInstructions = this.hitDetectionInstructions;
      // step 1 - reverse array
      hitDetectionInstructions.reverse();
      // step 2 - reverse instructions within geometry blocks
      var i;
      var n = hitDetectionInstructions.length;
      var instruction;
      var type;
      var begin = -1;
      for (i = 0; i < n; ++i) {
        instruction = hitDetectionInstructions[i];
        type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
        if (type == ol.render.canvas.Instruction.END_GEOMETRY) {
          goog.asserts.assert(begin == -1, 'begin should be -1');
          begin = i;
        } else if (type == ol.render.canvas.Instruction.BEGIN_GEOMETRY) {
          instruction[2] = i;
          goog.asserts.assert(begin >= 0,
              'begin should be larger than or equal to 0');
          ol.array.reverseSubArray(this.hitDetectionInstructions, begin, i);
          begin = -1;
        }
      }
    };

    /**
     * @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
     * @param {ol.Feature|ol.render.Feature} feature Feature.
     */
    ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
      goog.asserts.assert(this.beginGeometryInstruction1_,
          'this.beginGeometryInstruction1_ should not be null');
      this.beginGeometryInstruction1_[2] = this.instructions.length;
      this.beginGeometryInstruction1_ = null;
      goog.asserts.assert(this.beginGeometryInstruction2_,
          'this.beginGeometryInstruction2_ should not be null');
      this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
      this.beginGeometryInstruction2_ = null;
      var endGeometryInstruction =
          [ol.render.canvas.Instruction.END_GEOMETRY, feature];
      this.instructions.push(endGeometryInstruction);
      this.hitDetectionInstructions.push(endGeometryInstruction);
    };

    /**
     * FIXME empty description for jsdoc
     */
    ol.render.canvas.Replay.prototype.finish = ol.nullFunction;

    /**
     * Get the buffered rendering extent.  Rendering will be clipped to the extent
     * provided to the constructor.  To account for symbolizers that may intersect
     * this extent, we calculate a buffered extent (e.g. based on stroke width).
     * @return {ol.Extent} The buffered rendering extent.
     * @protected
     */
    ol.render.canvas.Replay.prototype.getBufferedMaxExtent = function() {
      return this.maxExtent;
    };

    /**
     * @constructor
     * @extends {ol.render.canvas.Replay}
     * @param {number} tolerance Tolerance.
     * @param {ol.Extent} maxExtent Maximum extent.
     * @param {number} resolution Resolution.
     * @protected
     * @struct
     */
    ol.render.canvas.ImageReplay = function(tolerance, maxExtent, resolution) {
      goog.base(this, tolerance, maxExtent, resolution);

      /**
       * @private
       * @type {HTMLCanvasElement|HTMLVideoElement|Image}
       */
      this.hitDetectionImage_ = null;

      /**
       * @private
       * @type {HTMLCanvasElement|HTMLVideoElement|Image}
       */
      this.image_ = null;

      /**
       * @private
       * @type {number|undefined}
       */
      this.anchorX_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.anchorY_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.height_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.opacity_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.originX_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.originY_ = undefined;

      /**
       * @private
       * @type {boolean|undefined}
       */
      this.rotateWithView_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.rotation_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.scale_ = undefined;

      /**
       * @private
       * @type {boolean|undefined}
       */
      this.snapToPixel_ = undefined;

      /**
       * @private
       * @type {number|undefined}
       */
      this.width_ = undefined;

    };
    goog.inherits(ol.render.canvas.ImageReplay, ol.render.canvas.Replay);

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {number} end End.
     * @param {number} stride Stride.
     * @private
     * @return {number} My end.
     */
    ol.render.canvas.ImageReplay.prototype.drawCoordinates_ =
        function(flatCoordinates, offset, end, stride) {
      return this.appendFlatCoordinates(
          flatCoordinates, offset, end, stride, false);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.ImageReplay.prototype.drawPointGeometry =
        function(pointGeometry, feature) {
      Iif (!this.image_) {
        return;
      }
      goog.asserts.assert(this.anchorX_ !== undefined,
          'this.anchorX_ should be defined');
      goog.asserts.assert(this.anchorY_ !== undefined,
          'this.anchorY_ should be defined');
      goog.asserts.assert(this.height_ !== undefined,
          'this.height_ should be defined');
      goog.asserts.assert(this.opacity_ !== undefined,
          'this.opacity_ should be defined');
      goog.asserts.assert(this.originX_ !== undefined,
          'this.originX_ should be defined');
      goog.asserts.assert(this.originY_ !== undefined,
          'this.originY_ should be defined');
      goog.asserts.assert(this.rotateWithView_ !== undefined,
          'this.rotateWithView_ should be defined');
      goog.asserts.assert(this.rotation_ !== undefined,
          'this.rotation_ should be defined');
      goog.asserts.assert(this.scale_ !== undefined,
          'this.scale_ should be defined');
      goog.asserts.assert(this.width_ !== undefined,
          'this.width_ should be defined');
      this.beginGeometry(pointGeometry, feature);
      var flatCoordinates = pointGeometry.getFlatCoordinates();
      var stride = pointGeometry.getStride();
      var myBegin = this.coordinates.length;
      var myEnd = this.drawCoordinates_(
          flatCoordinates, 0, flatCoordinates.length, stride);
      this.instructions.push([
        ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
        // Remaining arguments to DRAW_IMAGE are in alphabetical order
        this.anchorX_, this.anchorY_, this.height_, this.opacity_,
        this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
        this.scale_, this.snapToPixel_, this.width_
      ]);
      this.hitDetectionInstructions.push([
        ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd,
        this.hitDetectionImage_,
        // Remaining arguments to DRAW_IMAGE are in alphabetical order
        this.anchorX_, this.anchorY_, this.height_, this.opacity_,
        this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
        this.scale_, this.snapToPixel_, this.width_
      ]);
      this.endGeometry(pointGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry =
        function(multiPointGeometry, feature) {
      if (!this.image_) {
        return;
      }
      goog.asserts.assert(this.anchorX_ !== undefined,
          'this.anchorX_ should be defined');
      goog.asserts.assert(this.anchorY_ !== undefined,
          'this.anchorY_ should be defined');
      goog.asserts.assert(this.height_ !== undefined,
          'this.height_ should be defined');
      goog.asserts.assert(this.opacity_ !== undefined,
          'this.opacity_ should be defined');
      goog.asserts.assert(this.originX_ !== undefined,
          'this.originX_ should be defined');
      goog.asserts.assert(this.originY_ !== undefined,
          'this.originY_ should be defined');
      goog.asserts.assert(this.rotateWithView_ !== undefined,
          'this.rotateWithView_ should be defined');
      goog.asserts.assert(this.rotation_ !== undefined,
          'this.rotation_ should be defined');
      goog.asserts.assert(this.scale_ !== undefined,
          'this.scale_ should be defined');
      goog.asserts.assert(this.width_ !== undefined,
          'this.width_ should be defined');
      this.beginGeometry(multiPointGeometry, feature);
      var flatCoordinates = multiPointGeometry.getFlatCoordinates();
      var stride = multiPointGeometry.getStride();
      var myBegin = this.coordinates.length;
      var myEnd = this.drawCoordinates_(
          flatCoordinates, 0, flatCoordinates.length, stride);
      this.instructions.push([
        ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
        // Remaining arguments to DRAW_IMAGE are in alphabetical order
        this.anchorX_, this.anchorY_, this.height_, this.opacity_,
        this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
        this.scale_, this.snapToPixel_, this.width_
      ]);
      this.hitDetectionInstructions.push([
        ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd,
        this.hitDetectionImage_,
        // Remaining arguments to DRAW_IMAGE are in alphabetical order
        this.anchorX_, this.anchorY_, this.height_, this.opacity_,
        this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
        this.scale_, this.snapToPixel_, this.width_
      ]);
      this.endGeometry(multiPointGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.ImageReplay.prototype.finish = function() {
      this.reverseHitDetectionInstructions_();
      // FIXME this doesn't really protect us against further calls to draw*Geometry
      this.anchorX_ = undefined;
      this.anchorY_ = undefined;
      this.hitDetectionImage_ = null;
      this.image_ = null;
      this.height_ = undefined;
      this.scale_ = undefined;
      this.opacity_ = undefined;
      this.originX_ = undefined;
      this.originY_ = undefined;
      this.rotateWithView_ = undefined;
      this.rotation_ = undefined;
      this.snapToPixel_ = undefined;
      this.width_ = undefined;
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
      goog.asserts.assert(imageStyle, 'imageStyle should not be null');
      var anchor = imageStyle.getAnchor();
      goog.asserts.assert(anchor, 'anchor should not be null');
      var size = imageStyle.getSize();
      goog.asserts.assert(size, 'size should not be null');
      var hitDetectionImage = imageStyle.getHitDetectionImage(1);
      goog.asserts.assert(hitDetectionImage,
          'hitDetectionImage should not be null');
      var image = imageStyle.getImage(1);
      goog.asserts.assert(image, 'image should not be null');
      var origin = imageStyle.getOrigin();
      goog.asserts.assert(origin, 'origin should not be null');
      this.anchorX_ = anchor[0];
      this.anchorY_ = anchor[1];
      this.hitDetectionImage_ = hitDetectionImage;
      this.image_ = image;
      this.height_ = size[1];
      this.opacity_ = imageStyle.getOpacity();
      this.originX_ = origin[0];
      this.originY_ = origin[1];
      this.rotateWithView_ = imageStyle.getRotateWithView();
      this.rotation_ = imageStyle.getRotation();
      this.scale_ = imageStyle.getScale();
      this.snapToPixel_ = imageStyle.getSnapToPixel();
      this.width_ = size[0];
    };

    /**
     * @constructor
     * @extends {ol.render.canvas.Replay}
     * @param {number} tolerance Tolerance.
     * @param {ol.Extent} maxExtent Maximum extent.
     * @param {number} resolution Resolution.
     * @protected
     * @struct
     */
    ol.render.canvas.LineStringReplay = function(tolerance, maxExtent, resolution) {

      goog.base(this, tolerance, maxExtent, resolution);

      /**
       * @private
       * @type {{currentStrokeStyle: (string|undefined),
       *         currentLineCap: (string|undefined),
       *         currentLineDash: Array.<number>,
       *         currentLineJoin: (string|undefined),
       *         currentLineWidth: (number|undefined),
       *         currentMiterLimit: (number|undefined),
       *         lastStroke: number,
       *         strokeStyle: (string|undefined),
       *         lineCap: (string|undefined),
       *         lineDash: Array.<number>,
       *         lineJoin: (string|undefined),
       *         lineWidth: (number|undefined),
       *         miterLimit: (number|undefined)}|null}
       */
      this.state_ = {
        currentStrokeStyle: undefined,
        currentLineCap: undefined,
        currentLineDash: null,
        currentLineJoin: undefined,
        currentLineWidth: undefined,
        currentMiterLimit: undefined,
        lastStroke: 0,
        strokeStyle: undefined,
        lineCap: undefined,
        lineDash: null,
        lineJoin: undefined,
        lineWidth: undefined,
        miterLimit: undefined
      };

    };
    goog.inherits(ol.render.canvas.LineStringReplay, ol.render.canvas.Replay);

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {number} end End.
     * @param {number} stride Stride.
     * @private
     * @return {number} end.
     */
    ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ =
        function(flatCoordinates, offset, end, stride) {
      var myBegin = this.coordinates.length;
      var myEnd = this.appendFlatCoordinates(
          flatCoordinates, offset, end, stride, false);
      var moveToLineToInstruction =
          [ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd];
      this.instructions.push(moveToLineToInstruction);
      this.hitDetectionInstructions.push(moveToLineToInstruction);
      return end;
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() {
      Eif (!this.bufferedMaxExtent_) {
        this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
        Eif (this.maxLineWidth > 0) {
          var width = this.resolution * (this.maxLineWidth + 1) / 2;
          ol.extent.buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
        }
      }
      return this.bufferedMaxExtent_;
    };

    /**
     * @private
     */
    ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
      var state = this.state_;
      var strokeStyle = state.strokeStyle;
      var lineCap = state.lineCap;
      var lineDash = state.lineDash;
      var lineJoin = state.lineJoin;
      var lineWidth = state.lineWidth;
      var miterLimit = state.miterLimit;
      goog.asserts.assert(strokeStyle !== undefined,
          'strokeStyle should be defined');
      goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
      goog.asserts.assert(lineDash, 'lineDash should not be null');
      goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
      goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
      goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined');
      if (state.currentStrokeStyle != strokeStyle ||
          state.currentLineCap != lineCap ||
          !goog.array.equals(state.currentLineDash, lineDash) ||
          state.currentLineJoin != lineJoin ||
          state.currentLineWidth != lineWidth ||
          state.currentMiterLimit != miterLimit) {
        if (state.lastStroke != this.coordinates.length) {
          this.instructions.push(
              [ol.render.canvas.Instruction.STROKE]);
          state.lastStroke = this.coordinates.length;
        }
        this.instructions.push(
            [ol.render.canvas.Instruction.SET_STROKE_STYLE,
             strokeStyle, lineWidth, lineCap, lineJoin, miterLimit, lineDash],
            [ol.render.canvas.Instruction.BEGIN_PATH]);
        state.currentStrokeStyle = strokeStyle;
        state.currentLineCap = lineCap;
        state.currentLineDash = lineDash;
        state.currentLineJoin = lineJoin;
        state.currentLineWidth = lineWidth;
        state.currentMiterLimit = miterLimit;
      }
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry =
        function(lineStringGeometry, feature) {
      var state = this.state_;
      goog.asserts.assert(state, 'state should not be null');
      var strokeStyle = state.strokeStyle;
      var lineWidth = state.lineWidth;
      if (strokeStyle === undefined || lineWidth === undefined) {
        return;
      }
      this.setStrokeStyle_();
      this.beginGeometry(lineStringGeometry, feature);
      this.hitDetectionInstructions.push(
          [ol.render.canvas.Instruction.SET_STROKE_STYLE,
           state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
           state.miterLimit, state.lineDash],
          [ol.render.canvas.Instruction.BEGIN_PATH]);
      var flatCoordinates = lineStringGeometry.getFlatCoordinates();
      var stride = lineStringGeometry.getStride();
      this.drawFlatCoordinates_(
          flatCoordinates, 0, flatCoordinates.length, stride);
      this.hitDetectionInstructions.push([ol.render.canvas.Instruction.STROKE]);
      this.endGeometry(lineStringGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry =
        function(multiLineStringGeometry, feature) {
      var state = this.state_;
      goog.asserts.assert(state, 'state should not be null');
      var strokeStyle = state.strokeStyle;
      var lineWidth = state.lineWidth;
      if (strokeStyle === undefined || lineWidth === undefined) {
        return;
      }
      this.setStrokeStyle_();
      this.beginGeometry(multiLineStringGeometry, feature);
      this.hitDetectionInstructions.push(
          [ol.render.canvas.Instruction.SET_STROKE_STYLE,
           state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
           state.miterLimit, state.lineDash],
          [ol.render.canvas.Instruction.BEGIN_PATH]);
      var ends = multiLineStringGeometry.getEnds();
      var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
      var stride = multiLineStringGeometry.getStride();
      var offset = 0;
      var i, ii;
      for (i = 0, ii = ends.length; i < ii; ++i) {
        offset = this.drawFlatCoordinates_(
            flatCoordinates, offset, ends[i], stride);
      }
      this.hitDetectionInstructions.push([ol.render.canvas.Instruction.STROKE]);
      this.endGeometry(multiLineStringGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.LineStringReplay.prototype.finish = function() {
      var state = this.state_;
      goog.asserts.assert(state, 'state should not be null');
      if (state.lastStroke != this.coordinates.length) {
        this.instructions.push([ol.render.canvas.Instruction.STROKE]);
      }
      this.reverseHitDetectionInstructions_();
      this.state_ = null;
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle =
        function(fillStyle, strokeStyle) {
      goog.asserts.assert(this.state_, 'this.state_ should not be null');
      goog.asserts.assert(!fillStyle, 'fillStyle should be null');
      goog.asserts.assert(strokeStyle, 'strokeStyle should not be null');
      var strokeStyleColor = strokeStyle.getColor();
      this.state_.strokeStyle = ol.color.asString(strokeStyleColor ?
          strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
      var strokeStyleLineCap = strokeStyle.getLineCap();
      this.state_.lineCap = strokeStyleLineCap !== undefined ?
          strokeStyleLineCap : ol.render.canvas.defaultLineCap;
      var strokeStyleLineDash = strokeStyle.getLineDash();
      this.state_.lineDash = strokeStyleLineDash ?
          strokeStyleLineDash : ol.render.canvas.defaultLineDash;
      var strokeStyleLineJoin = strokeStyle.getLineJoin();
      this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
          strokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
      var strokeStyleWidth = strokeStyle.getWidth();
      this.state_.lineWidth = strokeStyleWidth !== undefined ?
          strokeStyleWidth : ol.render.canvas.defaultLineWidth;
      var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
      this.state_.miterLimit = strokeStyleMiterLimit !== undefined ?
          strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;

      Eif (this.state_.lineWidth > this.maxLineWidth) {
        this.maxLineWidth = this.state_.lineWidth;
        // invalidate the buffered max extent cache
        this.bufferedMaxExtent_ = null;
      }
    };

    /**
     * @constructor
     * @extends {ol.render.canvas.Replay}
     * @param {number} tolerance Tolerance.
     * @param {ol.Extent} maxExtent Maximum extent.
     * @param {number} resolution Resolution.
     * @protected
     * @struct
     */
    ol.render.canvas.PolygonReplay = function(tolerance, maxExtent, resolution) {

      goog.base(this, tolerance, maxExtent, resolution);

      /**
       * @private
       * @type {{currentFillStyle: (string|undefined),
       *         currentStrokeStyle: (string|undefined),
       *         currentLineCap: (string|undefined),
       *         currentLineDash: Array.<number>,
       *         currentLineJoin: (string|undefined),
       *         currentLineWidth: (number|undefined),
       *         currentMiterLimit: (number|undefined),
       *         fillStyle: (string|undefined),
       *         strokeStyle: (string|undefined),
       *         lineCap: (string|undefined),
       *         lineDash: Array.<number>,
       *         lineJoin: (string|undefined),
       *         lineWidth: (number|undefined),
       *         miterLimit: (number|undefined)}|null}
       */
      this.state_ = {
        currentFillStyle: undefined,
        currentStrokeStyle: undefined,
        currentLineCap: undefined,
        currentLineDash: null,
        currentLineJoin: undefined,
        currentLineWidth: undefined,
        currentMiterLimit: undefined,
        fillStyle: undefined,
        strokeStyle: undefined,
        lineCap: undefined,
        lineDash: null,
        lineJoin: undefined,
        lineWidth: undefined,
        miterLimit: undefined
      };

    };
    goog.inherits(ol.render.canvas.PolygonReplay, ol.render.canvas.Replay);

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {Array.<number>} ends Ends.
     * @param {number} stride Stride.
     * @private
     * @return {number} End.
     */
    ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ =
        function(flatCoordinates, offset, ends, stride) {
      var state = this.state_;
      var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH];
      this.instructions.push(beginPathInstruction);
      this.hitDetectionInstructions.push(beginPathInstruction);
      var i, ii;
      for (i = 0, ii = ends.length; i < ii; ++i) {
        var end = ends[i];
        var myBegin = this.coordinates.length;
        var myEnd = this.appendFlatCoordinates(
            flatCoordinates, offset, end, stride, true);
        var moveToLineToInstruction =
            [ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd];
        var closePathInstruction = [ol.render.canvas.Instruction.CLOSE_PATH];
        this.instructions.push(moveToLineToInstruction, closePathInstruction);
        this.hitDetectionInstructions.push(moveToLineToInstruction,
            closePathInstruction);
        offset = end;
      }
      // FIXME is it quicker to fill and stroke each polygon individually,
      // FIXME or all polygons together?
      var fillInstruction = [ol.render.canvas.Instruction.FILL];
      this.hitDetectionInstructions.push(fillInstruction);
      Eif (state.fillStyle !== undefined) {
        this.instructions.push(fillInstruction);
      }
      Eif (state.strokeStyle !== undefined) {
        goog.asserts.assert(state.lineWidth !== undefined,
            'state.lineWidth should be defined');
        var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
        this.instructions.push(strokeInstruction);
        this.hitDetectionInstructions.push(strokeInstruction);
      }
      return offset;
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
        function(circleGeometry, feature) {
      var state = this.state_;
      goog.asserts.assert(state, 'state should not be null');
      var fillStyle = state.fillStyle;
      var strokeStyle = state.strokeStyle;
      if (fillStyle === undefined && strokeStyle === undefined) {
        return;
      }
      if (strokeStyle !== undefined) {
        goog.asserts.assert(state.lineWidth !== undefined,
            'state.lineWidth should be defined');
      }
      this.setFillStrokeStyles_();
      this.beginGeometry(circleGeometry, feature);
      // always fill the circle for hit detection
      this.hitDetectionInstructions.push(
          [ol.render.canvas.Instruction.SET_FILL_STYLE,
           ol.color.asString(ol.render.canvas.defaultFillStyle)]);
      if (state.strokeStyle !== undefined) {
        this.hitDetectionInstructions.push(
            [ol.render.canvas.Instruction.SET_STROKE_STYLE,
             state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
             state.miterLimit, state.lineDash]);
      }
      var flatCoordinates = circleGeometry.getFlatCoordinates();
      var stride = circleGeometry.getStride();
      var myBegin = this.coordinates.length;
      this.appendFlatCoordinates(
          flatCoordinates, 0, flatCoordinates.length, stride, false);
      var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH];
      var circleInstruction = [ol.render.canvas.Instruction.CIRCLE, myBegin];
      this.instructions.push(beginPathInstruction, circleInstruction);
      this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
      var fillInstruction = [ol.render.canvas.Instruction.FILL];
      this.hitDetectionInstructions.push(fillInstruction);
      if (state.fillStyle !== undefined) {
        this.instructions.push(fillInstruction);
      }
      if (state.strokeStyle !== undefined) {
        goog.asserts.assert(state.lineWidth !== undefined,
            'state.lineWidth should be defined');
        var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
        this.instructions.push(strokeInstruction);
        this.hitDetectionInstructions.push(strokeInstruction);
      }
      this.endGeometry(circleGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
        function(polygonGeometry, feature) {
      var state = this.state_;
      goog.asserts.assert(state, 'state should not be null');
      var fillStyle = state.fillStyle;
      var strokeStyle = state.strokeStyle;
      Iif (fillStyle === undefined && strokeStyle === undefined) {
        return;
      }
      Eif (strokeStyle !== undefined) {
        goog.asserts.assert(state.lineWidth !== undefined,
            'state.lineWidth should be defined');
      }
      this.setFillStrokeStyles_();
      this.beginGeometry(polygonGeometry, feature);
      // always fill the polygon for hit detection
      this.hitDetectionInstructions.push(
          [ol.render.canvas.Instruction.SET_FILL_STYLE,
           ol.color.asString(ol.render.canvas.defaultFillStyle)]);
      Eif (state.strokeStyle !== undefined) {
        this.hitDetectionInstructions.push(
            [ol.render.canvas.Instruction.SET_STROKE_STYLE,
             state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
             state.miterLimit, state.lineDash]);
      }
      var ends = polygonGeometry.getEnds();
      var flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
      var stride = polygonGeometry.getStride();
      this.drawFlatCoordinatess_(flatCoordinates, 0, ends, stride);
      this.endGeometry(polygonGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
        function(multiPolygonGeometry, feature) {
      var state = this.state_;
      goog.asserts.assert(state, 'state should not be null');
      var fillStyle = state.fillStyle;
      var strokeStyle = state.strokeStyle;
      if (fillStyle === undefined && strokeStyle === undefined) {
        return;
      }
      if (strokeStyle !== undefined) {
        goog.asserts.assert(state.lineWidth !== undefined,
            'state.lineWidth should be defined');
      }
      this.setFillStrokeStyles_();
      this.beginGeometry(multiPolygonGeometry, feature);
      // always fill the multi-polygon for hit detection
      this.hitDetectionInstructions.push(
          [ol.render.canvas.Instruction.SET_FILL_STYLE,
           ol.color.asString(ol.render.canvas.defaultFillStyle)]);
      if (state.strokeStyle !== undefined) {
        this.hitDetectionInstructions.push(
            [ol.render.canvas.Instruction.SET_STROKE_STYLE,
             state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
             state.miterLimit, state.lineDash]);
      }
      var endss = multiPolygonGeometry.getEndss();
      var flatCoordinates = multiPolygonGeometry.getOrientedFlatCoordinates();
      var stride = multiPolygonGeometry.getStride();
      var offset = 0;
      var i, ii;
      for (i = 0, ii = endss.length; i < ii; ++i) {
        offset = this.drawFlatCoordinatess_(
            flatCoordinates, offset, endss[i], stride);
      }
      this.endGeometry(multiPolygonGeometry, feature);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.PolygonReplay.prototype.finish = function() {
      goog.asserts.assert(this.state_, 'this.state_ should not be null');
      this.reverseHitDetectionInstructions_();
      this.state_ = null;
      // We want to preserve topology when drawing polygons.  Polygons are
      // simplified using quantization and point elimination. However, we might
      // have received a mix of quantized and non-quantized geometries, so ensure
      // that all are quantized by quantizing all coordinates in the batch.
      var tolerance = this.tolerance;
      Eif (tolerance !== 0) {
        var coordinates = this.coordinates;
        var i, ii;
        for (i = 0, ii = coordinates.length; i < ii; ++i) {
          coordinates[i] = ol.geom.flat.simplify.snap(coordinates[i], tolerance);
        }
      }
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
      if (!this.bufferedMaxExtent_) {
        this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
        Eif (this.maxLineWidth > 0) {
          var width = this.resolution * (this.maxLineWidth + 1) / 2;
          ol.extent.buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
        }
      }
      return this.bufferedMaxExtent_;
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle =
        function(fillStyle, strokeStyle) {
      goog.asserts.assert(this.state_, 'this.state_ should not be null');
      goog.asserts.assert(fillStyle || strokeStyle,
          'fillStyle or strokeStyle should not be null');
      var state = this.state_;
      if (fillStyle) {
        var fillStyleColor = fillStyle.getColor();
        state.fillStyle = ol.color.asString(fillStyleColor ?
            fillStyleColor : ol.render.canvas.defaultFillStyle);
      } else {
        state.fillStyle = undefined;
      }
      Eif (strokeStyle) {
        var strokeStyleColor = strokeStyle.getColor();
        state.strokeStyle = ol.color.asString(strokeStyleColor ?
            strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
        var strokeStyleLineCap = strokeStyle.getLineCap();
        state.lineCap = strokeStyleLineCap !== undefined ?
            strokeStyleLineCap : ol.render.canvas.defaultLineCap;
        var strokeStyleLineDash = strokeStyle.getLineDash();
        state.lineDash = strokeStyleLineDash ?
            strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash;
        var strokeStyleLineJoin = strokeStyle.getLineJoin();
        state.lineJoin = strokeStyleLineJoin !== undefined ?
            strokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
        var strokeStyleWidth = strokeStyle.getWidth();
        state.lineWidth = strokeStyleWidth !== undefined ?
            strokeStyleWidth : ol.render.canvas.defaultLineWidth;
        var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
        state.miterLimit = strokeStyleMiterLimit !== undefined ?
            strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;

        if (state.lineWidth > this.maxLineWidth) {
          this.maxLineWidth = state.lineWidth;
          // invalidate the buffered max extent cache
          this.bufferedMaxExtent_ = null;
        }
      } else {
        state.strokeStyle = undefined;
        state.lineCap = undefined;
        state.lineDash = null;
        state.lineJoin = undefined;
        state.lineWidth = undefined;
        state.miterLimit = undefined;
      }
    };

    /**
     * @private
     */
    ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() {
      var state = this.state_;
      var fillStyle = state.fillStyle;
      var strokeStyle = state.strokeStyle;
      var lineCap = state.lineCap;
      var lineDash = state.lineDash;
      var lineJoin = state.lineJoin;
      var lineWidth = state.lineWidth;
      var miterLimit = state.miterLimit;
      if (fillStyle !== undefined && state.currentFillStyle != fillStyle) {
        this.instructions.push(
            [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle]);
        state.currentFillStyle = state.fillStyle;
      }
      Eif (strokeStyle !== undefined) {
        goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
        goog.asserts.assert(lineDash, 'lineDash should not be null');
        goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
        goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
        goog.asserts.assert(miterLimit !== undefined,
            'miterLimit should be defined');
        if (state.currentStrokeStyle != strokeStyle ||
            state.currentLineCap != lineCap ||
            state.currentLineDash != lineDash ||
            state.currentLineJoin != lineJoin ||
            state.currentLineWidth != lineWidth ||
            state.currentMiterLimit != miterLimit) {
          this.instructions.push(
              [ol.render.canvas.Instruction.SET_STROKE_STYLE,
               strokeStyle, lineWidth, lineCap, lineJoin, miterLimit, lineDash]);
          state.currentStrokeStyle = strokeStyle;
          state.currentLineCap = lineCap;
          state.currentLineDash = lineDash;
          state.currentLineJoin = lineJoin;
          state.currentLineWidth = lineWidth;
          state.currentMiterLimit = miterLimit;
        }
      }
    };

    /**
     * @constructor
     * @extends {ol.render.canvas.Replay}
     * @param {number} tolerance Tolerance.
     * @param {ol.Extent} maxExtent Maximum extent.
     * @param {number} resolution Resolution.
     * @protected
     * @struct
     */
    ol.render.canvas.TextReplay = function(tolerance, maxExtent, resolution) {

      goog.base(this, tolerance, maxExtent, resolution);

      /**
       * @private
       * @type {?ol.render.canvas.FillState}
       */
      this.replayFillState_ = null;

      /**
       * @private
       * @type {?ol.render.canvas.StrokeState}
       */
      this.replayStrokeState_ = null;

      /**
       * @private
       * @type {?ol.render.canvas.TextState}
       */
      this.replayTextState_ = null;

      /**
       * @private
       * @type {string}
       */
      this.text_ = '';

      /**
       * @private
       * @type {number}
       */
      this.textOffsetX_ = 0;

      /**
       * @private
       * @type {number}
       */
      this.textOffsetY_ = 0;

      /**
       * @private
       * @type {number}
       */
      this.textRotation_ = 0;

      /**
       * @private
       * @type {number}
       */
      this.textScale_ = 0;

      /**
       * @private
       * @type {?ol.render.canvas.FillState}
       */
      this.textFillState_ = null;

      /**
       * @private
       * @type {?ol.render.canvas.StrokeState}
       */
      this.textStrokeState_ = null;

      /**
       * @private
       * @type {?ol.render.canvas.TextState}
       */
      this.textState_ = null;

    };
    goog.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay);

    /**
     * @inheritDoc
     */
    ol.render.canvas.TextReplay.prototype.drawText =
        function(flatCoordinates, offset, end, stride, geometry, feature) {
      Iif (this.text_ === '' || !this.textState_ ||
          (!this.textFillState_ && !this.textStrokeState_)) {
        return;
      }
      Eif (this.textFillState_) {
        this.setReplayFillState_(this.textFillState_);
      }
      Iif (this.textStrokeState_) {
        this.setReplayStrokeState_(this.textStrokeState_);
      }
      this.setReplayTextState_(this.textState_);
      this.beginGeometry(geometry, feature);
      var myBegin = this.coordinates.length;
      var myEnd =
          this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false);
      var fill = !!this.textFillState_;
      var stroke = !!this.textStrokeState_;
      var drawTextInstruction = [
        ol.render.canvas.Instruction.DRAW_TEXT, myBegin, myEnd, this.text_,
        this.textOffsetX_, this.textOffsetY_, this.textRotation_, this.textScale_,
        fill, stroke];
      this.instructions.push(drawTextInstruction);
      this.hitDetectionInstructions.push(drawTextInstruction);
      this.endGeometry(geometry, feature);
    };

    /**
     * @param {ol.render.canvas.FillState} fillState Fill state.
     * @private
     */
    ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
        function(fillState) {
      var replayFillState = this.replayFillState_;
      if (replayFillState &&
          replayFillState.fillStyle == fillState.fillStyle) {
        return;
      }
      var setFillStyleInstruction =
          [ol.render.canvas.Instruction.SET_FILL_STYLE, fillState.fillStyle];
      this.instructions.push(setFillStyleInstruction);
      this.hitDetectionInstructions.push(setFillStyleInstruction);
      Eif (!replayFillState) {
        this.replayFillState_ = {
          fillStyle: fillState.fillStyle
        };
      } else {
        replayFillState.fillStyle = fillState.fillStyle;
      }
    };

    /**
     * @param {ol.render.canvas.StrokeState} strokeState Stroke state.
     * @private
     */
    ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
        function(strokeState) {
      var replayStrokeState = this.replayStrokeState_;
      if (replayStrokeState &&
          replayStrokeState.lineCap == strokeState.lineCap &&
          replayStrokeState.lineDash == strokeState.lineDash &&
          replayStrokeState.lineJoin == strokeState.lineJoin &&
          replayStrokeState.lineWidth == strokeState.lineWidth &&
          replayStrokeState.miterLimit == strokeState.miterLimit &&
          replayStrokeState.strokeStyle == strokeState.strokeStyle) {
        return;
      }
      var setStrokeStyleInstruction = [
        ol.render.canvas.Instruction.SET_STROKE_STYLE, strokeState.strokeStyle,
        strokeState.lineWidth, strokeState.lineCap, strokeState.lineJoin,
        strokeState.miterLimit, strokeState.lineDash, false
      ];
      this.instructions.push(setStrokeStyleInstruction);
      this.hitDetectionInstructions.push(setStrokeStyleInstruction);
      if (!replayStrokeState) {
        this.replayStrokeState_ = {
          lineCap: strokeState.lineCap,
          lineDash: strokeState.lineDash,
          lineJoin: strokeState.lineJoin,
          lineWidth: strokeState.lineWidth,
          miterLimit: strokeState.miterLimit,
          strokeStyle: strokeState.strokeStyle
        };
      } else {
        replayStrokeState.lineCap = strokeState.lineCap;
        replayStrokeState.lineDash = strokeState.lineDash;
        replayStrokeState.lineJoin = strokeState.lineJoin;
        replayStrokeState.lineWidth = strokeState.lineWidth;
        replayStrokeState.miterLimit = strokeState.miterLimit;
        replayStrokeState.strokeStyle = strokeState.strokeStyle;
      }
    };

    /**
     * @param {ol.render.canvas.TextState} textState Text state.
     * @private
     */
    ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
        function(textState) {
      var replayTextState = this.replayTextState_;
      if (replayTextState &&
          replayTextState.font == textState.font &&
          replayTextState.textAlign == textState.textAlign &&
          replayTextState.textBaseline == textState.textBaseline) {
        return;
      }
      var setTextStyleInstruction = [ol.render.canvas.Instruction.SET_TEXT_STYLE,
        textState.font, textState.textAlign, textState.textBaseline];
      this.instructions.push(setTextStyleInstruction);
      this.hitDetectionInstructions.push(setTextStyleInstruction);
      Eif (!replayTextState) {
        this.replayTextState_ = {
          font: textState.font,
          textAlign: textState.textAlign,
          textBaseline: textState.textBaseline
        };
      } else {
        replayTextState.font = textState.font;
        replayTextState.textAlign = textState.textAlign;
        replayTextState.textBaseline = textState.textBaseline;
      }
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
      Iif (!textStyle) {
        this.text_ = '';
      } else {
        var textFillStyle = textStyle.getFill();
        Iif (!textFillStyle) {
          this.textFillState_ = null;
        } else {
          var textFillStyleColor = textFillStyle.getColor();
          var fillStyle = ol.color.asString(textFillStyleColor ?
              textFillStyleColor : ol.render.canvas.defaultFillStyle);
          if (!this.textFillState_) {
            this.textFillState_ = {
              fillStyle: fillStyle
            };
          } else {
            var textFillState = this.textFillState_;
            textFillState.fillStyle = fillStyle;
          }
        }
        var textStrokeStyle = textStyle.getStroke();
        Eif (!textStrokeStyle) {
          this.textStrokeState_ = null;
        } else {
          var textStrokeStyleColor = textStrokeStyle.getColor();
          var textStrokeStyleLineCap = textStrokeStyle.getLineCap();
          var textStrokeStyleLineDash = textStrokeStyle.getLineDash();
          var textStrokeStyleLineJoin = textStrokeStyle.getLineJoin();
          var textStrokeStyleWidth = textStrokeStyle.getWidth();
          var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit();
          var lineCap = textStrokeStyleLineCap !== undefined ?
              textStrokeStyleLineCap : ol.render.canvas.defaultLineCap;
          var lineDash = textStrokeStyleLineDash ?
              textStrokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash;
          var lineJoin = textStrokeStyleLineJoin !== undefined ?
              textStrokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
          var lineWidth = textStrokeStyleWidth !== undefined ?
              textStrokeStyleWidth : ol.render.canvas.defaultLineWidth;
          var miterLimit = textStrokeStyleMiterLimit !== undefined ?
              textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
          var strokeStyle = ol.color.asString(textStrokeStyleColor ?
              textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle);
          if (!this.textStrokeState_) {
            this.textStrokeState_ = {
              lineCap: lineCap,
              lineDash: lineDash,
              lineJoin: lineJoin,
              lineWidth: lineWidth,
              miterLimit: miterLimit,
              strokeStyle: strokeStyle
            };
          } else {
            var textStrokeState = this.textStrokeState_;
            textStrokeState.lineCap = lineCap;
            textStrokeState.lineDash = lineDash;
            textStrokeState.lineJoin = lineJoin;
            textStrokeState.lineWidth = lineWidth;
            textStrokeState.miterLimit = miterLimit;
            textStrokeState.strokeStyle = strokeStyle;
          }
        }
        var textFont = textStyle.getFont();
        var textOffsetX = textStyle.getOffsetX();
        var textOffsetY = textStyle.getOffsetY();
        var textRotation = textStyle.getRotation();
        var textScale = textStyle.getScale();
        var textText = textStyle.getText();
        var textTextAlign = textStyle.getTextAlign();
        var textTextBaseline = textStyle.getTextBaseline();
        var font = textFont !== undefined ?
            textFont : ol.render.canvas.defaultFont;
        var textAlign = textTextAlign !== undefined ?
            textTextAlign : ol.render.canvas.defaultTextAlign;
        var textBaseline = textTextBaseline !== undefined ?
            textTextBaseline : ol.render.canvas.defaultTextBaseline;
        if (!this.textState_) {
          this.textState_ = {
            font: font,
            textAlign: textAlign,
            textBaseline: textBaseline
          };
        } else {
          var textState = this.textState_;
          textState.font = font;
          textState.textAlign = textAlign;
          textState.textBaseline = textBaseline;
        }
        this.text_ = textText !== undefined ? textText : '';
        this.textOffsetX_ = textOffsetX !== undefined ? textOffsetX : 0;
        this.textOffsetY_ = textOffsetY !== undefined ? textOffsetY : 0;
        this.textRotation_ = textRotation !== undefined ? textRotation : 0;
        this.textScale_ = textScale !== undefined ? textScale : 1;
      }
    };

    /**
     * @constructor
     * @implements {ol.render.IReplayGroup}
     * @param {number} tolerance Tolerance.
     * @param {ol.Extent} maxExtent Max extent.
     * @param {number} resolution Resolution.
     * @param {number=} opt_renderBuffer Optional rendering buffer.
     * @struct
     */
    ol.render.canvas.ReplayGroup = function(
        tolerance, maxExtent, resolution, opt_renderBuffer) {

      /**
       * @private
       * @type {number}
       */
      this.tolerance_ = tolerance;

      /**
       * @private
       * @type {ol.Extent}
       */
      this.maxExtent_ = maxExtent;

      /**
       * @private
       * @type {number}
       */
      this.resolution_ = resolution;

      /**
       * @private
       * @type {number|undefined}
       */
      this.renderBuffer_ = opt_renderBuffer;

      /**
       * @private
       * @type {!Object.<string,
       *        Object.<ol.render.ReplayType, ol.render.canvas.Replay>>}
       */
      this.replaysByZIndex_ = {};

      /**
       * @private
       * @type {CanvasRenderingContext2D}
       */
      this.hitDetectionContext_ = ol.dom.createCanvasContext2D(1, 1);

      /**
       * @private
       * @type {!goog.vec.Mat4.Number}
       */
      this.hitDetectionTransform_ = goog.vec.Mat4.createNumber();

    };

    /**
     * FIXME empty description for jsdoc
     */
    ol.render.canvas.ReplayGroup.prototype.finish = function() {
      var zKey;
      for (zKey in this.replaysByZIndex_) {
        var replays = this.replaysByZIndex_[zKey];
        var replayKey;
        for (replayKey in replays) {
          replays[replayKey].finish();
        }
      }
    };

    /**
     * @param {ol.Coordinate} coordinate Coordinate.
     * @param {number} resolution Resolution.
     * @param {number} rotation Rotation.
     * @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
     *     to skip.
     * @param {function((ol.Feature|ol.render.Feature)): T} callback Feature
     *     callback.
     * @return {T|undefined} Callback result.
     * @template T
     */
    ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
        coordinate, resolution, rotation, skippedFeaturesHash, callback) {

      var transform = this.hitDetectionTransform_;
      ol.vec.Mat4.makeTransform2D(transform, 0.5, 0.5,
          1 / resolution, -1 / resolution, -rotation,
          -coordinate[0], -coordinate[1]);

      var context = this.hitDetectionContext_;
      context.clearRect(0, 0, 1, 1);

      /**
       * @type {ol.Extent}
       */
      var hitExtent;
      Eif (this.renderBuffer_ !== undefined) {
        hitExtent = ol.extent.createEmpty();
        ol.extent.extendCoordinate(hitExtent, coordinate);
        ol.extent.buffer(hitExtent, resolution * this.renderBuffer_, hitExtent);
      }

      return this.replayHitDetection_(context, transform, rotation,
          skippedFeaturesHash,
          /**
           * @param {ol.Feature|ol.render.Feature} feature Feature.
           * @return {?} Callback result.
           */
          function(feature) {
            var imageData = context.getImageData(0, 0, 1, 1).data;
            if (imageData[3] > 0) {
              var result = callback(feature);
              if (result) {
                return result;
              }
              context.clearRect(0, 0, 1, 1);
            }
          }, hitExtent);
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.ReplayGroup.prototype.getReplay =
        function(zIndex, replayType) {
      var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
      var replays = this.replaysByZIndex_[zIndexKey];
      if (replays === undefined) {
        replays = {};
        this.replaysByZIndex_[zIndexKey] = replays;
      }
      var replay = replays[replayType];
      if (replay === undefined) {
        var Constructor = ol.render.canvas.BATCH_CONSTRUCTORS_[replayType];
        goog.asserts.assert(Constructor !== undefined,
            replayType +
            ' constructor missing from ol.render.canvas.BATCH_CONSTRUCTORS_');
        replay = new Constructor(this.tolerance_, this.maxExtent_,
            this.resolution_);
        replays[replayType] = replay;
      }
      return replay;
    };

    /**
     * @inheritDoc
     */
    ol.render.canvas.ReplayGroup.prototype.isEmpty = function() {
      return goog.object.isEmpty(this.replaysByZIndex_);
    };

    /**
     * @param {CanvasRenderingContext2D} context Context.
     * @param {number} pixelRatio Pixel ratio.
     * @param {goog.vec.Mat4.Number} transform Transform.
     * @param {number} viewRotation View rotation.
     * @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
     *     to skip.
     */
    ol.render.canvas.ReplayGroup.prototype.replay = function(
        context, pixelRatio, transform, viewRotation, skippedFeaturesHash) {

      /** @type {Array.<number>} */
      var zs = Object.keys(this.replaysByZIndex_).map(Number);
      goog.array.sort(zs);

      // setup clipping so that the parts of over-simplified geometries are not
      // visible outside the current extent when panning
      var maxExtent = this.maxExtent_;
      var minX = maxExtent[0];
      var minY = maxExtent[1];
      var maxX = maxExtent[2];
      var maxY = maxExtent[3];
      var flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
      ol.geom.flat.transform.transform2D(
          flatClipCoords, 0, 8, 2, transform, flatClipCoords);
      context.save();
      context.beginPath();
      context.moveTo(flatClipCoords[0], flatClipCoords[1]);
      context.lineTo(flatClipCoords[2], flatClipCoords[3]);
      context.lineTo(flatClipCoords[4], flatClipCoords[5]);
      context.lineTo(flatClipCoords[6], flatClipCoords[7]);
      context.closePath();
      context.clip();

      var i, ii, j, jj, replays, replay;
      for (i = 0, ii = zs.length; i < ii; ++i) {
        replays = this.replaysByZIndex_[zs[i].toString()];
        for (j = 0, jj = ol.render.REPLAY_ORDER.length; j < jj; ++j) {
          replay = replays[ol.render.REPLAY_ORDER[j]];
          if (replay !== undefined) {
            replay.replay(context, pixelRatio, transform, viewRotation,
                skippedFeaturesHash);
          }
        }
      }

      context.restore();
    };

    /**
     * @private
     * @param {CanvasRenderingContext2D} context Context.
     * @param {goog.vec.Mat4.Number} transform Transform.
     * @param {number} viewRotation View rotation.
     * @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
     *     to skip.
     * @param {function((ol.Feature|ol.render.Feature)): T} featureCallback
     *     Feature callback.
     * @param {ol.Extent=} opt_hitExtent Only check features that intersect this
     *     extent.
     * @return {T|undefined} Callback result.
     * @template T
     */
    ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
        context, transform, viewRotation, skippedFeaturesHash,
        featureCallback, opt_hitExtent) {
      /** @type {Array.<number>} */
      var zs = Object.keys(this.replaysByZIndex_).map(Number);
      goog.array.sort(zs, function(a, b) { return b - a; });

      var i, ii, j, replays, replay, result;
      for (i = 0, ii = zs.length; i < ii; ++i) {
        replays = this.replaysByZIndex_[zs[i].toString()];
        for (j = ol.render.REPLAY_ORDER.length - 1; j >= 0; --j) {
          replay = replays[ol.render.REPLAY_ORDER[j]];
          if (replay !== undefined) {
            result = replay.replayHitDetection(context, transform, viewRotation,
                skippedFeaturesHash, featureCallback, opt_hitExtent);
            if (result) {
              return result;
            }
          }
        }
      }
      return undefined;
    };

    /**
     * @const
     * @private
     * @type {Object.<ol.render.ReplayType,
     *                function(new: ol.render.canvas.Replay, number, ol.Extent,
     *                number)>}
     */
    ol.render.canvas.BATCH_CONSTRUCTORS_ = {
      'Image': ol.render.canvas.ImageReplay,
      'LineString': ol.render.canvas.LineStringReplay,
      'Polygon': ol.render.canvas.PolygonReplay,
      'Text': ol.render.canvas.TextReplay
    };