From 6724ce627516b89cc126ee7f4a876fc8472d46ca Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Sat, 26 Jul 2014 12:43:49 +0200 Subject: [PATCH] Cosmetic changes based on feedback on PR #506. --- Source/Core/Core/Host.h | 2 +- Source/Core/DolphinWX/Frame.cpp | 35 +++++++++++++---------- Source/Core/DolphinWX/FrameTools.cpp | 2 +- Source/Core/DolphinWX/Main.cpp | 4 +-- Source/Core/DolphinWX/MainAndroid.cpp | 2 +- Source/Core/DolphinWX/MainNoGUI.cpp | 2 +- Source/Core/DolphinWX/VideoConfigDiag.cpp | 4 +-- Source/Core/VideoBackends/D3D/Render.cpp | 12 ++++---- Source/Core/VideoCommon/VideoConfig.cpp | 6 ++-- Source/Core/VideoCommon/VideoConfig.h | 5 ++-- 10 files changed, 40 insertions(+), 34 deletions(-) diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index fe9ff11a6d..2d2587138e 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -31,7 +31,7 @@ void Host_Message(int Id); void Host_NotifyMapLoaded(); void Host_RefreshDSPDebuggerWindow(); void Host_RequestRenderWindowSize(int width, int height); -void Host_RequestFullscreen(bool fullscreen); +void Host_RequestFullscreen(bool enable_fullscreen); void Host_SetStartupDebuggingParameters(); void Host_SetWiiMoteConnectionState(int _State); void Host_ShowJitResults(unsigned int address); diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index 1d7fb03819..43d5185ee3 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -642,10 +642,14 @@ void CFrame::OnHostMessage(wxCommandEvent& event) case IDM_FULLSCREENREQUEST: { - bool fullscreen = event.GetInt() == 0 ? false : true; - ToggleDisplayMode(fullscreen); + bool enable_fullscreen = event.GetInt() == 0 ? false : true; + ToggleDisplayMode(enable_fullscreen); if (m_RenderFrame != nullptr) - m_RenderFrame->ShowFullScreen(fullscreen); + m_RenderFrame->ShowFullScreen(enable_fullscreen); + + // If the stop dialog initiated this fullscreen switch then we need + // to pause the emulator after we've completed the switch. + // TODO: Allow the renderer to switch fullscreen modes while paused. if (m_confirmStop) Core::SetState(Core::CORE_PAUSE); } @@ -1183,35 +1187,36 @@ void CFrame::OnMouse(wxMouseEvent& event) event.Skip(); } -void CFrame::DoFullscreen(bool bF) +void CFrame::DoFullscreen(bool enable_fullscreen) { - if (g_Config.ExclusiveFullscreenEnabled() && + if (!g_Config.bBorderlessFullscreen && !SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain && Core::GetState() != Core::CORE_RUN) { - // A responsive renderer is required for exclusive fullscreen, - // but the renderer can only respond in the running state. - // Therefore we ignore fullscreen switches if we support - // exclusive fullscreen, but the renderer is not running. + // A responsive renderer is required for exclusive fullscreen, but the + // renderer can only respond in the running state. Therefore we ignore + // fullscreen switches if we support exclusive fullscreen, but the + // renderer is not running. + // TODO: Allow the renderer to switch fullscreen modes while paused. return; } - ToggleDisplayMode(bF); + ToggleDisplayMode(enable_fullscreen); #if defined(__APPLE__) NSView *view = (NSView *) m_RenderFrame->GetHandle(); NSWindow *window = [view window]; - if (bF != RendererIsFullscreen()) + if (enable_fullscreen != RendererIsFullscreen()) { [window toggleFullScreen:nil]; } #else - if (bF) + if (enable_fullscreen) { m_RenderFrame->ShowFullScreen(true, wxFULLSCREEN_ALL); } - else if (!g_Config.ExclusiveFullscreenEnabled() || + else if (g_Config.bBorderlessFullscreen || SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) { // Exiting exclusive fullscreen should be done from a Renderer callback. @@ -1222,7 +1227,7 @@ void CFrame::DoFullscreen(bool bF) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) { - if (bF) + if (enable_fullscreen) { // Save the current mode before going to fullscreen AuiCurrent = m_Mgr->SavePerspective(); @@ -1239,7 +1244,7 @@ void CFrame::DoFullscreen(bool bF) m_RenderFrame->Raise(); } - g_Config.bFullscreen = bF; + g_Config.bFullscreen = enable_fullscreen; } const CGameListCtrl *CFrame::GetGameListCtrl() const diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 937809e050..7da062645f 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -1104,7 +1104,7 @@ void CFrame::DoStop() // If exclusive fullscreen is not enabled then we can pause the emulation // before we've exited fullscreen. If not then we need to exit fullscreen first. - if (!RendererIsFullscreen() || !g_Config.ExclusiveFullscreenEnabled() || + if (!RendererIsFullscreen() || g_Config.bBorderlessFullscreen || SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) { Core::SetState(Core::CORE_PAUSE); diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 712aca5895..18a693fb82 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -627,10 +627,10 @@ void Host_RequestRenderWindowSize(int width, int height) main_frame->GetEventHandler()->AddPendingEvent(event); } -void Host_RequestFullscreen(bool fullscreen) +void Host_RequestFullscreen(bool enable_fullscreen) { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FULLSCREENREQUEST); - event.SetInt(fullscreen ? 1 : 0); + event.SetInt(enable_fullscreen ? 1 : 0); main_frame->GetEventHandler()->AddPendingEvent(event); } diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp index cdbc2a0785..cb1d14c023 100644 --- a/Source/Core/DolphinWX/MainAndroid.cpp +++ b/Source/Core/DolphinWX/MainAndroid.cpp @@ -95,7 +95,7 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) void Host_RequestRenderWindowSize(int width, int height) {} -void Host_RequestFullscreen(bool fullscreen) {} +void Host_RequestFullscreen(bool enable_fullscreen) {} void Host_SetStartupDebuggingParameters() { diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index ee532f702a..df9276bb59 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -89,7 +89,7 @@ void Host_GetRenderWindowSize(int& x, int& y, int& width, int& height) void Host_RequestRenderWindowSize(int width, int height) {} -void Host_RequestFullscreen(bool fullscreen) {} +void Host_RequestFullscreen(bool enable_fullscreen) {} void Host_SetStartupDebuggingParameters() { diff --git a/Source/Core/DolphinWX/VideoConfigDiag.cpp b/Source/Core/DolphinWX/VideoConfigDiag.cpp index d128b8854e..37d7fb8bbd 100644 --- a/Source/Core/DolphinWX/VideoConfigDiag.cpp +++ b/Source/Core/DolphinWX/VideoConfigDiag.cpp @@ -113,7 +113,7 @@ static wxString scaled_efb_copy_desc = wxTRANSLATE("Greatly increases quality of static wxString pixel_lighting_desc = wxTRANSLATE("Calculate lighting of 3D graphics per-pixel rather than per vertex.\nDecreases emulation speed by some percent (depending on your GPU).\nThis usually is a safe enhancement, but might cause issues sometimes.\n\nIf unsure, leave this unchecked."); static wxString fast_depth_calc_desc = wxTRANSLATE("Use a less accurate algorithm to calculate depth values.\nCauses issues in a few games but might give a decent speedup.\n\nIf unsure, leave this checked."); static wxString force_filtering_desc = wxTRANSLATE("Force texture filtering even if the emulated game explicitly disabled it.\nImproves texture quality slightly but causes glitches in some games.\n\nIf unsure, leave this unchecked."); -static wxString borderless_fullscreen_desc = wxTRANSLATE("Don't use exclusive mode when in fullscreen.\nAllows for faster transitions between fullscreen and windowed mode.\nIncreases input latency, makes movement less smooth and slightly decreases performance.\nExclusive mode is required to support 3D Vision.\n\nIf unsure, leave this unchecked."); +static wxString borderless_fullscreen_desc = wxTRANSLATE("Implement fullscreen mode with a borderless window spanning the whole screen instead of using exclusive mode.\nAllows for faster transitions between fullscreen and windowed mode, but increases input latency, makes movement less smooth and slightly decreases performance.\nExclusive mode is required to support Nvidia 3D Vision.\n\nIf unsure, leave this unchecked."); static wxString internal_res_desc = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality a lot but is also quite heavy on performance and might cause glitches in certain games.\n\"Multiple of 640x528\" is a bit slower than \"Window Size\" but yields less issues. Generally speaking, the lower the internal resolution is, the better your performance will be.\n\nIf unsure, select 640x528."); static wxString efb_access_desc = wxTRANSLATE("Ignore any requests of the CPU to read from or write to the EFB.\nImproves performance in some games, but might disable some gameplay-related features or graphical effects.\n\nIf unsure, leave this unchecked."); static wxString efb_emulate_format_changes_desc = wxTRANSLATE("Ignore any changes to the EFB format.\nImproves performance in many games without any negative effect. Causes graphical defects in a small number of other games though.\n\nIf unsure, leave this checked."); @@ -579,7 +579,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con } // Borderless Fullscreen - borderless_fullscreen = CreateCheckBox(page_advanced, _("Borderless Fullscreen"), wxGetTranslation(borderless_fullscreen_desc), vconfig.bForceBorderlessFullscreen); + borderless_fullscreen = CreateCheckBox(page_advanced, _("Borderless Fullscreen"), wxGetTranslation(borderless_fullscreen_desc), vconfig.bBorderlessFullscreen); borderless_fullscreen->Show(vconfig.backend_info.bSupportsExclusiveFullscreen); szr_misc->Add(borderless_fullscreen); diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 1f883c18fe..551d40b95c 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -938,7 +938,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl SetWindowSize(fbWidth, fbHeight); const bool windowResized = CheckForResize(); - const bool fullscreen = g_ActiveConfig.bFullscreen && !g_ActiveConfig.bForceBorderlessFullscreen && + const bool fullscreen = g_ActiveConfig.ExclusiveFullscreenEnabled() && !SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain; bool fullscreen_changed = s_last_fullscreen_mode != fullscreen; @@ -948,7 +948,9 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl { if (!!fullscreen_state != fullscreen && Host_RendererHasFocus()) { - // We should be in fullscreen, but we're not. Restore it when we regain focus. + // The current fullscreen state does not match the configuration, + // this may happen when the renderer frame loses focus. When the + // render frame is in focus again we can re-apply the configuration. fullscreen_changed = true; } } @@ -967,7 +969,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl // Flip/present backbuffer to frontbuffer here D3D::Present(); - // resize the back buffers NOW to avoid flickering + // Resize the back buffers NOW to avoid flickering if (xfbchanged || windowResized || fullscreen_changed || @@ -979,13 +981,13 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbHeight,const EFBRectangl if (windowResized || fullscreen_changed) { - // apply fullscreen state + // Apply fullscreen state if (fullscreen_changed) { s_last_fullscreen_mode = fullscreen; D3D::swapchain->SetFullscreenState(fullscreen, nullptr); - // notify the host that it is safe to exit fullscreen + // Notify the host that it is safe to exit fullscreen if (!fullscreen) { Host_RequestFullscreen(false); diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 4ef7423a92..cf7685ada6 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -83,7 +83,7 @@ void VideoConfig::Load(const std::string& ini_file) settings->Get("DisableFog", &bDisableFog, 0); settings->Get("OMPDecoder", &bOMPDecoder, false); settings->Get("EnableShaderDebugging", &bEnableShaderDebugging, false); - settings->Get("ForceBorderlessFullscreen", &bForceBorderlessFullscreen, false); + settings->Get("BorderlessFullscreen", &bBorderlessFullscreen, false); IniFile::Section* enhancements = iniFile.GetOrCreateSection("Enhancements"); enhancements->Get("ForceFiltering", &bForceFiltering, 0); @@ -209,7 +209,7 @@ void VideoConfig::VerifyValidity() // TODO: Check iMaxAnisotropy value if (iAdapter < 0 || iAdapter > ((int)backend_info.Adapters.size() - 1)) iAdapter = 0; if (iMultisampleMode < 0 || iMultisampleMode >= (int)backend_info.AAModes.size()) iMultisampleMode = 0; - if (!backend_info.bSupportsExclusiveFullscreen) bForceBorderlessFullscreen = false; + if (!backend_info.bSupportsExclusiveFullscreen) bBorderlessFullscreen = true; } void VideoConfig::Save(const std::string& ini_file) @@ -254,7 +254,7 @@ void VideoConfig::Save(const std::string& ini_file) settings->Set("DisableFog", bDisableFog); settings->Set("OMPDecoder", bOMPDecoder); settings->Set("EnableShaderDebugging", bEnableShaderDebugging); - settings->Set("ForceBorderlessFullscreen", bForceBorderlessFullscreen); + settings->Set("BorderlessFullscreen", bBorderlessFullscreen); IniFile::Section* enhancements = iniFile.GetOrCreateSection("Enhancements"); enhancements->Set("ForceFiltering", bForceFiltering); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index 88a2913d2e..2ff29bf87b 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -100,8 +100,7 @@ struct VideoConfig final bool bAnaglyphStereo; int iAnaglyphStereoSeparation; int iAnaglyphFocalAngle; - bool b3DVision; - bool bForceBorderlessFullscreen; + bool bBorderlessFullscreen; // Hacks bool bEFBAccessEnable; @@ -153,7 +152,7 @@ struct VideoConfig final bool VirtualXFBEnabled() const { return bUseXFB && !bUseRealXFB; } bool EFBCopiesToTextureEnabled() const { return bEFBCopyEnable && bCopyEFBToTexture; } bool EFBCopiesToRamEnabled() const { return bEFBCopyEnable && !bCopyEFBToTexture; } - bool ExclusiveFullscreenEnabled() const { return backend_info.bSupportsExclusiveFullscreen && !bForceBorderlessFullscreen; } + bool ExclusiveFullscreenEnabled() const { return bFullscreen && !bBorderlessFullscreen; } }; extern VideoConfig g_Config;