From ebe6c40a6abb2789349c2b6471eef24ac270ab94 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 27 Aug 2017 22:21:05 -0500 Subject: SDL: Do not reset window size when engines update rendering surface This change allows: * Engines to update their target rendering surface/size and pixel format with the backend multiple times during gameplay; * Users to resize the ScummVM window without having it reset size/position every time an engine updates its target surface format; * Conversions/scaling to continue to run efficiently in hardware, instead of requiring engines to pick their maximum possible output format once and upscale inefficiently in software; * The window to reset size once when an engine calls to set its initial output size, and to reset again once ScummVM returns to the launcher. This is relevant for at least SCI32 and DreamWeb engines, which perform graphics mode switches during games. --- backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'backends/graphics/surfacesdl') diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 983b71ab28..cd7e11b32d 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -784,9 +784,14 @@ void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFo } #endif - // Avoid redundant res changes +#if !SDL_VERSION_ATLEAST(2, 0, 0) + // Avoid redundant res changes, only in SDL1. In SDL2, redundancies may not + // actually be redundant if ScummVM is switching between game engines and + // the screen dimensions are being reinitialized, since window resizing is + // supposed to reset when this happens if ((int)w == _videoMode.screenWidth && (int)h == _videoMode.screenHeight) return; +#endif _videoMode.screenWidth = w; _videoMode.screenHeight = h; @@ -2797,7 +2802,7 @@ SDL_Surface *SurfaceSdlGraphicsManager::SDL_SetVideoMode(int width, int height, createWindowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } - if (!_window->createOrUpdateWindow(width, height, createWindowFlags)) { + if (!createOrUpdateWindow(width, height, createWindowFlags)) { return nullptr; } -- cgit v1.2.3