diff --git a/xbmc/cores/RetroPlayer/rendering/RPRenderManager.cpp b/xbmc/cores/RetroPlayer/rendering/RPRenderManager.cpp index 8340bad2506b7..c5a2a4ae504fa 100644 --- a/xbmc/cores/RetroPlayer/rendering/RPRenderManager.cpp +++ b/xbmc/cores/RetroPlayer/rendering/RPRenderManager.cpp @@ -100,7 +100,9 @@ void CRPRenderManager::Render(bool clear, DWORD alpha) CSingleExit exitLock(g_graphicsContext); - m_renderer->RenderUpdate(clear, alpha); + m_renderer->PreRender(clear, alpha); + m_renderer->RenderUpdate(); + m_renderer->PostRender(); } void CRPRenderManager::Flush() diff --git a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp index b7ba90f5af4e8..9bccc183e3049 100644 --- a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp +++ b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp @@ -19,6 +19,7 @@ */ #include "RPBaseRenderer.h" +#include "ServiceBroker.h" #include "cores/RetroPlayer/rendering/VideoShaders/IVideoShaderPreset.h" #include "guilib/GraphicContext.h" #include "guilib/GUIWindowManager.h" @@ -26,7 +27,7 @@ #include "settings/MediaSettings.h" #include "settings/Settings.h" #include "utils/MathUtils.h" -#include "ServiceBroker.h" +#include "windowing/WindowingFactory.h" #include #include @@ -542,3 +543,39 @@ void CRPBaseRenderer::UpdateVideoShaders() } } } + +void CRPBaseRenderer::PreRender(bool clear, unsigned int alpha) +{ + if (m_bUseShaderPreset) + { + // select destination rectangle + if (m_renderOrientation) + { + for (size_t i = 0; i < 4; i++) + m_destPoints[i] = m_rotatedDestCoords[i]; + } + else + { + CRect destRect = g_graphicsContext.StereoCorrection(m_destRect); + m_destPoints[0] = { destRect.x1, destRect.y1 }; + m_destPoints[1] = { destRect.x2, destRect.y1 }; + m_destPoints[2] = { destRect.x2, destRect.y2 }; + m_destPoints[3] = { destRect.x1, destRect.y2 }; + } + } + // Clear screen + if (clear) + g_graphicsContext.Clear(g_Windowing.UseLimitedColor() ? 0x101010 : 0); + + // Set alpha blend state + g_Windowing.SetAlphaBlendEnable(alpha < 255); + + ManageRenderArea(); + + UpdateVideoShaders(); +} + +void CRPBaseRenderer::PostRender() +{ + g_Windowing.ApplyStateBlock(); +} diff --git a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.h b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.h index 278179d001985..7b70271ef54ae 100644 --- a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.h +++ b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.h @@ -45,7 +45,7 @@ namespace RETRO virtual bool Configure(AVPixelFormat format, unsigned int width, unsigned int height, unsigned int orientation) = 0; virtual void AddFrame(const uint8_t* data, unsigned int size) = 0; virtual void Flush() = 0; - virtual void RenderUpdate(bool clear, unsigned int alpha) = 0; + virtual void RenderUpdate() = 0; virtual void Deinitialize() = 0; virtual void SetSpeed(double speed) = 0; @@ -83,6 +83,16 @@ namespace RETRO bool IsNonLinearStretch() const { return m_bNonLinearStretch; } + /*! + * \brief Performs whatever nessesary before rendering the frame. Must be called before RenderUpdate() + */ + void PreRender(bool clear, unsigned int alpha); + + /*! + * \brief Performs whatever nessesary after a frame has been rendered. Must be called after RenderUpdate() + */ + void PostRender(); + protected: /*! * \brief Call this from the base class to initialize render settings @@ -102,6 +112,8 @@ namespace RETRO unsigned int m_sourceWidth = 0; unsigned int m_sourceHeight = 0; unsigned int m_renderOrientation = 0; // Degrees counter-clockwise + // select destination rectangle + CPoint m_destPoints[4]; /*! * \brief Orientation of the previous frame diff --git a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.cpp b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.cpp index d28f2598e14b0..769f8011544f0 100644 --- a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.cpp +++ b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.cpp @@ -120,20 +120,11 @@ void CRPWinRenderer::Flush() m_bQueued = false; } -void CRPWinRenderer::RenderUpdate(bool clear, unsigned int alpha) +void CRPWinRenderer::RenderUpdate() { - if (clear) - g_graphicsContext.Clear(g_Windowing.UseLimitedColor() ? 0x101010 : 0); - if (!m_bConfigured) return; - g_Windowing.SetAlphaBlendEnable(alpha < 255); - - ManageRenderArea(); - - UpdateVideoShaders(); - if (m_bQueued) { if (UploadTexture()) @@ -223,25 +214,9 @@ void CRPWinRenderer::Render(CD3DTexture *target) // Are we using video shaders? if (m_bUseShaderPreset) { - // select destination rectangle - CPoint destPoints[4]; - if (m_renderOrientation) - { - for (size_t i = 0; i < 4; i++) - destPoints[i] = m_rotatedDestCoords[i]; - } - else - { - CRect destRect = g_graphicsContext.StereoCorrection(m_destRect); - destPoints[0] = { destRect.x1, destRect.y1 }; - destPoints[1] = { destRect.x2, destRect.y1 }; - destPoints[2] = { destRect.x2, destRect.y2 }; - destPoints[3] = { destRect.x1, destRect.y2 }; - } - // Render shaders and ouput to display m_targetTexture.SetTexture(target); - if (!m_shaderPreset->RenderUpdate(destPoints, m_intermediateTarget.get(), &m_targetTexture)) + if (!m_shaderPreset->RenderUpdate(m_destPoints, m_intermediateTarget.get(), &m_targetTexture)) { m_shadersNeedUpdate = false; m_bUseShaderPreset = false; @@ -257,5 +232,4 @@ void CRPWinRenderer::Render(CD3DTexture *target) g_Windowing.UseLimitedColor() ? 1 : 0, 0.5f, 0.5f); } } - g_Windowing.ApplyStateBlock(); } diff --git a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.h b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.h index 21779dfd55b86..e9c4e48cc4409 100644 --- a/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.h +++ b/xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPWinRenderer.h @@ -51,7 +51,7 @@ namespace RETRO bool Configure(AVPixelFormat format, unsigned int width, unsigned int height, unsigned int orientation) override; void AddFrame(const uint8_t* data, unsigned int size) override; void Flush() override; - void RenderUpdate(bool clear, unsigned int alpha) override; + void RenderUpdate() override; void Deinitialize() override; bool Supports(ERENDERFEATURE feature) const override; bool Supports(ESCALINGMETHOD method) const override;