From 97d26718a376a1e5d9df85277a77ba58d8c0c212 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 18 Dec 2023 22:13:01 +0100 Subject: [PATCH] Small rendering optimization for the system and gamelist views --- es-app/src/views/GamelistView.cpp | 42 ++++++++++++------------ es-app/src/views/SystemView.cpp | 53 +++++++++++++++++-------------- 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 962e69c87..46ce49260 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -416,26 +416,20 @@ void GamelistView::render(const glm::mat4& parentTrans) const ViewController::State viewState {ViewController::getInstance()->getState()}; bool stationaryApplicable {false}; - auto renderChildFunc = [this, &viewState](int i, glm::mat4 trans) { - if (getChild(i)->getRenderDuringTransitions()) { + auto renderChildCondFunc = [this, &viewState](int i, glm::mat4 trans) { + bool renderChild {false}; + if (!ViewController::getInstance()->isCameraMoving()) + renderChild = true; + else if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) + renderChild = true; + else if (viewState.viewing == viewState.previouslyViewed) + renderChild = true; + else if (static_cast(Settings::getInstance()->getInt( + "TransitionsGamelistToSystem")) != ViewTransitionAnimation::SLIDE && + viewState.viewing == ViewController::ViewMode::SYSTEM_SELECT) + renderChild = true; + if (renderChild) getChild(i)->render(trans); - } - else { - bool renderChild {false}; - if (!ViewController::getInstance()->isCameraMoving()) - renderChild = true; - else if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) - renderChild = true; - else if (viewState.viewing == viewState.previouslyViewed) - renderChild = true; - else if (static_cast(Settings::getInstance()->getInt( - "TransitionsGamelistToSystem")) != ViewTransitionAnimation::SLIDE && - viewState.viewing == ViewController::ViewMode::SYSTEM_SELECT) - renderChild = true; - - if (renderChild) - getChild(i)->render(trans); - } }; // If it's the startup animation, then don't apply stationary properties. @@ -489,11 +483,17 @@ void GamelistView::render(const glm::mat4& parentTrans) if (viewState.getSystem() != mRoot->getSystem()) continue; mRenderer->popClipRect(); - renderChildFunc(i, mRenderer->getIdentity()); + if (getChild(i)->getRenderDuringTransitions()) + getChild(i)->render(mRenderer->getIdentity()); + else + renderChildCondFunc(i, mRenderer->getIdentity()); clipRectFunc(); } else { - renderChildFunc(i, trans); + if (getChild(i)->getRenderDuringTransitions()) + getChild(i)->render(trans); + else + renderChildCondFunc(i, trans); } } diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index e54c7263b..257b1cc51 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -1476,27 +1476,20 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary) glm::ivec2 {static_cast(mSize.x), static_cast(mSize.y)}); }; - auto renderChildFunc = [this, &viewState](GuiComponent* child, glm::mat4 trans) { - if (child->getRenderDuringTransitions()) { + auto renderChildCondFunc = [this, &viewState](GuiComponent* child, glm::mat4 trans) { + bool renderChild {false}; + if (!ViewController::getInstance()->isCameraMoving()) + renderChild = true; + else if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) + renderChild = true; + else if (viewState.viewing == viewState.previouslyViewed) + renderChild = true; + else if (static_cast(Settings::getInstance()->getInt( + "TransitionsSystemToGamelist")) != ViewTransitionAnimation::SLIDE && + viewState.viewing == ViewController::ViewMode::GAMELIST) + renderChild = true; + if (renderChild) child->render(trans); - } - else { - bool renderChild {false}; - if (!ViewController::getInstance()->isCameraMoving()) - renderChild = true; - else if (viewState.previouslyViewed == ViewController::ViewMode::NOTHING) - renderChild = true; - else if (viewState.viewing == viewState.previouslyViewed) - renderChild = true; - else if (static_cast( - Settings::getInstance()->getInt("TransitionsSystemToGamelist")) != - ViewTransitionAnimation::SLIDE && - viewState.viewing == ViewController::ViewMode::GAMELIST) - renderChild = true; - - if (renderChild) - child->render(trans); - } }; clipRectFunc(); @@ -1543,11 +1536,17 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary) if (renderChild) { if (childStationary) { mRenderer->popClipRect(); - renderChildFunc(child, mRenderer->getIdentity()); + if (child->getRenderDuringTransitions()) + child->render(mRenderer->getIdentity()); + else + renderChildCondFunc(child, mRenderer->getIdentity()); clipRectFunc(); } else { - renderChildFunc(child, elementTrans); + if (child->getRenderDuringTransitions()) + child->render(elementTrans); + else + renderChildCondFunc(child, elementTrans); } } } @@ -1557,11 +1556,17 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary) if (renderChild) { if (childStationary) { mRenderer->popClipRect(); - renderChildFunc(child, mRenderer->getIdentity()); + if (child->getRenderDuringTransitions()) + child->render(mRenderer->getIdentity()); + else + renderChildCondFunc(child, mRenderer->getIdentity()); clipRectFunc(); } else { - renderChildFunc(child, elementTrans); + if (child->getRenderDuringTransitions()) + child->render(elementTrans); + else + renderChildCondFunc(child, elementTrans); } } }