Skip to content

Commit

Permalink
egl: Create a way to bypass render completely
Browse files Browse the repository at this point in the history
If render is disabled, we essentially go headless. This is necessary on android
because when our window is destroyed, all graphics operations become errors.

This also has the effect of dropping cpu usage down to ~0% while we're running
in the background, so it could be used on other platforms when minimized.
  • Loading branch information
Cory Fields committed Oct 10, 2012
1 parent 52840a4 commit d72df19
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions xbmc/Application.cpp
Expand Up @@ -2955,7 +2955,7 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
// never set a frametime less than 2 fps to avoid problems when debuggin and on breaks
if( frameTime > 0.5 ) frameTime = 0.5;

if (processGUI)
if (processGUI && m_renderGUI)
{
g_graphicsContext.Lock();
// check if there are notifications to display
Expand Down Expand Up @@ -2985,13 +2985,13 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
ProcessGamepad(frameTime);
ProcessEventServer(frameTime);
ProcessPeripherals(frameTime);
if (processGUI)
if (processGUI && m_renderGUI)
{
m_pInertialScrollingHandler->ProcessInertialScroll(frameTime);
m_seekHandler->Process();
}
}
if (processGUI)
if (processGUI && m_renderGUI)
{
if (!m_bStop)
g_windowManager.Process(CTimeUtils::GetFrameTime());
Expand Down Expand Up @@ -6030,6 +6030,11 @@ bool CApplication::IsPresentFrame()
return ret;
}

void CApplication::SetRenderGUI(bool renderGUI)
{
m_renderGUI = renderGUI;
}

#if defined(HAS_LINUX_NETWORK)
CNetworkLinux& CApplication::getNetwork()
{
Expand Down
1 change: 1 addition & 0 deletions xbmc/Application.h
Expand Up @@ -371,6 +371,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool SwitchToFullScreen();

CSplash* GetSplash() { return m_splash; }
void SetRenderGUI(bool renderGUI);
protected:
bool LoadSkin(const CStdString& skinID);
void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);
Expand Down
7 changes: 4 additions & 3 deletions xbmc/XBApplicationEx.cpp
Expand Up @@ -82,6 +82,7 @@ INT CXBApplicationEx::Run(bool renderGUI)
unsigned int lastFrameTime = 0;
unsigned int frameTime = 0;
const unsigned int noRenderFrameTime = 15; // Simulates ~66fps
m_renderGUI = renderGUI;

#ifdef XBMC_TRACK_EXCEPTIONS
BYTE processExceptionCount = 0;
Expand Down Expand Up @@ -138,7 +139,7 @@ INT CXBApplicationEx::Run(bool renderGUI)
try
{
#endif
if (!m_bStop) FrameMove(true, renderGUI);
if (!m_bStop) FrameMove(true, m_renderGUI);
//reset exception count
#ifdef XBMC_TRACK_EXCEPTIONS
frameMoveExceptionCount = 0;
Expand Down Expand Up @@ -173,8 +174,8 @@ INT CXBApplicationEx::Run(bool renderGUI)
try
{
#endif
if (renderGUI && !m_bStop) Render();
else if (!renderGUI)
if (m_renderGUI && !m_bStop) Render();
else if (!m_renderGUI)
{
frameTime = XbmcThreads::SystemClockMillis() - lastFrameTime;
if(frameTime < noRenderFrameTime)
Expand Down
2 changes: 2 additions & 0 deletions xbmc/XBApplicationEx.h
Expand Up @@ -42,10 +42,12 @@ class CXBApplicationEx : public IWindowManagerCallback
int m_ExitCode;
bool m_AppActive;
bool m_AppFocused;
bool m_renderGUI;

// Overridable functions for the 3D scene created by the app
virtual bool Initialize() { return true; }
virtual bool Cleanup() { return true; }
virtual void SetRenderGUI(bool renderGUI) {};

public:
// Functions to create, run, and clean up the application
Expand Down

0 comments on commit d72df19

Please sign in to comment.