2007-04-29 17:35:43 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_SCENE_OPENGL_H
|
|
|
|
#define KWIN_SCENE_OPENGL_H
|
|
|
|
|
|
|
|
#include "scene.h"
|
|
|
|
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class SceneOpenGL
|
|
|
|
: public Scene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class Texture;
|
|
|
|
class Window;
|
|
|
|
SceneOpenGL( Workspace* ws );
|
|
|
|
virtual ~SceneOpenGL();
|
2007-05-30 14:22:09 +00:00
|
|
|
virtual bool initFailed() const;
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual CompositingType compositingType() const { return OpenGLCompositing; }
|
|
|
|
virtual void paint( QRegion damage, ToplevelList windows );
|
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* );
|
|
|
|
virtual void windowOpacityChanged( Toplevel* );
|
|
|
|
virtual void windowAdded( Toplevel* );
|
|
|
|
virtual void windowClosed( Toplevel*, Deleted* );
|
|
|
|
virtual void windowDeleted( Deleted* );
|
|
|
|
protected:
|
|
|
|
virtual void paintGenericScreen( int mask, ScreenPaintData data );
|
|
|
|
virtual void paintBackground( QRegion region );
|
|
|
|
private:
|
2007-05-30 14:22:09 +00:00
|
|
|
bool selectMode();
|
2007-04-29 17:35:43 +00:00
|
|
|
bool initTfp();
|
|
|
|
bool initShm();
|
|
|
|
void cleanupShm();
|
2007-05-30 14:22:09 +00:00
|
|
|
bool initBuffer();
|
|
|
|
bool initRenderingContext();
|
2007-04-29 17:35:43 +00:00
|
|
|
bool initBufferConfigs();
|
|
|
|
bool initDrawableConfigs();
|
|
|
|
void waitSync();
|
|
|
|
void flushBuffer( int mask, QRegion damage );
|
|
|
|
GC gcroot;
|
|
|
|
class FBConfigInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLXFBConfig fbconfig;
|
|
|
|
int bind_texture_format;
|
|
|
|
int y_inverted;
|
|
|
|
int mipmap;
|
|
|
|
};
|
|
|
|
Drawable buffer;
|
|
|
|
GLXFBConfig fbcbuffer;
|
|
|
|
static bool db;
|
|
|
|
static GLXFBConfig fbcbuffer_db;
|
|
|
|
static GLXFBConfig fbcbuffer_nondb;
|
|
|
|
static FBConfigInfo fbcdrawableinfo[ 32 + 1 ];
|
|
|
|
static GLXDrawable glxbuffer;
|
|
|
|
static GLXContext ctxbuffer;
|
|
|
|
static GLXContext ctxdrawable;
|
|
|
|
static GLXDrawable last_pixmap; // for a workaround in bindTexture()
|
|
|
|
static bool tfp_mode;
|
|
|
|
static bool shm_mode;
|
|
|
|
QHash< Toplevel*, Window* > windows;
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
static XShmSegmentInfo shm;
|
|
|
|
#endif
|
2007-05-30 14:22:09 +00:00
|
|
|
bool init_ok;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGL::Texture
|
|
|
|
: public GLTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Texture();
|
|
|
|
Texture( const Pixmap& pix, const QSize& size, int depth );
|
|
|
|
virtual ~Texture();
|
|
|
|
|
|
|
|
using GLTexture::load;
|
|
|
|
virtual bool load( const Pixmap& pix, const QSize& size, int depth,
|
|
|
|
QRegion region );
|
|
|
|
virtual bool load( const Pixmap& pix, const QSize& size, int depth );
|
|
|
|
virtual bool load( const QImage& image, GLenum target = GL_TEXTURE_2D );
|
|
|
|
virtual bool load( const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D );
|
|
|
|
virtual void discard();
|
2007-07-05 19:59:55 +00:00
|
|
|
virtual void release(); // undo the tfp_mode binding
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void findTarget();
|
|
|
|
QRegion optimizeBindDamage( const QRegion& reg, int limit );
|
2007-08-26 19:47:18 +00:00
|
|
|
void createTexture();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
|
|
|
|
GLXPixmap bound_glxpixmap; // the glx pixmap the texture is bound to, only for tfp_mode
|
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGL::Window
|
|
|
|
: public Scene::Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
|
|
|
virtual ~Window();
|
|
|
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
2007-07-05 19:59:55 +00:00
|
|
|
virtual void pixmapDiscarded();
|
2007-04-29 17:35:43 +00:00
|
|
|
bool bindTexture();
|
|
|
|
void discardTexture();
|
|
|
|
|
|
|
|
protected:
|
2007-07-19 10:07:49 +00:00
|
|
|
void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads );
|
2007-08-14 15:22:23 +00:00
|
|
|
void prepareStates( float opacity, float brightness, float saturation, GLShader* shader );
|
|
|
|
void prepareRenderStates( float opacity, float brightness, float saturation );
|
|
|
|
void prepareShaderRenderStates( float opacity, float brightness, float saturation, GLShader* shader );
|
|
|
|
void restoreStates( float opacity, float brightness, float saturation, GLShader* shader );
|
|
|
|
void restoreRenderStates( float opacity, float brightness, float saturation );
|
|
|
|
void restoreShaderRenderStates( float opacity, float brightness, float saturation, GLShader* shader );
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Texture texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|