| 1 |
/* |
| 2 |
* Copyright (C) 2023 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 |
#include "RendererStarfish.h" |
| 10 |
|
| 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" |
| 18 |
|
| 19 |
#include <appswitching-control-block/AcbAPI.h> |
| 20 |
|
| 21 |
CRendererStarfish::CRendererStarfish() |
| 22 |
{ |
| 23 |
CLog::LogF(LOGINFO, "CRendererStarfish: Instanced"); |
| 24 |
} |
| 25 |
|
| 26 |
CRendererStarfish::~CRendererStarfish() = default; |
| 27 |
|
| 28 |
CBaseRenderer* CRendererStarfish::Create(CVideoBuffer* buffer) |
| 29 |
{ |
| 30 |
if (buffer && dynamic_cast<CStarfishVideoBuffer*>(buffer)) |
| 31 |
return new CRendererStarfish(); |
| 32 |
return nullptr; |
| 33 |
} |
| 34 |
|
| 35 |
bool CRendererStarfish::Configure(const VideoPicture& picture, float fps, unsigned int orientation) |
| 36 |
{ |
| 37 |
auto buffer = static_cast<CStarfishVideoBuffer*>(picture.videoBuffer); |
| 38 |
m_acbId = buffer->m_acbId; |
| 39 |
if (m_acbId) |
| 40 |
{ |
| 41 |
EnableAlwaysClip(); |
| 42 |
} |
| 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); |
| 47 |
|
| 48 |
m_format = picture.videoBuffer->GetFormat(); |
| 49 |
m_sourceWidth = picture.iWidth; |
| 50 |
m_sourceHeight = picture.iHeight; |
| 51 |
m_renderOrientation = orientation; |
| 52 |
|
| 53 |
// Calculate the input frame aspect ratio. |
| 54 |
CalculateFrameAspectRatio(picture.iDisplayWidth, picture.iDisplayHeight); |
| 55 |
SetViewMode(m_videoSettings.m_ViewMode); |
| 56 |
ManageRenderArea(); |
| 57 |
|
| 58 |
m_configured = true; |
| 59 |
|
| 60 |
return true; |
| 61 |
} |
| 62 |
|
| 63 |
bool CRendererStarfish::IsConfigured() |
| 64 |
{ |
| 65 |
return m_configured; |
| 66 |
} |
| 67 |
|
| 68 |
bool CRendererStarfish::ConfigChanged(const VideoPicture& picture) |
| 69 |
{ |
| 70 |
if (picture.videoBuffer->GetFormat() != m_format) |
| 71 |
{ |
| 72 |
return true; |
| 73 |
} |
| 74 |
|
| 75 |
return false; |
| 76 |
} |
| 77 |
|
| 78 |
bool CRendererStarfish::Register() |
| 79 |
{ |
| 80 |
VIDEOPLAYER::CRendererFactory::RegisterRenderer("starfish", CRendererStarfish::Create); |
| 81 |
return true; |
| 82 |
} |
| 83 |
|
| 84 |
void CRendererStarfish::ManageRenderArea() |
| 85 |
{ |
| 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); |
| 90 |
|
| 91 |
CBaseRenderer::ManageRenderArea(); |
| 92 |
|
| 93 |
if (stereoMode == RENDER_STEREO_MODE_MONO) |
| 94 |
CServiceBroker::GetWinSystem()->GetGfxContext().SetStereoView(RENDER_STEREO_VIEW_OFF); |
| 95 |
|
| 96 |
switch (stereoMode) |
| 97 |
{ |
| 98 |
case RENDER_STEREO_MODE_SPLIT_HORIZONTAL: |
| 99 |
m_destRect.y2 *= 2.0f; |
| 100 |
break; |
| 101 |
case RENDER_STEREO_MODE_SPLIT_VERTICAL: |
| 102 |
m_destRect.x2 *= 2.0f; |
| 103 |
break; |
| 104 |
default: |
| 105 |
break; |
| 106 |
} |
| 107 |
|
| 108 |
if ((m_exportedDestRect != m_destRect || m_exportedSourceRect != m_sourceRect) && |
| 109 |
!m_sourceRect.IsEmpty() && !m_destRect.IsEmpty()) |
| 110 |
{ |
| 111 |
auto origRect = |
| 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()) |
| 116 |
{ |
| 117 |
winSystem->SetExportedWindow(origRect, m_sourceRect, m_destRect); |
| 118 |
} |
| 119 |
else if (m_acbId) |
| 120 |
{ |
| 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); |
| 124 |
} |
| 125 |
m_exportedSourceRect = m_sourceRect; |
| 126 |
m_exportedDestRect = m_destRect; |
| 127 |
} |
| 128 |
} |
| 129 |
|
| 130 |
bool CRendererStarfish::Supports(ERENDERFEATURE feature) const |
| 131 |
{ |
| 132 |
return (feature == RENDERFEATURE_ZOOM || feature == RENDERFEATURE_STRETCH || |
| 133 |
feature == RENDERFEATURE_PIXEL_RATIO || feature == RENDERFEATURE_VERTICAL_SHIFT || |
| 134 |
feature == RENDERFEATURE_ROTATION); |
| 135 |
} |
| 136 |
|
| 137 |
bool CRendererStarfish::Supports(ESCALINGMETHOD method) const |
| 138 |
{ |
| 139 |
return false; |
| 140 |
} |
| 141 |
|
| 142 |
bool CRendererStarfish::SupportsMultiPassRendering() |
| 143 |
{ |
| 144 |
return false; |
| 145 |
} |
| 146 |
|
| 147 |
void CRendererStarfish::AddVideoPicture(const VideoPicture& picture, int index) |
| 148 |
{ |
| 149 |
} |
| 150 |
|
| 151 |
void CRendererStarfish::ReleaseBuffer(int idx) |
| 152 |
{ |
| 153 |
} |
| 154 |
|
| 155 |
CRenderInfo CRendererStarfish::GetRenderInfo() |
| 156 |
{ |
| 157 |
CRenderInfo info; |
| 158 |
info.max_buffer_size = 4; |
| 159 |
return info; |
| 160 |
} |
| 161 |
|
| 162 |
bool CRendererStarfish::IsGuiLayer() |
| 163 |
{ |
| 164 |
return false; |
| 165 |
} |
| 166 |
|
| 167 |
bool CRendererStarfish::RenderCapture(int index, CRenderCapture* capture) |
| 168 |
{ |
| 169 |
return false; |
| 170 |
} |
| 171 |
|
| 172 |
void CRendererStarfish::UnInit() |
| 173 |
{ |
| 174 |
m_configured = false; |
| 175 |
} |
| 176 |
|
| 177 |
void CRendererStarfish::Update() |
| 178 |
{ |
| 179 |
if (!m_configured) |
| 180 |
{ |
| 181 |
return; |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
void CRendererStarfish::RenderUpdate( |
| 186 |
int index, int index2, bool clear, unsigned int flags, unsigned int alpha) |
| 187 |
{ |
| 188 |
if (!m_configured) |
| 189 |
{ |
| 190 |
return; |
| 191 |
} |
| 192 |
|
| 193 |
ManageRenderArea(); |
| 194 |
} |