Added support for fade-in and fade-out of static videos.

This commit is contained in:
Leon Styhre 2022-09-16 23:54:13 +02:00
parent 6fd47a5599
commit 720a6fcc22
4 changed files with 8 additions and 1 deletions

View file

@ -194,6 +194,7 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
ALL);
if (mStaticVideoComponents.back()->getMetadataElement())
mStaticVideoComponents.back()->setScrollHide(true);
mStaticVideoComponents.back()->setGeneralFade(true);
}
else {
mVideoComponents.push_back(std::make_unique<VideoFFmpegComponent>());

View file

@ -37,6 +37,7 @@ VideoComponent::VideoComponent()
, mRenderScanlines {false}
, mLegacyTheme {false}
, mHasVideo {false}
, mGeneralFade {false}
, mFadeIn {1.0f}
, mFadeInTime {1000.0f}
{

View file

@ -49,6 +49,8 @@ public:
void setOpacity(float opacity) override { mOpacity = opacity; }
// Set whether to draw black pillarboxes/letterboxes behind videos.
void setDrawPillarboxes(bool state) { mDrawPillarboxes = state; }
// Whether to fade out the entire video surface including the black rectangle.
void setGeneralFade(bool state) { mGeneralFade = state; }
bool hasStaticVideo() { return !mConfig.staticVideoPath.empty(); }
bool hasStaticImage() { return mStaticImage.getTextureSize() != glm::ivec2 {0, 0}; }
@ -129,6 +131,7 @@ protected:
bool mRenderScanlines;
bool mLegacyTheme;
bool mHasVideo;
bool mGeneralFade;
float mFadeIn;
float mFadeInTime;

View file

@ -140,7 +140,9 @@ void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
unsigned int rectColor {0x000000FF};
if (mThemeOpacity != 1.0f)
if (!mGeneralFade && mThemeOpacity != 1.0f)
rectColor = static_cast<int>(mThemeOpacity * 255.0f);
if (mGeneralFade && (mOpacity != 1.0f || mThemeOpacity != 1.0f))
rectColor = static_cast<int>(mFadeIn * mOpacity * mThemeOpacity * 255.0f);
// Render the black rectangle behind the video.