| 1 |
/* |
| 2 |
* Copyright (C) 2017-2018 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 "WinSystemWaylandEGLContextGLES.h" |
| 10 |
|
| 11 |
#include "OptionalsReg.h" |
| 12 |
#include "cores/RetroPlayer/process/RPProcessInfo.h" |
| 13 |
#include "cores/RetroPlayer/rendering/VideoRenderers/RPRendererDMA.h" |
| 14 |
#include "cores/RetroPlayer/rendering/VideoRenderers/RPRendererOpenGLES.h" |
| 15 |
#include "cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.h" |
| 16 |
#include "cores/VideoPlayer/VideoRenderers/HwDecRender/RendererDRMPRIMEGLES.h" |
| 17 |
#include "cores/VideoPlayer/VideoRenderers/LinuxRendererGLES.h" |
| 18 |
#include "cores/VideoPlayer/VideoRenderers/RenderFactory.h" |
| 19 |
#include "rendering/gles/ScreenshotSurfaceGLES.h" |
| 20 |
#include "utils/BufferObjectFactory.h" |
| 21 |
#include "utils/DMAHeapBufferObject.h" |
| 22 |
#include "utils/UDMABufferObject.h" |
| 23 |
#include "utils/log.h" |
| 24 |
#include "windowing/WindowSystemFactory.h" |
| 25 |
|
| 26 |
using namespace KODI::WINDOWING::WAYLAND; |
| 27 |
|
| 28 |
void CWinSystemWaylandEGLContextGLES::Register() |
| 29 |
{ |
| 30 |
CWindowSystemFactory::RegisterWindowSystem(CreateWinSystem, "wayland"); |
| 31 |
} |
| 32 |
|
| 33 |
std::unique_ptr<CWinSystemBase> CWinSystemWaylandEGLContextGLES::CreateWinSystem() |
| 34 |
{ |
| 35 |
return std::make_unique<CWinSystemWaylandEGLContextGLES>(); |
| 36 |
} |
| 37 |
|
| 38 |
bool CWinSystemWaylandEGLContextGLES::InitWindowSystem() |
| 39 |
{ |
| 40 |
if (!CWinSystemWaylandEGLContext::InitWindowSystemEGL(EGL_OPENGL_ES2_BIT, EGL_OPENGL_ES_API)) |
| 41 |
{ |
| 42 |
return false; |
| 43 |
} |
| 44 |
|
| 45 |
CLinuxRendererGLES::Register(); |
| 46 |
|
| 47 |
CDVDVideoCodecDRMPRIME::Register(); |
| 48 |
CRendererDRMPRIMEGLES::Register(); |
| 49 |
|
| 50 |
RETRO::CRPProcessInfo::RegisterRendererFactory(new RETRO::CRendererFactoryDMA); |
| 51 |
RETRO::CRPProcessInfo::RegisterRendererFactory(new RETRO::CRendererFactoryOpenGLES); |
| 52 |
|
| 53 |
bool general, deepColor; |
| 54 |
m_vaapiProxy.reset(WAYLAND::VaapiProxyCreate()); |
| 55 |
WAYLAND::VaapiProxyConfig(m_vaapiProxy.get(), GetConnection()->GetDisplay(), |
| 56 |
m_eglContext.GetEGLDisplay()); |
| 57 |
WAYLAND::VAAPIRegisterRenderGLES(m_vaapiProxy.get(), general, deepColor); |
| 58 |
if (general) |
| 59 |
{ |
| 60 |
WAYLAND::VAAPIRegister(m_vaapiProxy.get(), deepColor); |
| 61 |
} |
| 62 |
|
| 63 |
CBufferObjectFactory::ClearBufferObjects(); |
| 64 |
#if defined(HAVE_LINUX_MEMFD) && defined(HAVE_LINUX_UDMABUF) |
| 65 |
CUDMABufferObject::Register(); |
| 66 |
#endif |
| 67 |
#if defined(HAVE_LINUX_DMA_HEAP) |
| 68 |
CDMAHeapBufferObject::Register(); |
| 69 |
#endif |
| 70 |
|
| 71 |
CScreenshotSurfaceGLES::Register(); |
| 72 |
|
| 73 |
return true; |
| 74 |
} |
| 75 |
|
| 76 |
bool CWinSystemWaylandEGLContextGLES::CreateContext() |
| 77 |
{ |
| 78 |
CEGLAttributesVec contextAttribs; |
| 79 |
contextAttribs.Add({{EGL_CONTEXT_CLIENT_VERSION, 2}}); |
| 80 |
|
| 81 |
if (!m_eglContext.CreateContext(contextAttribs)) |
| 82 |
{ |
| 83 |
CLog::Log(LOGERROR, "EGL context creation failed"); |
| 84 |
return false; |
| 85 |
} |
| 86 |
return true; |
| 87 |
} |
| 88 |
|
| 89 |
void CWinSystemWaylandEGLContextGLES::SetContextSize(CSizeInt size) |
| 90 |
{ |
| 91 |
CWinSystemWaylandEGLContext::SetContextSize(size); |
| 92 |
|
| 93 |
// Propagate changed dimensions to render system if necessary |
| 94 |
if (CRenderSystemGLES::m_width != size.Width() || CRenderSystemGLES::m_height != size.Height()) |
| 95 |
{ |
| 96 |
CLog::LogF(LOGDEBUG, "Resetting render system to {}x{}", size.Width(), size.Height()); |
| 97 |
CRenderSystemGLES::ResetRenderSystem(size.Width(), size.Height()); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
void CWinSystemWaylandEGLContextGLES::SetVSyncImpl(bool enable) |
| 102 |
{ |
| 103 |
// Unsupported |
| 104 |
} |
| 105 |
|
| 106 |
void CWinSystemWaylandEGLContextGLES::PresentRenderImpl(bool rendered) |
| 107 |
{ |
| 108 |
PresentFrame(rendered); |
| 109 |
} |
| 110 |
|
| 111 |
void CWinSystemWaylandEGLContextGLES::delete_CVaapiProxy::operator()(CVaapiProxy *p) const |
| 112 |
{ |
| 113 |
WAYLAND::VaapiProxyDelete(p); |
| 114 |
} |