Eliminated unnecessary rendering during view transitions.

This commit is contained in:
Leon Styhre 2020-11-18 23:47:32 +01:00
parent e30e636780
commit 50e74595e4
4 changed files with 23 additions and 36 deletions

View file

@ -53,6 +53,7 @@ ViewController::ViewController(
mPreviousView(nullptr), mPreviousView(nullptr),
mSkipView(nullptr), mSkipView(nullptr),
mCamera(Transform4x4f::Identity()), mCamera(Transform4x4f::Identity()),
mSystemViewTransition(false),
mWrappedViews(false), mWrappedViews(false),
mFadeOpacity(0), mFadeOpacity(0),
mCancelledTransition(false), mCancelledTransition(false),
@ -198,19 +199,17 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
mPreviousView = mCurrentView; mPreviousView = mCurrentView;
// Pause the video and flag the view to not be rendered. The onHide() will take place // Pause the video. The onHide() call will take place later in the transition animation lambda
// later in the transition animation lambda function. For views without videos this has // function. For views without videos this has no effect (and no adverse effect either).
// no effect (and no adverse effect either). if (mCurrentView)
if (mCurrentView) {
mCurrentView->onPauseVideo(); mCurrentView->onPauseVideo();
mCurrentView->setRenderView(false);
}
if (system->isGroupedCustomCollection()) if (system->isGroupedCustomCollection())
system = system->getRootFolder()->getParent()->getSystem(); system = system->getRootFolder()->getParent()->getSystem();
mState.viewing = SYSTEM_SELECT; mState.viewing = SYSTEM_SELECT;
mState.system = system; mState.system = system;
mSystemViewTransition = true;
auto systemList = getSystemListView(); auto systemList = getSystemListView();
systemList->setPosition(getSystemId(system) * static_cast<float>(Renderer::getScreenWidth()), systemList->setPosition(getSystemId(system) * static_cast<float>(Renderer::getScreenWidth()),
@ -219,7 +218,6 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
systemList->goToSystem(system, false); systemList->goToSystem(system, false);
mCurrentView = systemList; mCurrentView = systemList;
mCurrentView->onShow(); mCurrentView->onShow();
mCurrentView->setRenderView(true);
PowerSaver::setState(true); PowerSaver::setState(true);
// Application startup animation. // Application startup animation.
@ -292,8 +290,13 @@ void ViewController::goToGameList(SystemData* system)
mPreviousView = nullptr; mPreviousView = nullptr;
} }
if (mState.viewing != SYSTEM_SELECT) if (mState.viewing != SYSTEM_SELECT) {
mPreviousView = mCurrentView; mPreviousView = mCurrentView;
mSystemViewTransition = false;
}
else {
mSystemViewTransition = true;
}
// Find if we're wrapping around the first and last systems, which requires the gamelist // Find if we're wrapping around the first and last systems, which requires the gamelist
// to be moved in order to avoid weird camera movements. This is only needed for the // to be moved in order to avoid weird camera movements. This is only needed for the
@ -319,17 +322,10 @@ void ViewController::goToGameList(SystemData* system)
if (slideTransitions) if (slideTransitions)
cancelViewTransitions(); cancelViewTransitions();
// Disable rendering of the system view. // Pause the video. The onHide() call will take place later in the transition animation lambda
if (getSystemListView()->getRenderView()) { // function. For views without videos this has no effect (and no adverse effect either).
getSystemListView()->setRenderView(false); else if (mCurrentView)
}
// Pause the video and flag the view to not be rendered. The onHide() will take place
// later in the transition animation lambda function. For views without videos this has
// no effect (and no adverse effect either).
else if (mCurrentView) {
mCurrentView->onPauseVideo(); mCurrentView->onPauseVideo();
mCurrentView->setRenderView(false);
}
if (mState.viewing == SYSTEM_SELECT) { if (mState.viewing == SYSTEM_SELECT) {
// Move the system list. // Move the system list.
@ -388,10 +384,9 @@ void ViewController::goToGameList(SystemData* system)
mState.viewing = GAME_LIST; mState.viewing = GAME_LIST;
mState.system = system; mState.system = system;
if (mCurrentView) { if (mCurrentView)
mCurrentView->onShow(); mCurrentView->onShow();
mCurrentView->setRenderView(true);
}
playViewTransition(); playViewTransition();
} }
@ -696,17 +691,15 @@ void ViewController::render(const Transform4x4f& parentTrans)
// Keep track of UI mode changes. // Keep track of UI mode changes.
UIModeController::getInstance()->monitorUIMode(); UIModeController::getInstance()->monitorUIMode();
// Draw the system view if it's flagged to be rendered. // Render the system view if it's the currently displayed view, or if we're in the progress
// If the camera is moving, we're transitioning and in that case render it regardless // of transitioning to or from this view.
// of whether it's flagged for rendering or not. (Otherwise there will be a black portion if (mSystemListView == mCurrentView || (mSystemViewTransition && isCameraMoving()))
// shown on the screen during the animation).
if (getSystemListView()->getRenderView() || isCameraMoving())
getSystemListView()->render(trans); getSystemListView()->render(trans);
// Draw the gamelists. // Draw the gamelists.
for (auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++) { for (auto it = mGameListViews.cbegin(); it != mGameListViews.cend(); it++) {
// Same thing as for the system view, limit the rendering only to what needs to be drawn. // Same thing as for the system view, limit the rendering only to what needs to be drawn.
if (it->second->getRenderView() || isCameraMoving()) { if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) {
// Clipping. // Clipping.
Vector3f guiStart = it->second->getPosition(); Vector3f guiStart = it->second->getPosition();
Vector3f guiEnd = it->second->getPosition() + Vector3f(it->second->getSize().x(), Vector3f guiEnd = it->second->getPosition() + Vector3f(it->second->getSize().x(),
@ -788,10 +781,8 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
#endif #endif
// Redisplay the current view. // Redisplay the current view.
if (mCurrentView) { if (mCurrentView)
mCurrentView->onShow(); mCurrentView->onShow();
mCurrentView->setRenderView(true);
}
} }
void ViewController::reloadAll() void ViewController::reloadAll()
@ -835,7 +826,6 @@ void ViewController::reloadAll()
SystemData::sSystemVector.front()->getTheme()); SystemData::sSystemVector.front()->getTheme());
mCurrentView->onShow(); mCurrentView->onShow();
mCurrentView->setRenderView(true);
updateHelpPrompts(); updateHelpPrompts();
} }

View file

@ -122,6 +122,7 @@ private:
std::shared_ptr<SystemView> mSystemListView; std::shared_ptr<SystemView> mSystemListView;
Transform4x4f mCamera; Transform4x4f mCamera;
bool mSystemViewTransition;
bool mWrappedViews; bool mWrappedViews;
float mWrapPreviousPositionX; float mWrapPreviousPositionX;
float mFadeOpacity; float mFadeOpacity;

View file

@ -32,8 +32,7 @@ GuiComponent::GuiComponent(Window* window)
mTransform(Transform4x4f::Identity()), mTransform(Transform4x4f::Identity()),
mIsProcessing(false), mIsProcessing(false),
mVisible(true), mVisible(true),
mEnabled(true), mEnabled(true)
mRenderView(false)
{ {
for (unsigned char i = 0; i < MAX_ANIMATIONS; i++) for (unsigned char i = 0; i < MAX_ANIMATIONS; i++)
mAnimationMap[i] = nullptr; mAnimationMap[i] = nullptr;

View file

@ -174,8 +174,6 @@ public:
virtual void onPauseVideo(); virtual void onPauseVideo();
virtual void onUnpauseVideo(); virtual void onUnpauseVideo();
virtual bool isVideoPaused() { return false; }; virtual bool isVideoPaused() { return false; };
virtual void setRenderView(bool status) { mRenderView = status; }
virtual bool getRenderView() { return mRenderView; };
virtual void onScreensaverActivate(); virtual void onScreensaverActivate();
virtual void onScreensaverDeactivate(); virtual void onScreensaverDeactivate();
@ -234,7 +232,6 @@ protected:
bool mIsProcessing; bool mIsProcessing;
bool mVisible; bool mVisible;
bool mEnabled; bool mEnabled;
bool mRenderView;
private: private:
// Don't access this directly! Use getTransform()! // Don't access this directly! Use getTransform()!