| 1809 | } |
| 1810 | |
| 1811 | void ViewportDoDraw(const Viewport &vp, int left, int top, int right, int bottom) |
| 1812 | { |
| 1813 | _vd.dpi.zoom = vp.zoom; |
| 1814 | int mask = ScaleByZoom(-1, vp.zoom); |
| 1815 | |
| 1816 | _vd.combine_sprites = SPRITE_COMBINE_NONE; |
| 1817 | |
| 1818 | _vd.dpi.width = (right - left) & mask; |
| 1819 | _vd.dpi.height = (bottom - top) & mask; |
| 1820 | _vd.dpi.left = left & mask; |
| 1821 | _vd.dpi.top = top & mask; |
| 1822 | _vd.dpi.pitch = _cur_dpi->pitch; |
| 1823 | _vd.last_child = LAST_CHILD_NONE; |
| 1824 | |
| 1825 | int x = UnScaleByZoom(_vd.dpi.left - (vp.virtual_left & mask), vp.zoom) + vp.left; |
| 1826 | int y = UnScaleByZoom(_vd.dpi.top - (vp.virtual_top & mask), vp.zoom) + vp.top; |
| 1827 | |
| 1828 | _vd.dpi.dst_ptr = BlitterFactory::GetCurrentBlitter()->MoveTo(_cur_dpi->dst_ptr, x - _cur_dpi->left, y - _cur_dpi->top); |
| 1829 | AutoRestoreBackup dpi_backup(_cur_dpi, &_vd.dpi); |
| 1830 | |
| 1831 | ViewportAddLandscape(); |
| 1832 | ViewportAddVehicles(&_vd.dpi); |
| 1833 | |
| 1834 | ViewportAddKdtreeSigns(&_vd.dpi); |
| 1835 | |
| 1836 | DrawTextEffects(&_vd.dpi); |
| 1837 | |
| 1838 | if (!_vd.tile_sprites_to_draw.empty()) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); |
| 1839 | |
| 1840 | for (auto &psd : _vd.parent_sprites_to_draw) { |
| 1841 | _vd.parent_sprites_to_sort.push_back(&psd); |
| 1842 | } |
| 1843 | |
| 1844 | _vp_sprite_sorter(&_vd.parent_sprites_to_sort); |
| 1845 | ViewportDrawParentSprites(&_vd.parent_sprites_to_sort, &_vd.child_screen_sprites_to_draw); |
| 1846 | |
| 1847 | if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(&_vd.parent_sprites_to_sort); |
| 1848 | if (_draw_dirty_blocks) ViewportDrawDirtyBlocks(); |
| 1849 | |
| 1850 | DrawPixelInfo dp = _vd.dpi; |
| 1851 | ZoomLevel zoom = _vd.dpi.zoom; |
| 1852 | dp.zoom = ZoomLevel::Min; |
| 1853 | dp.width = UnScaleByZoom(dp.width, zoom); |
| 1854 | dp.height = UnScaleByZoom(dp.height, zoom); |
| 1855 | AutoRestoreBackup cur_dpi(_cur_dpi, &dp); |
| 1856 | |
| 1857 | if (vp.overlay != nullptr && vp.overlay->GetCargoMask() != 0 && vp.overlay->GetCompanyMask().Any()) { |
| 1858 | /* translate to window coordinates */ |
| 1859 | dp.left = x; |
| 1860 | dp.top = y; |
| 1861 | vp.overlay->Draw(&dp); |
| 1862 | } |
| 1863 | |
| 1864 | if (!_vd.string_sprites_to_draw.empty()) { |
| 1865 | /* translate to world coordinates */ |
| 1866 | dp.left = UnScaleByZoom(_vd.dpi.left, zoom); |
| 1867 | dp.top = UnScaleByZoom(_vd.dpi.top, zoom); |
| 1868 | ViewportDrawStrings(zoom, &_vd.string_sprites_to_draw); |
no test coverage detected