Small rendering optimization for the system and gamelist views

This commit is contained in:
Leon Styhre 2023-12-18 22:13:01 +01:00
parent c41cc5a94f
commit 97d26718a3
2 changed files with 50 additions and 45 deletions

View file

@ -416,26 +416,20 @@ void GamelistView::render(const glm::mat4& parentTrans)
const ViewController::State viewState {ViewController::getInstance()->getState()}; const ViewController::State viewState {ViewController::getInstance()->getState()};
bool stationaryApplicable {false}; bool stationaryApplicable {false};
auto renderChildFunc = [this, &viewState](int i, glm::mat4 trans) { auto renderChildCondFunc = [this, &viewState](int i, glm::mat4 trans) {
if (getChild(i)->getRenderDuringTransitions()) { 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<ViewTransitionAnimation>(Settings::getInstance()->getInt(
"TransitionsGamelistToSystem")) != ViewTransitionAnimation::SLIDE &&
viewState.viewing == ViewController::ViewMode::SYSTEM_SELECT)
renderChild = true;
if (renderChild)
getChild(i)->render(trans); 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<ViewTransitionAnimation>(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. // 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()) if (viewState.getSystem() != mRoot->getSystem())
continue; continue;
mRenderer->popClipRect(); mRenderer->popClipRect();
renderChildFunc(i, mRenderer->getIdentity()); if (getChild(i)->getRenderDuringTransitions())
getChild(i)->render(mRenderer->getIdentity());
else
renderChildCondFunc(i, mRenderer->getIdentity());
clipRectFunc(); clipRectFunc();
} }
else { else {
renderChildFunc(i, trans); if (getChild(i)->getRenderDuringTransitions())
getChild(i)->render(trans);
else
renderChildCondFunc(i, trans);
} }
} }

View file

@ -1476,27 +1476,20 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)}); glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
}; };
auto renderChildFunc = [this, &viewState](GuiComponent* child, glm::mat4 trans) { auto renderChildCondFunc = [this, &viewState](GuiComponent* child, glm::mat4 trans) {
if (child->getRenderDuringTransitions()) { 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<ViewTransitionAnimation>(Settings::getInstance()->getInt(
"TransitionsSystemToGamelist")) != ViewTransitionAnimation::SLIDE &&
viewState.viewing == ViewController::ViewMode::GAMELIST)
renderChild = true;
if (renderChild)
child->render(trans); 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<ViewTransitionAnimation>(
Settings::getInstance()->getInt("TransitionsSystemToGamelist")) !=
ViewTransitionAnimation::SLIDE &&
viewState.viewing == ViewController::ViewMode::GAMELIST)
renderChild = true;
if (renderChild)
child->render(trans);
}
}; };
clipRectFunc(); clipRectFunc();
@ -1543,11 +1536,17 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
if (renderChild) { if (renderChild) {
if (childStationary) { if (childStationary) {
mRenderer->popClipRect(); mRenderer->popClipRect();
renderChildFunc(child, mRenderer->getIdentity()); if (child->getRenderDuringTransitions())
child->render(mRenderer->getIdentity());
else
renderChildCondFunc(child, mRenderer->getIdentity());
clipRectFunc(); clipRectFunc();
} }
else { 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 (renderChild) {
if (childStationary) { if (childStationary) {
mRenderer->popClipRect(); mRenderer->popClipRect();
renderChildFunc(child, mRenderer->getIdentity()); if (child->getRenderDuringTransitions())
child->render(mRenderer->getIdentity());
else
renderChildCondFunc(child, mRenderer->getIdentity());
clipRectFunc(); clipRectFunc();
} }
else { else {
renderChildFunc(child, elementTrans); if (child->getRenderDuringTransitions())
child->render(elementTrans);
else
renderChildCondFunc(child, elementTrans);
} }
} }
} }