2006-09-29 16:49:34 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_SCENE_OPENGL_H
|
|
|
|
#define KWIN_SCENE_OPENGL_H
|
|
|
|
|
|
|
|
#include "scene.h"
|
2006-09-30 16:17:54 +00:00
|
|
|
#include "toplevel.h"
|
2006-09-29 16:49:34 +00:00
|
|
|
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
class SceneOpenGL
|
|
|
|
: public Scene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SceneOpenGL( Workspace* ws );
|
|
|
|
virtual ~SceneOpenGL();
|
2006-09-30 15:40:03 +00:00
|
|
|
virtual void paint( QRegion damage, ToplevelList windows );
|
2006-10-01 21:14:53 +00:00
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* );
|
|
|
|
virtual void windowOpacityChanged( Toplevel* );
|
|
|
|
virtual void windowAdded( Toplevel* );
|
|
|
|
virtual void windowDeleted( Toplevel* );
|
2006-09-29 16:49:34 +00:00
|
|
|
private:
|
2006-10-08 20:31:00 +00:00
|
|
|
void initBuffer();
|
|
|
|
bool findConfig( const int* attrs, GLXFBConfig& config, VisualID visual = None );
|
2006-10-12 21:49:54 +00:00
|
|
|
void paintGenericScreen( ToplevelList windows );
|
|
|
|
void paintSimpleScreen( QRegion damage, ToplevelList windows );
|
2006-10-14 07:15:23 +00:00
|
|
|
void paintBackground( QRegion damage );
|
|
|
|
static QRegion infiniteRegion();
|
2006-09-29 19:05:36 +00:00
|
|
|
typedef GLuint Texture;
|
2006-09-29 16:49:34 +00:00
|
|
|
GC gcroot;
|
2006-10-08 20:31:00 +00:00
|
|
|
Drawable buffer;
|
2006-09-29 16:49:34 +00:00
|
|
|
GLXFBConfig fbcroot;
|
2006-10-08 20:31:00 +00:00
|
|
|
bool root_db;
|
2006-09-29 19:05:36 +00:00
|
|
|
static GLXFBConfig fbcdrawable;
|
2006-10-08 20:31:00 +00:00
|
|
|
static GLXDrawable glxroot;
|
2006-09-30 16:17:54 +00:00
|
|
|
static GLXContext context;
|
2006-10-07 21:23:46 +00:00
|
|
|
static bool tfp_mode;
|
2006-09-29 19:05:36 +00:00
|
|
|
class Window;
|
|
|
|
QMap< Toplevel*, Window > windows;
|
2006-10-14 07:15:23 +00:00
|
|
|
struct Phase2Data
|
|
|
|
{
|
|
|
|
Phase2Data( Window* w, QRegion r ) : window( w ), region( r ) {}
|
|
|
|
Window* window;
|
|
|
|
QRegion region;
|
|
|
|
};
|
2006-09-29 16:49:34 +00:00
|
|
|
};
|
|
|
|
|
2006-09-29 19:05:36 +00:00
|
|
|
class SceneOpenGL::Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
|
|
|
~Window();
|
|
|
|
void free(); // is often copied by value, use manually instead of dtor
|
2006-10-12 21:12:51 +00:00
|
|
|
int x() const;
|
|
|
|
int y() const;
|
2006-09-30 16:17:54 +00:00
|
|
|
int width() const;
|
|
|
|
int height() const;
|
2006-10-14 07:15:23 +00:00
|
|
|
void paint( QRegion region );
|
2006-09-30 18:09:41 +00:00
|
|
|
bool isVisible() const;
|
|
|
|
bool isOpaque() const;
|
2006-09-30 16:17:54 +00:00
|
|
|
void bindTexture();
|
2006-09-30 17:28:27 +00:00
|
|
|
QRegion shape() const;
|
2006-09-29 19:05:36 +00:00
|
|
|
void discardTexture();
|
2006-09-30 17:28:27 +00:00
|
|
|
void discardShape();
|
|
|
|
Window() {} // QMap sucks even in Qt4
|
|
|
|
private:
|
2006-09-29 19:05:36 +00:00
|
|
|
Toplevel* toplevel;
|
2006-09-30 16:17:54 +00:00
|
|
|
Texture texture;
|
2006-10-07 21:23:46 +00:00
|
|
|
bool texture_y_inverted;
|
|
|
|
Pixmap bound_pixmap;
|
|
|
|
GLXPixmap bound_glxpixmap; // only for tfp_mode
|
2006-09-30 17:28:27 +00:00
|
|
|
mutable QRegion shape_region;
|
|
|
|
mutable bool shape_valid;
|
2006-09-29 19:05:36 +00:00
|
|
|
};
|
|
|
|
|
2006-10-14 07:15:23 +00:00
|
|
|
inline
|
|
|
|
QRegion SceneOpenGL::infiniteRegion()
|
|
|
|
{ // INT_MIN / 2 because it's width/height (INT_MIN+INT_MAX==-1)
|
|
|
|
return QRegion( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
|
|
|
|
}
|
|
|
|
|
2006-09-30 16:17:54 +00:00
|
|
|
inline
|
2006-10-12 21:12:51 +00:00
|
|
|
int SceneOpenGL::Window::x() const
|
2006-09-30 16:17:54 +00:00
|
|
|
{
|
|
|
|
return toplevel->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2006-10-12 21:12:51 +00:00
|
|
|
int SceneOpenGL::Window::y() const
|
2006-09-30 16:17:54 +00:00
|
|
|
{
|
2006-10-12 21:12:51 +00:00
|
|
|
return toplevel->y();
|
2006-09-30 16:17:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneOpenGL::Window::width() const
|
|
|
|
{
|
|
|
|
return toplevel->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneOpenGL::Window::height() const
|
|
|
|
{
|
|
|
|
return toplevel->height();
|
|
|
|
}
|
|
|
|
|
2006-09-29 16:49:34 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|