From 5bf84faaae42851fd84e7edf74f9770d34f02cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Sat, 1 Apr 2023 18:12:19 +0200 Subject: SlideShowPicture: Fix off-by-one error --- xbmc/pictures/SlideShowPicture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/pictures/SlideShowPicture.cpp b/xbmc/pictures/SlideShowPicture.cpp index fd0fd2cdd6..fa8ce492da 100644 --- a/xbmc/pictures/SlideShowPicture.cpp +++ b/xbmc/pictures/SlideShowPicture.cpp @@ -411,7 +411,7 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg */ m_iCounter++; } - if (m_iCounter > m_transitionEnd.start + m_transitionEnd.length) + if (m_iCounter >= m_transitionEnd.start + m_transitionEnd.length) m_bIsFinished = true; RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(); -- cgit v1.2.3 From 300ce52958ddf791c5635b3643c4a69ec328f847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Sat, 4 May 2024 16:17:29 +0200 Subject: SlideShowPicture: Remove m_bIsFinished member --- xbmc/pictures/SlideShowPicture.cpp | 13 +++++++------ xbmc/pictures/SlideShowPicture.h | 3 +-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xbmc/pictures/SlideShowPicture.cpp b/xbmc/pictures/SlideShowPicture.cpp index fa8ce492da..e02e3b4e07 100644 --- a/xbmc/pictures/SlideShowPicture.cpp +++ b/xbmc/pictures/SlideShowPicture.cpp @@ -38,7 +38,6 @@ static float zoomamount[10] = { 1.0f, 1.2f, 1.5f, 2.0f, 2.8f, 4.0f, 6.0f, 9.0f, CSlideShowPic::CSlideShowPic() : m_pImage(nullptr) { m_bIsLoaded = false; - m_bIsFinished = false; m_bDrawNextImage = false; m_bTransitionImmediately = false; @@ -56,7 +55,6 @@ void CSlideShowPic::Close() std::unique_lock lock(m_textureAccess); m_pImage.reset(); m_bIsLoaded = false; - m_bIsFinished = false; m_bDrawNextImage = false; m_bTransitionImmediately = false; m_bIsDirty = true; @@ -81,6 +79,11 @@ bool CSlideShowPic::DisplayEffectNeedChange(DISPLAY_EFFECT newDispEffect) const return true; } +bool CSlideShowPic::IsFinished() const +{ + return IsLoaded() && m_iCounter >= m_transitionEnd.start + m_transitionEnd.length; +} + void CSlideShowPic::SetTexture(int iSlideNumber, std::unique_ptr pTexture, DISPLAY_EFFECT dispEffect, @@ -207,7 +210,6 @@ void CSlideShowPic::SetTexture_Internal(int iSlideNumber, m_transitionEnd.start = m_transitionStart.length + iFrames; - m_bIsFinished = false; m_bDrawNextImage = false; m_bIsLoaded = true; } @@ -272,7 +274,8 @@ void CSlideShowPic::UpdateVertices(float cur_x[4], float cur_y[4], const float n void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) { - if (!m_pImage || !m_bIsLoaded || m_bIsFinished) return ; + if (!m_pImage || !m_bIsLoaded || IsFinished()) + return; UTILS::COLOR::Color alpha = m_alpha; if (m_iCounter <= m_transitionStart.length) { // do start transition @@ -411,8 +414,6 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg */ m_iCounter++; } - if (m_iCounter >= m_transitionEnd.start + m_transitionEnd.length) - m_bIsFinished = true; RESOLUTION_INFO info = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(); diff --git a/xbmc/pictures/SlideShowPicture.h b/xbmc/pictures/SlideShowPicture.h index 9e2a5d9323..a4454c9e80 100644 --- a/xbmc/pictures/SlideShowPicture.h +++ b/xbmc/pictures/SlideShowPicture.h @@ -50,7 +50,7 @@ public: DISPLAY_EFFECT DisplayEffect() const { return m_displayEffect; } bool DisplayEffectNeedChange(DISPLAY_EFFECT newDispEffect) const; bool IsStarted() const { return m_iCounter > 0; } - bool IsFinished() const { return m_bIsFinished; } + bool IsFinished() const; bool DrawNextImage() const { return m_bDrawNextImage; } int GetWidth() const { return (int)m_fWidth; } @@ -95,7 +95,6 @@ private: int m_iOriginalHeight; int m_iSlideNumber; bool m_bIsLoaded; - bool m_bIsFinished; bool m_bDrawNextImage; bool m_bIsDirty; std::string m_strFileName; -- cgit v1.2.3 From e135956bb6e51b98c3794a8b510a02afe5aeebe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Sat, 4 May 2024 16:42:39 +0200 Subject: SlideShowPicture: Add UpdateAlpha() member function --- xbmc/pictures/SlideShowPicture.cpp | 104 ++++++++++++++++++++++--------------- xbmc/pictures/SlideShowPicture.h | 1 + 2 files changed, 63 insertions(+), 42 deletions(-) diff --git a/xbmc/pictures/SlideShowPicture.cpp b/xbmc/pictures/SlideShowPicture.cpp index e02e3b4e07..57a73a5b72 100644 --- a/xbmc/pictures/SlideShowPicture.cpp +++ b/xbmc/pictures/SlideShowPicture.cpp @@ -16,6 +16,7 @@ #include "windowing/GraphicContext.h" #include "windowing/WinSystem.h" +#include #include #ifndef _USE_MATH_DEFINES @@ -276,24 +277,9 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg { if (!m_pImage || !m_bIsLoaded || IsFinished()) return; - UTILS::COLOR::Color alpha = m_alpha; - if (m_iCounter <= m_transitionStart.length) - { // do start transition - if (m_transitionStart.type == CROSSFADE) - { // fade in at 1x speed - alpha = (UTILS::COLOR::Color)((float)m_iCounter / (float)m_transitionStart.length * 255.0f); - } - else if (m_transitionStart.type == FADEIN_FADEOUT) - { // fade in at 2x speed, then keep solid - alpha = - (UTILS::COLOR::Color)((float)m_iCounter / (float)m_transitionStart.length * 255.0f * 2); - if (alpha > 255) alpha = 255; - } - else // m_transitionEffect == TRANSITION_NONE - { - alpha = 0xFF; // opaque - } - } + + UpdateAlpha(); + bool bPaused = m_bPause | (m_fZoomAmount != 1.0f); // check if we're doing a temporary effect (such as rotate + zoom) if (m_transitionTemp.type != TRANSITION_NONE) @@ -381,31 +367,7 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg m_transitionEnd.start++; } if (m_iCounter >= m_transitionEnd.start) - { // do end transition -// CLog::Log(LOGDEBUG,"Transitioning"); m_bDrawNextImage = true; - if (m_transitionEnd.type == CROSSFADE) - { // fade out at 1x speed - alpha = 255 - (UTILS::COLOR::Color)((float)(m_iCounter - m_transitionEnd.start) / - (float)m_transitionEnd.length * 255.0f); - } - else if (m_transitionEnd.type == FADEIN_FADEOUT) - { // keep solid, then fade out at 2x speed - alpha = (UTILS::COLOR::Color)( - (float)(m_transitionEnd.length - m_iCounter + m_transitionEnd.start) / - (float)m_transitionEnd.length * 255.0f * 2); - if (alpha > 255) alpha = 255; - } - else // m_transitionEffect == TRANSITION_NONE - { - alpha = 0xFF; // opaque - } - } - if (alpha != m_alpha) - { - m_alpha = alpha; - m_bIsDirty = true; - } if (m_displayEffect != EFFECT_NO_TIMEOUT || m_iCounter < m_transitionStart.length || m_iCounter >= m_transitionEnd.start || (m_iCounter >= m_transitionTemp.start && m_iCounter < m_transitionTemp.start + m_transitionTemp.length)) { /* this really annoying. there's non-stop logging when viewing a pic outside of the slideshow @@ -718,6 +680,64 @@ void CSlideShowPic::Zoom(float fZoom, bool immediate /* = false */) m_bNoEffect = true; } +void CSlideShowPic::UpdateAlpha() +{ + assert(m_iCounter >= 0); + + UTILS::COLOR::Color alpha = m_alpha; + + if (m_iCounter < m_transitionStart.length) + { // do start transition + switch (m_transitionStart.type) + { + case CROSSFADE: + // fade in at 1x speed + alpha = + static_cast(static_cast(m_iCounter + 1) / + static_cast(m_transitionStart.length) * 255.0f); + break; + case FADEIN_FADEOUT: + // fade in at 2x speed, then keep solid + alpha = std::min(static_cast( + static_cast(m_iCounter + 1) / + static_cast(m_transitionStart.length) * 255.0f * 2), + UTILS::COLOR::Color{255}); + break; + default: + alpha = 255; // opaque + } + } + + if (m_iCounter >= m_transitionEnd.start) + { // do end transition + switch (m_transitionEnd.type) + { + case CROSSFADE: + // fade in at 1x speed + alpha = 255 - static_cast( + static_cast(m_iCounter - m_transitionEnd.start + 1) / + static_cast(m_transitionEnd.length) * 255.0f); + break; + case FADEIN_FADEOUT: + // fade in at 2x speed, then keep solid + alpha = std::min(static_cast( + static_cast(m_transitionEnd.length - m_iCounter + + m_transitionEnd.start + 1) / + static_cast(m_transitionEnd.length) * 255.0f * 2), + UTILS::COLOR::Color{255}); + break; + default: + alpha = 255; // opaque + } + } + + if (alpha != m_alpha) + { + m_alpha = alpha; + m_bIsDirty = true; + } +} + void CSlideShowPic::Move(float fDeltaX, float fDeltaY) { m_fZoomLeft += fDeltaX; diff --git a/xbmc/pictures/SlideShowPicture.h b/xbmc/pictures/SlideShowPicture.h index a4454c9e80..7e764f0a19 100644 --- a/xbmc/pictures/SlideShowPicture.h +++ b/xbmc/pictures/SlideShowPicture.h @@ -65,6 +65,7 @@ public: void Zoom(float fZoomAmount, bool immediate = false); void Rotate(float fRotateAngle, bool immediate = false); + void UpdateAlpha(); void Pause(bool bPause); void SetInSlideshow(bool slideshow); void SetOriginalSize(int iOriginalWidth, int iOriginalHeight, bool bFullSize); -- cgit v1.2.3 From 8d002f35d6ed76dd332ca55ff6b52c695aa61d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Sat, 4 May 2024 17:39:27 +0200 Subject: SlideShowPicture: Add IsAnimating() member function --- xbmc/pictures/SlideShowPicture.cpp | 12 +++++++++++- xbmc/pictures/SlideShowPicture.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/xbmc/pictures/SlideShowPicture.cpp b/xbmc/pictures/SlideShowPicture.cpp index 57a73a5b72..b66c27520e 100644 --- a/xbmc/pictures/SlideShowPicture.cpp +++ b/xbmc/pictures/SlideShowPicture.cpp @@ -85,6 +85,16 @@ bool CSlideShowPic::IsFinished() const return IsLoaded() && m_iCounter >= m_transitionEnd.start + m_transitionEnd.length; } +bool CSlideShowPic::IsAnimating() const +{ + return !IsFinished() && + (m_displayEffect != EFFECT_NO_TIMEOUT || // Special snowflake, doesn't work without this + m_iCounter < m_transitionStart.length || // Inside start transition + m_iCounter >= m_transitionEnd.start || // Inside end transition + (m_iCounter >= m_transitionTemp.start && + m_iCounter < m_transitionTemp.start + m_transitionTemp.length)); // Inside display effect +} + void CSlideShowPic::SetTexture(int iSlideNumber, std::unique_ptr pTexture, DISPLAY_EFFECT dispEffect, @@ -368,7 +378,7 @@ void CSlideShowPic::Process(unsigned int currentTime, CDirtyRegionList &dirtyreg } if (m_iCounter >= m_transitionEnd.start) m_bDrawNextImage = true; - if (m_displayEffect != EFFECT_NO_TIMEOUT || m_iCounter < m_transitionStart.length || m_iCounter >= m_transitionEnd.start || (m_iCounter >= m_transitionTemp.start && m_iCounter < m_transitionTemp.start + m_transitionTemp.length)) + if (IsAnimating()) { /* this really annoying. there's non-stop logging when viewing a pic outside of the slideshow if (m_displayEffect == EFFECT_NO_TIMEOUT) diff --git a/xbmc/pictures/SlideShowPicture.h b/xbmc/pictures/SlideShowPicture.h index 7e764f0a19..6b480fb166 100644 --- a/xbmc/pictures/SlideShowPicture.h +++ b/xbmc/pictures/SlideShowPicture.h @@ -51,6 +51,7 @@ public: bool DisplayEffectNeedChange(DISPLAY_EFFECT newDispEffect) const; bool IsStarted() const { return m_iCounter > 0; } bool IsFinished() const; + bool IsAnimating() const; bool DrawNextImage() const { return m_bDrawNextImage; } int GetWidth() const { return (int)m_fWidth; } -- cgit v1.2.3 From d8c2cc727a4e9830d1346af740f3a36cc58ba247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20H=C3=A4rer?= Date: Sat, 1 Apr 2023 21:56:00 +0200 Subject: GUIWindowSlideShow: Add missing MarkDirtyRegion() to fix smartredraw --- xbmc/pictures/GUIWindowSlideShow.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xbmc/pictures/GUIWindowSlideShow.cpp b/xbmc/pictures/GUIWindowSlideShow.cpp index 4a47726dc8..b1fe3d56c5 100644 --- a/xbmc/pictures/GUIWindowSlideShow.cpp +++ b/xbmc/pictures/GUIWindowSlideShow.cpp @@ -408,9 +408,12 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re // if we haven't processed yet, we should mark the whole screen if (!HasProcessed()) + { regions.emplace_back(CRect( 0.0f, 0.0f, static_cast(CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth()), static_cast(CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight()))); + MarkDirtyRegion(); + } if (m_iCurrentSlide < 0 || m_iCurrentSlide >= static_cast(m_slides.size())) m_iCurrentSlide = 0; @@ -496,6 +499,7 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re regions.emplace_back(CRect( 0.0f, 0.0f, static_cast(CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth()), static_cast(CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight()))); + MarkDirtyRegion(); return; } @@ -558,6 +562,9 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re // render the current image if (m_Image[m_iCurrentPic]->IsLoaded()) { + if (m_Image[m_iCurrentPic]->IsAnimating()) + MarkDirtyRegion(); + m_Image[m_iCurrentPic]->SetInSlideshow(bSlideShow); m_Image[m_iCurrentPic]->Pause(!bSlideShow); m_Image[m_iCurrentPic]->Process(currentTime, regions); @@ -572,6 +579,7 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re { m_Image[m_iCurrentPic]->SetTransitionTime(1, IMMEDIATE_TRANSITION_TIME); m_bLoadNextPic = false; + MarkDirtyRegion(); } } @@ -598,6 +606,10 @@ void CGUIWindowSlideShow::Process(unsigned int currentTime, CDirtyRegionList &re if (m_Image[1 - m_iCurrentPic]->DisplayEffectNeedChange(effect)) m_Image[1 - m_iCurrentPic]->Reset(effect); } + + if (m_Image[1 - m_iCurrentPic]->IsAnimating()) + MarkDirtyRegion(); + // set the appropriate transition time m_Image[1 - m_iCurrentPic]->SetTransitionTime(0, m_Image[m_iCurrentPic]->GetTransitionTime(1)); @@ -980,6 +992,7 @@ bool CGUIWindowSlideShow::OnAction(const CAction &action) default: return CGUIDialog::OnAction(action); } + MarkDirtyRegion(); return true; } -- cgit v1.2.3