diff options
-rw-r--r-- | xbmc/windowing/amlogic/CMakeLists.txt | 6 | ||||
-rw-r--r-- | xbmc/windowing/amlogic/GLContextEGL.cpp | 229 | ||||
-rw-r--r-- | xbmc/windowing/amlogic/GLContextEGL.h | 48 | ||||
-rw-r--r-- | xbmc/windowing/amlogic/WinSystemAmlogicGLESContext.h | 4 |
4 files changed, 4 insertions, 283 deletions
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 3647c71af0..99dbf035a5 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" @@ -50,7 +50,7 @@ protected: void PresentRenderImpl(bool rendered) override; private: - CGLContextEGL m_pGLContext; + CEGLContextUtils m_pGLContext; }; |