From 5f8335c1e49ce108ef3481863833c98efa00411b Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 2 Jul 2020 23:09:26 +0200 Subject: sync with upstream --- .../include/kodi/gui/controls/Rendering.h | 323 +++++++++++---------- 1 file changed, 162 insertions(+), 161 deletions(-) (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h') diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h index b3dadcd..7cc9b24 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h @@ -10,6 +10,7 @@ #include "../../AddonBase.h" #include "../Window.h" +#include "../renderHelper.h" namespace kodi { @@ -18,186 +19,186 @@ namespace gui namespace controls { - //============================================================================ +//============================================================================ +/// +/// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering +/// \ingroup cpp_kodi_gui +/// @brief \cpp_class{ kodi::gui::controls::CRendering } +/// **Window control for rendering own parts** +/// +/// This rendering control is used when own parts are needed. You have the +/// control over them to render direct OpenGL or DirectX content to the +/// screen set by the size of them. +/// +/// Alternative can be the virtual functions from t his been ignored if the +/// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and +/// class is used as single and not as a parent class. +/// +/// It has the header \ref Rendering.h "#include " +/// be included to enjoy it. +/// +/// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" +/// +/// @note The call of the control is only possible from the corresponding +/// window as its class and identification number is required. +/// + +//============================================================================ +/// +/// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators +/// \ingroup cpp_kodi_gui_controls_CRendering +/// @brief **Library definition values** +/// + +class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase +{ +public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Construct a new control + /// + /// @param[in] window related window control class + /// @param[in] controlId Used skin xml control id + /// + CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) + { + m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( + m_interface->kodiBase, m_Window->GetControlHandle(), controlId); + if (m_controlHandle) + m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, + m_controlHandle, this, OnCreateCB, + OnRenderCB, OnStopCB, OnDirtyCB); + else + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", + __FUNCTION__); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Destructor + /// + ~CRendering() override + { + m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== /// - /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering - /// \ingroup cpp_kodi_gui - /// @brief \cpp_class{ kodi::gui::controls::CRendering } - /// **Window control for rendering own parts** + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief To create rendering control on Add-on /// - /// This rendering control is used when own parts are needed. You have the - /// control over them to render direct OpenGL or DirectX content to the - /// screen set by the size of them. + /// Function creates the needed rendering control for Kodi which becomes + /// handled and processed from Add-on /// - /// Alternative can be the virtual functions from t his been ignored if the - /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and - /// class is used as single and not as a parent class. + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. /// - /// It has the header \ref Rendering.h "#include " - /// be included to enjoy it. + /// @param[in] x Horizontal position + /// @param[in] y Vertical position + /// @param[in] w Width of control + /// @param[in] h Height of control + /// @param[in] device The device to use. For OpenGL is empty + /// on Direct X is the needed device send. + /// @return Add-on needs to return true if successed, + /// otherwise false. /// - /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" + virtual bool Create(int x, int y, int w, int h, void* device) { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Render process call from Kodi /// - /// @note The call of the control is only possible from the corresponding - /// window as its class and identification number is required. + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. /// + virtual void Render() {} + //-------------------------------------------------------------------------- - //============================================================================ + //========================================================================== /// - /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief **Library definition values** + /// @brief Call from Kodi to stop rendering process /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + virtual void Stop() {} + //-------------------------------------------------------------------------- - class CRendering : public CAddonGUIControlBase + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// @brief Call from Kodi where add-on becomes asked about dirty rendering + /// region. + /// + /// @note This is callback function from Kodi to Add-on and not to use + /// for calls from add-on to this function. + /// + virtual bool Dirty() { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_controls_CRendering + /// \anchor CRendering_SetIndependentCallbacks + /// @brief If the class is used independent (with "new CRendering") + /// and not as parent (with "cCLASS_own : CRendering") from own must + /// be the callback from Kodi to add-on overdriven with own functions! + /// + void SetIndependentCallbacks( + GUIHANDLE cbhdl, + bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device), + void (*CBRender)(GUIHANDLE cbhdl), + void (*CBStop)(GUIHANDLE cbhdl), + bool (*CBDirty)(GUIHANDLE cbhdl)) { - public: - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief Construct a new control - /// - /// @param[in] window related window control class - /// @param[in] controlId Used skin xml control id - /// - CRendering(CWindow* window, int controlId) - : CAddonGUIControlBase(window) - { - m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); - if (m_controlHandle) - m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, this, - OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); - else - kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", __FUNCTION__); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief Destructor - /// - ~CRendering() override - { - m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); - } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief To create rendering control on Add-on - /// - /// Function creates the needed rendering control for Kodi which becomes - /// handled and processed from Add-on - /// - /// @note This is callback function from Kodi to Add-on and not to use - /// for calls from add-on to this function. - /// - /// @param[in] x Horizontal position - /// @param[in] y Vertical position - /// @param[in] w Width of control - /// @param[in] h Height of control - /// @param[in] device The device to use. For OpenGL is empty - /// on Direct X is the needed device send. - /// @return Add-on needs to return true if successed, - /// otherwise false. - /// - virtual bool Create(int x, int y, int w, int h, void* device) { return false; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief Render process call from Kodi - /// - /// @note This is callback function from Kodi to Add-on and not to use - /// for calls from add-on to this function. - /// - virtual void Render() { } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief Call from Kodi to stop rendering process - /// - /// @note This is callback function from Kodi to Add-on and not to use - /// for calls from add-on to this function. - /// - virtual void Stop() { } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// @brief Call from Kodi where add-on becomes asked about dirty rendering - /// region. - /// - /// @note This is callback function from Kodi to Add-on and not to use - /// for calls from add-on to this function. - /// - virtual bool Dirty() { return false; } - //-------------------------------------------------------------------------- - - //========================================================================== - /// - /// \ingroup cpp_kodi_gui_controls_CRendering - /// \anchor CRendering_SetIndependentCallbacks - /// @brief If the class is used independent (with "new CRendering") - /// and not as parent (with "cCLASS_own : CRendering") from own must - /// be the callback from Kodi to add-on overdriven with own functions! - /// - void SetIndependentCallbacks( - GUIHANDLE cbhdl, - bool (*CBCreate)(GUIHANDLE cbhdl, - int x, - int y, - int w, - int h, - void* device), - void (*CBRender)(GUIHANDLE cbhdl), - void (*CBStop) (GUIHANDLE cbhdl), - bool (*CBDirty) (GUIHANDLE cbhdl)) - { - if (!cbhdl || - !CBCreate || !CBRender || !CBStop || !CBDirty) - { - kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); - return; - } - - m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, - CBCreate, CBRender, CBStop, CBDirty); - } - //-------------------------------------------------------------------------- - - private: - /* - * Defined callback functions from Kodi to add-on, for use in parent / child system - * (is private)! - */ - static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) + if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) { - return static_cast(cbhdl)->Create(x, y, w, h, device); + kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); + return; } - static void OnRenderCB(void* cbhdl) - { - static_cast(cbhdl)->Render(); - } + m_interface->kodi_gui->control_rendering->set_callbacks( + m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); + } + //-------------------------------------------------------------------------- + +private: + /* + * Defined callback functions from Kodi to add-on, for use in parent / child system + * (is private)! + */ + static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) + { + static_cast(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); + return static_cast(cbhdl)->Create(x, y, w, h, device); + } - static void OnStopCB(void* cbhdl) - { - static_cast(cbhdl)->Stop(); - } + static void OnRenderCB(void* cbhdl) + { + if (!static_cast(cbhdl)->m_renderHelper) + return; + static_cast(cbhdl)->m_renderHelper->Begin(); + static_cast(cbhdl)->Render(); + static_cast(cbhdl)->m_renderHelper->End(); + } + + static void OnStopCB(void* cbhdl) + { + static_cast(cbhdl)->Stop(); + static_cast(cbhdl)->m_renderHelper = nullptr; + } - static bool OnDirtyCB(void* cbhdl) - { - return static_cast(cbhdl)->Dirty(); - } + static bool OnDirtyCB(void* cbhdl) { return static_cast(cbhdl)->Dirty(); } - }; + std::shared_ptr m_renderHelper; +}; } /* namespace controls */ } /* namespace gui */ -- cgit v1.2.3