aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2018-03-23 10:09:44 -0700
committerGitHub <noreply@github.com>2018-03-23 10:09:44 -0700
commitcf7dd38abb6901f536b6a8d937a0a56248e06652 (patch)
tree674abfd51e9872644cb7c7c331ee5f2f4ad880f1
parentf5e7d8c1ca0a14bb9c12571baa814aea603d4932 (diff)
parentd5f4f3760bb7926c36fbc0941ab27b6930794e3e (diff)
Merge pull request #13558 from lrusak/egl-cleanup
EGL cleanup and consolidation
-rw-r--r--xbmc/utils/EGLUtils.cpp226
-rw-r--r--xbmc/utils/EGLUtils.h27
-rw-r--r--xbmc/windowing/amlogic/CMakeLists.txt6
-rw-r--r--xbmc/windowing/amlogic/GLContextEGL.cpp229
-rw-r--r--xbmc/windowing/amlogic/GLContextEGL.h48
-rw-r--r--xbmc/windowing/amlogic/WinSystemAmlogicGLESContext.h4
-rw-r--r--xbmc/windowing/android/CMakeLists.txt6
-rw-r--r--xbmc/windowing/android/GLContextEGL.cpp229
-rw-r--r--xbmc/windowing/android/GLContextEGL.h48
-rw-r--r--xbmc/windowing/android/WinSystemAndroidGLESContext.h4
-rw-r--r--xbmc/windowing/gbm/CMakeLists.txt2
-rw-r--r--xbmc/windowing/gbm/GLContextEGL.cpp252
-rw-r--r--xbmc/windowing/gbm/GLContextEGL.h48
-rw-r--r--xbmc/windowing/gbm/WinSystemGbm.cpp10
-rw-r--r--xbmc/windowing/gbm/WinSystemGbm.h4
-rw-r--r--xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp4
-rw-r--r--xbmc/windowing/gbm/WinSystemGbmGLESContext.h4
-rw-r--r--xbmc/windowing/rpi/CMakeLists.txt6
-rw-r--r--xbmc/windowing/rpi/GLContextEGL.cpp229
-rw-r--r--xbmc/windowing/rpi/GLContextEGL.h48
-rw-r--r--xbmc/windowing/rpi/WinSystemRpiGLESContext.h4
21 files changed, 267 insertions, 1171 deletions
diff --git a/xbmc/utils/EGLUtils.cpp b/xbmc/utils/EGLUtils.cpp
index 9e93dbb8fe..f1785c05fd 100644
--- a/xbmc/utils/EGLUtils.cpp
+++ b/xbmc/utils/EGLUtils.cpp
@@ -21,12 +21,18 @@
#include "EGLUtils.h"
#include "log.h"
+#include "guilib/IDirtyRegionSolver.h"
+#include "settings/AdvancedSettings.h"
+
+#include <EGL/eglext.h>
+#include <string.h>
+
std::set<std::string> CEGLUtils::GetClientExtensions()
{
const char* extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (!extensions)
{
- throw std::runtime_error("Could not query EGL for client extensions, maybe EGL_EXT_client_extensions is not supported?");
+ return {};
}
std::set<std::string> result;
StringUtils::SplitTo(std::inserter(result, result.begin()), extensions, " ");
@@ -55,3 +61,221 @@ void CEGLUtils::LogError(const std::string& what)
{
CLog::Log(LOGERROR, "%s (EGL error %d)", what.c_str(), eglGetError());
}
+
+CEGLContextUtils::CEGLContextUtils() :
+ m_eglDisplay(EGL_NO_DISPLAY),
+ m_eglSurface(EGL_NO_SURFACE),
+ m_eglContext(EGL_NO_CONTEXT),
+ m_eglConfig(0)
+{
+}
+
+CEGLContextUtils::~CEGLContextUtils()
+{
+ Destroy();
+}
+
+bool CEGLContextUtils::CreateDisplay(EGLDisplay display,
+ EGLint renderable_type,
+ EGLint rendering_api)
+{
+ EGLint neglconfigs = 0;
+ int major, minor;
+
+ EGLint surface_type = EGL_WINDOW_BIT;
+ // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
+ if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
+ g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
+ surface_type |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
+
+ EGLint attribs[] =
+ {
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_DEPTH_SIZE, 16,
+ EGL_STENCIL_SIZE, 0,
+ EGL_SAMPLE_BUFFERS, 0,
+ EGL_SAMPLES, 0,
+ EGL_SURFACE_TYPE, surface_type,
+ EGL_RENDERABLE_TYPE, renderable_type,
+ EGL_NONE
+ };
+
+#if defined(EGL_EXT_platform_base) && defined(EGL_KHR_platform_gbm) && defined(HAVE_GBM)
+ if (m_eglDisplay == EGL_NO_DISPLAY &&
+ CEGLUtils::HasExtension(EGL_NO_DISPLAY, "EGL_EXT_platform_base") &&
+ CEGLUtils::HasExtension(EGL_NO_DISPLAY, "EGL_KHR_platform_gbm"))
+ {
+ PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
+ if (getPlatformDisplayEXT)
+ {
+ m_eglDisplay = getPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, (EGLNativeDisplayType)display, NULL);
+ }
+ }
+#endif
+
+ if (m_eglDisplay == EGL_NO_DISPLAY)
+ {
+ m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
+ }
+
+ if (m_eglDisplay == EGL_NO_DISPLAY)
+ {
+ CLog::Log(LOGERROR, "failed to get EGL display");
+ return false;
+ }
+
+ if (!eglInitialize(m_eglDisplay, &major, &minor))
+ {
+ CLog::Log(LOGERROR, "failed to initialize EGL display");
+ return false;
+ }
+
+ eglBindAPI(rendering_api);
+
+ if (!eglChooseConfig(m_eglDisplay, attribs,
+ &m_eglConfig, 1, &neglconfigs))
+ {
+ CLog::Log(LOGERROR, "Failed to query number of EGL configs");
+ return false;
+ }
+
+ if (neglconfigs <= 0)
+ {
+ CLog::Log(LOGERROR, "No suitable EGL configs found");
+ return false;
+ }
+
+ return true;
+}
+
+bool CEGLContextUtils::CreateContext()
+{
+ int client_version = 2;
+
+ const EGLint context_attribs[] =
+ {
+ EGL_CONTEXT_CLIENT_VERSION, client_version, EGL_NONE
+ };
+
+ if (m_eglContext == EGL_NO_CONTEXT)
+ {
+ m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig,
+ EGL_NO_CONTEXT, context_attribs);
+ }
+
+ if (m_eglContext == EGL_NO_CONTEXT)
+ {
+ CLog::Log(LOGERROR, "failed to create EGL context");
+ return false;
+ }
+
+ return true;
+}
+
+bool CEGLContextUtils::BindContext()
+{
+ if (!eglMakeCurrent(m_eglDisplay, m_eglSurface,
+ m_eglSurface, m_eglContext))
+ {
+ CLog::Log(LOGERROR, "Failed to make context current %p %p %p",
+ m_eglDisplay, m_eglSurface, m_eglContext);
+ return false;
+ }
+
+ return true;
+}
+
+bool CEGLContextUtils::SurfaceAttrib()
+{
+ // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
+ if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
+ g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
+ {
+ if ((m_eglDisplay == EGL_NO_DISPLAY) || (m_eglSurface == EGL_NO_SURFACE))
+ {
+ return false;
+ }
+
+ if (!eglSurfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED))
+ {
+ CLog::Log(LOGDEBUG, "%s: Could not set EGL_SWAP_BEHAVIOR",__FUNCTION__);
+ }
+ }
+
+ return true;
+}
+
+bool CEGLContextUtils::CreateSurface(EGLNativeWindowType surface)
+{
+ m_eglSurface = eglCreateWindowSurface(m_eglDisplay,
+ m_eglConfig,
+ surface,
+ nullptr);
+
+ if (m_eglSurface == EGL_NO_SURFACE)
+ {
+ CLog::Log(LOGERROR, "failed to create EGL window surface %d", eglGetError());
+ return false;
+ }
+
+ return true;
+}
+
+void CEGLContextUtils::Destroy()
+{
+ if (m_eglContext != EGL_NO_CONTEXT)
+ {
+ eglDestroyContext(m_eglDisplay, m_eglContext);
+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ m_eglContext = EGL_NO_CONTEXT;
+ }
+
+ if (m_eglSurface != EGL_NO_SURFACE)
+ {
+ eglDestroySurface(m_eglDisplay, m_eglSurface);
+ m_eglSurface = EGL_NO_SURFACE;
+ }
+
+ if (m_eglDisplay != EGL_NO_DISPLAY)
+ {
+ eglTerminate(m_eglDisplay);
+ m_eglDisplay = EGL_NO_DISPLAY;
+ }
+}
+
+void CEGLContextUtils::Detach()
+{
+ if (m_eglContext != EGL_NO_CONTEXT)
+ {
+ eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ }
+
+ if (m_eglSurface != EGL_NO_SURFACE)
+ {
+ eglDestroySurface(m_eglDisplay, m_eglSurface);
+ m_eglSurface = EGL_NO_SURFACE;
+ }
+}
+
+bool CEGLContextUtils::SetVSync(bool enable)
+{
+ if (!eglSwapInterval(m_eglDisplay, enable))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+void CEGLContextUtils::SwapBuffers()
+{
+ if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
+ {
+ return;
+ }
+
+ eglSwapBuffers(m_eglDisplay, m_eglSurface);
+}
diff --git a/xbmc/utils/EGLUtils.h b/xbmc/utils/EGLUtils.h
index 3879d5a91f..665fbae826 100644
--- a/xbmc/utils/EGLUtils.h
+++ b/xbmc/utils/EGLUtils.h
@@ -118,4 +118,29 @@ public:
private:
std::array<EGLint, AttributeCount * 2 + 1> m_attributes;
int m_writePosition{};
-}; \ No newline at end of file
+};
+
+class CEGLContextUtils
+{
+public:
+ CEGLContextUtils();
+ virtual ~CEGLContextUtils();
+
+ bool CreateDisplay(EGLDisplay display,
+ EGLint renderable_type,
+ EGLint rendering_api);
+
+ bool CreateSurface(EGLNativeWindowType surface);
+ bool CreateContext();
+ bool BindContext();
+ bool SurfaceAttrib();
+ void Destroy();
+ void Detach();
+ bool SetVSync(bool enable);
+ void SwapBuffers();
+
+ EGLDisplay m_eglDisplay;
+ EGLSurface m_eglSurface;
+ EGLContext m_eglContext;
+ EGLConfig m_eglConfig;
+};
diff --git a/xbmc/windowing/amlogic/CMakeLists.txt b/xbmc/windowing/amlogic/CMakeLists.txt
index 2ad0319615..5df7176c70 100644
--- a/xbmc/windowing/amlogic/CMakeLists.txt
+++ b/xbmc/windowing/amlogic/CMakeLists.txt
@@ -1,9 +1,7 @@
-set(SOURCES GLContextEGL.cpp
- WinSystemAmlogic.cpp
+set(SOURCES WinSystemAmlogic.cpp
VideoSyncAML.cpp)
-set(HEADERS GLContextEGL.h
- WinSystemAmlogic.h
+set(HEADERS WinSystemAmlogic.h
VideoSyncAML.h)
if(OPENGLES_FOUND)
diff --git a/xbmc/windowing/amlogic/GLContextEGL.cpp b/xbmc/windowing/amlogic/GLContextEGL.cpp
deleted file mode 100644
index 91d19465d0..0000000000
--- a/xbmc/windowing/amlogic/GLContextEGL.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "GLContextEGL.h"
-
-#include "guilib/IDirtyRegionSolver.h"
-#include "settings/AdvancedSettings.h"
-#include "utils/log.h"
-
-CGLContextEGL::CGLContextEGL() :
- m_eglDisplay(EGL_NO_DISPLAY),
- m_eglSurface(EGL_NO_SURFACE),
- m_eglContext(EGL_NO_CONTEXT),
- m_eglConfig(0)
-{
-}
-
-CGLContextEGL::~CGLContextEGL()
-{
- Destroy();
-}
-
-bool CGLContextEGL::CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api)
-{
- EGLint neglconfigs = 0;
- int major, minor;
-
- EGLint surface_type = EGL_WINDOW_BIT;
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- surface_type |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
-
- EGLint attribs[] =
- {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_DEPTH_SIZE, 16,
- EGL_STENCIL_SIZE, 0,
- EGL_SAMPLE_BUFFERS, 0,
- EGL_SAMPLES, 0,
- EGL_SURFACE_TYPE, surface_type,
- EGL_RENDERABLE_TYPE, renderable_type,
- EGL_NONE
- };
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
- }
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- CLog::Log(LOGERROR, "failed to get EGL display");
- return false;
- }
-
- if (!eglInitialize(m_eglDisplay, &major, &minor))
- {
- CLog::Log(LOGERROR, "failed to initialize EGL display");
- return false;
- }
-
- eglBindAPI(rendering_api);
-
- if (!eglChooseConfig(m_eglDisplay, attribs,
- &m_eglConfig, 1, &neglconfigs))
- {
- CLog::Log(LOGERROR, "Failed to query number of EGL configs");
- return false;
- }
-
- if (neglconfigs <= 0)
- {
- CLog::Log(LOGERROR, "No suitable EGL configs found");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateContext()
-{
- int client_version = 2;
-
- const EGLint context_attribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, client_version, EGL_NONE
- };
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig,
- EGL_NO_CONTEXT, context_attribs);
- }
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- CLog::Log(LOGERROR, "failed to create EGL context");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::BindContext()
-{
- if (!eglMakeCurrent(m_eglDisplay, m_eglSurface,
- m_eglSurface, m_eglContext))
- {
- CLog::Log(LOGERROR, "Failed to make context current %p %p %p",
- m_eglDisplay, m_eglSurface, m_eglContext);
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::SurfaceAttrib()
-{
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- {
- if ((m_eglDisplay == EGL_NO_DISPLAY) || (m_eglSurface == EGL_NO_SURFACE))
- {
- return false;
- }
-
- if (!eglSurfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED))
- {
- CLog::Log(LOGDEBUG, "%s: Could not set EGL_SWAP_BEHAVIOR",__FUNCTION__);
- }
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateSurface(EGLNativeWindowType surface)
-{
- m_eglSurface = eglCreateWindowSurface(m_eglDisplay,
- m_eglConfig,
- surface,
- nullptr);
-
- if (m_eglSurface == EGL_NO_SURFACE)
- {
- CLog::Log(LOGERROR, "failed to create EGL window surface %d", eglGetError());
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::Destroy()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglDestroyContext(m_eglDisplay, m_eglContext);
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- m_eglContext = EGL_NO_CONTEXT;
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-
- if (m_eglDisplay != EGL_NO_DISPLAY)
- {
- eglTerminate(m_eglDisplay);
- m_eglDisplay = EGL_NO_DISPLAY;
- }
-}
-
-void CGLContextEGL::Detach()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-}
-
-bool CGLContextEGL::SetVSync(bool enable)
-{
- if (!eglSwapInterval(m_eglDisplay, enable))
- {
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::SwapBuffers()
-{
- if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
- {
- return;
- }
-
- eglSwapBuffers(m_eglDisplay, m_eglSurface);
-}
diff --git a/xbmc/windowing/amlogic/GLContextEGL.h b/xbmc/windowing/amlogic/GLContextEGL.h
deleted file mode 100644
index 9370684d57..0000000000
--- a/xbmc/windowing/amlogic/GLContextEGL.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "EGL/egl.h"
-
-class CGLContextEGL
-{
-public:
- CGLContextEGL();
- virtual ~CGLContextEGL();
-
- bool CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api);
-
- bool CreateSurface(EGLNativeWindowType surface);
- bool CreateContext();
- bool BindContext();
- bool SurfaceAttrib();
- void Destroy();
- void Detach();
- bool SetVSync(bool enable);
- void SwapBuffers();
-
- EGLDisplay m_eglDisplay;
- EGLSurface m_eglSurface;
- EGLContext m_eglContext;
- EGLConfig m_eglConfig;
-};
diff --git a/xbmc/windowing/amlogic/WinSystemAmlogicGLESContext.h b/xbmc/windowing/amlogic/WinSystemAmlogicGLESContext.h
index 96d9bc6b5e..200f8b49fa 100644
--- a/xbmc/windowing/amlogic/WinSystemAmlogicGLESContext.h
+++ b/xbmc/windowing/amlogic/WinSystemAmlogicGLESContext.h
@@ -20,7 +20,7 @@
#pragma once
-#include "GLContextEGL.h"
+#include "utils/EGLUtils.h"
#include "rendering/gles/RenderSystemGLES.h"
#include "utils/GlobalsHandling.h"
#include "WinSystemAmlogic.h"
@@ -52,7 +52,7 @@ protected:
void PresentRenderImpl(bool rendered) override;
private:
- CGLContextEGL m_pGLContext;
+ CEGLContextUtils m_pGLContext;
};
diff --git a/xbmc/windowing/android/CMakeLists.txt b/xbmc/windowing/android/CMakeLists.txt
index 5d248630a3..a10c9e4980 100644
--- a/xbmc/windowing/android/CMakeLists.txt
+++ b/xbmc/windowing/android/CMakeLists.txt
@@ -1,11 +1,9 @@
-set(SOURCES GLContextEGL.cpp
- WinEventsAndroid.cpp
+set(SOURCES WinEventsAndroid.cpp
WinSystemAndroid.cpp
AndroidUtils.cpp
VideoSyncAndroid.cpp)
-set(HEADERS GLContextEGL.h
- WinEventsAndroid.h
+set(HEADERS WinEventsAndroid.h
WinSystemAndroid.h
AndroidUtils.h
VideoSyncAndroid.h)
diff --git a/xbmc/windowing/android/GLContextEGL.cpp b/xbmc/windowing/android/GLContextEGL.cpp
deleted file mode 100644
index 91d19465d0..0000000000
--- a/xbmc/windowing/android/GLContextEGL.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "GLContextEGL.h"
-
-#include "guilib/IDirtyRegionSolver.h"
-#include "settings/AdvancedSettings.h"
-#include "utils/log.h"
-
-CGLContextEGL::CGLContextEGL() :
- m_eglDisplay(EGL_NO_DISPLAY),
- m_eglSurface(EGL_NO_SURFACE),
- m_eglContext(EGL_NO_CONTEXT),
- m_eglConfig(0)
-{
-}
-
-CGLContextEGL::~CGLContextEGL()
-{
- Destroy();
-}
-
-bool CGLContextEGL::CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api)
-{
- EGLint neglconfigs = 0;
- int major, minor;
-
- EGLint surface_type = EGL_WINDOW_BIT;
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- surface_type |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
-
- EGLint attribs[] =
- {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_DEPTH_SIZE, 16,
- EGL_STENCIL_SIZE, 0,
- EGL_SAMPLE_BUFFERS, 0,
- EGL_SAMPLES, 0,
- EGL_SURFACE_TYPE, surface_type,
- EGL_RENDERABLE_TYPE, renderable_type,
- EGL_NONE
- };
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
- }
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- CLog::Log(LOGERROR, "failed to get EGL display");
- return false;
- }
-
- if (!eglInitialize(m_eglDisplay, &major, &minor))
- {
- CLog::Log(LOGERROR, "failed to initialize EGL display");
- return false;
- }
-
- eglBindAPI(rendering_api);
-
- if (!eglChooseConfig(m_eglDisplay, attribs,
- &m_eglConfig, 1, &neglconfigs))
- {
- CLog::Log(LOGERROR, "Failed to query number of EGL configs");
- return false;
- }
-
- if (neglconfigs <= 0)
- {
- CLog::Log(LOGERROR, "No suitable EGL configs found");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateContext()
-{
- int client_version = 2;
-
- const EGLint context_attribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, client_version, EGL_NONE
- };
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig,
- EGL_NO_CONTEXT, context_attribs);
- }
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- CLog::Log(LOGERROR, "failed to create EGL context");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::BindContext()
-{
- if (!eglMakeCurrent(m_eglDisplay, m_eglSurface,
- m_eglSurface, m_eglContext))
- {
- CLog::Log(LOGERROR, "Failed to make context current %p %p %p",
- m_eglDisplay, m_eglSurface, m_eglContext);
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::SurfaceAttrib()
-{
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- {
- if ((m_eglDisplay == EGL_NO_DISPLAY) || (m_eglSurface == EGL_NO_SURFACE))
- {
- return false;
- }
-
- if (!eglSurfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED))
- {
- CLog::Log(LOGDEBUG, "%s: Could not set EGL_SWAP_BEHAVIOR",__FUNCTION__);
- }
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateSurface(EGLNativeWindowType surface)
-{
- m_eglSurface = eglCreateWindowSurface(m_eglDisplay,
- m_eglConfig,
- surface,
- nullptr);
-
- if (m_eglSurface == EGL_NO_SURFACE)
- {
- CLog::Log(LOGERROR, "failed to create EGL window surface %d", eglGetError());
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::Destroy()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglDestroyContext(m_eglDisplay, m_eglContext);
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- m_eglContext = EGL_NO_CONTEXT;
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-
- if (m_eglDisplay != EGL_NO_DISPLAY)
- {
- eglTerminate(m_eglDisplay);
- m_eglDisplay = EGL_NO_DISPLAY;
- }
-}
-
-void CGLContextEGL::Detach()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-}
-
-bool CGLContextEGL::SetVSync(bool enable)
-{
- if (!eglSwapInterval(m_eglDisplay, enable))
- {
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::SwapBuffers()
-{
- if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
- {
- return;
- }
-
- eglSwapBuffers(m_eglDisplay, m_eglSurface);
-}
diff --git a/xbmc/windowing/android/GLContextEGL.h b/xbmc/windowing/android/GLContextEGL.h
deleted file mode 100644
index 9370684d57..0000000000
--- a/xbmc/windowing/android/GLContextEGL.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "EGL/egl.h"
-
-class CGLContextEGL
-{
-public:
- CGLContextEGL();
- virtual ~CGLContextEGL();
-
- bool CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api);
-
- bool CreateSurface(EGLNativeWindowType surface);
- bool CreateContext();
- bool BindContext();
- bool SurfaceAttrib();
- void Destroy();
- void Detach();
- bool SetVSync(bool enable);
- void SwapBuffers();
-
- EGLDisplay m_eglDisplay;
- EGLSurface m_eglSurface;
- EGLContext m_eglContext;
- EGLConfig m_eglConfig;
-};
diff --git a/xbmc/windowing/android/WinSystemAndroidGLESContext.h b/xbmc/windowing/android/WinSystemAndroidGLESContext.h
index 6ad852bda9..0cdabc3eda 100644
--- a/xbmc/windowing/android/WinSystemAndroidGLESContext.h
+++ b/xbmc/windowing/android/WinSystemAndroidGLESContext.h
@@ -20,7 +20,7 @@
#pragma once
-#include "GLContextEGL.h"
+#include "utils/EGLUtils.h"
#include "rendering/gles/RenderSystemGLES.h"
#include "utils/GlobalsHandling.h"
#include "WinSystemAndroid.h"
@@ -52,7 +52,7 @@ protected:
void PresentRenderImpl(bool rendered) override;
private:
- CGLContextEGL m_pGLContext;
+ CEGLContextUtils m_pGLContext;
};
diff --git a/xbmc/windowing/gbm/CMakeLists.txt b/xbmc/windowing/gbm/CMakeLists.txt
index 53de4bac91..692561382e 100644
--- a/xbmc/windowing/gbm/CMakeLists.txt
+++ b/xbmc/windowing/gbm/CMakeLists.txt
@@ -1,5 +1,4 @@
set(SOURCES OptionalsReg.cpp
- GLContextEGL.cpp
WinSystemGbm.cpp
GBMUtils.cpp
DRMUtils.cpp
@@ -7,7 +6,6 @@ set(SOURCES OptionalsReg.cpp
DRMAtomic.cpp)
set(HEADERS OptionalsReg.h
- GLContextEGL.h
WinSystemGbm.h
GBMUtils.h
DRMUtils.h
diff --git a/xbmc/windowing/gbm/GLContextEGL.cpp b/xbmc/windowing/gbm/GLContextEGL.cpp
deleted file mode 100644
index 52b58082ab..0000000000
--- a/xbmc/windowing/gbm/GLContextEGL.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "GLContextEGL.h"
-
-#include "guilib/IDirtyRegionSolver.h"
-#include "settings/AdvancedSettings.h"
-#include "utils/log.h"
-
-#include <EGL/eglext.h>
-#include <string.h>
-
-CGLContextEGL::CGLContextEGL() :
- m_eglDisplay(EGL_NO_DISPLAY),
- m_eglSurface(EGL_NO_SURFACE),
- m_eglContext(EGL_NO_CONTEXT),
- m_eglConfig(0)
-{
-}
-
-CGLContextEGL::~CGLContextEGL()
-{
- Destroy();
-}
-
-bool CGLContextEGL::CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api)
-{
- EGLint neglconfigs = 0;
- int major, minor;
-
- EGLint surface_type = EGL_WINDOW_BIT;
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- surface_type |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
-
- EGLint attribs[] =
- {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_DEPTH_SIZE, 16,
- EGL_STENCIL_SIZE, 0,
- EGL_SAMPLE_BUFFERS, 0,
- EGL_SAMPLES, 0,
- EGL_SURFACE_TYPE, surface_type,
- EGL_RENDERABLE_TYPE, renderable_type,
- EGL_NONE
- };
-
- const char *client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
- CLog::Log(LOGNOTICE, "EGL_EXTENSIONS = %s", client_extensions);
-
-#if defined(EGL_EXT_platform_base) && defined(EGL_KHR_platform_gbm)
- if (m_eglDisplay == EGL_NO_DISPLAY &&
- client_extensions != NULL &&
- strstr(client_extensions, "EGL_EXT_platform_base") &&
- strstr(client_extensions, "EGL_KHR_platform_gbm"))
- {
- PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
- if (getPlatformDisplayEXT)
- {
- m_eglDisplay = getPlatformDisplayEXT(EGL_PLATFORM_GBM_KHR, (EGLNativeDisplayType)display, NULL);
- }
- }
-#endif
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
- }
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- CLog::Log(LOGERROR, "failed to get EGL display");
- return false;
- }
-
- if (!eglInitialize(m_eglDisplay, &major, &minor))
- {
- CLog::Log(LOGERROR, "failed to initialize EGL display");
- return false;
- }
-
- eglBindAPI(rendering_api);
-
- if (!eglChooseConfig(m_eglDisplay, attribs,
- &m_eglConfig, 1, &neglconfigs))
- {
- CLog::Log(LOGERROR, "Failed to query number of EGL configs");
- return false;
- }
-
- if (neglconfigs <= 0)
- {
- CLog::Log(LOGERROR, "No suitable EGL configs found");
- return false;
- }
-
- const char *display_extensions = eglQueryString(m_eglDisplay, EGL_EXTENSIONS);
- CLog::Log(LOGNOTICE, "EGL_EXTENSIONS = %s", display_extensions);
-
- return true;
-}
-
-bool CGLContextEGL::CreateContext()
-{
- int client_version = 2;
-
- const EGLint context_attribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, client_version, EGL_NONE
- };
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig,
- EGL_NO_CONTEXT, context_attribs);
- }
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- CLog::Log(LOGERROR, "failed to create EGL context");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::BindContext()
-{
- if (!eglMakeCurrent(m_eglDisplay, m_eglSurface,
- m_eglSurface, m_eglContext))
- {
- CLog::Log(LOGERROR, "Failed to make context current %p %p %p",
- m_eglDisplay, m_eglSurface, m_eglContext);
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::SurfaceAttrib()
-{
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- {
- if ((m_eglDisplay == EGL_NO_DISPLAY) || (m_eglSurface == EGL_NO_SURFACE))
- {
- return false;
- }
-
- if (!eglSurfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED))
- {
- CLog::Log(LOGDEBUG, "%s: Could not set EGL_SWAP_BEHAVIOR",__FUNCTION__);
- }
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateSurface(EGLNativeWindowType surface)
-{
- m_eglSurface = eglCreateWindowSurface(m_eglDisplay,
- m_eglConfig,
- surface,
- nullptr);
-
- if (m_eglSurface == EGL_NO_SURFACE)
- {
- CLog::Log(LOGERROR, "failed to create EGL window surface %d", eglGetError());
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::Destroy()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglDestroyContext(m_eglDisplay, m_eglContext);
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- m_eglContext = EGL_NO_CONTEXT;
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-
- if (m_eglDisplay != EGL_NO_DISPLAY)
- {
- eglTerminate(m_eglDisplay);
- m_eglDisplay = EGL_NO_DISPLAY;
- }
-}
-
-void CGLContextEGL::Detach()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-}
-
-bool CGLContextEGL::SetVSync(bool enable)
-{
- if (!eglSwapInterval(m_eglDisplay, enable))
- {
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::SwapBuffers()
-{
- if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
- {
- return;
- }
-
- eglSwapBuffers(m_eglDisplay, m_eglSurface);
-}
diff --git a/xbmc/windowing/gbm/GLContextEGL.h b/xbmc/windowing/gbm/GLContextEGL.h
deleted file mode 100644
index 9370684d57..0000000000
--- a/xbmc/windowing/gbm/GLContextEGL.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "EGL/egl.h"
-
-class CGLContextEGL
-{
-public:
- CGLContextEGL();
- virtual ~CGLContextEGL();
-
- bool CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api);
-
- bool CreateSurface(EGLNativeWindowType surface);
- bool CreateContext();
- bool BindContext();
- bool SurfaceAttrib();
- void Destroy();
- void Detach();
- bool SetVSync(bool enable);
- void SwapBuffers();
-
- EGLDisplay m_eglDisplay;
- EGLSurface m_eglSurface;
- EGLContext m_eglContext;
- EGLConfig m_eglConfig;
-};
diff --git a/xbmc/windowing/gbm/WinSystemGbm.cpp b/xbmc/windowing/gbm/WinSystemGbm.cpp
index 561e61f12e..906b53783d 100644
--- a/xbmc/windowing/gbm/WinSystemGbm.cpp
+++ b/xbmc/windowing/gbm/WinSystemGbm.cpp
@@ -40,8 +40,6 @@
CWinSystemGbm::CWinSystemGbm() :
m_DRM(nullptr),
m_GBM(new CGBMUtils),
- m_nativeDisplay(nullptr),
- m_nativeWindow(nullptr),
m_delayDispReset(false)
{
std::string envSink;
@@ -99,8 +97,6 @@ bool CWinSystemGbm::InitWindowSystem()
return false;
}
- m_nativeDisplay = m_GBM->m_device;
-
CLog::Log(LOGDEBUG, "CWinSystemGbm::%s - initialized DRM", __FUNCTION__);
return CWinSystemBase::InitWindowSystem();
}
@@ -108,10 +104,7 @@ bool CWinSystemGbm::InitWindowSystem()
bool CWinSystemGbm::DestroyWindowSystem()
{
m_GBM->DestroySurface();
- m_nativeWindow = nullptr;
-
m_GBM->DestroyDevice();
- m_nativeDisplay = nullptr;
CLog::Log(LOGDEBUG, "CWinSystemGbm::%s - deinitialized DRM", __FUNCTION__);
return true;
@@ -136,8 +129,6 @@ bool CWinSystemGbm::CreateNewWindow(const std::string& name,
return false;
}
- m_nativeWindow = reinterpret_cast<EGLNativeWindowType>(m_GBM->m_surface);
-
CLog::Log(LOGDEBUG, "CWinSystemGbm::%s - initialized GBM", __FUNCTION__);
return true;
}
@@ -145,7 +136,6 @@ bool CWinSystemGbm::CreateNewWindow(const std::string& name,
bool CWinSystemGbm::DestroyWindow()
{
m_GBM->DestroySurface();
- m_nativeWindow = nullptr;
CLog::Log(LOGDEBUG, "CWinSystemGbm::%s - deinitialized GBM", __FUNCTION__);
return true;
diff --git a/xbmc/windowing/gbm/WinSystemGbm.h b/xbmc/windowing/gbm/WinSystemGbm.h
index 5ad76c273e..87a5afcbae 100644
--- a/xbmc/windowing/gbm/WinSystemGbm.h
+++ b/xbmc/windowing/gbm/WinSystemGbm.h
@@ -26,7 +26,6 @@
#include "threads/CriticalSection.h"
#include "windowing/WinSystem.h"
#include "DRMUtils.h"
-#include "GLContextEGL.h"
class IDispResource;
@@ -65,9 +64,6 @@ protected:
std::unique_ptr<CGBMUtils> m_GBM;
- EGLDisplay m_nativeDisplay;
- EGLNativeWindowType m_nativeWindow;
-
CCriticalSection m_resourceSection;
std::vector<IDispResource*> m_resources;
diff --git a/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp b/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp
index 8a3f2432df..b06ae324e5 100644
--- a/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp
+++ b/xbmc/windowing/gbm/WinSystemGbmGLESContext.cpp
@@ -50,7 +50,7 @@ bool CWinSystemGbmGLESContext::InitWindowSystem()
return false;
}
- if (!m_pGLContext.CreateDisplay(m_nativeDisplay,
+ if (!m_pGLContext.CreateDisplay(m_GBM->m_device,
EGL_OPENGL_ES2_BIT,
EGL_OPENGL_ES_API))
{
@@ -99,7 +99,7 @@ bool CWinSystemGbmGLESContext::CreateNewWindow(const std::string& name,
return false;
}
- if (!m_pGLContext.CreateSurface(m_nativeWindow))
+ if (!m_pGLContext.CreateSurface(reinterpret_cast<EGLNativeWindowType>(m_GBM->m_surface)))
{
return false;
}
diff --git a/xbmc/windowing/gbm/WinSystemGbmGLESContext.h b/xbmc/windowing/gbm/WinSystemGbmGLESContext.h
index 5ea45390aa..d422fd3065 100644
--- a/xbmc/windowing/gbm/WinSystemGbmGLESContext.h
+++ b/xbmc/windowing/gbm/WinSystemGbmGLESContext.h
@@ -20,7 +20,7 @@
#pragma once
-#include "GLContextEGL.h"
+#include "utils/EGLUtils.h"
#include "rendering/gles/RenderSystemGLES.h"
#include "WinSystemGbm.h"
#include <memory>
@@ -52,7 +52,7 @@ protected:
void PresentRenderImpl(bool rendered) override {};
private:
- CGLContextEGL m_pGLContext;
+ CEGLContextUtils m_pGLContext;
struct delete_CVaapiProxy
{
void operator()(CVaapiProxy *p) const;
diff --git a/xbmc/windowing/rpi/CMakeLists.txt b/xbmc/windowing/rpi/CMakeLists.txt
index f19dd6c0e4..f42c6419fc 100644
--- a/xbmc/windowing/rpi/CMakeLists.txt
+++ b/xbmc/windowing/rpi/CMakeLists.txt
@@ -1,10 +1,8 @@
-set(SOURCES GLContextEGL.cpp
- WinSystemRpi.cpp
+set(SOURCES WinSystemRpi.cpp
RPIUtils.cpp
VideoSyncPi.cpp)
-set(HEADERS GLContextEGL.h
- WinSystemRpi.h
+set(HEADERS WinSystemRpi.h
RPIUtils.h
VideoSyncPi.h)
diff --git a/xbmc/windowing/rpi/GLContextEGL.cpp b/xbmc/windowing/rpi/GLContextEGL.cpp
deleted file mode 100644
index 91d19465d0..0000000000
--- a/xbmc/windowing/rpi/GLContextEGL.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "GLContextEGL.h"
-
-#include "guilib/IDirtyRegionSolver.h"
-#include "settings/AdvancedSettings.h"
-#include "utils/log.h"
-
-CGLContextEGL::CGLContextEGL() :
- m_eglDisplay(EGL_NO_DISPLAY),
- m_eglSurface(EGL_NO_SURFACE),
- m_eglContext(EGL_NO_CONTEXT),
- m_eglConfig(0)
-{
-}
-
-CGLContextEGL::~CGLContextEGL()
-{
- Destroy();
-}
-
-bool CGLContextEGL::CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api)
-{
- EGLint neglconfigs = 0;
- int major, minor;
-
- EGLint surface_type = EGL_WINDOW_BIT;
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- surface_type |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
-
- EGLint attribs[] =
- {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_DEPTH_SIZE, 16,
- EGL_STENCIL_SIZE, 0,
- EGL_SAMPLE_BUFFERS, 0,
- EGL_SAMPLES, 0,
- EGL_SURFACE_TYPE, surface_type,
- EGL_RENDERABLE_TYPE, renderable_type,
- EGL_NONE
- };
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)display);
- }
-
- if (m_eglDisplay == EGL_NO_DISPLAY)
- {
- CLog::Log(LOGERROR, "failed to get EGL display");
- return false;
- }
-
- if (!eglInitialize(m_eglDisplay, &major, &minor))
- {
- CLog::Log(LOGERROR, "failed to initialize EGL display");
- return false;
- }
-
- eglBindAPI(rendering_api);
-
- if (!eglChooseConfig(m_eglDisplay, attribs,
- &m_eglConfig, 1, &neglconfigs))
- {
- CLog::Log(LOGERROR, "Failed to query number of EGL configs");
- return false;
- }
-
- if (neglconfigs <= 0)
- {
- CLog::Log(LOGERROR, "No suitable EGL configs found");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateContext()
-{
- int client_version = 2;
-
- const EGLint context_attribs[] = {
- EGL_CONTEXT_CLIENT_VERSION, client_version, EGL_NONE
- };
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig,
- EGL_NO_CONTEXT, context_attribs);
- }
-
- if (m_eglContext == EGL_NO_CONTEXT)
- {
- CLog::Log(LOGERROR, "failed to create EGL context");
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::BindContext()
-{
- if (!eglMakeCurrent(m_eglDisplay, m_eglSurface,
- m_eglSurface, m_eglContext))
- {
- CLog::Log(LOGERROR, "Failed to make context current %p %p %p",
- m_eglDisplay, m_eglSurface, m_eglContext);
- return false;
- }
-
- return true;
-}
-
-bool CGLContextEGL::SurfaceAttrib()
-{
- // for the non-trivial dirty region modes, we need the EGL buffer to be preserved across updates
- if (g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_COST_REDUCTION ||
- g_advancedSettings.m_guiAlgorithmDirtyRegions == DIRTYREGION_SOLVER_UNION)
- {
- if ((m_eglDisplay == EGL_NO_DISPLAY) || (m_eglSurface == EGL_NO_SURFACE))
- {
- return false;
- }
-
- if (!eglSurfaceAttrib(m_eglDisplay, m_eglSurface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED))
- {
- CLog::Log(LOGDEBUG, "%s: Could not set EGL_SWAP_BEHAVIOR",__FUNCTION__);
- }
- }
-
- return true;
-}
-
-bool CGLContextEGL::CreateSurface(EGLNativeWindowType surface)
-{
- m_eglSurface = eglCreateWindowSurface(m_eglDisplay,
- m_eglConfig,
- surface,
- nullptr);
-
- if (m_eglSurface == EGL_NO_SURFACE)
- {
- CLog::Log(LOGERROR, "failed to create EGL window surface %d", eglGetError());
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::Destroy()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglDestroyContext(m_eglDisplay, m_eglContext);
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- m_eglContext = EGL_NO_CONTEXT;
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-
- if (m_eglDisplay != EGL_NO_DISPLAY)
- {
- eglTerminate(m_eglDisplay);
- m_eglDisplay = EGL_NO_DISPLAY;
- }
-}
-
-void CGLContextEGL::Detach()
-{
- if (m_eglContext != EGL_NO_CONTEXT)
- {
- eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- }
-
- if (m_eglSurface != EGL_NO_SURFACE)
- {
- eglDestroySurface(m_eglDisplay, m_eglSurface);
- m_eglSurface = EGL_NO_SURFACE;
- }
-}
-
-bool CGLContextEGL::SetVSync(bool enable)
-{
- if (!eglSwapInterval(m_eglDisplay, enable))
- {
- return false;
- }
-
- return true;
-}
-
-void CGLContextEGL::SwapBuffers()
-{
- if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
- {
- return;
- }
-
- eglSwapBuffers(m_eglDisplay, m_eglSurface);
-}
diff --git a/xbmc/windowing/rpi/GLContextEGL.h b/xbmc/windowing/rpi/GLContextEGL.h
deleted file mode 100644
index 9370684d57..0000000000
--- a/xbmc/windowing/rpi/GLContextEGL.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://kodi.tv
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "EGL/egl.h"
-
-class CGLContextEGL
-{
-public:
- CGLContextEGL();
- virtual ~CGLContextEGL();
-
- bool CreateDisplay(EGLDisplay display,
- EGLint renderable_type,
- EGLint rendering_api);
-
- bool CreateSurface(EGLNativeWindowType surface);
- bool CreateContext();
- bool BindContext();
- bool SurfaceAttrib();
- void Destroy();
- void Detach();
- bool SetVSync(bool enable);
- void SwapBuffers();
-
- EGLDisplay m_eglDisplay;
- EGLSurface m_eglSurface;
- EGLContext m_eglContext;
- EGLConfig m_eglConfig;
-};
diff --git a/xbmc/windowing/rpi/WinSystemRpiGLESContext.h b/xbmc/windowing/rpi/WinSystemRpiGLESContext.h
index d70293dc8c..632b1b639b 100644
--- a/xbmc/windowing/rpi/WinSystemRpiGLESContext.h
+++ b/xbmc/windowing/rpi/WinSystemRpiGLESContext.h
@@ -20,7 +20,7 @@
#pragma once
-#include "GLContextEGL.h"
+#include "utils/EGLUtils.h"
#include "rendering/gles/RenderSystemGLES.h"
#include "WinSystemRpi.h"
@@ -51,6 +51,6 @@ protected:
void PresentRenderImpl(bool rendered) override;
private:
- CGLContextEGL m_pGLContext;
+ CEGLContextUtils m_pGLContext;
};