summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h
diff options
context:
space:
mode:
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.h205
1 files changed, 0 insertions, 205 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
deleted file mode 100644
index 7cc9b24..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h
+++ /dev/null
@@ -1,205 +0,0 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../AddonBase.h"
12#include "../Window.h"
13#include "../renderHelper.h"
14
15namespace kodi
16{
17namespace gui
18{
19namespace controls
20{
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
53class ATTRIBUTE_HIDDEN CRendering : public CAddonGUIControlBase
54{
55public:
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 //==========================================================================
90 ///
91 /// \ingroup cpp_kodi_gui_controls_CRendering
92 /// @brief To create rendering control on Add-on
93 ///
94 /// Function creates the needed rendering control for Kodi which becomes
95 /// handled and processed from Add-on
96 ///
97 /// @note This is callback function from Kodi to Add-on and not to use
98 /// for calls from add-on to this function.
99 ///
100 /// @param[in] x Horizontal position
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.
108 ///
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
116 ///
117 /// @note This is callback function from Kodi to Add-on and not to use
118 /// for calls from add-on to this function.
119 ///
120 virtual void Render() {}
121 //--------------------------------------------------------------------------
122
123 //==========================================================================
124 ///
125 /// \ingroup cpp_kodi_gui_controls_CRendering
126 /// @brief Call from Kodi to stop rendering process
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 //--------------------------------------------------------------------------
133
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))
160 {
161 if (!cbhdl || !CBCreate || !CBRender || !CBStop || !CBDirty)
162 {
163 kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__);
164 return;
165 }
166
167 m_interface->kodi_gui->control_rendering->set_callbacks(
168 m_interface->kodiBase, m_controlHandle, cbhdl, CBCreate, CBRender, CBStop, CBDirty);
169 }
170 //--------------------------------------------------------------------------
171
172private:
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 }
182
183 static void OnRenderCB(void* cbhdl)
184 {
185 if (!static_cast<CRendering*>(cbhdl)->m_renderHelper)
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 }
197
198 static bool OnDirtyCB(void* cbhdl) { return static_cast<CRendering*>(cbhdl)->Dirty(); }
199
200 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
201};
202
203} /* namespace controls */
204} /* namespace gui */
205} /* namespace kodi */