Skip to content

Commit 2d3f31d

Browse files
committed
android: reset vsync after minimizing window
1 parent 5ea9937 commit 2d3f31d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

appframework/sdlmgr.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ class CSDLMgr : public ILauncherMgr
404404
int m_MouseButtonDownX;
405405
int m_MouseButtonDownY;
406406

407+
bool m_bResetVsync;
408+
int m_nFramesToSkip;
409+
407410
double m_flPrevGLSwapWindowTime;
408411
};
409412

@@ -584,6 +587,9 @@ InitReturnVal_t CSDLMgr::Init()
584587
m_nWarpDelta = 0;
585588
m_bRawInput = false;
586589

590+
m_nFramesToSkip = 0;
591+
m_bResetVsync = false;
592+
587593
m_flPrevGLSwapWindowTime = 0.0f;
588594

589595
memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs));
@@ -1431,7 +1437,20 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
14311437

14321438
m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF();
14331439

1434-
1440+
#ifdef ANDROID
1441+
// ADRENO GPU MOMENT, SKIP 5 FRAMES
1442+
if( m_bResetVsync )
1443+
{
1444+
if( m_nFramesToSkip <= 0 )
1445+
{
1446+
SDL_GL_SetSwapInterval(swapInterval);
1447+
m_bResetVsync = false;
1448+
}
1449+
else
1450+
m_nFramesToSkip--;
1451+
}
1452+
#endif
1453+
14351454
CheckGLError( __LINE__ );
14361455
}
14371456
#endif // DX_TO_GL_ABSTRACTION
@@ -1887,6 +1906,7 @@ void CSDLMgr::PumpWindowsMessageLoop()
18871906
}
18881907
case SDL_WINDOWEVENT_FOCUS_GAINED:
18891908
{
1909+
m_bResetVsync = true; m_nFramesToSkip = 3;
18901910
m_bHasFocus = true;
18911911
SDL_ShowCursor( m_bCursorVisible ? 1 : 0 );
18921912
CCocoaEvent theEvent;

0 commit comments

Comments
 (0)