Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
renderHelper.h
1/*
2 * Copyright (C) 2005-2019 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
13#ifdef __cplusplus
14
15namespace kodi
16{
17namespace gui
18{
19struct ATTR_DLL_LOCAL IRenderHelper
20{
21 virtual ~IRenderHelper() = default;
22 virtual bool Init() = 0;
23 virtual void Begin() = 0;
24 virtual void End() = 0;
25}; /* class IRenderHelper */
26} /* namespace gui */
27} /* namespace kodi */
28
29#if defined(WIN32) && defined(HAS_ANGLE)
30#include "gl/GLonDX.h"
31#else
32/*
33 * Default background GUI render helper class
34 */
35namespace kodi
36{
37namespace gui
38{
39struct ATTR_DLL_LOCAL CRenderHelperStub : public IRenderHelper
40{
41 bool Init() override { return true; }
42 void Begin() override {}
43 void End() override {}
44}; /* class CRenderHelperStub */
45
47} /* namespace gui */
48} /* namespace kodi */
49#endif
50
51namespace kodi
52{
53namespace gui
54{
55
56/*
57 * Create render background handler, e.g. becomes on "Windows" Angle used
58 * to emulate GL.
59 *
60 * This only be used internal and not from addon's direct.
61 *
62 * Function defines here and not in CAddonBase because of a hen and egg problem.
63 */
64inline std::shared_ptr<IRenderHelper> ATTR_DLL_LOCAL GetRenderHelper()
65{
66 using namespace ::kodi::addon;
67 if (static_cast<CAddonBase*>(CPrivateBase::m_interface->addonBase)->m_renderHelper)
68 return static_cast<CAddonBase*>(CPrivateBase::m_interface->addonBase)->m_renderHelper;
69
70 std::shared_ptr<kodi::gui::IRenderHelper> renderHelper(new CRenderHelper());
71 if (!renderHelper->Init())
72 return nullptr;
73
74 static_cast<CAddonBase*>(CPrivateBase::m_interface->addonBase)->m_renderHelper =
75 renderHelper; // Hold on base for other types
76 return renderHelper;
77}
78
79} /* namespace gui */
80} /* namespace kodi */
81
82#endif /* __cplusplus */
Definition renderHelper.h:40
Definition renderHelper.h:20