2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-09-18 13:59:06 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
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 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-09-18 13:59:06 +00:00
|
|
|
|
|
|
|
#include "compositingprefs.h"
|
|
|
|
|
2007-09-26 16:34:08 +00:00
|
|
|
#include "kwinglobals.h"
|
2010-12-03 21:13:43 +00:00
|
|
|
#include "kwinglplatform.h"
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2011-04-03 19:59:57 +00:00
|
|
|
#include <kconfiggroup.h>
|
2007-09-18 13:59:06 +00:00
|
|
|
#include <kdebug.h>
|
2007-09-26 13:47:01 +00:00
|
|
|
#include <kxerrorhandler.h>
|
2007-11-12 16:32:25 +00:00
|
|
|
#include <klocale.h>
|
2007-12-17 14:14:53 +00:00
|
|
|
#include <kdeversion.h>
|
2011-04-03 19:59:57 +00:00
|
|
|
#include <ksharedconfig.h>
|
2010-02-26 20:47:00 +00:00
|
|
|
#include <kstandarddirs.h>
|
|
|
|
|
|
|
|
#include <qprocess.h>
|
2007-09-18 13:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
CompositingPrefs::CompositingPrefs()
|
2011-01-30 14:34:42 +00:00
|
|
|
: mRecommendCompositing(false)
|
|
|
|
, mEnableVSync(true)
|
|
|
|
, mEnableDirectRendering(true)
|
|
|
|
, mStrictBinding(true)
|
|
|
|
{
|
|
|
|
}
|
2007-10-17 15:37:14 +00:00
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
CompositingPrefs::~CompositingPrefs()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2009-12-04 09:29:08 +00:00
|
|
|
bool CompositingPrefs::recommendCompositing() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-12-04 09:29:08 +00:00
|
|
|
return mRecommendCompositing;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-01-03 19:10:44 +00:00
|
|
|
|
2011-04-03 19:59:57 +00:00
|
|
|
bool CompositingPrefs::openGlIsBroken()
|
|
|
|
{
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig("kwinrc");
|
|
|
|
return KConfigGroup(config, "Compositing").readEntry("OpenGLIsUnsafe", false);
|
|
|
|
}
|
|
|
|
|
2007-09-26 16:34:08 +00:00
|
|
|
bool CompositingPrefs::compositingPossible()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-03 19:59:57 +00:00
|
|
|
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig("kwinrc");
|
|
|
|
KConfigGroup gl_workaround_group(config, "Compositing");
|
|
|
|
if (gl_workaround_group.readEntry("Backend", "OpenGL") == "OpenGL" &&
|
|
|
|
gl_workaround_group.readEntry("OpenGLIsUnsafe", false))
|
|
|
|
return false;
|
|
|
|
|
2007-09-26 16:34:08 +00:00
|
|
|
Extensions::init();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!Extensions::compositeAvailable()) {
|
|
|
|
kDebug(1212) << "No composite extension available";
|
2007-09-26 16:34:08 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (!Extensions::damageAvailable()) {
|
|
|
|
kDebug(1212) << "No damage extension available";
|
2007-09-26 16:34:08 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-07-20 20:10:03 +00:00
|
|
|
if (hasGlx())
|
2007-12-17 14:14:53 +00:00
|
|
|
return true;
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2011-01-30 14:34:42 +00:00
|
|
|
if (Extensions::renderAvailable() && Extensions::fixesAvailable())
|
2007-12-17 14:14:53 +00:00
|
|
|
return true;
|
2010-12-12 11:08:23 +00:00
|
|
|
#endif
|
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
|
|
|
return true;
|
2007-12-17 14:14:53 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "No OpenGL or XRender/XFixes support";
|
2007-12-17 14:14:53 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:34:08 +00:00
|
|
|
|
2007-11-12 16:32:25 +00:00
|
|
|
QString CompositingPrefs::compositingNotPossibleReason()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-03 19:59:57 +00:00
|
|
|
// first off, check whether we figured that we'll crash on detection because of a buggy driver
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig("kwinrc");
|
|
|
|
KConfigGroup gl_workaround_group(config, "Compositing");
|
|
|
|
if (gl_workaround_group.readEntry("Backend", "OpenGL") == "OpenGL" &&
|
|
|
|
gl_workaround_group.readEntry("OpenGLIsUnsafe", false))
|
|
|
|
return i18n("<b>OpenGL compositing (the default) has crashed KWin in the past.</b><br>"
|
|
|
|
"This was most likely due to a driver bug."
|
|
|
|
"<p>If you think that you have meanwhile upgraded to a stable driver,<br>"
|
|
|
|
"you can reset this protection but <b>be aware that this might result in an immediate crash!</b></p>"
|
|
|
|
"<p>Alternatively, you might want to use the XRender backend instead.</p>");
|
|
|
|
|
2007-11-12 16:32:25 +00:00
|
|
|
Extensions::init();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!Extensions::compositeAvailable() || !Extensions::damageAvailable()) {
|
2007-11-12 16:32:25 +00:00
|
|
|
return i18n("Required X extensions (XComposite and XDamage) are not available.");
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-08-13 13:21:51 +00:00
|
|
|
#if !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
2011-07-20 20:10:03 +00:00
|
|
|
if (!hasGlx())
|
2011-01-30 14:34:42 +00:00
|
|
|
return i18n("GLX/OpenGL are not available and only OpenGL support is compiled.");
|
2008-01-08 11:26:52 +00:00
|
|
|
#else
|
2011-07-20 20:10:03 +00:00
|
|
|
if (!(hasGlx()
|
2011-01-30 14:34:42 +00:00
|
|
|
|| (Extensions::renderAvailable() && Extensions::fixesAvailable()))) {
|
|
|
|
return i18n("GLX/OpenGL and XRender/XFixes are not available.");
|
|
|
|
}
|
2007-12-17 14:14:53 +00:00
|
|
|
#endif
|
2007-11-12 16:32:25 +00:00
|
|
|
return QString();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-11-12 16:32:25 +00:00
|
|
|
|
2011-07-20 20:10:03 +00:00
|
|
|
static bool s_glxDetected = false;
|
|
|
|
static bool s_hasGlx = false;
|
|
|
|
|
|
|
|
bool CompositingPrefs::hasGlx()
|
|
|
|
{
|
|
|
|
if (s_glxDetected) {
|
|
|
|
return s_hasGlx;
|
|
|
|
}
|
|
|
|
#ifndef KWIN_HAVE_OPENGLES
|
|
|
|
int event_base, error_base;
|
|
|
|
s_hasGlx = glXQueryExtension(display(), &event_base, &error_base);
|
|
|
|
#endif
|
|
|
|
s_glxDetected = true;
|
|
|
|
return s_hasGlx;
|
|
|
|
}
|
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
void CompositingPrefs::detect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-04-03 19:59:57 +00:00
|
|
|
if (!compositingPossible() || openGlIsBroken()) {
|
2007-09-26 16:34:08 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:34:08 +00:00
|
|
|
|
2011-04-03 19:59:57 +00:00
|
|
|
// NOTICE: this is intended to workaround broken GL implementations that successfully segfault
|
|
|
|
// on glXQuery :-(
|
|
|
|
// we tag GL as unsafe. It *must* be reset before every return, and in case we "unexpectedly"
|
|
|
|
// end (aka "segfaulted") we know that we shall not try again
|
|
|
|
KSharedConfigPtr config = KSharedConfig::openConfig("kwinrc");
|
|
|
|
KConfigGroup gl_workaround_config = KConfigGroup(config, "Compositing");
|
|
|
|
gl_workaround_config.writeEntry("OpenGLIsUnsafe", true);
|
|
|
|
gl_workaround_config.sync();
|
|
|
|
|
2010-12-12 11:08:23 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
|
|
|
bool haveContext = false;
|
|
|
|
bool canDetect = false;
|
|
|
|
EGLDisplay dpy = eglGetCurrentDisplay();
|
|
|
|
if (dpy != EGL_NO_DISPLAY) {
|
|
|
|
EGLContext ctx = eglGetCurrentContext();
|
|
|
|
if (ctx != EGL_NO_CONTEXT) {
|
|
|
|
haveContext = true;
|
|
|
|
canDetect = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!haveContext) {
|
|
|
|
canDetect = initEGLContext();
|
|
|
|
}
|
|
|
|
if (canDetect) {
|
|
|
|
detectDriverAndVersion();
|
|
|
|
applyDriverSpecificOptions();
|
|
|
|
}
|
|
|
|
if (!haveContext) {
|
|
|
|
deleteEGLContext();
|
|
|
|
}
|
|
|
|
#else
|
2010-02-26 20:47:00 +00:00
|
|
|
// HACK: This is needed for AIGLX
|
2011-07-26 05:55:20 +00:00
|
|
|
const bool forceIndirect = qstrcmp(qgetenv("LIBGL_ALWAYS_INDIRECT"), "1") == 0;
|
|
|
|
if (!forceIndirect && qstrcmp(qgetenv("KWIN_DIRECT_GL"), "1") != 0) {
|
2010-02-26 20:47:00 +00:00
|
|
|
// Start an external helper program that initializes GLX and returns
|
|
|
|
// 0 if we can use direct rendering, and 1 otherwise.
|
|
|
|
// The reason we have to use an external program is that after GLX
|
|
|
|
// has been initialized, it's too late to set the LIBGL_ALWAYS_INDIRECT
|
|
|
|
// environment variable.
|
|
|
|
// Direct rendering is preferred, since not all OpenGL extensions are
|
|
|
|
// available with indirect rendering.
|
2011-01-30 14:34:42 +00:00
|
|
|
const QString opengl_test = KStandardDirs::findExe("kwin_opengl_test");
|
2011-07-26 05:55:20 +00:00
|
|
|
if (QProcess::execute(opengl_test) != 0) {
|
|
|
|
mEnableDirectRendering = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
setenv("LIBGL_ALWAYS_INDIRECT", "1", true);
|
2011-07-26 05:55:20 +00:00
|
|
|
} else {
|
|
|
|
mEnableDirectRendering = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mEnableDirectRendering = !forceIndirect;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-07-20 20:10:03 +00:00
|
|
|
if (!hasGlx()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "No GLX available";
|
2011-04-03 19:59:57 +00:00
|
|
|
gl_workaround_config.writeEntry("OpenGLIsUnsafe", false);
|
|
|
|
gl_workaround_config.sync();
|
2007-09-27 19:04:18 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-30 14:08:24 +00:00
|
|
|
int glxmajor, glxminor;
|
2011-01-30 14:34:42 +00:00
|
|
|
glXQueryVersion(display(), &glxmajor, &glxminor);
|
|
|
|
kDebug(1212) << "glx version is " << glxmajor << "." << glxminor;
|
|
|
|
bool hasglx13 = (glxmajor > 1 || (glxmajor == 1 && glxminor >= 3));
|
2007-09-27 19:04:18 +00:00
|
|
|
|
2007-09-25 10:14:57 +00:00
|
|
|
// remember and later restore active context
|
|
|
|
GLXContext oldcontext = glXGetCurrentContext();
|
|
|
|
GLXDrawable olddrawable = glXGetCurrentDrawable();
|
2008-03-19 16:55:07 +00:00
|
|
|
GLXDrawable oldreaddrawable = None;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (hasglx13)
|
2007-09-30 14:08:24 +00:00
|
|
|
oldreaddrawable = glXGetCurrentReadDrawable();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (initGLXContext()) {
|
2007-09-18 13:59:06 +00:00
|
|
|
detectDriverAndVersion();
|
|
|
|
applyDriverSpecificOptions();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (hasglx13)
|
|
|
|
glXMakeContextCurrent(display(), olddrawable, oldreaddrawable, oldcontext);
|
2007-10-31 16:28:59 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
glXMakeCurrent(display(), olddrawable, oldcontext);
|
2008-01-22 17:04:41 +00:00
|
|
|
deleteGLXContext();
|
2010-11-20 12:33:24 +00:00
|
|
|
#endif
|
2011-04-03 19:59:57 +00:00
|
|
|
gl_workaround_config.writeEntry("OpenGLIsUnsafe", false);
|
|
|
|
gl_workaround_config.sync();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2008-01-22 17:04:41 +00:00
|
|
|
bool CompositingPrefs::initGLXContext()
|
2007-09-18 13:59:06 +00:00
|
|
|
{
|
2010-11-20 12:33:24 +00:00
|
|
|
#ifndef KWIN_HAVE_OPENGLES
|
2008-01-22 17:04:41 +00:00
|
|
|
mGLContext = NULL;
|
2007-09-26 13:47:01 +00:00
|
|
|
KXErrorHandler handler;
|
2007-09-18 13:59:06 +00:00
|
|
|
// Most of this code has been taken from glxinfo.c
|
|
|
|
QVector<int> attribs;
|
|
|
|
attribs << GLX_RGBA;
|
|
|
|
attribs << GLX_RED_SIZE << 1;
|
|
|
|
attribs << GLX_GREEN_SIZE << 1;
|
|
|
|
attribs << GLX_BLUE_SIZE << 1;
|
|
|
|
attribs << None;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
XVisualInfo* visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
|
|
|
|
if (!visinfo) {
|
2007-09-18 13:59:06 +00:00
|
|
|
attribs.last() = GLX_DOUBLEBUFFER;
|
|
|
|
attribs << None;
|
2011-01-30 14:34:42 +00:00
|
|
|
visinfo = glXChooseVisual(display(), DefaultScreen(display()), attribs.data());
|
|
|
|
if (!visinfo) {
|
|
|
|
kDebug(1212) << "Error: couldn't find RGB GLX visual";
|
2007-09-18 13:59:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
mGLContext = glXCreateContext(display(), visinfo, NULL, True);
|
|
|
|
if (!mGLContext) {
|
|
|
|
kDebug(1212) << "glXCreateContext failed";
|
|
|
|
XDestroyWindow(display(), mGLWindow);
|
2007-09-18 13:59:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.border_pixel = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
attr.colormap = XCreateColormap(display(), rootWindow(), visinfo->visual, AllocNone);
|
2007-09-18 13:59:06 +00:00
|
|
|
attr.event_mask = StructureNotifyMask | ExposureMask;
|
|
|
|
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
|
|
|
int width = 100, height = 100;
|
2011-01-30 14:34:42 +00:00
|
|
|
mGLWindow = XCreateWindow(display(), rootWindow(), 0, 0, width, height,
|
|
|
|
0, visinfo->depth, InputOutput,
|
|
|
|
visinfo->visual, mask, &attr);
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
return glXMakeCurrent(display(), mGLWindow, mGLContext) && !handler.error(true);
|
2010-11-20 12:33:24 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2007-09-18 13:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CompositingPrefs::deleteGLXContext()
|
|
|
|
{
|
2010-11-20 12:33:24 +00:00
|
|
|
#ifndef KWIN_HAVE_OPENGLES
|
2011-01-30 14:34:42 +00:00
|
|
|
if (mGLContext == NULL)
|
2008-01-22 17:04:41 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
glXDestroyContext(display(), mGLContext);
|
|
|
|
XDestroyWindow(display(), mGLWindow);
|
2007-09-18 13:59:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-12-12 11:08:23 +00:00
|
|
|
bool CompositingPrefs::initEGLContext()
|
|
|
|
{
|
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
2011-01-30 14:34:42 +00:00
|
|
|
mEGLDisplay = eglGetDisplay(display());
|
2010-12-12 11:08:23 +00:00
|
|
|
if (mEGLDisplay == EGL_NO_DISPLAY) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (eglInitialize(mEGLDisplay, 0, 0) == EGL_FALSE) {
|
2010-12-12 11:08:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
eglBindAPI(EGL_OPENGL_ES_API);
|
2010-12-12 11:08:23 +00:00
|
|
|
|
|
|
|
const EGLint config_attribs[] = {
|
|
|
|
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|
|
|
EGL_RED_SIZE, 1,
|
|
|
|
EGL_GREEN_SIZE, 1,
|
|
|
|
EGL_BLUE_SIZE, 1,
|
|
|
|
EGL_ALPHA_SIZE, 0,
|
|
|
|
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
|
|
EGL_CONFIG_CAVEAT, EGL_NONE,
|
|
|
|
EGL_NONE,
|
|
|
|
};
|
|
|
|
|
|
|
|
EGLint count;
|
|
|
|
EGLConfig configs[1024];
|
|
|
|
eglChooseConfig(mEGLDisplay, config_attribs, configs, 1024, &count);
|
|
|
|
|
2011-12-01 21:41:10 +00:00
|
|
|
if (count == 0) {
|
|
|
|
// egl_glx only supports indirect rendering, which itself does not allow GLES2
|
|
|
|
kWarning(1212) << "You might be using mesa egl_glx, which is not supported!";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-12-12 11:08:23 +00:00
|
|
|
EGLint visualId = XVisualIDFromVisual((Visual*)QX11Info::appVisual());
|
|
|
|
|
|
|
|
EGLConfig config = configs[0];
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
EGLint val;
|
|
|
|
eglGetConfigAttrib(mEGLDisplay, configs[i], EGL_NATIVE_VISUAL_ID, &val);
|
|
|
|
if (visualId == val) {
|
|
|
|
config = configs[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.border_pixel = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
attr.colormap = XCreateColormap(display(), rootWindow(), (Visual*)QX11Info::appVisual(), AllocNone);
|
2010-12-12 11:08:23 +00:00
|
|
|
attr.event_mask = StructureNotifyMask | ExposureMask;
|
|
|
|
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
|
|
|
int width = 100, height = 100;
|
2011-01-30 14:34:42 +00:00
|
|
|
mGLWindow = XCreateWindow(display(), rootWindow(), 0, 0, width, height,
|
|
|
|
0, QX11Info::appDepth(), InputOutput,
|
|
|
|
(Visual*)QX11Info::appVisual(), mask, &attr);
|
2010-12-12 11:08:23 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
mEGLSurface = eglCreateWindowSurface(mEGLDisplay, config, mGLWindow, 0);
|
2010-12-12 11:08:23 +00:00
|
|
|
|
|
|
|
const EGLint context_attribs[] = {
|
|
|
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
|
|
EGL_NONE
|
|
|
|
};
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
mEGLContext = eglCreateContext(mEGLDisplay, config, EGL_NO_CONTEXT, context_attribs);
|
2010-12-12 11:08:23 +00:00
|
|
|
if (mEGLContext == EGL_NO_CONTEXT) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext) == EGL_FALSE) {
|
2010-12-12 11:08:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
EGLint error = eglGetError();
|
|
|
|
if (error != EGL_SUCCESS) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompositingPrefs::deleteEGLContext()
|
|
|
|
{
|
|
|
|
#ifdef KWIN_HAVE_OPENGLES
|
|
|
|
eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
|
|
|
eglDestroyContext(mEGLDisplay, mEGLContext);
|
|
|
|
eglDestroySurface(mEGLDisplay, mEGLSurface);
|
|
|
|
eglTerminate(mEGLDisplay);
|
|
|
|
eglReleaseThread();
|
2011-01-30 14:34:42 +00:00
|
|
|
XDestroyWindow(display(), mGLWindow);
|
2010-12-12 11:08:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
void CompositingPrefs::detectDriverAndVersion()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-12-03 21:13:43 +00:00
|
|
|
GLPlatform *gl = GLPlatform::instance();
|
|
|
|
gl->detect();
|
|
|
|
gl->printResults();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2008-10-15 14:10:43 +00:00
|
|
|
// See http://techbase.kde.org/Projects/KWin/HW for a list of some cards that are known to work.
|
2007-09-18 13:59:06 +00:00
|
|
|
void CompositingPrefs::applyDriverSpecificOptions()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2010-01-25 10:02:08 +00:00
|
|
|
// Always recommend
|
|
|
|
mRecommendCompositing = true;
|
|
|
|
|
2010-12-03 21:13:43 +00:00
|
|
|
GLPlatform *gl = GLPlatform::instance();
|
2011-01-30 14:34:42 +00:00
|
|
|
mStrictBinding = !gl->supports(LooseBinding);
|
|
|
|
if (gl->driver() == Driver_Intel)
|
2007-09-22 11:19:22 +00:00
|
|
|
mEnableVSync = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|