From 9f2ff9448d87c07cf74b37af6c4a43e406b2ccb4 Mon Sep 17 00:00:00 2001 From: Ryan McClelland Date: Wed, 19 May 2021 15:16:26 -0700 Subject: [PATCH] return early if info panel already the same info updateInfoPanel() is an expensive function due to access to file system for reading screenshots, videos, etc. Record what is already up there and if another request comes in for the same thing, then return early. --- es-app/src/views/gamelist/DetailedGameListView.cpp | 13 +++++++++++-- es-app/src/views/gamelist/DetailedGameListView.h | 2 ++ es-app/src/views/gamelist/VideoGameListView.cpp | 14 +++++++++++--- es-app/src/views/gamelist/VideoGameListView.h | 2 ++ es-core/src/components/IList.h | 6 +----- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/es-app/src/views/gamelist/DetailedGameListView.cpp b/es-app/src/views/gamelist/DetailedGameListView.cpp index 0dbbbafbb5..12da1c4a5f 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.cpp +++ b/es-app/src/views/gamelist/DetailedGameListView.cpp @@ -215,12 +215,19 @@ void DetailedGameListView::updateInfoPanel() FileData* file = (mList.size() == 0 || mList.isScrolling()) ? NULL : mList.getSelected(); bool fadingOut; - if(file == NULL) + if(mFile == file) + { + // Info is already on the panel, don't waste time reloading + return; + } + else if(file == NULL) { //mImage.setImage(""); //mDescription.setText(""); fadingOut = true; - }else{ + } + else + { mThumbnail.setImage(file->getThumbnailPath()); mMarquee.setImage(file->getMarqueePath()); mImage.setImage(file->getImagePath()); @@ -244,6 +251,8 @@ void DetailedGameListView::updateInfoPanel() fadingOut = false; } + mFile = file; + std::vector comps = getMDValues(); comps.push_back(&mThumbnail); comps.push_back(&mMarquee); diff --git a/es-app/src/views/gamelist/DetailedGameListView.h b/es-app/src/views/gamelist/DetailedGameListView.h index 6add975f4d..50352f6fcb 100644 --- a/es-app/src/views/gamelist/DetailedGameListView.h +++ b/es-app/src/views/gamelist/DetailedGameListView.h @@ -26,6 +26,8 @@ class DetailedGameListView : public BasicGameListView void initMDLabels(); void initMDValues(); + FileData* mFile; + ImageComponent mThumbnail; ImageComponent mMarquee; ImageComponent mImage; diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 9b2e50a10c..b028938831 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -249,7 +249,12 @@ void VideoGameListView::updateInfoPanel() FileData* file = (mList.size() == 0 || mList.isScrolling()) ? NULL : mList.getSelected(); bool fadingOut; - if(file == NULL) + if(mFile == file) + { + // Info is already on the panel, don't waste time reloading + return; + } + else if(file == NULL) { mVideo->setVideo(""); mVideo->setImage(""); @@ -257,8 +262,9 @@ void VideoGameListView::updateInfoPanel() //mMarquee.setImage(""); //mDescription.setText(""); fadingOut = true; - - }else{ + } + else + { if (!mVideo->setVideo(file->getVideoPath())) { mVideo->setDefaultVideo(); @@ -290,6 +296,8 @@ void VideoGameListView::updateInfoPanel() fadingOut = false; } + mFile = file; + std::vector comps = getMDValues(); comps.push_back(&mThumbnail); comps.push_back(&mMarquee); diff --git a/es-app/src/views/gamelist/VideoGameListView.h b/es-app/src/views/gamelist/VideoGameListView.h index b5f36c6277..f0799b2396 100644 --- a/es-app/src/views/gamelist/VideoGameListView.h +++ b/es-app/src/views/gamelist/VideoGameListView.h @@ -33,6 +33,8 @@ class VideoGameListView : public BasicGameListView void initMDLabels(); void initMDValues(); + FileData* mFile; + ImageComponent mThumbnail; ImageComponent mMarquee; VideoComponent* mVideo; diff --git a/es-core/src/components/IList.h b/es-core/src/components/IList.h index 93f61ce9a8..2a60f94518 100644 --- a/es-core/src/components/IList.h +++ b/es-core/src/components/IList.h @@ -191,10 +191,6 @@ class IList : public GuiComponent { PowerSaver::setState(velocity == 0); - // generate an onCursorChanged event in the stopped state when the user lets go of the key - if(velocity == 0 && mScrollVelocity != 0) - onCursorChanged(CURSOR_STOPPED); - mScrollVelocity = velocity; mScrollTier = 0; mScrollTierAccumulator = 0; @@ -302,7 +298,7 @@ class IList : public GuiComponent onScroll(absAmt); mCursor = cursor; - onCursorChanged((mScrollTier > 0) ? CURSOR_SCROLLING : CURSOR_STOPPED); + onCursorChanged((amt != 0) ? CURSOR_SCROLLING : CURSOR_STOPPED); } virtual void onCursorChanged(const CursorState& /*state*/) {}