| 1 |
/* |
| 2 |
* Copyright (C) 2005-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 |
#pragma once |
| 10 |
|
| 11 |
#include "GLContext.h" |
| 12 |
#include "system_egl.h" |
| 13 |
#include "threads/CriticalSection.h" |
| 14 |
|
| 15 |
#include <cstdint> |
| 16 |
|
| 17 |
#include <EGL/eglext.h> |
| 18 |
#ifdef HAVE_EGLEXTANGLE |
| 19 |
#include <EGL/eglext_angle.h> |
| 20 |
#else |
| 21 |
#include <EGL/eglextchromium.h> |
| 22 |
#endif |
| 23 |
#include <X11/Xutil.h> |
| 24 |
|
| 25 |
class CGLContextEGL : public CGLContext |
| 26 |
{ |
| 27 |
public: |
| 28 |
explicit CGLContextEGL(Display *dpy, EGLint renderingApi); |
| 29 |
~CGLContextEGL() override; |
| 30 |
bool Refresh(bool force, int screen, Window glWindow, bool &newContext) override; |
| 31 |
bool CreatePB() override; |
| 32 |
void Destroy() override; |
| 33 |
void Detach() override; |
| 34 |
void SetVSync(bool enable) override; |
| 35 |
void SwapBuffers() override; |
| 36 |
void QueryExtensions() override; |
| 37 |
uint64_t GetVblankTiming(uint64_t &msc, uint64_t &interval) override; |
| 38 |
|
| 39 |
EGLint m_renderingApi; |
| 40 |
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; |
| 41 |
EGLSurface m_eglSurface = EGL_NO_SURFACE; |
| 42 |
EGLContext m_eglContext = EGL_NO_CONTEXT; |
| 43 |
EGLConfig m_eglConfig; |
| 44 |
protected: |
| 45 |
bool SuitableCheck(EGLDisplay eglDisplay, EGLConfig config); |
| 46 |
EGLConfig GetEGLConfig(EGLDisplay eglDisplay, XVisualInfo *vInfo); |
| 47 |
PFNEGLGETSYNCVALUESCHROMIUMPROC m_eglGetSyncValuesCHROMIUM = nullptr; |
| 48 |
PFNEGLGETPLATFORMDISPLAYEXTPROC m_eglGetPlatformDisplayEXT = nullptr; |
| 49 |
|
| 50 |
struct Sync |
| 51 |
{ |
| 52 |
uint64_t cont = 0; |
| 53 |
uint64_t ust1 = 0; |
| 54 |
uint64_t ust2 = 0; |
| 55 |
uint64_t msc1 = 0; |
| 56 |
uint64_t msc2 = 0; |
| 57 |
uint64_t interval = 0; |
| 58 |
} m_sync; |
| 59 |
|
| 60 |
CCriticalSection m_syncLock; |
| 61 |
|
| 62 |
bool m_usePB = false; |
| 63 |
}; |