summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
diff options
context:
space:
mode:
authordP <dp@dpointer.org>2020-02-15 01:10:04 +0300
committerPatric Stout <github@truebrain.nl>2020-12-20 10:13:35 +0100
commite82333cf77861fd78ef156f97865b5f17ae38e4b (patch)
treec9538827867332e7dc01e34abfe323ad8033c2ff /src/viewport.cpp
parent5ca8a0bda9157ee34c12cb4360f46493dba69979 (diff)
downloadopenttd-e82333cf77861fd78ef156f97865b5f17ae38e4b.tar.xz
Feature #7962: Improve rendering of large viewports
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r--src/viewport.cpp33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 88a7d4046..e9e8d34da 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1782,32 +1782,6 @@ void ViewportDoDraw(const Viewport *vp, int left, int top, int right, int bottom
_vd.child_screen_sprites_to_draw.clear();
}
-/**
- * Make sure we don't draw a too big area at a time.
- * If we do, the sprite memory will overflow.
- */
-static void ViewportDrawChk(const Viewport *vp, int left, int top, int right, int bottom)
-{
- if ((int64)ScaleByZoom(bottom - top, vp->zoom) * (int64)ScaleByZoom(right - left, vp->zoom) > (int64)(180000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE)) {
- if ((bottom - top) > (right - left)) {
- int t = (top + bottom) >> 1;
- ViewportDrawChk(vp, left, top, right, t);
- ViewportDrawChk(vp, left, t, right, bottom);
- } else {
- int t = (left + right) >> 1;
- ViewportDrawChk(vp, left, top, t, bottom);
- ViewportDrawChk(vp, t, top, right, bottom);
- }
- } else {
- ViewportDoDraw(vp,
- ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
- ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top,
- ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left,
- ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top
- );
- }
-}
-
static inline void ViewportDraw(const Viewport *vp, int left, int top, int right, int bottom)
{
if (right <= vp->left || bottom <= vp->top) return;
@@ -1822,7 +1796,12 @@ static inline void ViewportDraw(const Viewport *vp, int left, int top, int right
if (top < vp->top) top = vp->top;
if (bottom > vp->top + vp->height) bottom = vp->top + vp->height;
- ViewportDrawChk(vp, left, top, right, bottom);
+ ViewportDoDraw(vp,
+ ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
+ ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top,
+ ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left,
+ ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top
+ );
}
/**