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"
|
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>
|
2007-09-18 13:59:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
CompositingPrefs::CompositingPrefs()
|
2007-10-17 15:37:14 +00:00
|
|
|
: mXgl( false )
|
2009-12-04 09:29:08 +00:00
|
|
|
, mRecommendCompositing( false )
|
2007-10-17 15:37:14 +00:00
|
|
|
, mEnableVSync( true )
|
|
|
|
, mEnableDirectRendering( true )
|
|
|
|
, mStrictBinding( true )
|
2007-09-18 13:59:06 +00:00
|
|
|
{
|
|
|
|
}
|
2007-10-17 15:37:14 +00:00
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
CompositingPrefs::~CompositingPrefs()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-04 09:29:08 +00:00
|
|
|
bool CompositingPrefs::recommendCompositing() const
|
2008-01-03 19:10:44 +00:00
|
|
|
{
|
2009-12-04 09:29:08 +00:00
|
|
|
return mRecommendCompositing;
|
2008-01-03 19:10:44 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 16:34:08 +00:00
|
|
|
bool CompositingPrefs::compositingPossible()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_COMPOSITING
|
2007-09-26 16:34:08 +00:00
|
|
|
Extensions::init();
|
|
|
|
if( !Extensions::compositeAvailable())
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "No composite extension available";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if( !Extensions::damageAvailable())
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "No damage extension available";
|
|
|
|
return false;
|
|
|
|
}
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
|
|
|
if( Extensions::glxAvailable())
|
|
|
|
return true;
|
2007-11-21 15:54:06 +00:00
|
|
|
#endif
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
|
|
if( Extensions::renderAvailable() && Extensions::fixesAvailable())
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
kDebug( 1212 ) << "No OpenGL or XRender/XFixes support";
|
|
|
|
return false;
|
2007-09-26 16:34:08 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-11-12 16:32:25 +00:00
|
|
|
QString CompositingPrefs::compositingNotPossibleReason()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_COMPOSITING
|
2007-11-12 16:32:25 +00:00
|
|
|
Extensions::init();
|
2007-12-17 14:14:53 +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.");
|
|
|
|
}
|
2008-01-08 11:26:52 +00:00
|
|
|
#if defined( KWIN_HAVE_OPENGL_COMPOSITING ) && !defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
|
|
|
if( !Extensions::glxAvailable())
|
|
|
|
return i18n( "GLX/OpenGL are not available and only OpenGL support is compiled." );
|
|
|
|
#elif !defined( KWIN_HAVE_OPENGL_COMPOSITING ) && defined( KWIN_HAVE_XRENDER_COMPOSITING )
|
2008-01-08 16:28:43 +00:00
|
|
|
if( !( Extensions::renderAvailable() && Extensions::fixesAvailable()))
|
2008-01-08 11:26:52 +00:00
|
|
|
return i18n( "XRender/XFixes extensions are not available and only XRender support"
|
|
|
|
" is compiled." );
|
|
|
|
#else
|
|
|
|
if( !( Extensions::glxAvailable()
|
|
|
|
|| ( 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();
|
|
|
|
#else
|
|
|
|
return i18n("Compositing was disabled at compile time.\n"
|
2008-04-19 22:36:47 +00:00
|
|
|
"It is likely Xorg development headers were not installed.");
|
2007-11-12 16:32:25 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-10-15 13:41:53 +00:00
|
|
|
// This function checks selected compositing setup and returns false if it should not
|
2008-10-23 09:31:44 +00:00
|
|
|
// be used even if explicitly configured (unless checks are overridden).
|
2008-10-15 13:41:53 +00:00
|
|
|
// More checks like broken XRender setups etc. should be added here.
|
|
|
|
bool CompositingPrefs::validateSetup( CompositingType compositingType ) const
|
|
|
|
{
|
|
|
|
switch( compositingType )
|
|
|
|
{
|
|
|
|
case NoCompositing:
|
|
|
|
return false;
|
|
|
|
case OpenGLCompositing:
|
|
|
|
if( mDriver == "software" )
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "Software GL renderer detected, forcing compositing off.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true; // allow
|
|
|
|
case XRenderCompositing:
|
|
|
|
return true; // xrender - always allow?
|
|
|
|
}
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
void CompositingPrefs::detect()
|
|
|
|
{
|
2007-09-26 16:34:08 +00:00
|
|
|
if( !compositingPossible())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-09-27 19:04:18 +00:00
|
|
|
if( !Extensions::glxAvailable())
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "No GLX available";
|
|
|
|
return;
|
|
|
|
}
|
2007-09-30 14:08:24 +00:00
|
|
|
int glxmajor, glxminor;
|
|
|
|
glXQueryVersion( display(), &glxmajor, &glxminor );
|
2008-01-16 21:58:37 +00:00
|
|
|
kDebug( 1212 ) << "glx version is " << glxmajor << "." << glxminor;
|
2007-09-30 14:08:24 +00:00
|
|
|
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;
|
2007-09-30 14:08:24 +00:00
|
|
|
if( hasglx13 )
|
|
|
|
oldreaddrawable = glXGetCurrentReadDrawable();
|
|
|
|
|
2008-01-22 17:04:41 +00:00
|
|
|
if( initGLXContext() )
|
2007-09-18 13:59:06 +00:00
|
|
|
{
|
|
|
|
detectDriverAndVersion();
|
|
|
|
applyDriverSpecificOptions();
|
|
|
|
}
|
2007-10-31 16:28:59 +00:00
|
|
|
if( hasglx13 )
|
|
|
|
glXMakeContextCurrent( display(), olddrawable, oldreaddrawable, oldcontext );
|
|
|
|
else
|
|
|
|
glXMakeCurrent( display(), olddrawable, oldcontext );
|
2008-01-22 17:04:41 +00:00
|
|
|
deleteGLXContext();
|
2007-09-18 13:59:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-01-22 17:04:41 +00:00
|
|
|
bool CompositingPrefs::initGLXContext()
|
2007-09-18 13:59:06 +00:00
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
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;
|
|
|
|
|
2007-10-31 17:10:33 +00:00
|
|
|
XVisualInfo* visinfo = glXChooseVisual( display(), DefaultScreen( display()), attribs.data() );
|
2007-09-18 13:59:06 +00:00
|
|
|
if( !visinfo )
|
|
|
|
{
|
|
|
|
attribs.last() = GLX_DOUBLEBUFFER;
|
|
|
|
attribs << None;
|
2007-10-31 17:21:18 +00:00
|
|
|
visinfo = glXChooseVisual( display(), DefaultScreen( display()), attribs.data() );
|
2007-09-18 13:59:06 +00:00
|
|
|
if (!visinfo)
|
|
|
|
{
|
2008-01-14 22:16:29 +00:00
|
|
|
kDebug( 1212 ) << "Error: couldn't find RGB GLX visual";
|
2007-09-18 13:59:06 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mGLContext = glXCreateContext( display(), visinfo, NULL, True );
|
|
|
|
if ( !mGLContext )
|
|
|
|
{
|
2008-01-14 22:16:29 +00:00
|
|
|
kDebug( 1212 ) << "glXCreateContext failed";
|
2007-09-18 13:59:06 +00:00
|
|
|
XDestroyWindow( display(), mGLWindow );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.colormap = XCreateColormap( display(), rootWindow(), visinfo->visual, AllocNone );
|
|
|
|
attr.event_mask = StructureNotifyMask | ExposureMask;
|
|
|
|
unsigned long mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
|
|
|
int width = 100, height = 100;
|
|
|
|
mGLWindow = XCreateWindow( display(), rootWindow(), 0, 0, width, height,
|
|
|
|
0, visinfo->depth, InputOutput,
|
|
|
|
visinfo->visual, mask, &attr );
|
|
|
|
|
2007-09-26 13:47:01 +00:00
|
|
|
return glXMakeCurrent( display(), mGLWindow, mGLContext ) && !handler.error( true );
|
2007-09-18 13:59:06 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompositingPrefs::deleteGLXContext()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2008-01-22 17:04:41 +00:00
|
|
|
if( mGLContext == NULL )
|
|
|
|
return;
|
2007-09-18 13:59:06 +00:00
|
|
|
glXDestroyContext( display(), mGLContext );
|
|
|
|
XDestroyWindow( display(), mGLWindow );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompositingPrefs::detectDriverAndVersion()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-09-27 13:59:58 +00:00
|
|
|
mGLVendor = QString((const char*)glGetString( GL_VENDOR ));
|
|
|
|
mGLRenderer = QString((const char*)glGetString( GL_RENDERER ));
|
|
|
|
mGLVersion = QString((const char*)glGetString( GL_VERSION ));
|
2007-10-17 15:37:14 +00:00
|
|
|
mXgl = detectXgl();
|
2008-01-16 21:58:37 +00:00
|
|
|
kDebug( 1212 ) << "GL vendor is" << mGLVendor;
|
|
|
|
kDebug( 1212 ) << "GL renderer is" << mGLRenderer;
|
|
|
|
kDebug( 1212 ) << "GL version is" << mGLVersion;
|
|
|
|
kDebug( 1212 ) << "XGL:" << ( mXgl ? "yes" : "no" );
|
2007-09-27 13:59:58 +00:00
|
|
|
|
2009-10-30 08:10:35 +00:00
|
|
|
if( mGLRenderer.startsWith( "Mesa DRI Intel" ) || mGLRenderer.startsWith( "Mesa DRI Mobile Intel" )) // krazy:exclude=strings
|
2007-10-17 15:37:14 +00:00
|
|
|
{
|
2007-09-18 13:59:06 +00:00
|
|
|
mDriver = "intel";
|
2009-10-30 06:51:59 +00:00
|
|
|
QStringList words = mGLRenderer.split(' ');
|
2007-09-18 13:59:06 +00:00
|
|
|
mVersion = Version( words[ words.count() - 2 ] );
|
2007-10-17 15:37:14 +00:00
|
|
|
}
|
2008-09-24 16:36:24 +00:00
|
|
|
else if( mGLVendor == "NVIDIA Corporation" )
|
2007-10-17 15:37:14 +00:00
|
|
|
{
|
2007-09-18 13:59:06 +00:00
|
|
|
mDriver = "nvidia";
|
2009-10-30 06:51:59 +00:00
|
|
|
QStringList words = mGLVersion.split(' ');
|
2007-09-18 13:59:06 +00:00
|
|
|
mVersion = Version( words[ words.count() - 1 ] );
|
2007-10-17 15:37:14 +00:00
|
|
|
}
|
2008-09-24 16:36:24 +00:00
|
|
|
else if( mGLVendor == "ATI Technologies Inc." )
|
|
|
|
{
|
|
|
|
mDriver = "fglrx";
|
2009-04-27 10:12:12 +00:00
|
|
|
// Ati changed the version string.
|
|
|
|
// The GL version is either in the first or second part
|
2009-10-30 06:51:59 +00:00
|
|
|
QStringList versionParts = mGLVersion.split(' ');
|
2009-04-27 10:12:12 +00:00
|
|
|
if( versionParts.first().count(".") == 2 || versionParts.count() == 1 )
|
|
|
|
mVersion = Version( versionParts.first() );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// version in second part is encapsulated in ()
|
|
|
|
mVersion = Version( versionParts[1].mid( 1, versionParts[1].length() -2 ) );
|
|
|
|
}
|
2008-09-24 16:36:24 +00:00
|
|
|
}
|
2009-10-30 08:10:35 +00:00
|
|
|
else if( mGLRenderer.startsWith( "Mesa DRI R" )) // krazy:exclude=strings
|
2008-10-15 14:10:43 +00:00
|
|
|
{
|
2008-09-24 16:36:24 +00:00
|
|
|
mDriver = "radeon";
|
2009-10-30 06:51:59 +00:00
|
|
|
mVersion = Version( mGLRenderer.split(' ')[ 3 ] );
|
2009-12-04 01:13:33 +00:00
|
|
|
// Check that the version string is changed, and try the fifth element if it does
|
|
|
|
if (!mVersion.startsWith("20"))
|
|
|
|
mVersion = Version( mGLRenderer.split(' ')[ 5 ] );
|
2008-09-24 16:36:24 +00:00
|
|
|
}
|
2008-10-15 13:41:53 +00:00
|
|
|
else if( mGLRenderer == "Software Rasterizer" )
|
|
|
|
{
|
|
|
|
mDriver = "software";
|
2009-10-30 06:51:59 +00:00
|
|
|
QStringList words = mGLVersion.split(' ');
|
2008-10-15 13:41:53 +00:00
|
|
|
mVersion = Version( words[ words.count() - 1 ] );
|
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
else
|
2007-10-17 15:37:14 +00:00
|
|
|
{
|
2007-09-18 13:59:06 +00:00
|
|
|
mDriver = "unknown";
|
2007-10-17 15:37:14 +00:00
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
|
2008-01-16 21:58:37 +00:00
|
|
|
kDebug( 1212 ) << "Detected driver" << mDriver << ", version" << mVersion.join(".");
|
2007-09-18 13:59:06 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-12-04 08:58:54 +00:00
|
|
|
void CompositingPrefs::parseMesaVersion( const QString &version, int *major, int *minor )
|
|
|
|
{
|
|
|
|
*major = 0;
|
|
|
|
*minor = 0;
|
|
|
|
|
|
|
|
const QStringList tokens = version.split( ' ' );
|
|
|
|
int token = 0;
|
|
|
|
while( token < tokens.count() && !tokens.at( token ).endsWith( "Mesa" ) )
|
|
|
|
token++;
|
|
|
|
|
|
|
|
if( token < tokens.count() - 1 )
|
|
|
|
{
|
|
|
|
const QStringList version = tokens.at( token + 1 ).split( '.' );
|
|
|
|
if( version.count() >= 2 )
|
|
|
|
{
|
|
|
|
*major = version[ 0 ].toInt();
|
|
|
|
|
|
|
|
int end = 0;
|
|
|
|
while( end < version[ 1 ].length() && version[ 1 ][ end ].isDigit() )
|
|
|
|
end++;
|
|
|
|
|
|
|
|
*minor = version[ 1 ].left( end ).toInt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2007-10-17 15:37:14 +00:00
|
|
|
if( mXgl )
|
|
|
|
{
|
2008-01-16 21:58:37 +00:00
|
|
|
kDebug( 1212 ) << "xgl, enabling";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2007-10-17 15:37:14 +00:00
|
|
|
mStrictBinding = false;
|
|
|
|
}
|
2007-10-31 16:28:59 +00:00
|
|
|
else if( mDriver == "intel" )
|
2007-09-18 13:59:06 +00:00
|
|
|
{
|
2008-01-16 21:58:37 +00:00
|
|
|
kDebug( 1212 ) << "intel driver, disabling vsync, enabling direct";
|
2007-09-22 11:19:22 +00:00
|
|
|
mEnableVSync = false;
|
|
|
|
mEnableDirectRendering = true;
|
2008-10-15 14:10:43 +00:00
|
|
|
if( mVersion >= Version( "20061017" ))
|
|
|
|
{
|
|
|
|
if( mGLRenderer.contains( "Intel(R) 9" ))
|
|
|
|
{ // Enable compositing by default on 900-series cards
|
|
|
|
kDebug( 1212 ) << "intel >= 20061017 and 900-series card, enabling compositing";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2008-10-15 14:10:43 +00:00
|
|
|
}
|
|
|
|
if( mGLRenderer.contains( "Mesa DRI Intel(R) G" ))
|
|
|
|
{ // e.g. G43 chipset
|
|
|
|
kDebug( 1212 ) << "intel >= 20061017 and Gxx-series card, enabling compositing";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2008-10-15 14:10:43 +00:00
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( mDriver == "nvidia" )
|
|
|
|
{
|
2007-10-17 15:37:14 +00:00
|
|
|
mStrictBinding = false;
|
2008-11-06 09:31:33 +00:00
|
|
|
if( mVersion >= Version( "173.14.12" ))
|
2007-10-23 12:07:39 +00:00
|
|
|
{
|
2008-11-06 09:31:33 +00:00
|
|
|
kDebug( 1212 ) << "nvidia >= 173.14.12, enabling compositing";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2007-09-18 13:59:06 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-15 14:10:43 +00:00
|
|
|
else if( mDriver == "radeon" )
|
2009-12-04 08:58:54 +00:00
|
|
|
{
|
2009-10-30 08:10:35 +00:00
|
|
|
if( mGLRenderer.startsWith( "Mesa DRI R200" ) && mVersion >= Version( "20060602" )) // krazy:exclude=strings
|
2008-10-15 14:10:43 +00:00
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "radeon r200 >= 20060602, enabling compositing";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2008-10-15 14:10:43 +00:00
|
|
|
}
|
2009-12-04 01:13:33 +00:00
|
|
|
if( mGLRenderer.startsWith( "Mesa DRI R300" ) && mVersion >= Version( "20090101" )) // krazy:exclude=strings
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "radeon r300 >= 20090101, enabling compositing";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2009-12-04 01:13:33 +00:00
|
|
|
}
|
2009-12-04 08:58:54 +00:00
|
|
|
if( mGLRenderer.startsWith( "Mesa DRI R600" ) )
|
|
|
|
{
|
|
|
|
// Enable compositing with Mesa 7.7 or later
|
|
|
|
int major, minor;
|
|
|
|
parseMesaVersion( mGLVersion, &major, &minor );
|
|
|
|
if( major > 7 || ( major == 7 && minor >= 7 ) )
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "Radeon R600/R700, Mesa 7.7 or better. Enabling compositing.";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2009-12-04 08:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-15 14:10:43 +00:00
|
|
|
}
|
|
|
|
else if( mDriver == "fglrx" )
|
|
|
|
{ // radeon r200 only ?
|
|
|
|
if( mVersion >= Version( "2.1.7412" ))
|
|
|
|
{
|
|
|
|
kDebug( 1212 ) << "fglrx >= 2.1.7412, enabling compositing";
|
2009-12-04 09:29:08 +00:00
|
|
|
mRecommendCompositing = true;
|
2008-10-15 14:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-18 13:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-17 15:37:14 +00:00
|
|
|
bool CompositingPrefs::detectXgl()
|
|
|
|
{ // Xgl apparently uses only this specific X version
|
|
|
|
return VendorRelease(display()) == 70000001;
|
|
|
|
}
|
|
|
|
|
2007-09-18 13:59:06 +00:00
|
|
|
CompositingPrefs::Version::Version( const QString& str ) :
|
|
|
|
QStringList()
|
|
|
|
{
|
|
|
|
QRegExp numrx( "(\\d+)|(\\D+)" );
|
|
|
|
int pos = 0;
|
|
|
|
while(( pos = numrx.indexIn( str, pos )) != -1 )
|
|
|
|
{
|
|
|
|
pos += numrx.matchedLength();
|
|
|
|
|
|
|
|
QString part = numrx.cap();
|
|
|
|
if( part == "." )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
append( part );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int CompositingPrefs::Version::compare( const Version& v ) const
|
|
|
|
{
|
|
|
|
for( int i = 0; i < qMin( count(), v.count() ); i++ )
|
|
|
|
{
|
|
|
|
if( at( i )[ 0 ].isDigit() )
|
|
|
|
{
|
|
|
|
// This part of version string is numeric - compare numbers
|
|
|
|
int num = at( i ).toInt();
|
|
|
|
int vnum = v.at( i ).toInt();
|
|
|
|
if( num > vnum )
|
|
|
|
return 1;
|
|
|
|
else if( num < vnum )
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This part is string
|
|
|
|
if( at( i ) > v.at( i ))
|
|
|
|
return 1;
|
|
|
|
else if( at( i ) < v.at( i ))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( count() > v.count() )
|
|
|
|
return 1;
|
|
|
|
else if( count() < v.count() )
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|