• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KWin

scene_opengl.h

Go to the documentation of this file.
00001 /********************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
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; // for a workaround in bindTexture()
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(); // undo the tfp_mode binding
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; // the glx pixmap the texture is bound to, only for tfp_mode
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 } // namespace
00151 
00152 #endif
00153 
00154 #endif

KWin

Skip menu "KWin"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal