diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h | 323 |
1 files changed, 162 insertions, 161 deletions
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 @@ | |||
| 10 | 10 | ||
| 11 | #include "../../AddonBase.h" | 11 | #include "../../AddonBase.h" |
| 12 | #include "../Window.h" | 12 | #include "../Window.h" |
| 13 | #include "../renderHelper.h" | ||
| 13 | 14 | ||
| 14 | namespace kodi | 15 | namespace kodi |
| 15 | { | 16 | { |
| @@ -18,186 +19,186 @@ namespace gui | |||
| 18 | namespace controls | 19 | namespace controls |
| 19 | { | 20 | { |
| 20 | 21 | ||
| 21 | //============================================================================ | 22 | //============================================================================ |
| 23 | /// | ||
| 24 | /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering | ||
| 25 | /// \ingroup cpp_kodi_gui | ||
| 26 | /// @brief \cpp_class{ kodi::gui::controls::CRendering } | ||
| 27 | /// **Window control for rendering own parts** | ||
| 28 | /// | ||
| 29 | /// This rendering control is used when own parts are needed. You have the | ||
| 30 | /// control over them to render direct OpenGL or DirectX content to the | ||
| 31 | /// screen set by the size of them. | ||
| 32 | /// | ||
| 33 | /// Alternative can be the virtual functions from t his been ignored if the | ||
| 34 | /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and | ||
| 35 | /// class is used as single and not as a parent class. | ||
| 36 | /// | ||
| 37 | /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | ||
| 38 | /// be included to enjoy it. | ||
| 39 | /// | ||
| 40 | /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" | ||
| 41 | /// | ||
| 42 | /// @note The call of the control is only possible from the corresponding | ||
| 43 | /// window as its class and identification number is required. | ||
| 44 | /// | ||
| 45 | |||
| 46 | //============================================================================ | ||
| 47 | /// | ||
| 48 | /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators | ||
| 49 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 50 | /// @brief **Library definition values** | ||
| 51 | /// | ||
| 52 | |||
| 53 | class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase | ||
| 54 | { | ||
| 55 | public: | ||
| 56 | //========================================================================== | ||
| 57 | /// | ||
| 58 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 59 | /// @brief Construct a new control | ||
| 60 | /// | ||
| 61 | /// @param[in] window related window control class | ||
| 62 | /// @param[in] controlId Used skin xml control id | ||
| 63 | /// | ||
| 64 | CRendering(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 65 | { | ||
| 66 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon( | ||
| 67 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 68 | if (m_controlHandle) | ||
| 69 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, | ||
| 70 | m_controlHandle, this, OnCreateCB, | ||
| 71 | OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 72 | else | ||
| 73 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", | ||
| 74 | __FUNCTION__); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 81 | /// @brief Destructor | ||
| 82 | /// | ||
| 83 | ~CRendering() override | ||
| 84 | { | ||
| 85 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 86 | } | ||
| 87 | //-------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | //========================================================================== | ||
| 22 | /// | 90 | /// |
| 23 | /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering | 91 | /// \ingroup cpp_kodi_gui_controls_CRendering |
| 24 | /// \ingroup cpp_kodi_gui | 92 | /// @brief To create rendering control on Add-on |
| 25 | /// @brief \cpp_class{ kodi::gui::controls::CRendering } | ||
| 26 | /// **Window control for rendering own parts** | ||
| 27 | /// | 93 | /// |
| 28 | /// This rendering control is used when own parts are needed. You have the | 94 | /// Function creates the needed rendering control for Kodi which becomes |
| 29 | /// control over them to render direct OpenGL or DirectX content to the | 95 | /// handled and processed from Add-on |
| 30 | /// screen set by the size of them. | ||
| 31 | /// | 96 | /// |
| 32 | /// Alternative can be the virtual functions from t his been ignored if the | 97 | /// @note This is callback function from Kodi to Add-on and not to use |
| 33 | /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and | 98 | /// for calls from add-on to this function. |
| 34 | /// class is used as single and not as a parent class. | ||
| 35 | /// | 99 | /// |
| 36 | /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>" | 100 | /// @param[in] x Horizontal position |
| 37 | /// be included to enjoy it. | 101 | /// @param[in] y Vertical position |
| 102 | /// @param[in] w Width of control | ||
| 103 | /// @param[in] h Height of control | ||
| 104 | /// @param[in] device The device to use. For OpenGL is empty | ||
| 105 | /// on Direct X is the needed device send. | ||
| 106 | /// @return Add-on needs to return true if successed, | ||
| 107 | /// otherwise false. | ||
| 38 | /// | 108 | /// |
| 39 | /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control" | 109 | virtual bool Create(int x, int y, int w, int h, void* device) { return false; } |
| 110 | //-------------------------------------------------------------------------- | ||
| 111 | |||
| 112 | //========================================================================== | ||
| 113 | /// | ||
| 114 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 115 | /// @brief Render process call from Kodi | ||
| 40 | /// | 116 | /// |
| 41 | /// @note The call of the control is only possible from the corresponding | 117 | /// @note This is callback function from Kodi to Add-on and not to use |
| 42 | /// window as its class and identification number is required. | 118 | /// for calls from add-on to this function. |
| 43 | /// | 119 | /// |
| 120 | virtual void Render() {} | ||
| 121 | //-------------------------------------------------------------------------- | ||
| 44 | 122 | ||
| 45 | //============================================================================ | 123 | //========================================================================== |
| 46 | /// | 124 | /// |
| 47 | /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators | ||
| 48 | /// \ingroup cpp_kodi_gui_controls_CRendering | 125 | /// \ingroup cpp_kodi_gui_controls_CRendering |
| 49 | /// @brief **Library definition values** | 126 | /// @brief Call from Kodi to stop rendering process |
| 50 | /// | 127 | /// |
| 128 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 129 | /// for calls from add-on to this function. | ||
| 130 | /// | ||
| 131 | virtual void Stop() {} | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 51 | 133 | ||
| 52 | class CRendering : public CAddonGUIControlBase | 134 | //========================================================================== |
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 137 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 138 | /// region. | ||
| 139 | /// | ||
| 140 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 141 | /// for calls from add-on to this function. | ||
| 142 | /// | ||
| 143 | virtual bool Dirty() { return false; } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 149 | /// \anchor CRendering_SetIndependentCallbacks | ||
| 150 | /// @brief If the class is used independent (with "new CRendering") | ||
| 151 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 152 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 153 | /// | ||
| 154 | void SetIndependentCallbacks( | ||
| 155 | GUIHANDLE cbhdl, | ||
| 156 | bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void* device), | ||
| 157 | void (*CBRender)(GUIHANDLE cbhdl), | ||
| 158 | void (*CBStop)(GUIHANDLE cbhdl), | ||
| 159 | bool (*CBDirty)(GUIHANDLE cbhdl)) | ||
| 53 | { | 160 | { |
| 54 | public: | 161 | if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty) |
| 55 | //========================================================================== | ||
| 56 | /// | ||
| 57 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 58 | /// @brief Construct a new control | ||
| 59 | /// | ||
| 60 | /// @param[in] window related window control class | ||
| 61 | /// @param[in] controlId Used skin xml control id | ||
| 62 | /// | ||
| 63 | CRendering(CWindow* window, int controlId) | ||
| 64 | : CAddonGUIControlBase(window) | ||
| 65 | { | ||
| 66 | m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 67 | if (m_controlHandle) | ||
| 68 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 69 | OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB); | ||
| 70 | else | ||
| 71 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", __FUNCTION__); | ||
| 72 | } | ||
| 73 | //-------------------------------------------------------------------------- | ||
| 74 | |||
| 75 | //========================================================================== | ||
| 76 | /// | ||
| 77 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 78 | /// @brief Destructor | ||
| 79 | /// | ||
| 80 | ~CRendering() override | ||
| 81 | { | ||
| 82 | m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 83 | } | ||
| 84 | //-------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 89 | /// @brief To create rendering control on Add-on | ||
| 90 | /// | ||
| 91 | /// Function creates the needed rendering control for Kodi which becomes | ||
| 92 | /// handled and processed from Add-on | ||
| 93 | /// | ||
| 94 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 95 | /// for calls from add-on to this function. | ||
| 96 | /// | ||
| 97 | /// @param[in] x Horizontal position | ||
| 98 | /// @param[in] y Vertical position | ||
| 99 | /// @param[in] w Width of control | ||
| 100 | /// @param[in] h Height of control | ||
| 101 | /// @param[in] device The device to use. For OpenGL is empty | ||
| 102 | /// on Direct X is the needed device send. | ||
| 103 | /// @return Add-on needs to return true if successed, | ||
| 104 | /// otherwise false. | ||
| 105 | /// | ||
| 106 | virtual bool Create(int x, int y, int w, int h, void* device) { return false; } | ||
| 107 | //-------------------------------------------------------------------------- | ||
| 108 | |||
| 109 | //========================================================================== | ||
| 110 | /// | ||
| 111 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 112 | /// @brief Render process call from Kodi | ||
| 113 | /// | ||
| 114 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 115 | /// for calls from add-on to this function. | ||
| 116 | /// | ||
| 117 | virtual void Render() { } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 123 | /// @brief Call from Kodi to stop rendering process | ||
| 124 | /// | ||
| 125 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 126 | /// for calls from add-on to this function. | ||
| 127 | /// | ||
| 128 | virtual void Stop() { } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 134 | /// @brief Call from Kodi where add-on becomes asked about dirty rendering | ||
| 135 | /// region. | ||
| 136 | /// | ||
| 137 | /// @note This is callback function from Kodi to Add-on and not to use | ||
| 138 | /// for calls from add-on to this function. | ||
| 139 | /// | ||
| 140 | virtual bool Dirty() { return false; } | ||
| 141 | //-------------------------------------------------------------------------- | ||
| 142 | |||
| 143 | //========================================================================== | ||
| 144 | /// | ||
| 145 | /// \ingroup cpp_kodi_gui_controls_CRendering | ||
| 146 | /// \anchor CRendering_SetIndependentCallbacks | ||
| 147 | /// @brief If the class is used independent (with "new CRendering") | ||
| 148 | /// and not as parent (with "cCLASS_own : CRendering") from own must | ||
| 149 | /// be the callback from Kodi to add-on overdriven with own functions! | ||
| 150 | /// | ||
| 151 | void SetIndependentCallbacks( | ||
| 152 | GUIHANDLE cbhdl, | ||
| 153 | bool (*CBCreate)(GUIHANDLE cbhdl, | ||
| 154 | int x, | ||
| 155 | int y, | ||
| 156 | int w, | ||
| 157 | int h, | ||
| 158 | void* device), | ||
| 159 | void (*CBRender)(GUIHANDLE cbhdl), | ||
| 160 | void (*CBStop) (GUIHANDLE cbhdl), | ||
| 161 | bool (*CBDirty) (GUIHANDLE cbhdl)) | ||
| 162 | { | ||
| 163 | if (!cbhdl || | ||
| 164 | !CBCreate || !CBRender || !CBStop || !CBDirty) | ||
| 165 | { | ||
| 166 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); | ||
| 167 | return; | ||
| 168 | } | ||
| 169 | |||
| 170 | m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 171 | CBCreate, CBRender, CBStop, CBDirty); | ||
| 172 | } | ||
| 173 | //-------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | private: | ||
| 176 | /* | ||
| 177 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 178 | * (is private)! | ||
| 179 | */ | ||
| 180 | static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) | ||
| 181 | { | 162 | { |
| 182 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | 163 | kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__); |
| 164 | return; | ||
| 183 | } | 165 | } |
| 184 | 166 | ||
| 185 | static void OnRenderCB(void* cbhdl) | 167 | m_interface->kodi_gui->control_rendering->set_callbacks( |
| 186 | { | 168 | m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty); |
| 187 | static_cast<CRendering*>(cbhdl)->Render(); | 169 | } |
| 188 | } | 170 | //-------------------------------------------------------------------------- |
| 171 | |||
| 172 | private: | ||
| 173 | /* | ||
| 174 | * Defined callback functions from Kodi to add-on, for use in parent / child system | ||
| 175 | * (is private)! | ||
| 176 | */ | ||
| 177 | static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device) | ||
| 178 | { | ||
| 179 | static_cast<CRendering*>(cbhdl)->m_renderHelper = kodi::gui::GetRenderHelper(); | ||
| 180 | return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device); | ||
| 181 | } | ||
| 189 | 182 | ||
| 190 | static void OnStopCB(void* cbhdl) | 183 | static void OnRenderCB(void* cbhdl) |
| 191 | { | 184 | { |
| 192 | static_cast<CRendering*>(cbhdl)->Stop(); | 185 | if (!static_cast<CRendering*>(cbhdl)->m_renderHelper) |
| 193 | } | 186 | return; |
| 187 | static_cast<CRendering*>(cbhdl)->m_renderHelper->Begin(); | ||
| 188 | static_cast<CRendering*>(cbhdl)->Render(); | ||
| 189 | static_cast<CRendering*>(cbhdl)->m_renderHelper->End(); | ||
| 190 | } | ||
| 191 | |||
| 192 | static void OnStopCB(void* cbhdl) | ||
| 193 | { | ||
| 194 | static_cast<CRendering*>(cbhdl)->Stop(); | ||
| 195 | static_cast<CRendering*>(cbhdl)->m_renderHelper = nullptr; | ||
| 196 | } | ||
| 194 | 197 | ||
| 195 | static bool OnDirtyCB(void* cbhdl) | 198 | static bool OnDirtyCB(void* cbhdl) { return static_cast<CRendering*>(cbhdl)->Dirty(); } |
| 196 | { | ||
| 197 | return static_cast<CRendering*>(cbhdl)->Dirty(); | ||
| 198 | } | ||
| 199 | 199 | ||
| 200 | }; | 200 | std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper; |
| 201 | }; | ||
| 201 | 202 | ||
| 202 | } /* namespace controls */ | 203 | } /* namespace controls */ |
| 203 | } /* namespace gui */ | 204 | } /* namespace gui */ |
