summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
committermanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
commit4c3251ec645c8b71820dab7e51e612e5919d4e75 (patch)
tree9533268a93e58fc2e16de1b8ee3fafe3784e5225 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h
parentf44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (diff)
downloadkodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.gz
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.bz2
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.zip
sync with upstream
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.h215
1 files changed, 215 insertions, 0 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
new file mode 100644
index 0000000..f80fcfa
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Rendering.h
@@ -0,0 +1,215 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../../AddonBase.h"
23#include "../Window.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace controls
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_controls_CRendering Control Rendering
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::controls::CRendering }
37 /// **Window control for rendering own parts**
38 ///
39 /// This rendering control is used when own parts are needed. You have the
40 /// control over them to render direct OpenGL or DirectX content to the
41 /// screen set by the size of them.
42 ///
43 /// Alternative can be the virtual functions from t his been ignored if the
44 /// callbacks are defined by the \ref CRendering_SetIndependentCallbacks function and
45 /// class is used as single and not as a parent class.
46 ///
47 /// It has the header \ref Rendering.h "#include <kodi/gui/controls/Rendering.h>"
48 /// be included to enjoy it.
49 ///
50 /// Here you find the needed skin part for a \ref Addon_Rendering_control "rendering control"
51 ///
52 /// @note The call of the control is only possible from the corresponding
53 /// window as its class and identification number is required.
54 ///
55
56 //============================================================================
57 ///
58 /// \defgroup cpp_kodi_gui_controls_CRendering_Defs Definitions, structures and enumerators
59 /// \ingroup cpp_kodi_gui_controls_CRendering
60 /// @brief **Library definition values**
61 ///
62
63 class CRendering : public CAddonGUIControlBase
64 {
65 public:
66 //==========================================================================
67 ///
68 /// \ingroup cpp_kodi_gui_controls_CRendering
69 /// @brief Construct a new control
70 ///
71 /// @param[in] window related window control class
72 /// @param[in] controlId Used skin xml control id
73 ///
74 CRendering(CWindow* window, int controlId)
75 : CAddonGUIControlBase(window)
76 {
77 m_controlHandle = m_interface->kodi_gui->window->get_control_render_addon(m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
78 if (m_controlHandle)
79 m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, this,
80 OnCreateCB, OnRenderCB, OnStopCB, OnDirtyCB);
81 else
82 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::%s can't create control class from Kodi !!!", __FUNCTION__);
83 }
84 //--------------------------------------------------------------------------
85
86 //==========================================================================
87 ///
88 /// \ingroup cpp_kodi_gui_controls_CRendering
89 /// @brief Destructor
90 ///
91 ~CRendering() override
92 {
93 m_interface->kodi_gui->control_rendering->destroy(m_interface->kodiBase, m_controlHandle);
94 }
95 //--------------------------------------------------------------------------
96
97 //==========================================================================
98 ///
99 /// \ingroup cpp_kodi_gui_controls_CRendering
100 /// @brief To create rendering control on Add-on
101 ///
102 /// Function creates the needed rendering control for Kodi which becomes
103 /// handled and processed from Add-on
104 ///
105 /// @note This is callback function from Kodi to Add-on and not to use
106 /// for calls from add-on to this function.
107 ///
108 /// @param[in] x Horizontal position
109 /// @param[in] y Vertical position
110 /// @param[in] w Width of control
111 /// @param[in] h Height of control
112 /// @param[in] device The device to use. For OpenGL is empty
113 /// on Direct X is the needed device send.
114 /// @return Add-on needs to return true if successed,
115 /// otherwise false.
116 ///
117 virtual bool Create(int x, int y, int w, int h, void* device) { return false; }
118 //--------------------------------------------------------------------------
119
120 //==========================================================================
121 ///
122 /// \ingroup cpp_kodi_gui_controls_CRendering
123 /// @brief Render process call from Kodi
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 Render() { }
129 //--------------------------------------------------------------------------
130
131 //==========================================================================
132 ///
133 /// \ingroup cpp_kodi_gui_controls_CRendering
134 /// @brief Call from Kodi to stop rendering process
135 ///
136 /// @note This is callback function from Kodi to Add-on and not to use
137 /// for calls from add-on to this function.
138 ///
139 virtual void Stop() { }
140 //--------------------------------------------------------------------------
141
142 //==========================================================================
143 ///
144 /// \ingroup cpp_kodi_gui_controls_CRendering
145 /// @brief Call from Kodi where add-on becomes asked about dirty rendering
146 /// region.
147 ///
148 /// @note This is callback function from Kodi to Add-on and not to use
149 /// for calls from add-on to this function.
150 ///
151 virtual bool Dirty() { return false; }
152 //--------------------------------------------------------------------------
153
154 //==========================================================================
155 ///
156 /// \ingroup cpp_kodi_gui_controls_CRendering
157 /// \anchor CRendering_SetIndependentCallbacks
158 /// @brief If the class is used independent (with "new CRendering")
159 /// and not as parent (with "cCLASS_own : CRendering") from own must
160 /// be the callback from Kodi to add-on overdriven with own functions!
161 ///
162 void SetIndependentCallbacks(
163 GUIHANDLE cbhdl,
164 bool (*CBCreate)(GUIHANDLE cbhdl,
165 int x,
166 int y,
167 int w,
168 int h,
169 void* device),
170 void (*CBRender)(GUIHANDLE cbhdl),
171 void (*CBStop) (GUIHANDLE cbhdl),
172 bool (*CBDirty) (GUIHANDLE cbhdl))
173 {
174 if (!cbhdl ||
175 !CBCreate || !CBRender || !CBStop || !CBDirty)
176 {
177 kodi::Log(ADDON_LOG_ERROR, "kodi::gui::controls::%s called with nullptr !!!", __FUNCTION__);
178 return;
179 }
180
181 m_interface->kodi_gui->control_rendering->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl,
182 CBCreate, CBRender, CBStop, CBDirty);
183 }
184 //--------------------------------------------------------------------------
185
186 private:
187 /*
188 * Defined callback functions from Kodi to add-on, for use in parent / child system
189 * (is private)!
190 */
191 static bool OnCreateCB(void* cbhdl, int x, int y, int w, int h, void* device)
192 {
193 return static_cast<CRendering*>(cbhdl)->Create(x, y, w, h, device);
194 }
195
196 static void OnRenderCB(void* cbhdl)
197 {
198 static_cast<CRendering*>(cbhdl)->Render();
199 }
200
201 static void OnStopCB(void* cbhdl)
202 {
203 static_cast<CRendering*>(cbhdl)->Stop();
204 }
205
206 static bool OnDirtyCB(void* cbhdl)
207 {
208 return static_cast<CRendering*>(cbhdl)->Dirty();
209 }
210
211 };
212
213} /* namespace controls */
214} /* namespace gui */
215} /* namespace kodi */