Skip to content
Browse files

[droid] add nasty EGL changes. This needs to be redone.

  • Loading branch information...
1 parent 9f0558d commit f6ecaea0a4b653acf7d50512f7d8f7919c803c87 Cory Fields committed Jul 12, 2012
View
3 xbmc/windowing/WinSystem.h
@@ -33,7 +33,8 @@ typedef enum _WindowSystemType
WINDOW_SYSTEM_IOS,
WINDOW_SYSTEM_X11,
WINDOW_SYSTEM_SDL,
- WINDOW_SYSTEM_EGL
+ WINDOW_SYSTEM_EGL,
+ WINDOW_SYSTEM_ANDROID
} WindowSystemType;
struct RESOLUTION_WHR
View
2 xbmc/windowing/WindowingFactory.h
@@ -36,7 +36,7 @@
#elif defined(TARGET_LINUX) && defined(HAS_GLES) && defined(HAVE_X11)
#include "X11/WinSystemX11GLES.h"
-#elif defined(TARGET_LINUX) && defined(HAS_GLES) && defined(HAS_EGL)
+#elif defined(TARGET_LINUX) && defined(HAS_GLES) && defined(HAS_EGL)
#include "egl/WinSystemGLES.h"
#elif defined(TARGET_FREEBSD) && defined(HAS_GL) && defined(HAVE_X11)
View
9 xbmc/windowing/egl/Makefile
@@ -1,9 +1,10 @@
-INCLUDES=-I. -I../.. -I../../linux
+INCLUDES=-I.
-SRCS=WinBindingEGL.cpp \
- WinSystemGLES.cpp \
+SRCS = WinSystemGLES.cpp
+SRCS+= WinEGLPlatformGeneric.cpp
+SRCS+= WinEGLPlatformAndroid.cpp
-LIB=windowing_egl.a
+LIB = windowing_egl.a
include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
View
39 xbmc/windowing/egl/WinEGLPlatform.h
@@ -0,0 +1,39 @@
+#pragma once
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * 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, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#ifdef HAS_EGL
+
+#include "system.h"
+
+#if defined(TARGET_ANDROID)
+ #include "xbmc/windowing/egl/WinEGLPlatformAndroid.h"
+ class CWinEGLPlatformAndroid;
+ #define CWinEGLPlatform CWinEGLPlatformAndroid
+
+#else
+ #include "xbmc/windowing/egl/WinEGLPlatformGeneric.h"
+ class CWinEGLPlatformGeneric;
+ #define CWinEGLPlatform CWinEGLPlatformGeneric
+
+#endif
+
+#endif
View
71 xbmc/windowing/egl/WinEGLPlatformAndroid.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * 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, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <linux/fb.h>
+#include <sys/ioctl.h>
+
+#include "WinEGLPlatformAndroid.h"
+#include "android/activity/XBMCApp.h"
+////////////////////////////////////////////////////////////////////////////////////////////
+EGLNativeWindowType CWinEGLPlatformAndroid::InitWindowSystem(EGLNativeDisplayType nativeDisplay, int width, int height, int bpp)
+{
+ if (CXBMCApp::GetNativeWindow() == NULL)
+ return 0;
+
+ CWinEGLPlatformGeneric::InitWindowSystem(nativeDisplay, width, height, bpp);
+
+ return getNativeWindow();
+}
+
+void CWinEGLPlatformAndroid::DestroyWindowSystem(EGLNativeWindowType native_window)
+{
+ CWinEGLPlatformGeneric::DestroyWindowSystem(native_window);
+}
+
+bool CWinEGLPlatformAndroid::ClampToGUIDisplayLimits(int &width, int &height)
+{
+ return false;
+}
+
+bool CWinEGLPlatformAndroid::CreateWindow()
+{
+ EGLint format;
+ // EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
+ // guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
+ // As soon as we picked a EGLConfig, we can safely reconfigure the
+ // ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID.
+ eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &format);
+
+ CXBMCApp::SetBuffersGeometry(0, 0, format);
+
+ CWinEGLPlatformGeneric::CreateWindow();
+ return true;
+}
+
+EGLNativeWindowType CWinEGLPlatformAndroid::getNativeWindow()
+{
+ return (EGLNativeWindowType)CXBMCApp::GetNativeWindow();
+}
View
40 xbmc/windowing/egl/WinEGLPlatformAndroid.h
@@ -0,0 +1,40 @@
+#pragma once
+/*
+ * Copyright (C) 2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * 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, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#if defined(TARGET_ANDROID)
+
+#include "WinEGLPlatformGeneric.h"
+
+class CWinEGLPlatformAndroid : public CWinEGLPlatformGeneric
+{
+public:
+ virtual EGLNativeWindowType InitWindowSystem(EGLNativeDisplayType nativeDisplay, int width, int height, int bpp);
+ virtual void DestroyWindowSystem(EGLNativeWindowType native_window);
+ virtual bool ClampToGUIDisplayLimits(int &width, int &height);
+
+ virtual bool CreateWindow();
+
+protected:
+ virtual EGLNativeWindowType getNativeWindow();
+};
+
+#endif
View
214 xbmc/windowing/egl/WinBindingEGL.cpp → xbmc/windowing/egl/WinEGLPlatformGeneric.cpp
@@ -25,62 +25,80 @@
#ifdef HAS_EGL
-#include "WinBindingEGL.h"
+#include "WinEGLPlatformGeneric.h"
#include "utils/log.h"
#include <string>
-CWinBindingEGL::CWinBindingEGL()
+CWinEGLPlatformGeneric::CWinEGLPlatformGeneric()
{
m_surface = EGL_NO_SURFACE;
m_context = EGL_NO_CONTEXT;
m_display = EGL_NO_DISPLAY;
+
+ // most egl platforms cannot render 1080p
+ // default to 720p
+ m_width = 1280;
+ m_height = 720;
}
-CWinBindingEGL::~CWinBindingEGL()
+CWinEGLPlatformGeneric::~CWinEGLPlatformGeneric()
{
- DestroyWindow();
+ UninitializeDisplay();
}
-bool CWinBindingEGL::ReleaseSurface()
+EGLNativeWindowType CWinEGLPlatformGeneric::InitWindowSystem(EGLNativeDisplayType nativeDisplay, int width, int height, int bpp)
{
- EGLBoolean eglStatus;
+ m_nativeDisplay = nativeDisplay;
+ m_width = width;
+ m_height = height;
- if (m_surface == EGL_NO_SURFACE)
- {
- return true;
- }
+ return getNativeWindow();
+}
- eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+void CWinEGLPlatformGeneric::DestroyWindowSystem(EGLNativeWindowType native_window)
+{
+ UninitializeDisplay();
+}
- eglStatus = eglDestroySurface(m_display, m_surface);
- if (!eglStatus)
- {
- CLog::Log(LOGERROR, "Error destroying EGL surface");
- return false;
- }
+bool CWinEGLPlatformGeneric::SetDisplayResolution(int width, int height, float refresh, bool interlace)
+{
+ return false;
+}
- m_surface = EGL_NO_SURFACE;
+bool CWinEGLPlatformGeneric::ClampToGUIDisplayLimits(int &width, int &height)
+{
+ width = m_width;
+ height = m_height;
+ return true;
+}
+bool CWinEGLPlatformGeneric::ProbeDisplayResolutions(std::vector<CStdString> &resolutions)
+{
+ resolutions.clear();
+
+ CStdString resolution;
+ resolution.Format("%dx%dp60Hz", m_width, m_height);
+ resolutions.push_back(resolution);
return true;
}
-bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeWindowType nativeWindow)
+bool CWinEGLPlatformGeneric::InitializeDisplay()
{
+ if (m_display != EGL_NO_DISPLAY && m_config != NULL)
+ return true;
+
EGLBoolean eglStatus;
EGLint configCount;
- EGLConfig* configList = NULL;
+ EGLConfig* configList = NULL;
- m_nativeDisplay = nativeDisplay;
- m_nativeWindow = nativeWindow;
-
- m_display = eglGetDisplay(nativeDisplay);
+ m_display = eglGetDisplay(m_nativeDisplay);
if (m_display == EGL_NO_DISPLAY)
{
CLog::Log(LOGERROR, "EGL failed to obtain display");
return false;
}
-
+
if (!eglInitialize(m_display, 0, 0))
{
CLog::Log(LOGERROR, "EGL failed to initialize");
@@ -91,6 +109,7 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
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,
@@ -107,7 +126,7 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
CLog::Log(LOGERROR, "EGL failed to return any matching configurations: %d", eglStatus);
return false;
}
-
+
// Allocate room for the list of matching configurations
configList = (EGLConfig*)malloc(configCount * sizeof(EGLConfig));
if (!configList)
@@ -124,22 +143,108 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
CLog::Log(LOGERROR, "EGL failed to populate configuration list: %d", eglStatus);
return false;
}
-
+
// Select an EGL configuration that matches the native window
m_config = configList[0];
if (m_surface != EGL_NO_SURFACE)
- {
ReleaseSurface();
+
+ free(configList);
+ return true;
+}
+
+bool CWinEGLPlatformGeneric::UninitializeDisplay()
+{
+ EGLBoolean eglStatus;
+
+ DestroyWindow();
+
+ if (m_display != EGL_NO_DISPLAY)
+ {
+ eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+ eglStatus = eglTerminate(m_display);
+ if (!eglStatus)
+ CLog::Log(LOGERROR, "Error terminating EGL");
+ m_display = EGL_NO_DISPLAY;
+ }
+
+ return true;
+}
+
+bool CWinEGLPlatformGeneric::CreateWindow()
+{
+ if (m_display == EGL_NO_DISPLAY || m_config == NULL)
+ {
+ if (!InitializeDisplay())
+ return false;
}
+
+ if (m_surface != EGL_NO_SURFACE)
+ return true;
+
+ m_nativeWindow = getNativeWindow();
m_surface = eglCreateWindowSurface(m_display, m_config, m_nativeWindow, NULL);
if (!m_surface)
- {
+ {
CLog::Log(LOGERROR, "EGL couldn't create window surface");
return false;
}
+ // Let's get the current width and height
+ EGLint width, height;
+ if (!eglQuerySurface(m_display, m_surface, EGL_WIDTH, &width) || !eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &height) ||
+ width <= 0 || height <= 0)
+ {
+ CLog::Log(LOGERROR, "EGL couldn't provide the surface's width and/or height");
+ return false;
+ }
+
+ m_width = width;
+ m_height = height;
+
+ return true;
+}
+
+bool CWinEGLPlatformGeneric::DestroyWindow()
+{
+ EGLBoolean eglStatus;
+
+ ReleaseSurface();
+
+ if (m_surface == EGL_NO_SURFACE)
+ return true;
+
+ eglStatus = eglDestroySurface(m_display, m_surface);
+ if (!eglStatus)
+ {
+ CLog::Log(LOGERROR, "Error destroying EGL surface");
+ return false;
+ }
+
+ m_surface = EGL_NO_SURFACE;
+ m_width = 0;
+ m_height = 0;
+
+ return true;
+}
+
+bool CWinEGLPlatformGeneric::BindSurface()
+{
+ EGLBoolean eglStatus;
+
+ if (m_display == EGL_NO_DISPLAY || m_surface == EGL_NO_SURFACE || m_config == NULL)
+ {
+ CLog::Log(LOGINFO, "EGL not configured correctly. Let's try to do that now...");
+ if (!CreateWindow())
+ {
+ CLog::Log(LOGERROR, "EGL not configured correctly to create a surface");
+ return false;
+ }
+ }
+
eglStatus = eglBindAPI(EGL_OPENGL_ES_API);
if (!eglStatus)
{
@@ -171,8 +276,6 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
CLog::Log(LOGERROR, "EGL couldn't make context/surface current: %d", eglStatus);
return false;
}
-
- free(configList);
eglSwapInterval(m_display, 0);
@@ -203,9 +306,10 @@ bool CWinBindingEGL::CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeW
return true;
}
-bool CWinBindingEGL::DestroyWindow()
+bool CWinEGLPlatformGeneric::ReleaseSurface()
{
EGLBoolean eglStatus;
+
if (m_context != EGL_NO_CONTEXT)
{
eglStatus = eglDestroyContext(m_display, m_context);
@@ -214,40 +318,29 @@ bool CWinBindingEGL::DestroyWindow()
m_context = EGL_NO_CONTEXT;
}
- if (m_surface != EGL_NO_SURFACE)
- {
- eglStatus = eglDestroySurface(m_display, m_surface);
- if (!eglStatus)
- CLog::Log(LOGERROR, "Error destroying EGL surface");
- m_surface = EGL_NO_SURFACE;
- }
-
- if (m_display != EGL_NO_DISPLAY)
- {
- eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
- eglStatus = eglTerminate(m_display);
- if (!eglStatus)
- CLog::Log(LOGERROR, "Error terminating EGL");
- m_display = EGL_NO_DISPLAY;
- }
+ return true;
+}
+bool CWinEGLPlatformGeneric::ShowWindow(bool show)
+{
return true;
}
-void CWinBindingEGL::SwapBuffers()
+void CWinEGLPlatformGeneric::SwapBuffers()
{
eglSwapBuffers(m_display, m_surface);
}
-bool CWinBindingEGL::SetVSync(bool enable)
+bool CWinEGLPlatformGeneric::SetVSync(bool enable)
{
// depending how buffers are setup, eglSwapInterval
// might fail so let caller decide if this is an error.
return eglSwapInterval(m_display, enable ? 1 : 0);
}
-bool CWinBindingEGL::IsExtSupported(const char* extension)
+bool CWinEGLPlatformGeneric::IsExtSupported(const char* extension)
{
CStdString name;
@@ -258,27 +351,18 @@ bool CWinBindingEGL::IsExtSupported(const char* extension)
return m_eglext.find(name) != std::string::npos;
}
-EGLNativeWindowType CWinBindingEGL::GetNativeWindow()
-{
- return m_nativeWindow;
-}
-
-EGLNativeDisplayType CWinBindingEGL::GetNativeDisplay()
+EGLNativeWindowType CWinEGLPlatformGeneric::getNativeWindow()
{
- return m_nativeDisplay;
+ // most egl platforms can handle EGLNativeWindowType == 0
+ return 0;
}
-EGLDisplay CWinBindingEGL::GetDisplay()
+EGLDisplay CWinEGLPlatformGeneric::GetEGLDisplay()
{
return m_display;
}
-EGLSurface CWinBindingEGL::GetSurface()
-{
- return m_surface;
-}
-
-EGLContext CWinBindingEGL::GetContext()
+EGLContext CWinEGLPlatformGeneric::GetEGLContext()
{
return m_context;
}
View
47 xbmc/windowing/egl/WinBindingEGL.h → xbmc/windowing/egl/WinEGLPlatformGeneric.h
@@ -1,3 +1,4 @@
+#pragma once
/*
* Copyright (C) 2005-2011 Team XBMC
* http://www.xbmc.org
@@ -19,44 +20,50 @@
*
*/
-#ifndef WINDOW_BINDING_EGL_H
-#define WINDOW_BINDING_EGL_H
-
#include "utils/StringUtils.h"
#include <EGL/egl.h>
#ifndef TARGET_WINDOWS
#include <EGL/eglext.h>
#endif
-class CWinBindingEGL
+class CWinEGLPlatformGeneric
{
public:
- CWinBindingEGL();
- ~CWinBindingEGL();
+ CWinEGLPlatformGeneric();
+ virtual ~CWinEGLPlatformGeneric();
- bool CreateWindow(EGLNativeDisplayType nativeDisplay, EGLNativeWindowType nativeWindow);
- bool DestroyWindow();
- bool ReleaseSurface();
- void SwapBuffers();
- bool SetVSync(bool enable);
- bool IsExtSupported(const char* extension);
+ virtual EGLNativeWindowType InitWindowSystem(EGLNativeDisplayType nativeDisplay, int width, int height, int bpp);
+ virtual void DestroyWindowSystem(EGLNativeWindowType native_window);
+ virtual bool SetDisplayResolution(int width, int height, float refresh, bool interlace);
+ virtual bool ClampToGUIDisplayLimits(int &width, int &height);
+ virtual bool ProbeDisplayResolutions(std::vector<CStdString> &resolutions);
+
+ virtual bool InitializeDisplay();
+ virtual bool UninitializeDisplay();
+ virtual bool CreateWindow();
+ virtual bool DestroyWindow();
+ virtual bool BindSurface();
+ virtual bool ReleaseSurface();
+
+ virtual bool ShowWindow(bool show);
+ virtual void SwapBuffers();
+ virtual bool SetVSync(bool enable);
+ virtual bool IsExtSupported(const char* extension);
- EGLNativeWindowType GetNativeWindow();
- EGLNativeDisplayType GetNativeDisplay();
- EGLDisplay GetDisplay();
- EGLSurface GetSurface();
- EGLContext GetContext();
+ virtual EGLDisplay GetEGLDisplay();
+ virtual EGLContext GetEGLContext();
protected:
+ virtual EGLNativeWindowType getNativeWindow();
+
EGLNativeWindowType m_nativeWindow;
EGLNativeDisplayType m_nativeDisplay;
EGLDisplay m_display;
EGLSurface m_surface;
EGLConfig m_config;
EGLContext m_context;
CStdString m_eglext;
+ int m_width;
+ int m_height;
};
-
-#endif // WINDOW_BINDING_EGL_H
-
View
171 xbmc/windowing/egl/WinSystemGLES.cpp
@@ -27,37 +27,39 @@
#include "settings/Settings.h"
#include "guilib/Texture.h"
#include "utils/log.h"
-#include "WinBindingEGL.h"
#include <vector>
////////////////////////////////////////////////////////////////////////////////////////////
CWinSystemGLES::CWinSystemGLES() : CWinSystemBase()
{
m_window = NULL;
- m_eglBinding = new CWinBindingEGL();
+ m_eglplatform = new CWinEGLPlatform();
m_eWindowSystem = WINDOW_SYSTEM_EGL;
}
CWinSystemGLES::~CWinSystemGLES()
{
DestroyWindowSystem();
- delete m_eglBinding;
+ delete m_eglplatform;
}
bool CWinSystemGLES::InitWindowSystem()
{
- m_fb_width = 1280;
- m_fb_height = 720;
- m_fb_bpp = 8;
-
- CLog::Log(LOGDEBUG, "Video mode: %dx%d with %d bits per pixel.",
- m_fb_width, m_fb_height, m_fb_bpp);
-
m_display = EGL_DEFAULT_DISPLAY;
- m_window = (fbdev_window*)calloc(1, sizeof(fbdev_window));
- m_window->width = m_fb_width;
- m_window->height = m_fb_height;
+ m_window = m_eglplatform->InitWindowSystem(m_display, 1920, 1080, 8);
+
+ // Initialize the display
+ // This needs to happen before the call to CWinSystemBase::InitWindowSystem()
+ // (at least for Android)
+ if (!m_eglplatform->InitializeDisplay())
+ return false;
+
+ // Create a window to get valid width and height values
+ // This needs to happen before the call to CWinSystemBase::InitWindowSystem()
+ // (at least for Android)
+ if (!m_eglplatform->CreateWindow())
+ return false;
if (!CWinSystemBase::InitWindowSystem())
return false;
@@ -67,20 +69,43 @@ bool CWinSystemGLES::InitWindowSystem()
bool CWinSystemGLES::DestroyWindowSystem()
{
- free(m_window);
+ m_eglplatform->DestroyWindowSystem(m_window);
m_window = NULL;
return true;
}
bool CWinSystemGLES::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction)
{
+ if (m_bWindowCreated && m_nWidth == res.iWidth && m_nHeight == res.iHeight && m_bFullScreen == fullScreen)
+ {
+ CLog::Log(LOGDEBUG, "CWinSystemGLES::CreateNewWindow: No need to create a new window");
+ return true;
+ }
+
m_nWidth = res.iWidth;
m_nHeight = res.iHeight;
m_bFullScreen = fullScreen;
-
- if (!m_eglBinding->CreateWindow((EGLNativeDisplayType)m_display, (EGLNativeWindowType)m_window))
+
+ // Destroy any existing window
+ if (m_bWindowCreated)
+ m_eglplatform->DestroyWindow();
+
+ // temp until split gui/display res comes in
+ //m_eglplatform->SetDisplayResolution(res.iScreenWidth, res.iScreenHeight,
+ m_eglplatform->SetDisplayResolution(res.iWidth, res.iHeight,
+ res.fRefreshRate, res.dwFlags & D3DPRESENTFLAG_INTERLACED);
+
+ // If we previously destroyed an existing window we need to create a new one
+ // (otherwise this is taken care of by InitWindowSystem())
+ if (m_bWindowCreated)
+ m_eglplatform->CreateWindow();
+
+ if (!m_eglplatform->BindSurface())
+ {
+ m_eglplatform->DestroyWindow();
return false;
+ }
m_bWindowCreated = true;
@@ -89,7 +114,7 @@ bool CWinSystemGLES::CreateNewWindow(const CStdString& name, bool fullScreen, RE
bool CWinSystemGLES::DestroyWindow()
{
- if (!m_eglBinding->DestroyWindow())
+ if (!m_eglplatform->DestroyWindow())
return false;
m_bWindowCreated = false;
@@ -105,12 +130,7 @@ bool CWinSystemGLES::ResizeWindow(int newWidth, int newHeight, int newLeft, int
bool CWinSystemGLES::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
{
- CLog::Log(LOGDEBUG, "CWinSystemDFB::SetFullScreen");
- m_nWidth = res.iWidth;
- m_nHeight = res.iHeight;
- m_bFullScreen = fullScreen;
-
- m_eglBinding->ReleaseSurface();
+ CLog::Log(LOGDEBUG, "CWinSystemGLES::SetFullScreen");
CreateNewWindow("", fullScreen, res, NULL);
CRenderSystemGLES::ResetRenderSystem(res.iWidth, res.iHeight, true, 0);
@@ -120,39 +140,114 @@ bool CWinSystemGLES::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool b
void CWinSystemGLES::UpdateResolutions()
{
- CWinSystemBase::UpdateResolutions();
-
- int w = 1280;
- int h = 720;
- UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, w, h, 0.0);
+ std::vector<CStdString> resolutions;
+
+ m_eglplatform->ProbeDisplayResolutions(resolutions);
+
+ bool got_display_rez = false;
+ RESOLUTION Res720p60 = RES_INVALID;
+ RESOLUTION res_index = RES_DESKTOP;
+
+ for (size_t i = 0; i < resolutions.size(); i++)
+ {
+ // 1280x720p50Hz
+ // 1280x720p60Hz
+ // 1920x1080i50Hz
+ // 1920x1080i60Hz
+ // 1920x1080p24Hz
+ // 1920x1080p50Hz
+ // 1920x1080p60Hz
+
+ char interlacing;
+ int refresh, width, height;
+ if (sscanf(resolutions[i].c_str(), "%dx%d%c%dHz", &width, &height, &interlacing, &refresh) == 4)
+ {
+ got_display_rez = true;
+ // if this is a new setting,
+ // create a new empty setting to fill in.
+ if ((int)g_settings.m_ResInfo.size() <= res_index)
+ {
+ RESOLUTION_INFO res;
+ g_settings.m_ResInfo.push_back(res);
+ }
+ int gui_width = width;
+ int gui_height = height;
+ float gui_refresh = refresh;
+ m_eglplatform->ClampToGUIDisplayLimits(gui_width, gui_height);
+
+ g_settings.m_ResInfo[res_index].iScreen = 0;
+ g_settings.m_ResInfo[res_index].bFullScreen = true;
+ g_settings.m_ResInfo[res_index].iSubtitles = (int)(0.965 * gui_height);
+ g_settings.m_ResInfo[res_index].dwFlags = D3DPRESENTFLAG_PROGRESSIVE;
+ g_settings.m_ResInfo[res_index].fRefreshRate = gui_refresh;
+ g_settings.m_ResInfo[res_index].fPixelRatio = 1.0f;
+ g_settings.m_ResInfo[res_index].iWidth = gui_width;
+ g_settings.m_ResInfo[res_index].iHeight = gui_height;
+ // temp until split gui/display res comes in
+ //g_settings.m_ResInfo[res_index].iScreenWidth = width;
+ //g_settings.m_ResInfo[res_index].iScreenHeight = height;
+ g_settings.m_ResInfo[res_index].strMode.Format("%dx%d @ %.2f - Full Screen", width, height, gui_refresh);
+ g_graphicsContext.ResetOverscan(g_settings.m_ResInfo[res_index]);
+ /*
+ CLog::Log(LOGINFO, "Found possible resolution for display %d with %d x %d @ %f Hz\n",
+ g_settings.m_ResInfo[res_index].iScreen,
+ g_settings.m_ResInfo[res_index].iScreenWidth,
+ g_settings.m_ResInfo[res_index].iScreenHeight,
+ g_settings.m_ResInfo[res_index].fRefreshRate);
+ */
+
+ if (width == 1280 && height == 720 && refresh == 60)
+ Res720p60 = res_index;
+
+ res_index = (RESOLUTION)((int)res_index + 1);
+ }
+ }
+ // swap desktop index for 720p if available
+ if (Res720p60 != RES_INVALID)
+ {
+ CLog::Log(LOGINFO, "Found 720p at %d, setting to RES_DESKTOP at %d", (int)Res720p60, (int)RES_DESKTOP);
+
+ RESOLUTION_INFO desktop = g_settings.m_ResInfo[RES_DESKTOP];
+ g_settings.m_ResInfo[RES_DESKTOP] = g_settings.m_ResInfo[Res720p60];
+ g_settings.m_ResInfo[Res720p60] = desktop;
+ }
}
bool CWinSystemGLES::IsExtSupported(const char* extension)
{
if(strncmp(extension, "EGL_", 4) != 0)
return CRenderSystemGLES::IsExtSupported(extension);
- return m_eglBinding->IsExtSupported(extension);
+ return m_eglplatform->IsExtSupported(extension);
}
bool CWinSystemGLES::PresentRenderImpl(const CDirtyRegionList &dirty)
{
- m_eglBinding->SwapBuffers();
+ m_eglplatform->SwapBuffers();
return true;
}
void CWinSystemGLES::SetVSyncImpl(bool enable)
{
m_iVSyncMode = enable ? 10 : 0;
- if (m_eglBinding->SetVSync(enable) == FALSE)
+ if (m_eglplatform->SetVSync(enable) == FALSE)
CLog::Log(LOGERROR, "CWinSystemDFB::SetVSyncImpl: Could not set egl vsync");
}
void CWinSystemGLES::ShowOSMouse(bool show)
{
}
+bool CWinSystemGLES::HasCursor()
+{
+#ifdef TARGET_ANDROID
+ return false;
+#else
+ return true;
+#endif
+}
+
void CWinSystemGLES::NotifyAppActiveChange(bool bActivated)
{
}
@@ -171,12 +266,22 @@ bool CWinSystemGLES::Restore()
bool CWinSystemGLES::Hide()
{
- return true;
+ return m_eglplatform->ShowWindow(false);
}
bool CWinSystemGLES::Show(bool raise)
{
- return true;
+ return m_eglplatform->ShowWindow(true);
+}
+
+EGLDisplay CWinSystemGLES::GetEGLDisplay()
+{
+ return m_eglplatform->GetEGLDisplay();
+}
+
+EGLContext CWinSystemGLES::GetEGLContext()
+{
+ return m_eglplatform->GetEGLContext();
}
#endif
View
16 xbmc/windowing/egl/WinSystemGLES.h
@@ -26,12 +26,9 @@
#include "rendering/gles/RenderSystemGLES.h"
#include "utils/GlobalsHandling.h"
+#include "windowing/egl/WinEGLPlatform.h"
#include "windowing/WinSystem.h"
-class CWinBindingEGL;
-
-typedef struct fbdev_window fbdev_window;
-
class CWinSystemGLES : public CWinSystemBase, public CRenderSystemGLES
{
public:
@@ -48,6 +45,7 @@ class CWinSystemGLES : public CWinSystemBase, public CRenderSystemGLES
virtual bool IsExtSupported(const char* extension);
virtual void ShowOSMouse(bool show);
+ virtual bool HasCursor();
virtual void NotifyAppActiveChange(bool bActivated);
@@ -56,15 +54,15 @@ class CWinSystemGLES : public CWinSystemBase, public CRenderSystemGLES
virtual bool Hide();
virtual bool Show(bool raise = true);
+ EGLDisplay GetEGLDisplay();
+ EGLContext GetEGLContext();
+
protected:
virtual bool PresentRenderImpl(const CDirtyRegionList &dirty);
virtual void SetVSyncImpl(bool enable);
void *m_display;
- fbdev_window *m_window;
- CWinBindingEGL *m_eglBinding;
- int m_fb_width;
- int m_fb_height;
- int m_fb_bpp;
+ EGLNativeWindowType m_window;
+ CWinEGLPlatform *m_eglplatform;
};
XBMC_GLOBAL_REF(CWinSystemGLES,g_Windowing);

0 comments on commit f6ecaea

Please sign in to comment.
Something went wrong with that request. Please try again.