2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef KWIN_SCENE_OPENGL_H
|
|
|
|
#define KWIN_SCENE_OPENGL_H
|
|
|
|
|
|
|
|
#include "scene.h"
|
|
|
|
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class SceneOpenGL
|
|
|
|
: public Scene
|
|
|
|
{
|
|
|
|
public:
|
2010-07-18 16:32:37 +00:00
|
|
|
class EffectFrame;
|
2007-04-29 17:35:43 +00:00
|
|
|
class Texture;
|
|
|
|
class Window;
|
|
|
|
SceneOpenGL( Workspace* ws );
|
|
|
|
virtual ~SceneOpenGL();
|
2007-05-30 14:22:09 +00:00
|
|
|
virtual bool initFailed() const;
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual CompositingType compositingType() const { return OpenGLCompositing; }
|
|
|
|
virtual void paint( QRegion damage, ToplevelList windows );
|
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* );
|
|
|
|
virtual void windowOpacityChanged( Toplevel* );
|
|
|
|
virtual void windowAdded( Toplevel* );
|
|
|
|
virtual void windowClosed( Toplevel*, Deleted* );
|
|
|
|
virtual void windowDeleted( Deleted* );
|
|
|
|
protected:
|
|
|
|
virtual void paintGenericScreen( int mask, ScreenPaintData data );
|
|
|
|
virtual void paintBackground( QRegion region );
|
|
|
|
private:
|
2007-05-30 14:22:09 +00:00
|
|
|
bool selectMode();
|
2007-04-29 17:35:43 +00:00
|
|
|
bool initTfp();
|
|
|
|
bool initShm();
|
|
|
|
void cleanupShm();
|
2007-05-30 14:22:09 +00:00
|
|
|
bool initBuffer();
|
|
|
|
bool initRenderingContext();
|
2007-04-29 17:35:43 +00:00
|
|
|
bool initBufferConfigs();
|
|
|
|
bool initDrawableConfigs();
|
|
|
|
void waitSync();
|
|
|
|
void flushBuffer( int mask, QRegion damage );
|
2008-09-11 16:37:26 +00:00
|
|
|
bool selfCheck();
|
2009-02-09 14:51:11 +00:00
|
|
|
void selfCheckSetup();
|
|
|
|
bool selfCheckFinish();
|
2007-04-29 17:35:43 +00:00
|
|
|
GC gcroot;
|
|
|
|
class FBConfigInfo
|
2008-09-18 15:27:13 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
public:
|
|
|
|
GLXFBConfig fbconfig;
|
|
|
|
int bind_texture_format;
|
2010-10-08 22:18:57 +00:00
|
|
|
int texture_targets;
|
2007-04-29 17:35:43 +00:00
|
|
|
int y_inverted;
|
|
|
|
int mipmap;
|
2008-09-18 15:27:13 +00:00
|
|
|
};
|
2007-04-29 17:35:43 +00:00
|
|
|
Drawable buffer;
|
|
|
|
GLXFBConfig fbcbuffer;
|
|
|
|
static bool db;
|
|
|
|
static GLXFBConfig fbcbuffer_db;
|
|
|
|
static GLXFBConfig fbcbuffer_nondb;
|
|
|
|
static FBConfigInfo fbcdrawableinfo[ 32 + 1 ];
|
|
|
|
static GLXDrawable glxbuffer;
|
|
|
|
static GLXContext ctxbuffer;
|
|
|
|
static GLXContext ctxdrawable;
|
|
|
|
static GLXDrawable last_pixmap; // for a workaround in bindTexture()
|
|
|
|
static bool tfp_mode;
|
|
|
|
static bool shm_mode;
|
|
|
|
QHash< Toplevel*, Window* > windows;
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
static XShmSegmentInfo shm;
|
|
|
|
#endif
|
2007-05-30 14:22:09 +00:00
|
|
|
bool init_ok;
|
2009-02-09 14:51:11 +00:00
|
|
|
bool selfCheckDone;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGL::Texture
|
|
|
|
: public GLTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Texture();
|
|
|
|
Texture( const Pixmap& pix, const QSize& size, int depth );
|
|
|
|
virtual ~Texture();
|
|
|
|
|
|
|
|
using GLTexture::load;
|
|
|
|
virtual bool load( const Pixmap& pix, const QSize& size, int depth,
|
|
|
|
QRegion region );
|
|
|
|
virtual bool load( const Pixmap& pix, const QSize& size, int depth );
|
|
|
|
virtual bool load( const QImage& image, GLenum target = GL_TEXTURE_2D );
|
|
|
|
virtual bool load( const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D );
|
|
|
|
virtual void discard();
|
2007-07-05 19:59:55 +00:00
|
|
|
virtual void release(); // undo the tfp_mode binding
|
2007-04-29 17:35:43 +00:00
|
|
|
virtual void bind();
|
|
|
|
virtual void unbind();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void findTarget();
|
|
|
|
QRegion optimizeBindDamage( const QRegion& reg, int limit );
|
2007-08-26 19:47:18 +00:00
|
|
|
void createTexture();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
|
2010-10-03 18:49:36 +00:00
|
|
|
GLXPixmap glxpixmap; // the glx pixmap the texture is bound to, only for tfp_mode
|
|
|
|
bool damaged;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SceneOpenGL::Window
|
|
|
|
: public Scene::Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
|
|
|
virtual ~Window();
|
|
|
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
2007-07-05 19:59:55 +00:00
|
|
|
virtual void pixmapDiscarded();
|
2007-04-29 17:35:43 +00:00
|
|
|
bool bindTexture();
|
|
|
|
void discardTexture();
|
2008-03-20 10:05:41 +00:00
|
|
|
void checkTextureSize();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
protected:
|
2009-04-22 17:30:49 +00:00
|
|
|
enum TextureType
|
|
|
|
{
|
|
|
|
Content,
|
|
|
|
DecorationTop,
|
|
|
|
DecorationLeft,
|
|
|
|
DecorationRight,
|
|
|
|
DecorationBottom
|
|
|
|
};
|
|
|
|
void paintDecoration( const QPixmap* decoration, TextureType decorationType, const QRegion& region, const QRect& rect, const WindowPaintData& data, const WindowQuadList& quads, bool updateDeco );
|
|
|
|
void makeDecorationArrays( float** vertices, float** texcoords, const WindowQuadList& quads, const QRect& rect ) const;
|
2007-07-19 10:07:49 +00:00
|
|
|
void renderQuads( int mask, const QRegion& region, const WindowQuadList& quads );
|
2009-04-22 17:30:49 +00:00
|
|
|
void prepareStates( TextureType type, double opacity, double brightness, double saturation, GLShader* shader );
|
|
|
|
void prepareRenderStates( TextureType type, double opacity, double brightness, double saturation );
|
|
|
|
void prepareShaderRenderStates( TextureType type, double opacity, double brightness, double saturation, GLShader* shader );
|
|
|
|
void restoreStates( TextureType type, double opacity, double brightness, double saturation, GLShader* shader );
|
|
|
|
void restoreRenderStates( TextureType type, double opacity, double brightness, double saturation );
|
|
|
|
void restoreShaderRenderStates( TextureType type, double opacity, double brightness, double saturation, GLShader* shader );
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Texture texture;
|
2009-04-22 17:30:49 +00:00
|
|
|
Texture topTexture;
|
|
|
|
Texture leftTexture;
|
|
|
|
Texture rightTexture;
|
|
|
|
Texture bottomTexture;
|
2007-04-29 17:35:43 +00:00
|
|
|
};
|
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
class SceneOpenGL::EffectFrame
|
|
|
|
: public Scene::EffectFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EffectFrame( EffectFrameImpl* frame );
|
|
|
|
virtual ~EffectFrame();
|
|
|
|
|
|
|
|
virtual void free();
|
2010-07-20 21:11:03 +00:00
|
|
|
virtual void freeIconFrame();
|
2010-07-18 16:32:37 +00:00
|
|
|
virtual void freeTextFrame();
|
2010-07-26 20:00:04 +00:00
|
|
|
virtual void freeSelection();
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
virtual void render(QRegion region, double opacity, double frameOpacity);
|
|
|
|
|
2010-08-07 14:08:34 +00:00
|
|
|
virtual void crossFadeIcon();
|
|
|
|
virtual void crossFadeText();
|
|
|
|
|
2010-07-18 16:32:37 +00:00
|
|
|
static void cleanup();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateTexture();
|
|
|
|
void updateTextTexture();
|
|
|
|
|
|
|
|
GLTexture* m_texture;
|
|
|
|
GLTexture* m_textTexture;
|
2010-08-07 14:08:34 +00:00
|
|
|
GLTexture* m_oldTextTexture;
|
2010-07-20 21:11:03 +00:00
|
|
|
GLTexture* m_iconTexture;
|
2010-08-07 14:08:34 +00:00
|
|
|
GLTexture* m_oldIconTexture;
|
2010-07-26 20:00:04 +00:00
|
|
|
GLTexture* m_selectionTexture;
|
2010-07-24 08:04:17 +00:00
|
|
|
GLVertexBuffer* m_unstyledVBO;
|
2010-07-18 16:32:37 +00:00
|
|
|
|
|
|
|
static GLTexture* m_unstyledTexture;
|
|
|
|
static void updateUnstyledTexture(); // Update OpenGL unstyled frame texture
|
|
|
|
};
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|