Skip to content

Commit

Permalink
return early if info panel already the same info
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
XenuIsWatching committed May 26, 2021
1 parent 584f741 commit 083547c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 13 deletions.
17 changes: 15 additions & 2 deletions es-app/src/views/gamelist/DetailedGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,23 @@ 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)
{
LOG(LogDebug) << "DetailedGameListView::updateInfoPanel() : Clearing!";

//mImage.setImage("");
//mDescription.setText("");
fadingOut = true;
}else{
}
else
{
LOG(LogDebug) << "DetailedGameListView::updateInfoPanel() : Drawing!";

mThumbnail.setImage(file->getThumbnailPath());
mMarquee.setImage(file->getMarqueePath());
mImage.setImage(file->getImagePath());
Expand All @@ -244,6 +255,8 @@ void DetailedGameListView::updateInfoPanel()
fadingOut = false;
}

mFile = file;

std::vector<GuiComponent*> comps = getMDValues();
comps.push_back(&mThumbnail);
comps.push_back(&mMarquee);
Expand Down
2 changes: 2 additions & 0 deletions es-app/src/views/gamelist/DetailedGameListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class DetailedGameListView : public BasicGameListView
void initMDLabels();
void initMDValues();

FileData* mFile;

ImageComponent mThumbnail;
ImageComponent mMarquee;
ImageComponent mImage;
Expand Down
4 changes: 4 additions & 0 deletions es-app/src/views/gamelist/GridGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,17 @@ void GridGameListView::updateInfoPanel()
bool fadingOut;
if(file == NULL)
{
LOG(LogDebug) << "GridGameListView::updateInfoPanel() : Clearing!";

mVideo->setVideo("");
mVideo->setImage("");
mVideoPlaying = false;

//mDescription.setText("");
fadingOut = true;
}else{
LOG(LogDebug) << "GridGameListView::updateInfoPanel() : Drawing!";

if (!mVideo->setVideo(file->getVideoPath()))
{
mVideo->setDefaultVideo();
Expand Down
16 changes: 14 additions & 2 deletions es-app/src/views/gamelist/VideoGameListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,26 @@ 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)
{
LOG(LogDebug) << "VideoGameListView::updateInfoPanel() : Clearing!";

mVideo->setVideo("");
mVideo->setImage("");
mVideoPlaying = false;
//mMarquee.setImage("");
//mDescription.setText("");
fadingOut = true;
}
else
{
LOG(LogDebug) << "VideoGameListView::updateInfoPanel() : Drawing!";

}else{
if (!mVideo->setVideo(file->getVideoPath()))
{
mVideo->setDefaultVideo();
Expand Down Expand Up @@ -290,6 +300,8 @@ void VideoGameListView::updateInfoPanel()
fadingOut = false;
}

mFile = file;

std::vector<GuiComponent*> comps = getMDValues();
comps.push_back(&mThumbnail);
comps.push_back(&mMarquee);
Expand Down
2 changes: 2 additions & 0 deletions es-app/src/views/gamelist/VideoGameListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class VideoGameListView : public BasicGameListView
void initMDLabels();
void initMDValues();

FileData* mFile;

ImageComponent mThumbnail;
ImageComponent mMarquee;
VideoComponent* mVideo;
Expand Down
14 changes: 5 additions & 9 deletions es-core/src/components/IList.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class IList : public GuiComponent
};

protected:
int mCursor;
int mCursor; //This is the current position in the list

int mScrollTier;
int mScrollVelocity;
int mScrollTier; //This lists the the scrolling "speed gear"
int mScrollVelocity; //This is the the steps/interval and direction (-/+)

int mScrollTierAccumulator;
int mScrollTierAccumulator; //This counts until it needs to switch to higher gear
int mScrollCursorAccumulator;

unsigned char mTitleOverlayOpacity;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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*/) {}
Expand Down

0 comments on commit 083547c

Please sign in to comment.