From e23eaa164b116b9710d995d37e852219defd0967 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Fri, 26 Mar 2021 00:24:55 -0300 Subject: [PATCH] Extract RequireNewWindow to Platform --- src/openrct2/drawing/NewDrawing.cpp | 13 +++---------- src/openrct2/platform/Platform.Posix.cpp | 5 +++++ src/openrct2/platform/Platform.Win32.cpp | 7 +++++++ src/openrct2/platform/Platform2.h | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/openrct2/drawing/NewDrawing.cpp b/src/openrct2/drawing/NewDrawing.cpp index 7b1b3de45f..e29b5417c6 100644 --- a/src/openrct2/drawing/NewDrawing.cpp +++ b/src/openrct2/drawing/NewDrawing.cpp @@ -15,6 +15,7 @@ #include "../interface/Screenshot.h" #include "../localisation/StringIds.h" #include "../paint/Painter.h" +#include "../platform/Platform2.h" #include "../ui/UiContext.h" #include "../world/Location.hpp" #include "IDrawingContext.h" @@ -52,16 +53,8 @@ static IDrawingEngine* GetDrawingEngine() bool drawing_engine_requires_new_window(DrawingEngine srcEngine, DrawingEngine dstEngine) { -#ifdef _WIN32 - if (srcEngine != DrawingEngine::OpenGL && dstEngine != DrawingEngine::OpenGL) - { - // Windows is apparently able to switch to hardware rendering on the fly although - // using the same window in an unaccelerated and accelerated context is unsupported by SDL2 - return false; - } -#endif - - return true; + bool openGL = srcEngine == DrawingEngine::OpenGL || dstEngine == DrawingEngine::OpenGL; + return Platform::RequireNewWindow(openGL); } void drawing_engine_init() diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 9948a8fa55..8889749720 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -240,6 +240,11 @@ namespace Platform } return result; } + + bool RequireNewWindow(bool openGL) + { + return true; + } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 02f9be341d..d7d22fbbea 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -593,6 +593,13 @@ namespace Platform } return result; } + + bool RequireNewWindow(bool openGL) + { + // Windows is apparently able to switch to hardware rendering on the fly although + // using the same window in an unaccelerated and accelerated context is unsupported by SDL2 + return openGL; + } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform2.h b/src/openrct2/platform/Platform2.h index 9a2daaba83..6189f21b96 100644 --- a/src/openrct2/platform/Platform2.h +++ b/src/openrct2/platform/Platform2.h @@ -66,4 +66,5 @@ namespace Platform bool IsColourTerminalSupported(); bool HandleSpecialCommandLineArgument(const char* argument); utf8* StrDecompToPrecomp(utf8* input); + bool RequireNewWindow(bool openGL); } // namespace Platform