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,11 +416,7 @@ 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()) {
getChild(i)->render(trans);
}
else {
bool renderChild {false}; bool renderChild {false};
if (!ViewController::getInstance()->isCameraMoving()) if (!ViewController::getInstance()->isCameraMoving())
renderChild = true; renderChild = true;
@ -432,10 +428,8 @@ void GamelistView::render(const glm::mat4& parentTrans)
"TransitionsGamelistToSystem")) != ViewTransitionAnimation::SLIDE && "TransitionsGamelistToSystem")) != ViewTransitionAnimation::SLIDE &&
viewState.viewing == ViewController::ViewMode::SYSTEM_SELECT) viewState.viewing == ViewController::ViewMode::SYSTEM_SELECT)
renderChild = true; renderChild = true;
if (renderChild) if (renderChild)
getChild(i)->render(trans); 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,11 +1476,7 @@ 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()) {
child->render(trans);
}
else {
bool renderChild {false}; bool renderChild {false};
if (!ViewController::getInstance()->isCameraMoving()) if (!ViewController::getInstance()->isCameraMoving())
renderChild = true; renderChild = true;
@ -1488,15 +1484,12 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
renderChild = true; renderChild = true;
else if (viewState.viewing == viewState.previouslyViewed) else if (viewState.viewing == viewState.previouslyViewed)
renderChild = true; renderChild = true;
else if (static_cast<ViewTransitionAnimation>( else if (static_cast<ViewTransitionAnimation>(Settings::getInstance()->getInt(
Settings::getInstance()->getInt("TransitionsSystemToGamelist")) != "TransitionsSystemToGamelist")) != ViewTransitionAnimation::SLIDE &&
ViewTransitionAnimation::SLIDE &&
viewState.viewing == ViewController::ViewMode::GAMELIST) viewState.viewing == ViewController::ViewMode::GAMELIST)
renderChild = true; renderChild = true;
if (renderChild) if (renderChild)
child->render(trans); 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);
} }
} }
} }