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"
|
|
|
|
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
|
2006-11-16 08:36:30 +00:00
|
|
|
#include <X11/extensions/XShm.h>
|
|
|
|
|
2006-09-29 16:49:34 +00:00
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
class SceneOpenGL
|
|
|
|
: public Scene
|
|
|
|
{
|
|
|
|
public:
|
2007-01-24 11:51:38 +00:00
|
|
|
class Window;
|
2006-09-29 16:49:34 +00:00
|
|
|
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* );
|
2007-01-22 22:51:30 +00:00
|
|
|
virtual void windowClosed( Toplevel*, Deleted* );
|
|
|
|
virtual void windowDeleted( Deleted* );
|
2006-10-16 21:06:34 +00:00
|
|
|
protected:
|
2006-10-21 18:07:00 +00:00
|
|
|
virtual void paintGenericScreen( int mask, ScreenPaintData data );
|
2006-10-16 21:06:34 +00:00
|
|
|
virtual void paintBackground( QRegion region );
|
2006-09-29 16:49:34 +00:00
|
|
|
private:
|
2006-11-19 20:13:49 +00:00
|
|
|
void selectMode();
|
|
|
|
bool initTfp();
|
2006-11-16 08:36:30 +00:00
|
|
|
bool initShm();
|
|
|
|
void cleanupShm();
|
2006-10-08 20:31:00 +00:00
|
|
|
void initBuffer();
|
2006-11-16 09:02:03 +00:00
|
|
|
void initRenderingContext();
|
2007-01-31 14:32:52 +00:00
|
|
|
bool initBufferConfigs();
|
|
|
|
bool initDrawableConfigs();
|
2006-11-21 20:59:59 +00:00
|
|
|
void waitSync();
|
2006-11-21 22:22:48 +00:00
|
|
|
void flushBuffer( int mask, QRegion damage );
|
2006-09-29 19:05:36 +00:00
|
|
|
typedef GLuint Texture;
|
2007-01-24 21:35:58 +00:00
|
|
|
typedef GLenum Target;
|
2006-09-29 16:49:34 +00:00
|
|
|
GC gcroot;
|
2007-01-31 14:32:52 +00:00
|
|
|
class FBConfigInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GLXFBConfig fbconfig;
|
|
|
|
int bind_texture_format;
|
|
|
|
int y_inverted;
|
2007-02-02 19:56:18 +00:00
|
|
|
int mipmap;
|
2007-01-31 14:32:52 +00:00
|
|
|
};
|
2006-10-08 20:31:00 +00:00
|
|
|
Drawable buffer;
|
2006-11-07 22:44:39 +00:00
|
|
|
GLXFBConfig fbcbuffer;
|
|
|
|
static bool db;
|
2007-01-31 14:32:52 +00:00
|
|
|
static GLXFBConfig fbcbuffer_db;
|
|
|
|
static GLXFBConfig fbcbuffer_nondb;
|
|
|
|
static FBConfigInfo fbcdrawableinfo[ 32 + 1 ];
|
2006-11-07 22:44:39 +00:00
|
|
|
static GLXDrawable glxbuffer;
|
|
|
|
static GLXContext ctxbuffer;
|
2006-11-16 07:57:55 +00:00
|
|
|
static GLXContext ctxdrawable;
|
|
|
|
static GLXDrawable last_pixmap; // for a workaround in bindTexture()
|
2006-10-07 21:23:46 +00:00
|
|
|
static bool tfp_mode;
|
2006-11-16 08:36:30 +00:00
|
|
|
static bool shm_mode;
|
2006-11-16 07:46:39 +00:00
|
|
|
static bool strict_binding;
|
2006-10-21 15:23:01 +00:00
|
|
|
static bool copy_buffer_hack;
|
2007-01-24 21:35:58 +00:00
|
|
|
static bool supports_npot_textures;
|
2007-02-02 19:55:17 +00:00
|
|
|
static bool supports_fbo;
|
2006-11-07 23:33:23 +00:00
|
|
|
static bool supports_saturation;
|
2006-09-29 19:05:36 +00:00
|
|
|
QMap< Toplevel*, Window > windows;
|
2006-11-16 08:36:30 +00:00
|
|
|
static XShmSegmentInfo shm;
|
2006-09-29 16:49:34 +00:00
|
|
|
};
|
|
|
|
|
2006-09-29 19:05:36 +00:00
|
|
|
class SceneOpenGL::Window
|
2006-10-15 08:58:38 +00:00
|
|
|
: public Scene::Window
|
2006-09-29 19:05:36 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
2006-10-16 21:06:34 +00:00
|
|
|
virtual void free();
|
2006-10-22 10:15:19 +00:00
|
|
|
virtual void performPaint( int mask, QRegion region, WindowPaintData data );
|
2007-01-24 11:51:38 +00:00
|
|
|
virtual void prepareForPainting();
|
2007-01-24 21:35:58 +00:00
|
|
|
void findTextureTarget();
|
2006-09-30 16:17:54 +00:00
|
|
|
void bindTexture();
|
2006-11-16 07:46:39 +00:00
|
|
|
void enableTexture();
|
|
|
|
void disableTexture();
|
2006-09-29 19:05:36 +00:00
|
|
|
void discardTexture();
|
2007-01-30 16:42:03 +00:00
|
|
|
void discardVertices();
|
2006-09-30 17:28:27 +00:00
|
|
|
Window() {} // QMap sucks even in Qt4
|
2007-01-24 11:51:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Vertex class
|
|
|
|
* Vertex has position and texture coordinate which are equal at first,
|
|
|
|
* however effects can e.g. modify position to move the window or part of it.
|
|
|
|
**/
|
|
|
|
class Vertex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Vertex() {}
|
|
|
|
Vertex(float x, float y)
|
|
|
|
{
|
|
|
|
pos[0] = texcoord[0] = x; pos[1] = texcoord[1] = y; pos[2] = 0.0f;
|
|
|
|
}
|
|
|
|
Vertex(float x, float y, float u, float v)
|
|
|
|
{
|
|
|
|
pos[0] = x; pos[1] = y; pos[2] = 0.0f; texcoord[0] = u; texcoord[1] = v;
|
|
|
|
}
|
|
|
|
float pos[3];
|
|
|
|
float texcoord[2];
|
|
|
|
};
|
|
|
|
// Returns list of vertices
|
|
|
|
QVector<Vertex>& vertices() { return verticeslist; }
|
|
|
|
// Can be called in pre-paint pass. Makes sure that all quads that the
|
|
|
|
// window consists of are not bigger than maxquadsize x maxquadsize
|
|
|
|
// (in pixels) in the following paint pass.
|
|
|
|
void requestVertexGrid(int maxquadsize);
|
|
|
|
// Marks vertices of the window as dirty. Call this if you change
|
|
|
|
// position of the vertices
|
|
|
|
void markVerticesDirty() { verticesDirty = true; }
|
|
|
|
protected:
|
|
|
|
// Makes sure that vertex grid requests are fulfilled and that vertices
|
|
|
|
// aren't dirty. Call this before paint pass
|
|
|
|
void prepareVertices();
|
|
|
|
void createVertexGrid(int xres, int yres);
|
|
|
|
void resetVertices(); // Resets positions of vertices
|
2006-09-30 17:28:27 +00:00
|
|
|
private:
|
2006-11-19 20:10:25 +00:00
|
|
|
QRegion optimizeBindDamage( const QRegion& reg, int limit );
|
2006-09-30 16:17:54 +00:00
|
|
|
Texture texture;
|
2007-01-24 21:35:58 +00:00
|
|
|
Target texture_target;
|
|
|
|
float texture_scale_x, texture_scale_y; // to un-normalize GL_TEXTURE_2D
|
2006-10-29 19:23:45 +00:00
|
|
|
bool texture_y_inverted; // texture has y inverted
|
2007-02-02 19:56:18 +00:00
|
|
|
bool texture_can_use_mipmaps;
|
|
|
|
bool texture_has_valid_mipmaps;
|
2007-02-02 19:58:35 +00:00
|
|
|
bool texture_filter_trilinear;
|
2006-10-29 19:23:45 +00:00
|
|
|
GLXPixmap bound_glxpixmap; // the glx pixmap the texture is bound to, only for tfp_mode
|
2007-01-24 11:51:38 +00:00
|
|
|
|
|
|
|
QVector<Vertex> verticeslist;
|
|
|
|
// Maximum size of the biggest quad that window currently has, in pixels
|
|
|
|
int currentXResolution;
|
|
|
|
int currentYResolution;
|
|
|
|
// Requested maximum size of the biggest quad that window would have
|
|
|
|
// during the next paint pass, in pixels
|
|
|
|
int requestedXResolution;
|
|
|
|
int requestedYResolution;
|
|
|
|
bool verticesDirty; // vertices have been modified in some way
|
2006-09-29 19:05:36 +00:00
|
|
|
};
|
|
|
|
|
2006-09-29 16:49:34 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|