Prevent rendering and multiple WM_SIZE events when switching between windowed and fullscreen

May help #6295 but also it may not, I can't test it as I don't have that GPU.

Also gets rid of some outdated code.
This commit is contained in:
Henrik Rydgard 2014-06-29 21:03:24 +02:00
parent 498136bbf8
commit 56cee3c00e
5 changed files with 42 additions and 42 deletions

View File

@ -21,20 +21,6 @@ static int xres, yres;
// TODO: Make config?
static bool enableGLDebug = false;
void GL_Resized() {
if (!hWnd)
return;
RECT rc;
GetWindowRect(hWnd, &rc);
xres = rc.right - rc.left; //account for border :P
yres = rc.bottom - rc.top;
if (yres == 0)
yres = 1;
glstate.viewport.set(0, 0, xres, yres);
glstate.viewport.restore();
}
void GL_SwapBuffers() {
SwapBuffers(hDC);
}
@ -253,8 +239,6 @@ bool GL_Init(HWND window, std::string *error_message) {
glDebugMessageCallbackARB((GLDEBUGPROCARB)&DebugCallbackARB, 0); // print debug output to stderr
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
}
GL_Resized(); // Set up our perspective GL screen
return true; // Success
}

View File

@ -5,7 +5,5 @@
#include "Common/CommonWindows.h"
bool GL_Init(HWND window, std::string *error_message);
void GL_Shutdown();
void GL_Resized();
void GL_SwapBuffers();

View File

@ -335,9 +335,9 @@ bool WindowsHost::CreateDesktopShortcut(std::string argumentPath, std::string ga
void WindowsHost::GoFullscreen(bool viewFullscreen) {
if (viewFullscreen)
MainWindow::_ViewFullScreen(MainWindow::GetHWND());
MainWindow::SwitchToFullscreen(MainWindow::GetHWND());
else
MainWindow::_ViewNormal(MainWindow::GetHWND());
MainWindow::SwitchToWindowed(MainWindow::GetHWND());
}
void WindowsHost::ToggleDebugConsoleVisibility() {

View File

@ -132,6 +132,8 @@ namespace MainWindow {
static std::vector<std::string> availableShaders;
static W32Util::AsyncBrowseDialog *browseDialog;
static bool browsePauseAfter;
static bool g_inModeSwitch; // when true, don't react to WM_SIZE
#define MAX_LOADSTRING 100
const TCHAR *szTitle = TEXT("PPSSPP");
const TCHAR *szWindowClass = TEXT("PPSSPPWnd");
@ -286,7 +288,11 @@ namespace MainWindow {
}
}
void _ViewNormal(HWND hWnd) {
void SwitchToWindowed(HWND hWnd) {
// Make sure no rendering is happening during the switch.
Core_NotifyWindowHidden(true);
g_inModeSwitch = true; // Make sure WM_SIZE doesn't call Core_NotifyWindowHidden(false)...
// Put caption and border styles back.
DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE);
DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME | WS_SYSMENU;
@ -308,16 +314,23 @@ namespace MainWindow {
CorrectCursor();
bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO);
ResizeDisplay(true);
ResizeDisplay(false);
if (showOSM) {
ShowScreenResolution();
}
ShowOwnedPopups(hwndMain, TRUE);
W32Util::MakeTopMost(hwndMain, g_Config.bTopMost);
g_inModeSwitch = false;
Core_NotifyWindowHidden(false);
}
void _ViewFullScreen(HWND hWnd) {
// Keep in mind normal window rectangle.
void SwitchToFullscreen(HWND hWnd) {
// Make sure no rendering is happening during the switch.
Core_NotifyWindowHidden(true);
g_inModeSwitch = true; // Make sure WM_SIZE doesn't call Core_NotifyWindowHidden(false)...
// Remember the normal window rectangle.
::GetWindowRect(hWnd, &g_normalRC);
// Remove caption and border styles.
@ -341,12 +354,15 @@ namespace MainWindow {
CorrectCursor();
bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO);
ResizeDisplay(true);
ResizeDisplay(false);
if (showOSM) {
ShowScreenResolution();
}
ShowOwnedPopups(hwndMain, FALSE);
g_inModeSwitch = false;
Core_NotifyWindowHidden(false);
}
RECT DetermineWindowRectangle() {
@ -800,7 +816,7 @@ namespace MainWindow {
SetFocus(hwndMain);
if (g_Config.bFullScreen)
_ViewFullScreen(hwndMain);
SwitchToFullscreen(hwndMain);
return TRUE;
}
@ -914,18 +930,20 @@ namespace MainWindow {
switch (message) {
case WM_SIZE:
switch (wParam) {
case SIZE_MAXIMIZED:
case SIZE_RESTORED:
Core_NotifyWindowHidden(false);
SavePosition();
ResizeDisplay();
break;
case SIZE_MINIMIZED:
Core_NotifyWindowHidden(true);
break;
default:
break;
if (!g_inModeSwitch) {
switch (wParam) {
case SIZE_MAXIMIZED:
case SIZE_RESTORED:
Core_NotifyWindowHidden(false);
SavePosition();
ResizeDisplay();
break;
case SIZE_MINIMIZED:
Core_NotifyWindowHidden(true);
break;
default:
break;
}
}
break;
@ -1433,9 +1451,9 @@ namespace MainWindow {
g_Config.bFullScreen = !g_Config.bFullScreen;
if (g_Config.bFullScreen)
_ViewFullScreen(hWnd);
SwitchToFullscreen(hWnd);
else
_ViewNormal(hWnd);
SwitchToWindowed(hWnd);
break;

View File

@ -62,8 +62,8 @@ namespace MainWindow
HINSTANCE GetHInstance();
void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false);
void SaveStateActionFinished(bool result, void *userdata);
void _ViewFullScreen(HWND hWnd);
void _ViewNormal(HWND hWnd);
void SwitchToFullscreen(HWND hWnd);
void SwitchToWindowed(HWND hWnd);
void ToggleDebugConsoleVisibility();
void TranslateMenus();
void setTexScalingMultiplier(int level);