1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #ifndef KWIN_SCENE_OPENGL_H
22 #define KWIN_SCENE_OPENGL_H
26 #include "kwinglutils.h"
28 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
31 #include <X11/extensions/XShm.h>
43 SceneOpenGL( Workspace
* ws
);
44 virtual ~SceneOpenGL();
45 virtual bool initFailed() const;
46 virtual CompositingType
compositingType() const { return OpenGLCompositing
; }
47 virtual void paint( QRegion damage
, ToplevelList windows
);
48 virtual void windowGeometryShapeChanged( Toplevel
* );
49 virtual void windowOpacityChanged( Toplevel
* );
50 virtual void windowAdded( Toplevel
* );
51 virtual void windowClosed( Toplevel
*, Deleted
* );
52 virtual void windowDeleted( Deleted
* );
54 virtual void paintGenericScreen( int mask
, ScreenPaintData data
);
55 virtual void paintBackground( QRegion region
);
62 bool initRenderingContext();
63 bool initBufferConfigs();
64 bool initDrawableConfigs();
66 void flushBuffer( int mask
, QRegion damage
);
73 int bind_texture_format
;
78 GLXFBConfig fbcbuffer
;
80 static GLXFBConfig fbcbuffer_db
;
81 static GLXFBConfig fbcbuffer_nondb
;
82 static FBConfigInfo fbcdrawableinfo
[ 32 + 1 ];
83 static GLXDrawable glxbuffer
;
84 static GLXContext ctxbuffer
;
85 static GLXContext ctxdrawable
;
86 static GLXDrawable last_pixmap
; // for a workaround in bindTexture()
89 QHash
< Toplevel
*, Window
* > windows
;
91 static XShmSegmentInfo shm
;
96 class SceneOpenGL::Texture
101 Texture( const Pixmap
& pix
, const QSize
& size
, int depth
);
104 using GLTexture::load
;
105 virtual bool load( const Pixmap
& pix
, const QSize
& size
, int depth
,
107 virtual bool load( const Pixmap
& pix
, const QSize
& size
, int depth
);
108 virtual bool load( const QImage
& image
, GLenum target
= GL_TEXTURE_2D
);
109 virtual bool load( const QPixmap
& pixmap
, GLenum target
= GL_TEXTURE_2D
);
110 virtual void discard();
111 virtual void release(); // undo the tfp_mode binding
113 virtual void unbind();
117 QRegion
optimizeBindDamage( const QRegion
& reg
, int limit
);
118 void createTexture();
123 GLXPixmap bound_glxpixmap
; // the glx pixmap the texture is bound to, only for tfp_mode
126 class SceneOpenGL::Window
127 : public Scene::Window
130 Window( Toplevel
* c
);
132 virtual void performPaint( int mask
, QRegion region
, WindowPaintData data
);
133 virtual void pixmapDiscarded();
135 void discardTexture();
136 void checkTextureSize();
139 void renderQuads( int mask
, const QRegion
& region
, const WindowQuadList
& quads
);
140 void prepareStates( double opacity
, double brightness
, double saturation
, GLShader
* shader
);
141 void prepareRenderStates( double opacity
, double brightness
, double saturation
);
142 void prepareShaderRenderStates( double opacity
, double brightness
, double saturation
, GLShader
* shader
);
143 void restoreStates( double opacity
, double brightness
, double saturation
, GLShader
* shader
);
144 void restoreRenderStates( double opacity
, double brightness
, double saturation
);
145 void restoreShaderRenderStates( double opacity
, double brightness
, double saturation
, GLShader
* shader
);