From 720a6fcc22571dfa2e09f644f5095d8387e0c9b8 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 16 Sep 2022 23:54:13 +0200 Subject: [PATCH] Added support for fade-in and fade-out of static videos. --- es-app/src/views/GamelistView.cpp | 1 + es-core/src/components/VideoComponent.cpp | 1 + es-core/src/components/VideoComponent.h | 3 +++ es-core/src/components/VideoFFmpegComponent.cpp | 4 +++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 13c14e995..74f550d4f 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -194,6 +194,7 @@ void GamelistView::onThemeChanged(const std::shared_ptr& theme) ALL); if (mStaticVideoComponents.back()->getMetadataElement()) mStaticVideoComponents.back()->setScrollHide(true); + mStaticVideoComponents.back()->setGeneralFade(true); } else { mVideoComponents.push_back(std::make_unique()); diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 6839aee81..6965e03b0 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -37,6 +37,7 @@ VideoComponent::VideoComponent() , mRenderScanlines {false} , mLegacyTheme {false} , mHasVideo {false} + , mGeneralFade {false} , mFadeIn {1.0f} , mFadeInTime {1000.0f} { diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index b1e59da1e..3d3ce6bc0 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -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; diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index aa46e91a0..bbd199de4 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -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(mThemeOpacity * 255.0f); + if (mGeneralFade && (mOpacity != 1.0f || mThemeOpacity != 1.0f)) rectColor = static_cast(mFadeIn * mOpacity * mThemeOpacity * 255.0f); // Render the black rectangle behind the video.