From c440b8f9187ff5a851a560e524a23e371b54e79f Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 16 Feb 2020 14:05:00 +0100 Subject: [PATCH] Fix #10705: Apply multithreaded rendering to all viewports --- src/openrct2/interface/Viewport.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 87098c43a4..8a8c9a569f 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -1,4 +1,4 @@ -/***************************************************************************** +/***************************************************************************** * Copyright (c) 2014-2019 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md @@ -932,14 +932,14 @@ void viewport_paint( // make sure, the compare operation is done in int16_t to avoid the loop becoming an infiniteloop. // this as well as the [x += 32] in the loop causes signed integer overflow -> undefined behaviour. - int16_t rightBorder = dpi1.x + dpi1.width; + const int16_t rightBorder = dpi1.x + dpi1.width; + const int16_t alignedX = floor2(dpi1.x, 32); + const uint16_t columSize = rightBorder - alignedX; + const uint16_t columnCount = (columSize / 32); std::vector columns; bool useMultithreading = gConfigGeneral.multithreading; - if (window_get_main() != nullptr && viewport != window_get_main()->viewport) - useMultithreading = false; - if (useMultithreading && _paintJobs == nullptr) { _paintJobs = std::make_unique(); @@ -953,12 +953,13 @@ void viewport_paint( size_t index = 0; if (recorded_sessions != nullptr) { - const uint16_t column_count = (rightBorder - floor2(dpi1.x, 32)) / 32 + 1; + const uint16_t colums = rightBorder - floor2(dpi1.x, 32); + const uint16_t column_count = (colums / 32) + (colums % 32 > 0 ? 1 : 0); recorded_sessions->resize(column_count); } // Splits the area into 32 pixel columns and renders them - for (x = floor2(dpi1.x, 32); x < rightBorder; x += 32, index++) + for (x = alignedX; x < rightBorder; x += 32, index++) { paint_session* session = paint_session_alloc(&dpi1, viewFlags); columns.push_back(session);