summaryrefslogtreecommitdiffstats
path: root/xbmc/cores/RetroPlayer/guicontrols
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/cores/RetroPlayer/guicontrols
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/cores/RetroPlayer/guicontrols')
-rw-r--r--xbmc/cores/RetroPlayer/guicontrols/CMakeLists.txt9
-rw-r--r--xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp190
-rw-r--r--xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.dox45
-rw-r--r--xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.h82
-rw-r--r--xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp103
-rw-r--r--xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.h58
6 files changed, 487 insertions, 0 deletions
diff --git a/xbmc/cores/RetroPlayer/guicontrols/CMakeLists.txt b/xbmc/cores/RetroPlayer/guicontrols/CMakeLists.txt
new file mode 100644
index 0000000..86aba95
--- /dev/null
+++ b/xbmc/cores/RetroPlayer/guicontrols/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(SOURCES GUIGameControl.cpp
+ GUIRenderSettings.cpp
+)
+
+set(HEADERS GUIGameControl.h
+ GUIRenderSettings.h
+)
+
+core_add_library(retroplayer_guicontrols)
diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp
new file mode 100644
index 0000000..bf2ceb9
--- /dev/null
+++ b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2017-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "GUIGameControl.h"
+
+#include "GUIRenderSettings.h"
+#include "ServiceBroker.h"
+#include "cores/RetroPlayer/RetroPlayerUtils.h"
+#include "cores/RetroPlayer/guibridge/GUIGameRenderManager.h"
+#include "cores/RetroPlayer/guibridge/GUIRenderHandle.h"
+#include "settings/GameSettings.h"
+#include "settings/MediaSettings.h"
+#include "utils/Geometry.h"
+#include "utils/StringUtils.h"
+
+#include <sstream>
+
+using namespace KODI;
+using namespace RETRO;
+
+CGUIGameControl::CGUIGameControl(
+ int parentID, int controlID, float posX, float posY, float width, float height)
+ : CGUIControl(parentID, controlID, posX, posY, width, height),
+ m_renderSettings(new CGUIRenderSettings(*this))
+{
+ // Initialize CGUIControl
+ ControlType = GUICONTROL_GAME;
+
+ m_renderSettings->SetDimensions(CRect(CPoint(posX, posY), CSize(width, height)));
+
+ RegisterControl();
+}
+
+CGUIGameControl::CGUIGameControl(const CGUIGameControl& other)
+ : CGUIControl(other),
+ m_videoFilterInfo(other.m_videoFilterInfo),
+ m_stretchModeInfo(other.m_stretchModeInfo),
+ m_rotationInfo(other.m_rotationInfo),
+ m_pixelInfo(other.m_pixelInfo),
+ m_bHasVideoFilter(other.m_bHasVideoFilter),
+ m_bHasStretchMode(other.m_bHasStretchMode),
+ m_bHasRotation(other.m_bHasRotation),
+ m_bHasPixels(other.m_bHasPixels),
+ m_renderSettings(new CGUIRenderSettings(*this))
+{
+ m_renderSettings->SetSettings(other.m_renderSettings->GetSettings());
+ m_renderSettings->SetDimensions(CRect(CPoint(m_posX, m_posY), CSize(m_width, m_height)));
+
+ RegisterControl();
+}
+
+CGUIGameControl::~CGUIGameControl()
+{
+ UnregisterControl();
+}
+
+void CGUIGameControl::SetVideoFilter(const GUILIB::GUIINFO::CGUIInfoLabel& videoFilter)
+{
+ m_videoFilterInfo = videoFilter;
+}
+
+void CGUIGameControl::SetStretchMode(const GUILIB::GUIINFO::CGUIInfoLabel& stretchMode)
+{
+ m_stretchModeInfo = stretchMode;
+}
+
+void CGUIGameControl::SetRotation(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& rotation)
+{
+ m_rotationInfo = rotation;
+}
+
+void CGUIGameControl::SetPixels(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& pixels)
+{
+ m_pixelInfo = pixels;
+}
+
+IGUIRenderSettings* CGUIGameControl::GetRenderSettings() const
+{
+ return m_renderSettings.get();
+}
+
+void CGUIGameControl::Process(unsigned int currentTime, CDirtyRegionList& dirtyregions)
+{
+ //! @todo Proper processing which marks when its actually changed
+ if (m_renderHandle->IsDirty())
+ MarkDirtyRegion();
+
+ CGUIControl::Process(currentTime, dirtyregions);
+}
+
+void CGUIGameControl::Render()
+{
+ m_renderHandle->Render();
+
+ CGUIControl::Render();
+}
+
+void CGUIGameControl::RenderEx()
+{
+ m_renderHandle->RenderEx();
+
+ CGUIControl::RenderEx();
+}
+
+bool CGUIGameControl::CanFocus() const
+{
+ // Unfocusable
+ return false;
+}
+
+void CGUIGameControl::SetPosition(float posX, float posY)
+{
+ CGUIControl::SetPosition(posX, posY);
+ m_renderSettings->SetDimensions(CRect(CPoint(posX, posY), CSize(m_width, m_height)));
+}
+
+void CGUIGameControl::SetWidth(float width)
+{
+ CGUIControl::SetWidth(width);
+ m_renderSettings->SetDimensions(CRect(CPoint(m_posX, m_posY), CSize(width, m_height)));
+}
+
+void CGUIGameControl::SetHeight(float height)
+{
+ CGUIControl::SetHeight(height);
+ m_renderSettings->SetDimensions(CRect(CPoint(m_posX, m_posY), CSize(m_width, height)));
+}
+
+void CGUIGameControl::UpdateInfo(const CGUIListItem* item /* = nullptr */)
+{
+ if (item)
+ {
+ Reset();
+
+ std::string strVideoFilter = m_videoFilterInfo.GetItemLabel(item);
+ if (!strVideoFilter.empty())
+ {
+ m_renderSettings->SetVideoFilter(strVideoFilter);
+ m_bHasVideoFilter = true;
+ }
+
+ std::string strStretchMode = m_stretchModeInfo.GetItemLabel(item);
+ if (!strStretchMode.empty())
+ {
+ STRETCHMODE stretchMode = CRetroPlayerUtils::IdentifierToStretchMode(strStretchMode);
+ m_renderSettings->SetStretchMode(stretchMode);
+ m_bHasStretchMode = true;
+ }
+
+ std::string strRotation = m_rotationInfo.GetItemLabel(item);
+ if (StringUtils::IsNaturalNumber(strRotation))
+ {
+ unsigned int rotation;
+ std::istringstream(strRotation) >> rotation;
+ m_renderSettings->SetRotationDegCCW(rotation);
+ m_bHasRotation = true;
+ }
+
+ std::string strPixels = m_pixelInfo.GetItemLabel(item);
+ if (!strPixels.empty())
+ {
+ m_renderSettings->SetPixels(strPixels);
+ m_bHasPixels = true;
+ }
+ }
+}
+
+void CGUIGameControl::Reset()
+{
+ m_bHasVideoFilter = false;
+ m_bHasStretchMode = false;
+ m_bHasRotation = false;
+ m_bHasPixels = false;
+ m_renderSettings->Reset();
+}
+
+void CGUIGameControl::RegisterControl()
+{
+ m_renderHandle = CServiceBroker::GetGameRenderManager().RegisterControl(*this);
+}
+
+void CGUIGameControl::UnregisterControl()
+{
+ m_renderHandle.reset();
+}
diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.dox b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.dox
new file mode 100644
index 0000000..6350110
--- /dev/null
+++ b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.dox
@@ -0,0 +1,45 @@
+/*!
+
+\page Game_Control Game Control
+\brief **Used to display the currently playing game, with optional effects,
+whilst in the GUI.**
+
+\tableofcontents
+
+The gamewindow control is used for displaying the currently playing game
+elsewhere in the Kodi GUI. You can choose the position, and size of the game
+displayed, as well as various effects. Note that the control is only rendered if
+game is being played.
+
+
+--------------------------------------------------------------------------------
+\section Game_Control_sect1 Example
+
+~~~~~~~~~~~~~
+<control type="gamewindow" id="2">
+ <description>My first game control</description>
+ <posx>80</posx>
+ <posy>60</posy>
+ <width>250</width>
+ <height>200</height>
+ <visible>true</visible>
+</control>
+~~~~~~~~~~~~~
+
+
+--------------------------------------------------------------------------------
+\section Game_Control_sect2 Available tags
+
+The [default control](http://kodi.wiki/view/Default_Control_Tags) tags are
+applicable to this control.
+
+
+--------------------------------------------------------------------------------
+\section Game_Control_sect3 See also
+
+#### Development:
+
+- [Add-on development](http://kodi.wiki/view/Add-on_development)
+- [Skinning](http://kodi.wiki/view/Skinning)
+
+*/
diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.h b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.h
new file mode 100644
index 0000000..a386952
--- /dev/null
+++ b/xbmc/cores/RetroPlayer/guicontrols/GUIGameControl.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2017-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "guilib/GUIControl.h"
+#include "guilib/guiinfo/GUIInfoLabel.h"
+
+#include <memory>
+
+namespace KODI
+{
+namespace RETRO
+{
+class CGUIRenderSettings;
+class CGUIRenderHandle;
+class IGUIRenderSettings;
+
+// Label to use when disabling rendering via the <pixels> property. A path
+// to pixel data is expected, but instead this constant can be provided to
+// skip a file existence check in the renderer.
+constexpr const char* NO_PIXEL_DATA = "-";
+
+class CGUIGameControl : public CGUIControl
+{
+public:
+ CGUIGameControl(int parentID, int controlID, float posX, float posY, float width, float height);
+ CGUIGameControl(const CGUIGameControl& other);
+ ~CGUIGameControl() override;
+
+ // GUI functions
+ void SetVideoFilter(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& videoFilter);
+ void SetStretchMode(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& stretchMode);
+ void SetRotation(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& rotation);
+ void SetPixels(const KODI::GUILIB::GUIINFO::CGUIInfoLabel& pixels);
+
+ // Rendering functions
+ bool HasVideoFilter() const { return m_bHasVideoFilter; }
+ bool HasStretchMode() const { return m_bHasStretchMode; }
+ bool HasRotation() const { return m_bHasRotation; }
+ bool HasPixels() const { return m_bHasPixels; }
+ IGUIRenderSettings* GetRenderSettings() const;
+
+ // implementation of CGUIControl
+ CGUIGameControl* Clone() const override { return new CGUIGameControl(*this); }
+ void Process(unsigned int currentTime, CDirtyRegionList& dirtyregions) override;
+ void Render() override;
+ void RenderEx() override;
+ bool CanFocus() const override;
+ void SetPosition(float posX, float posY) override;
+ void SetWidth(float width) override;
+ void SetHeight(float height) override;
+ void UpdateInfo(const CGUIListItem* item = nullptr) override;
+
+private:
+ void Reset();
+
+ void RegisterControl();
+ void UnregisterControl();
+
+ // GUI properties
+ KODI::GUILIB::GUIINFO::CGUIInfoLabel m_videoFilterInfo;
+ KODI::GUILIB::GUIINFO::CGUIInfoLabel m_stretchModeInfo;
+ KODI::GUILIB::GUIINFO::CGUIInfoLabel m_rotationInfo;
+ KODI::GUILIB::GUIINFO::CGUIInfoLabel m_pixelInfo;
+
+ // Rendering properties
+ bool m_bHasVideoFilter = false;
+ bool m_bHasStretchMode = false;
+ bool m_bHasRotation = false;
+ bool m_bHasPixels = false;
+ std::unique_ptr<CGUIRenderSettings> m_renderSettings;
+ std::shared_ptr<CGUIRenderHandle> m_renderHandle;
+};
+
+} // namespace RETRO
+} // namespace KODI
diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp b/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp
new file mode 100644
index 0000000..66cb4ea
--- /dev/null
+++ b/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2017-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "GUIRenderSettings.h"
+
+#include "GUIGameControl.h"
+
+#include <mutex>
+
+using namespace KODI;
+using namespace RETRO;
+
+CGUIRenderSettings::CGUIRenderSettings(CGUIGameControl& guiControl) : m_guiControl(guiControl)
+{
+}
+
+bool CGUIRenderSettings::HasVideoFilter() const
+{
+ return m_guiControl.HasVideoFilter();
+}
+
+bool CGUIRenderSettings::HasStretchMode() const
+{
+ return m_guiControl.HasStretchMode();
+}
+
+bool CGUIRenderSettings::HasRotation() const
+{
+ return m_guiControl.HasRotation();
+}
+
+bool CGUIRenderSettings::HasPixels() const
+{
+ return m_guiControl.HasPixels();
+}
+
+CRenderSettings CGUIRenderSettings::GetSettings() const
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ return m_renderSettings;
+}
+
+CRect CGUIRenderSettings::GetDimensions() const
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ return m_renderDimensions;
+}
+
+void CGUIRenderSettings::Reset()
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ return m_renderSettings.Reset();
+}
+
+void CGUIRenderSettings::SetSettings(CRenderSettings settings)
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ m_renderSettings = settings;
+}
+
+void CGUIRenderSettings::SetDimensions(const CRect& dimensions)
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ m_renderDimensions = dimensions;
+}
+
+void CGUIRenderSettings::SetVideoFilter(const std::string& videoFilter)
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ m_renderSettings.VideoSettings().SetVideoFilter(videoFilter);
+}
+
+void CGUIRenderSettings::SetStretchMode(STRETCHMODE stretchMode)
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
+}
+
+void CGUIRenderSettings::SetRotationDegCCW(unsigned int rotationDegCCW)
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ m_renderSettings.VideoSettings().SetRenderRotation(rotationDegCCW);
+}
+
+void CGUIRenderSettings::SetPixels(const std::string& pixelPath)
+{
+ std::unique_lock<CCriticalSection> lock(m_mutex);
+
+ m_renderSettings.VideoSettings().SetPixels(pixelPath);
+}
diff --git a/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.h b/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.h
new file mode 100644
index 0000000..80ba115
--- /dev/null
+++ b/xbmc/cores/RetroPlayer/guicontrols/GUIRenderSettings.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017-2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "cores/GameSettings.h"
+#include "cores/RetroPlayer/guibridge/IGUIRenderSettings.h"
+#include "cores/RetroPlayer/rendering/RenderSettings.h"
+#include "threads/CriticalSection.h"
+#include "utils/Geometry.h"
+
+namespace KODI
+{
+namespace RETRO
+{
+class CGUIGameControl;
+
+class CGUIRenderSettings : public IGUIRenderSettings
+{
+public:
+ CGUIRenderSettings(CGUIGameControl& guiControl);
+ ~CGUIRenderSettings() override = default;
+
+ // implementation of IGUIRenderSettings
+ bool HasVideoFilter() const override;
+ bool HasStretchMode() const override;
+ bool HasRotation() const override;
+ bool HasPixels() const override;
+ CRenderSettings GetSettings() const override;
+ CRect GetDimensions() const override;
+
+ // Render functions
+ void Reset();
+ void SetSettings(CRenderSettings settings);
+ void SetDimensions(const CRect& dimensions);
+ void SetVideoFilter(const std::string& videoFilter);
+ void SetStretchMode(STRETCHMODE stretchMode);
+ void SetRotationDegCCW(unsigned int rotationDegCCW);
+ void SetPixels(const std::string& pixelPath);
+
+private:
+ // Construction parameters
+ CGUIGameControl& m_guiControl;
+
+ // Render parameters
+ CRenderSettings m_renderSettings;
+ CRect m_renderDimensions;
+
+ // Synchronization parameters
+ mutable CCriticalSection m_mutex;
+};
+} // namespace RETRO
+} // namespace KODI