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