- skip rendering when application is not active

Use vid_activeinbackground CVAR to override this behavior

(cherry picked from commit 2be84dc636)

# Conflicts:
#	src/gl/system/gl_framebuffer.cpp
#	src/posix/cocoa/i_video.mm
#	src/posix/sdl/gl_sysfb.h
#	src/posix/sdl/sdlglvideo.cpp
#	src/win32/gl_sysfb.h
#	src/win32/win32gliface.cpp
This commit is contained in:
alexey.lysiuk 2018-05-04 11:24:37 +03:00 committed by drfrag666
parent b0c013b9dc
commit 21ce592771
11 changed files with 25 additions and 59 deletions

View file

@ -250,6 +250,7 @@ FStartupInfo DoomStartupInfo;
FString lastIWAD;
int restart = 0;
bool batchrun; // just run the startup and collect all error messages in a logfile, then quit without any interaction
bool AppActive = true;
cycle_t FrameCycles;
@ -658,6 +659,8 @@ CVAR (Flag, compat_multiexit, compatflags2, COMPATF2_MULTIEXIT);
CVAR (Flag, compat_teleport, compatflags2, COMPATF2_TELEPORT);
CVAR (Flag, compat_pushwindow, compatflags2, COMPATF2_PUSHWINDOW);
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
//==========================================================================
//
// D_Display
@ -674,6 +677,11 @@ void D_Display ()
if (nodrawers || screen == NULL)
return; // for comparative timing / profiling
if (!AppActive && (screen->IsFullscreen() || !vid_activeinbackground))
{
return;
}
cycle_t cycles;
cycles.Reset();

View file

@ -166,12 +166,6 @@ void OpenGLFrameBuffer::InitializeState()
void OpenGLFrameBuffer::Update()
{
if (!CanUpdate())
{
GLRenderer->Flush();
return;
}
Begin2D(false);
DrawRateStuff();

View file

@ -302,18 +302,24 @@ ApplicationController* appCtrl;
}
extern bool AppActive;
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
{
ZD_UNUSED(aNotification);
S_SetSoundPaused(1);
AppActive = true;
}
- (void)applicationWillResignActive:(NSNotification*)aNotification
{
ZD_UNUSED(aNotification);
S_SetSoundPaused((!!i_soundinbackground) || 0);
S_SetSoundPaused(i_soundinbackground);
AppActive = false;
}

View file

@ -1122,22 +1122,6 @@ void SDLGLFB::InitializeState()
{
}
bool SDLGLFB::CanUpdate()
{
if (m_Lock != 1)
{
if (m_Lock > 0)
{
UpdatePending = true;
--m_Lock;
}
return false;
}
return true;
}
void SDLGLFB::SwapBuffers()
{
[[NSOpenGLContext currentContext] flushBuffer];

View file

@ -81,7 +81,6 @@ protected:
void InitializeState();
bool CanUpdate();
void SwapBuffers();
void SetGammaTable(uint16_t* table);

View file

@ -311,9 +311,16 @@ void MessagePump (const SDL_Event &sev)
case SDL_WINDOWEVENT:
switch (sev.window.event)
{
extern bool AppActive;
case SDL_WINDOWEVENT_FOCUS_GAINED:
S_SetSoundPaused(1);
AppActive = true;
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
S_SetSoundPaused((!!i_soundinbackground) || sev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED);
S_SetSoundPaused(i_soundinbackground);
AppActive = false;
break;
}
break;

View file

@ -405,20 +405,6 @@ void SDLGLFB::InitializeState()
{
}
bool SDLGLFB::CanUpdate ()
{
if (m_Lock != 1)
{
if (m_Lock > 0)
{
UpdatePending = true;
--m_Lock;
}
return false;
}
return true;
}
void SDLGLFB::SetGammaTable(uint16_t *tbl)
{
if (m_supportsGamma)

View file

@ -77,7 +77,6 @@ public:
virtual int GetTrueHeight() { return GetClientHeight(); }
protected:
bool CanUpdate();
void SetGammaTable(uint16_t *tbl);
void ResetGammaTable();
void InitializeState();

View file

@ -156,7 +156,7 @@ LPDIRECTINPUT8 g_pdi;
LPDIRECTINPUT g_pdi3;
BOOL AppActive = TRUE;
extern bool AppActive;
int SessionState = 0;
int BlockMouseMove;
@ -543,7 +543,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case WM_ACTIVATEAPP:
AppActive = wParam;
AppActive = wParam == TRUE;
if (wParam)
{
SetPriorityClass (GetCurrentProcess (), INGAME_PRIORITY_CLASS);

View file

@ -63,7 +63,6 @@
#include "gl/system/gl_swframebuffer.h"
extern HWND Window;
extern BOOL AppActive;
extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
@ -80,8 +79,6 @@ PFNWGLSWAPINTERVALEXTPROC myWglSwapIntervalExtProc;
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
@ -1143,18 +1140,6 @@ void Win32GLFrameBuffer::InitializeState()
//
//==========================================================================
bool Win32GLFrameBuffer::CanUpdate()
{
if (!AppActive && (IsFullscreen() || !vid_activeinbackground)) return false;
return true;
}
//==========================================================================
//
//
//
//==========================================================================
void Win32GLFrameBuffer::ResetGammaTable()
{
if (m_supportsGamma)

View file

@ -67,8 +67,6 @@ public:
void InitializeState();
protected:
bool CanUpdate();
void ResetGammaTable();
void SetGammaTable(uint16_t * tbl);