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 bool selfCheck();
00068 GC gcroot;
00069 class FBConfigInfo
00070 {
00071 public:
00072 GLXFBConfig fbconfig;
00073 int bind_texture_format;
00074 int y_inverted;
00075 int mipmap;
00076 };
00077 Drawable buffer;
00078 GLXFBConfig fbcbuffer;
00079 static bool db;
00080 static GLXFBConfig fbcbuffer_db;
00081 static GLXFBConfig fbcbuffer_nondb;
00082 static FBConfigInfo fbcdrawableinfo[ 32 + 1 ];
00083 static GLXDrawable glxbuffer;
00084 static GLXContext ctxbuffer;
00085 static GLXContext ctxdrawable;
00086 static GLXDrawable last_pixmap;
00087 static bool tfp_mode;
00088 static bool shm_mode;
00089 QHash< Toplevel*, Window* > windows;
00090 #ifdef HAVE_XSHM
00091 static XShmSegmentInfo shm;
00092 #endif
00093 bool init_ok;
00094 };
00095
00096 class SceneOpenGL::Texture
00097 : public GLTexture
00098 {
00099 public:
00100 Texture();
00101 Texture( const Pixmap& pix, const QSize& size, int depth );
00102 virtual ~Texture();
00103
00104 using GLTexture::load;
00105 virtual bool load( const Pixmap& pix, const QSize& size, int depth,
00106 QRegion region );
00107 virtual bool load( const Pixmap& pix, const QSize& size, int depth );
00108 virtual bool load( const QImage& image, GLenum target = GL_TEXTURE_2D );
00109 virtual bool load( const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D );
00110 virtual void discard();
00111 virtual void release();
00112 virtual void bind();
00113 virtual void unbind();
00114
00115 protected:
00116 void findTarget();
00117 QRegion optimizeBindDamage( const QRegion& reg, int limit );
00118 void createTexture();
00119
00120 private:
00121 void init();
00122
00123 GLXPixmap bound_glxpixmap;
00124 };
00125
00126 class SceneOpenGL::Window
00127 : public Scene::Window
00128 {
00129 public:
00130 Window( Toplevel* c );
00131 virtual ~Window();
00132 virtual void performPaint( int mask, QRegion region, WindowPaintData data );
00133 virtual void pixmapDiscarded();
00134 bool bindTexture();
00135 void discardTexture();
00136 void checkTextureSize();
00137
00138 protected:
00139 void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads );
00140 void prepareStates( double opacity, double brightness, double saturation, GLShader* shader );
00141 void prepareRenderStates( double opacity, double brightness, double saturation );
00142 void prepareShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader );
00143 void restoreStates( double opacity, double brightness, double saturation, GLShader* shader );
00144 void restoreRenderStates( double opacity, double brightness, double saturation );
00145 void restoreShaderRenderStates( double opacity, double brightness, double saturation, GLShader* shader );
00146
00147 private:
00148 Texture texture;
00149 };
00150
00151 }
00152
00153 #endif
00154
00155 #endif