Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only pause rendering if the Android activity is stopped #14211

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4207,7 +4207,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/*
==================== Drawing begins ====================
*/
if (RenderingEngine::shouldRender())
if (device->isWindowVisible())
drawScene(graph, stats);
/*
==================== End scene ====================
Expand Down
11 changes: 0 additions & 11 deletions src/client/renderingengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,6 @@ class RenderingEngine
const irr::core::dimension2d<u32> initial_screen_size,
const bool initial_window_maximized);

static bool shouldRender()
{
// On Android, pause rendering while the app is in background (generally not visible).
// Don't do this on desktop because windows can be partially visible.
#ifdef __ANDROID__
return get_raw_device()->isWindowActive();
#else
return true;
#endif
};

private:
v2u32 _getWindowSize() const;

Expand Down
5 changes: 2 additions & 3 deletions src/gui/guiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ bool GUIEngine::loadMainMenuScript()
/******************************************************************************/
void GUIEngine::run()
{
IrrlichtDevice *device = m_rendering_engine->get_raw_device();
// Always create clouds because they may or may not be
// needed based on the game selected
video::IVideoDriver *driver = m_rendering_engine->get_video_driver();
Expand Down Expand Up @@ -265,7 +266,7 @@ void GUIEngine::run()
f32 dtime = 0.0f;

while (m_rendering_engine->run() && (!m_startgame) && (!m_kill)) {
if (RenderingEngine::shouldRender()) {
if (device->isWindowVisible()) {
// check if we need to update the "upper left corner"-text
if (text_height != g_fontengine->getTextHeight()) {
updateTopLeftTextSize();
Expand Down Expand Up @@ -295,8 +296,6 @@ void GUIEngine::run()
driver->endScene();
}

IrrlichtDevice *device = m_rendering_engine->get_raw_device();

u32 frametime_min = 1000 / (device->isWindowFocused()
? g_settings->getFloat("fps_max")
: g_settings->getFloat("fps_max_unfocused"));
Expand Down