• Skip to content
  • Skip to link menu
KDE 4.2 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         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; // for a workaround in bindTexture()
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(); // undo the tfp_mode binding
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; // the glx pixmap the texture is bound to, only for tfp_mode
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 } // namespace
00152 
00153 #endif
00154 
00155 #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
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
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