11 #include "../AddonBase.h"
12 #include "../c-api/addon-instance/screensaver.h"
13 #include "../gui/renderHelper.h"
205 if (CAddonBase::m_interface->globalSingleInstance !=
nullptr)
206 throw std::logic_error(
"kodi::addon::CInstanceScreensaver: Creation of more as one in single "
207 "instance way is not allowed!");
209 SetAddonStruct(CAddonBase::m_interface->firstKodiInstance);
210 CAddonBase::m_interface->globalSingleInstance =
this;
257 !kodiVersion.empty() ? kodiVersion
260 if (CAddonBase::m_interface->globalSingleInstance !=
nullptr)
261 throw std::logic_error(
"kodi::addon::CInstanceScreensaver: Creation of multiple together "
262 "with single instance way is not allowed!");
264 SetAddonStruct(instance);
281 virtual bool Start() {
return true; }
330 inline kodi::HardwareContext
Device() {
return m_instanceData->props->device; }
339 inline int X() {
return m_instanceData->props->x; }
348 inline int Y() {
return m_instanceData->props->y; }
357 inline int Width() {
return m_instanceData->props->width; }
366 inline int Height() {
return m_instanceData->props->height; }
376 inline float PixelRatio() {
return m_instanceData->props->pixelRatio; }
385 inline std::string
Name() {
return m_instanceData->props->name; }
395 inline std::string
Presets() {
return m_instanceData->props->presets; }
408 inline std::string
Profile() {
return m_instanceData->props->profile; }
414 void SetAddonStruct(KODI_HANDLE instance)
416 if (instance ==
nullptr)
417 throw std::logic_error(
"kodi::addon::CInstanceScreensaver: Creation with empty addon "
418 "structure not allowed, table must be given from Kodi!");
421 m_instanceData->toAddon->addonInstance =
this;
422 m_instanceData->toAddon->Start = ADDON_Start;
423 m_instanceData->toAddon->Stop = ADDON_Stop;
424 m_instanceData->toAddon->Render = ADDON_Render;
429 CInstanceScreensaver* thisClass =
430 static_cast<CInstanceScreensaver*
>(instance->toAddon->addonInstance);
431 thisClass->m_renderHelper = kodi::gui::GetRenderHelper();
432 return thisClass->Start();
437 CInstanceScreensaver* thisClass =
438 static_cast<CInstanceScreensaver*
>(instance->toAddon->addonInstance);
440 thisClass->m_renderHelper =
nullptr;
445 CInstanceScreensaver* thisClass =
446 static_cast<CInstanceScreensaver*
>(instance->toAddon->addonInstance);
448 if (!thisClass->m_renderHelper)
450 thisClass->m_renderHelper->Begin();
452 thisClass->m_renderHelper->End();
464 std::shared_ptr<kodi::gui::IRenderHelper> m_renderHelper;
Definition: Screensaver.h:194
Definition: AddonBase.h:186
@ ADDON_INSTANCE_SCREENSAVER
PVR client instance, see kodi::addon::CInstanceScreensaver.
Definition: versions.h:235
std::string Presets()
Used to get the full path where the add-on is installed.
Definition: Screensaver.h:395
int Height()
Returns the height of the rendering window.
Definition: Screensaver.h:366
kodi::HardwareContext Device()
Device that represents the display adapter.
Definition: Screensaver.h:330
std::string Profile()
Used to get the full path to the add-on's user profile.
Definition: Screensaver.h:408
int X()
Returns the X position of the rendering window.
Definition: Screensaver.h:339
int Width()
Returns the width of the rendering window.
Definition: Screensaver.h:357
int Y()
Returns the Y position of the rendering window.
Definition: Screensaver.h:348
std::string Name()
Used to get the name of the add-on defined in addon.xml.
Definition: Screensaver.h:385
float PixelRatio()
Pixel aspect ratio (often abbreviated PAR) is a ratio that describes how the width of a pixel compare...
Definition: Screensaver.h:376
virtual void Render()
Used to indicate when the add-on should render.
Definition: Screensaver.h:296
CInstanceScreensaver()
Screensaver class constructor.
Definition: Screensaver.h:202
CInstanceScreensaver(KODI_HANDLE instance, const std::string &kodiVersion="")
Screensaver class constructor used to support multiple instance types.
Definition: Screensaver.h:255
virtual bool Start()
Used to notify the screensaver that it has been started.
Definition: Screensaver.h:281
~CInstanceScreensaver() override=default
Destructor.
virtual void Stop()
Used to inform the screensaver that the rendering control was stopped.
Definition: Screensaver.h:289
std::string ATTRIBUTE_HIDDEN GetKodiTypeVersion(int type)
To get used version inside Kodi itself about asked type.
Definition: AddonBase.h:630
Screensaver instance.
Definition: screensaver.h:68