KWin
scene_opengl.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KWIN_SCENE_OPENGL_H
00022 #define KWIN_SCENE_OPENGL_H
00023
00024 #include "scene.h"
00025
00026 #include "kwinglutils.h"
00027
00028 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
00029
00030 #ifdef HAVE_XSHM
00031 #include <X11/extensions/XShm.h>
00032 #endif
00033
00034 namespace KWin
00035 {
00036
00037 class SceneOpenGL
00038 : public Scene
00039 {
00040 public:
00041 class Texture;
00042 class Window;
00043 SceneOpenGL( Workspace* ws );
00044 virtual ~SceneOpenGL();
00045 virtual bool initFailed() const;
00046 virtual CompositingType compositingType() const { return OpenGLCompositing; }
00047 virtual void paint( QRegion damage, ToplevelList windows );
00048 virtual void windowGeometryShapeChanged( Toplevel* );
00049 virtual void windowOpacityChanged( Toplevel* );
00050 virtual void windowAdded( Toplevel* );
00051 virtual void windowClosed( Toplevel*, Deleted* );
00052 virtual void windowDeleted( Deleted* );
00053 protected:
00054 virtual void paintGenericScreen( int mask, ScreenPaintData data );
00055 virtual void paintBackground( QRegion region );
00056 private:
00057 bool selectMode();
00058 bool initTfp();
00059 bool initShm();
00060 void cleanupShm();
00061 bool initBuffer();
00062 bool initRenderingContext();
00063 bool initBufferConfigs();
00064 bool initDrawableConfigs();
00065 void waitSync();
00066 void flushBuffer( int mask, QRegion damage );
00067 GC gcroot;
00068 class FBConfigInfo
00069 {
00070 public:
00071 GLXFBConfig fbconfig;
00072 int bind_texture_format;
00073 int y_inverted;
00074 int mipmap;
00075 };
00076 Drawable buffer;
00077 GLXFBConfig fbcbuffer;
00078 static bool db;
00079 static GLXFBConfig fbcbuffer_db;
00080 static GLXFBConfig fbcbuffer_nondb;
00081 static FBConfigInfo fbcdrawableinfo[ 32 + 1 ];
00082 static GLXDrawable glxbuffer;
00083 static GLXContext ctxbuffer;
00084 static GLXContext ctxdrawable;
00085 static GLXDrawable last_pixmap;
00086 static bool tfp_mode;
00087 static bool shm_mode;
00088 QHash< Toplevel*, Window* > windows;
00089 #ifdef HAVE_XSHM
00090 static XShmSegmentInfo shm;
00091 #endif
00092 bool init_ok;
00093 };
00094
00095 class SceneOpenGL::Texture
00096 : public GLTexture
00097 {
00098 public:
00099 Texture();
00100 Texture( const Pixmap& pix, const QSize& size, int depth );
00101 virtual ~Texture();
00102
00103 using GLTexture::load;
00104 virtual bool load( const Pixmap& pix, const QSize& size, int depth,
00105 QRegion region );
00106 virtual bool load( const Pixmap& pix, const QSize& size, int depth );
00107 virtual bool load( const QImage& image, GLenum target = GL_TEXTURE_2D );
00108 virtual bool load( const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D );
00109 virtual void discard();
00110 virtual void release();
00111 virtual void bind();
00112 virtual void unbind();
00113
00114 protected:
00115 void findTarget();
00116 QRegion optimizeBindDamage( const QRegion& reg, int limit );
00117 void createTexture();
00118
00119 private:
00120 void init();
00121
00122 GLXPixmap bound_glxpixmap;
00123 };
00124
00125 class SceneOpenGL::Window
00126 : public Scene::Window
00127 {
00128 public:
00129 Window( Toplevel* c );
00130 virtual ~Window();
00131 virtual void performPaint( int mask, QRegion region, WindowPaintData data );
00132 virtual void pixmapDiscarded();
00133 bool bindTexture();
00134 void discardTexture();
00135 void checkTextureSize();
00136
00137 protected:
00138 void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads );
00139 void prepareStates( double opacity, double brightness, double saturation, GLShader* shader );
00140 void prepareRenderStates( double opacity, double brightness, double saturation );
00141 void prepareShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader );
00142 void restoreStates( double opacity, double brightness, double saturation, GLShader* shader );
00143 void restoreRenderStates( double opacity, double brightness, double saturation );
00144 void restoreShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader );
00145
00146 private:
00147 Texture texture;
00148 };
00149
00150 }
00151
00152 #endif
00153
00154 #endif