From 50e74595e439dad99302d7da4026675583da0959 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 18 Nov 2020 23:47:32 +0100 Subject: [PATCH] Eliminated unnecessary rendering during view transitions. --- es-app/src/views/ViewController.cpp | 52 ++++++++++++----------------- es-app/src/views/ViewController.h | 1 + es-core/src/GuiComponent.cpp | 3 +- es-core/src/GuiComponent.h | 3 -- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 327893a85..f423bdb03 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -53,6 +53,7 @@ ViewController::ViewController( mPreviousView(nullptr), mSkipView(nullptr), mCamera(Transform4x4f::Identity()), + mSystemViewTransition(false), mWrappedViews(false), mFadeOpacity(0), mCancelledTransition(false), @@ -198,19 +199,17 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition) mPreviousView = 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). - if (mCurrentView) { + // Pause the video. The onHide() call will take place later in the transition animation lambda + // function. For views without videos this has no effect (and no adverse effect either). + if (mCurrentView) mCurrentView->onPauseVideo(); - mCurrentView->setRenderView(false); - } if (system->isGroupedCustomCollection()) system = system->getRootFolder()->getParent()->getSystem(); mState.viewing = SYSTEM_SELECT; mState.system = system; + mSystemViewTransition = true; auto systemList = getSystemListView(); systemList->setPosition(getSystemId(system) * static_cast(Renderer::getScreenWidth()), @@ -219,7 +218,6 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition) systemList->goToSystem(system, false); mCurrentView = systemList; mCurrentView->onShow(); - mCurrentView->setRenderView(true); PowerSaver::setState(true); // Application startup animation. @@ -292,8 +290,13 @@ void ViewController::goToGameList(SystemData* system) mPreviousView = nullptr; } - if (mState.viewing != SYSTEM_SELECT) + if (mState.viewing != SYSTEM_SELECT) { mPreviousView = mCurrentView; + mSystemViewTransition = false; + } + else { + mSystemViewTransition = true; + } // 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 @@ -319,17 +322,10 @@ void ViewController::goToGameList(SystemData* system) if (slideTransitions) cancelViewTransitions(); - // Disable rendering of the system view. - if (getSystemListView()->getRenderView()) { - getSystemListView()->setRenderView(false); - } - // 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) { + // Pause the video. The onHide() call 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->setRenderView(false); - } if (mState.viewing == SYSTEM_SELECT) { // Move the system list. @@ -388,10 +384,9 @@ void ViewController::goToGameList(SystemData* system) mState.viewing = GAME_LIST; mState.system = system; - if (mCurrentView) { + if (mCurrentView) mCurrentView->onShow(); - mCurrentView->setRenderView(true); - } + playViewTransition(); } @@ -696,17 +691,15 @@ void ViewController::render(const Transform4x4f& parentTrans) // Keep track of UI mode changes. UIModeController::getInstance()->monitorUIMode(); - // Draw the system view if it's flagged to be rendered. - // If the camera is moving, we're transitioning and in that case render it regardless - // of whether it's flagged for rendering or not. (Otherwise there will be a black portion - // shown on the screen during the animation). - if (getSystemListView()->getRenderView() || isCameraMoving()) + // Render the system view if it's the currently displayed view, or if we're in the progress + // of transitioning to or from this view. + if (mSystemListView == mCurrentView || (mSystemViewTransition && isCameraMoving())) getSystemListView()->render(trans); // Draw the gamelists. 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. - if (it->second->getRenderView() || isCameraMoving()) { + if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) { // Clipping. Vector3f guiStart = it->second->getPosition(); Vector3f guiEnd = it->second->getPosition() + Vector3f(it->second->getSize().x(), @@ -788,10 +781,8 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme) #endif // Redisplay the current view. - if (mCurrentView) { + if (mCurrentView) mCurrentView->onShow(); - mCurrentView->setRenderView(true); - } } void ViewController::reloadAll() @@ -835,7 +826,6 @@ void ViewController::reloadAll() SystemData::sSystemVector.front()->getTheme()); mCurrentView->onShow(); - mCurrentView->setRenderView(true); updateHelpPrompts(); } diff --git a/es-app/src/views/ViewController.h b/es-app/src/views/ViewController.h index 0374944e4..7f0154817 100644 --- a/es-app/src/views/ViewController.h +++ b/es-app/src/views/ViewController.h @@ -122,6 +122,7 @@ private: std::shared_ptr mSystemListView; Transform4x4f mCamera; + bool mSystemViewTransition; bool mWrappedViews; float mWrapPreviousPositionX; float mFadeOpacity; diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index d41509a25..ebfafd885 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -32,8 +32,7 @@ GuiComponent::GuiComponent(Window* window) mTransform(Transform4x4f::Identity()), mIsProcessing(false), mVisible(true), - mEnabled(true), - mRenderView(false) + mEnabled(true) { for (unsigned char i = 0; i < MAX_ANIMATIONS; i++) mAnimationMap[i] = nullptr; diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index b7966f98b..90f915596 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -174,8 +174,6 @@ public: virtual void onPauseVideo(); virtual void onUnpauseVideo(); virtual bool isVideoPaused() { return false; }; - virtual void setRenderView(bool status) { mRenderView = status; } - virtual bool getRenderView() { return mRenderView; }; virtual void onScreensaverActivate(); virtual void onScreensaverDeactivate(); @@ -234,7 +232,6 @@ protected: bool mIsProcessing; bool mVisible; bool mEnabled; - bool mRenderView; private: // Don't access this directly! Use getTransform()!