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-09-30 17:28:27 +00:00
|
|
|
virtual void windowAdded( Toplevel* c );
|
|
|
|
virtual void windowDeleted( Toplevel* c );
|
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* c );
|
2006-09-29 16:49:34 +00:00
|
|
|
private:
|
2006-09-29 19:05:36 +00:00
|
|
|
typedef GLuint Texture;
|
2006-09-29 16:49:34 +00:00
|
|
|
GC gcroot;
|
|
|
|
Pixmap buffer;
|
|
|
|
GLXFBConfig fbcroot;
|
2006-09-29 19:05:36 +00:00
|
|
|
static GLXFBConfig fbcdrawable;
|
2006-09-30 18:09:41 +00:00
|
|
|
static GLXPixmap glxroot;
|
2006-09-30 16:17:54 +00:00
|
|
|
static GLXContext context;
|
2006-09-29 19:05:36 +00:00
|
|
|
class Window;
|
|
|
|
QMap< Toplevel*, Window > windows;
|
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-09-30 16:17:54 +00:00
|
|
|
int glX() const; // remap to OpenGL coordinates
|
|
|
|
int glY() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
2006-09-30 18:09:41 +00:00
|
|
|
void setDepth( int depth );
|
|
|
|
void draw();
|
|
|
|
bool isVisible() const;
|
|
|
|
bool isOpaque() const;
|
2006-09-29 19:05:36 +00:00
|
|
|
GLXPixmap glxPixmap() 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 discardPixmap();
|
|
|
|
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;
|
|
|
|
mutable GLXPixmap glxpixmap;
|
2006-09-30 16:17:54 +00:00
|
|
|
Texture texture;
|
2006-09-30 17:28:27 +00:00
|
|
|
mutable QRegion shape_region;
|
|
|
|
mutable bool shape_valid;
|
2006-09-30 18:09:41 +00:00
|
|
|
int depth;
|
2006-09-29 19:05:36 +00:00
|
|
|
};
|
|
|
|
|
2006-09-30 16:17:54 +00:00
|
|
|
inline
|
|
|
|
int SceneOpenGL::Window::glX() const
|
|
|
|
{
|
|
|
|
return toplevel->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneOpenGL::Window::glY() const
|
|
|
|
{
|
|
|
|
return displayHeight() - toplevel->y() - toplevel->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneOpenGL::Window::width() const
|
|
|
|
{
|
|
|
|
return toplevel->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneOpenGL::Window::height() const
|
|
|
|
{
|
|
|
|
return toplevel->height();
|
|
|
|
}
|
|
|
|
|
2006-09-29 19:05:36 +00:00
|
|
|
inline
|
|
|
|
void SceneOpenGL::Window::discardPixmap()
|
|
|
|
{
|
|
|
|
if( glxpixmap != None )
|
|
|
|
glXDestroyPixmap( display(), glxpixmap );
|
|
|
|
glxpixmap = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
void SceneOpenGL::Window::discardTexture()
|
|
|
|
{
|
2006-09-30 16:17:54 +00:00
|
|
|
if( texture != None )
|
|
|
|
glDeleteTextures( 1, &texture );
|
|
|
|
texture = None;
|
2006-09-29 19:05:36 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 16:49:34 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|