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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*
* Copyright (C) 2005-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 "VideoSyncAndroid.h"
#include "WinSystemAndroidGLESContext.h"
#include "utils/log.h"
#include "threads/SingleLock.h"
#include "platform/android/activity/XBMCApp.h"
std::unique_ptr<CWinSystemBase> CWinSystemBase::CreateWinSystem()
{
std::unique_ptr<CWinSystemBase> winSystem(new CWinSystemAndroidGLESContext());
return winSystem;
}
bool CWinSystemAndroidGLESContext::InitWindowSystem()
{
if (!CWinSystemAndroid::InitWindowSystem())
{
return false;
}
if (!m_pGLContext.CreateDisplay(m_nativeDisplay,
EGL_OPENGL_ES2_BIT,
EGL_OPENGL_ES_API))
{
return false;
}
CEGLAttributesVec contextAttribs;
contextAttribs.Add({{EGL_CONTEXT_CLIENT_VERSION, 2}});
if (!m_pGLContext.CreateContext(contextAttribs))
{
return false;
}
return true;
}
bool CWinSystemAndroidGLESContext::CreateNewWindow(const std::string& name,
bool fullScreen,
RESOLUTION_INFO& res)
{
m_pGLContext.DestroySurface();
if (!CWinSystemAndroid::CreateNewWindow(name, fullScreen, res))
{
return false;
}
if (!m_pGLContext.CreateSurface(m_nativeWindow))
{
return false;
}
if (!m_pGLContext.BindContext())
{
return false;
}
return true;
}
bool CWinSystemAndroidGLESContext::ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop)
{
CRenderSystemGLES::ResetRenderSystem(newWidth, newHeight);
return true;
}
bool CWinSystemAndroidGLESContext::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
{
CreateNewWindow("", fullScreen, res);
CRenderSystemGLES::ResetRenderSystem(res.iWidth, res.iHeight);
return true;
}
void CWinSystemAndroidGLESContext::SetVSyncImpl(bool enable)
{
// We use Choreographer for timing
m_pGLContext.SetVSync(false);
}
void CWinSystemAndroidGLESContext::PresentRenderImpl(bool rendered)
{
// Ignore EGL_BAD_SURFACE: It seems to happen during/after mode changes, but
// we can't actually do anything about it
if (rendered && !m_pGLContext.TrySwapBuffers() && eglGetError() != EGL_BAD_SURFACE)
{
CEGLUtils::LogError("eglSwapBuffers failed");
throw std::runtime_error("eglSwapBuffers failed");
}
CXBMCApp::get()->WaitVSync(1000);
}
float CWinSystemAndroidGLESContext::GetFrameLatencyAdjustment()
{
return CXBMCApp::GetFrameLatencyMs();
}
EGLDisplay CWinSystemAndroidGLESContext::GetEGLDisplay() const
{
return m_pGLContext.GetEGLDisplay();
}
EGLSurface CWinSystemAndroidGLESContext::GetEGLSurface() const
{
return m_pGLContext.GetEGLSurface();
}
EGLContext CWinSystemAndroidGLESContext::GetEGLContext() const
{
return m_pGLContext.GetEGLContext();
}
EGLConfig CWinSystemAndroidGLESContext::GetEGLConfig() const
{
return m_pGLContext.GetEGLConfig();
}
std::unique_ptr<CVideoSync> CWinSystemAndroidGLESContext::GetVideoSync(void *clock)
{
std::unique_ptr<CVideoSync> pVSync(new CVideoSyncAndroid(clock));
return pVSync;
}
|