android: reset vsync after minimizing window

This commit is contained in:
nillerusr 2023-08-18 15:40:38 +03:00
parent 5ea9937457
commit 2d3f31d37e

View File

@ -404,6 +404,9 @@ private:
int m_MouseButtonDownX; int m_MouseButtonDownX;
int m_MouseButtonDownY; int m_MouseButtonDownY;
bool m_bResetVsync;
int m_nFramesToSkip;
double m_flPrevGLSwapWindowTime; double m_flPrevGLSwapWindowTime;
}; };
@ -584,6 +587,9 @@ InitReturnVal_t CSDLMgr::Init()
m_nWarpDelta = 0; m_nWarpDelta = 0;
m_bRawInput = false; m_bRawInput = false;
m_nFramesToSkip = 0;
m_bResetVsync = false;
m_flPrevGLSwapWindowTime = 0.0f; m_flPrevGLSwapWindowTime = 0.0f;
memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs)); memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs));
@ -1431,6 +1437,19 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF(); m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF();
#ifdef ANDROID
// ADRENO GPU MOMENT, SKIP 5 FRAMES
if( m_bResetVsync )
{
if( m_nFramesToSkip <= 0 )
{
SDL_GL_SetSwapInterval(swapInterval);
m_bResetVsync = false;
}
else
m_nFramesToSkip--;
}
#endif
CheckGLError( __LINE__ ); CheckGLError( __LINE__ );
} }
@ -1887,6 +1906,7 @@ void CSDLMgr::PumpWindowsMessageLoop()
} }
case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_FOCUS_GAINED:
{ {
m_bResetVsync = true; m_nFramesToSkip = 3;
m_bHasFocus = true; m_bHasFocus = true;
SDL_ShowCursor( m_bCursorVisible ? 1 : 0 ); SDL_ShowCursor( m_bCursorVisible ? 1 : 0 );
CCocoaEvent theEvent; CCocoaEvent theEvent;