Skip to content

Commit

Permalink
Merge pull request xbmc#6575 from fosero/x11_egl_fixes
Browse files Browse the repository at this point in the history
X11 egl fixes
  • Loading branch information
FernetMenta committed Mar 2, 2015
2 parents 1b98e38 + ea8234e commit d996207
Showing 1 changed file with 43 additions and 11 deletions.
54 changes: 43 additions & 11 deletions xbmc/windowing/X11/WinSystemX11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,17 +506,36 @@ bool CWinSystemX11::IsCurrentOutput(std::string output)
#if defined(HAS_EGL)
EGLConfig getEGLConfig(EGLDisplay eglDisplay, XVisualInfo *vInfo)
{
EGLint attributes[] = {
EGLint attributes[] =
{
EGL_DEPTH_SIZE, 24,
EGL_NONE
};
EGLint numConfigs;
// TODO make dynamic
EGLConfig eglConfigs[1024];

if (!eglChooseConfig(eglDisplay, attributes, NULL, 0, &numConfigs))
{
CLog::Log(LOGERROR, "Failed to query number of egl configs");
return EGL_NO_CONFIG;
}
if (numConfigs == 0)
{
CLog::Log(LOGERROR, "No suitable egl configs found");
return EGL_NO_CONFIG;
}

EGLConfig *eglConfigs;
eglConfigs = (EGLConfig*)malloc(numConfigs * sizeof(EGLConfig));
if (!eglConfigs)
{
CLog::Log(LOGERROR, "eglConfigs malloc failed");
return EGL_NO_CONFIG;
}
EGLConfig eglConfig = EGL_NO_CONFIG;
if (!eglChooseConfig(eglDisplay, attributes, eglConfigs, 1024, &numConfigs))
if (!eglChooseConfig(eglDisplay, attributes, eglConfigs, numConfigs, &numConfigs))
{
CLog::Log(LOGERROR, "Failed to query egl configs");
return EGL_NO_CONFIG;
goto Exit;
}
for (EGLint i = 0;i < numConfigs;++i)
{
Expand All @@ -532,6 +551,8 @@ EGLConfig getEGLConfig(EGLDisplay eglDisplay, XVisualInfo *vInfo)
}
}

Exit:
free(eglConfigs);
return eglConfig;
}

Expand Down Expand Up @@ -720,7 +741,8 @@ bool CWinSystemX11::RefreshGlxContext(bool force)
}
}

GLint contextAttributes[] = {
EGLint contextAttributes[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
Expand Down Expand Up @@ -1026,7 +1048,7 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const std:
};
#endif
#if defined(HAS_EGL)
GLint att[] =
EGLint att[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
Expand Down Expand Up @@ -1080,17 +1102,27 @@ bool CWinSystemX11::SetWindow(int width, int height, bool fullscreen, const std:
CLog::Log(LOGERROR, "Failed to choose a config %d\n", eglGetError());
}

XVisualInfo x11_visual_info_template;
if (!eglGetConfigAttrib(m_eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, (EGLint*)&x11_visual_info_template.visualid)) {
EGLint eglVisualid;
if (!eglGetConfigAttrib(m_eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &eglVisualid))
{
CLog::Log(LOGERROR, "Failed to query native visual id\n");
}
XVisualInfo x11_visual_info_template;
x11_visual_info_template.visualid = eglVisualid;
int num_visuals;
vi = XGetVisualInfo(m_dpy,
VisualIDMask,
&x11_visual_info_template,
&num_visuals);
&x11_visual_info_template,
&num_visuals);

#endif

if(!vi)
{
CLog::Log(LOGERROR, "Failed to find matching visual");
return false;
}

cmap = XCreateColormap(m_dpy, RootWindow(m_dpy, vi->screen), vi->visual, AllocNone);

bool hasWM = HasWindowManager();
Expand Down

0 comments on commit d996207

Please sign in to comment.