2 * Copyright (C) 2023 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "RendererStarfish.h"
11 #include "../RenderFactory.h"
12 #include "DVDCodecs/Video/DVDVideoCodecStarfish.h"
13 #include "ServiceBroker.h"
14 #include "rendering/gles/RenderSystemGLES.h"
15 #include "settings/MediaSettings.h"
16 #include "utils/log.h"
17 #include "windowing/wayland/WinSystemWaylandWebOS.h"
19 #include <appswitching-control-block/AcbAPI.h>
21 CRendererStarfish::CRendererStarfish()
23 CLog::LogF(LOGINFO
, "CRendererStarfish: Instanced");
26 CRendererStarfish::~CRendererStarfish() = default;
28 CBaseRenderer
* CRendererStarfish::Create(CVideoBuffer
* buffer
)
30 if (buffer
&& dynamic_cast<CStarfishVideoBuffer
*>(buffer
))
31 return new CRendererStarfish();
35 bool CRendererStarfish::Configure(const VideoPicture
& picture
, float fps
, unsigned int orientation
)
37 auto buffer
= static_cast<CStarfishVideoBuffer
*>(picture
.videoBuffer
);
38 m_acbId
= buffer
->m_acbId
;
43 m_iFlags
= GetFlagsChromaPosition(picture
.chroma_position
) |
44 GetFlagsColorMatrix(picture
.color_space
, picture
.iWidth
, picture
.iHeight
) |
45 GetFlagsColorPrimaries(picture
.color_primaries
) |
46 GetFlagsStereoMode(picture
.stereoMode
);
48 m_format
= picture
.videoBuffer
->GetFormat();
49 m_sourceWidth
= picture
.iWidth
;
50 m_sourceHeight
= picture
.iHeight
;
51 m_renderOrientation
= orientation
;
53 // Calculate the input frame aspect ratio.
54 CalculateFrameAspectRatio(picture
.iDisplayWidth
, picture
.iDisplayHeight
);
55 SetViewMode(m_videoSettings
.m_ViewMode
);
63 bool CRendererStarfish::IsConfigured()
68 bool CRendererStarfish::ConfigChanged(const VideoPicture
& picture
)
70 if (picture
.videoBuffer
->GetFormat() != m_format
)
78 bool CRendererStarfish::Register()
80 VIDEOPLAYER::CRendererFactory::RegisterRenderer("starfish", CRendererStarfish::Create
);
84 void CRendererStarfish::ManageRenderArea()
86 // this hack is needed to get the 2D mode of a 3D movie going
87 RENDER_STEREO_MODE stereoMode
= CServiceBroker::GetWinSystem()->GetGfxContext().GetStereoMode();
88 if (stereoMode
== RENDER_STEREO_MODE_MONO
)
89 CServiceBroker::GetWinSystem()->GetGfxContext().SetStereoView(RENDER_STEREO_VIEW_LEFT
);
91 CBaseRenderer::ManageRenderArea();
93 if (stereoMode
== RENDER_STEREO_MODE_MONO
)
94 CServiceBroker::GetWinSystem()->GetGfxContext().SetStereoView(RENDER_STEREO_VIEW_OFF
);
98 case RENDER_STEREO_MODE_SPLIT_HORIZONTAL
:
99 m_destRect
.y2
*= 2.0f
;
101 case RENDER_STEREO_MODE_SPLIT_VERTICAL
:
102 m_destRect
.x2
*= 2.0f
;
108 if ((m_exportedDestRect
!= m_destRect
|| m_exportedSourceRect
!= m_sourceRect
) &&
109 !m_sourceRect
.IsEmpty() && !m_destRect
.IsEmpty())
112 CRect
{0, 0, static_cast<float>(m_sourceWidth
), static_cast<float>(m_sourceHeight
)};
113 using namespace KODI::WINDOWING::WAYLAND
;
114 auto winSystem
= static_cast<CWinSystemWaylandWebOS
*>(CServiceBroker::GetWinSystem());
115 if (winSystem
->SupportsExportedWindow())
117 winSystem
->SetExportedWindow(origRect
, m_sourceRect
, m_destRect
);
121 AcbAPI_setCustomDisplayWindow(m_acbId
, m_sourceRect
.x1
, m_sourceRect
.y1
, m_sourceRect
.Width(),
122 m_sourceRect
.Height(), m_destRect
.x1
, m_destRect
.y1
,
123 m_destRect
.Width(), m_destRect
.Height(), false, nullptr);
125 m_exportedSourceRect
= m_sourceRect
;
126 m_exportedDestRect
= m_destRect
;
130 bool CRendererStarfish::Supports(ERENDERFEATURE feature
) const
132 return (feature
== RENDERFEATURE_ZOOM
|| feature
== RENDERFEATURE_STRETCH
||
133 feature
== RENDERFEATURE_PIXEL_RATIO
|| feature
== RENDERFEATURE_VERTICAL_SHIFT
||
134 feature
== RENDERFEATURE_ROTATION
);
137 bool CRendererStarfish::Supports(ESCALINGMETHOD method
) const
142 bool CRendererStarfish::SupportsMultiPassRendering()
147 void CRendererStarfish::AddVideoPicture(const VideoPicture
& picture
, int index
)
151 void CRendererStarfish::ReleaseBuffer(int idx
)
155 CRenderInfo
CRendererStarfish::GetRenderInfo()
158 info
.max_buffer_size
= 4;
162 bool CRendererStarfish::IsGuiLayer()
167 bool CRendererStarfish::RenderCapture(int index
, CRenderCapture
* capture
)
172 void CRendererStarfish::UnInit()
174 m_configured
= false;
177 void CRendererStarfish::Update()
185 void CRendererStarfish::RenderUpdate(
186 int index
, int index2
, bool clear
, unsigned int flags
, unsigned int alpha
)