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 "EGL/egl.h"
12 #include "WinSystemX11.h"
13 #include "rendering/gles/RenderSystemGLES.h"
14 
15 class CGLContextEGL;
16 
17 namespace KODI
18 {
19 namespace WINDOWING
20 {
21 namespace X11
22 {
23 
24 class CWinSystemX11GLESContext : public CWinSystemX11, public CRenderSystemGLES
25 {
26 public:
27   CWinSystemX11GLESContext() = default;
28   virtual ~CWinSystemX11GLESContext() override;
29 
30   static void Register();
31   static std::unique_ptr<CWinSystemBase> CreateWinSystem();
32 
33   // Implementation of CWinSystem via CWinSystemX11
GetRenderSystem()34   CRenderSystemBase* GetRenderSystem() override { return this; }
35   bool CreateNewWindow(const std::string& name, bool fullScreen, RESOLUTION_INFO& res) override;
36   bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop) override;
37   void FinishWindowResize(int newWidth, int newHeight) override;
38   bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays) override;
39   bool DestroyWindowSystem() override;
40   bool DestroyWindow() override;
41 
42   bool IsExtSupported(const char* extension) const override;
43 
44   EGLDisplay GetEGLDisplay() const;
45   EGLSurface GetEGLSurface() const;
46   EGLContext GetEGLContext() const;
47   EGLConfig GetEGLConfig() const;
48 
49 protected:
50   bool SetWindow(int width, int height, bool fullscreen, const std::string& output, int* winstate = nullptr) override;
51   void PresentRenderImpl(bool rendered) override;
52   void SetVSyncImpl(bool enable) override;
53   bool RefreshGLContext(bool force);
54   XVisualInfo* GetVisual() override;
55 
56   CGLContextEGL* m_pGLContext = nullptr;
57   bool m_newGlContext;
58 };
59 
60 } // namespace X11
61 } // namespace WINDOWING
62 } // namespace KODI
63