2006-07-05 12:30:03 +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_XRENDER_H
|
|
|
|
#define KWIN_SCENE_XRENDER_H
|
|
|
|
|
2006-07-05 13:26:08 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_XRENDER
|
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
|
|
|
|
#include "scene.h"
|
2006-07-06 09:55:10 +00:00
|
|
|
#include "effects.h"
|
2006-10-15 07:41:19 +00:00
|
|
|
#include "toplevel.h"
|
2006-07-05 13:26:08 +00:00
|
|
|
|
2006-07-05 12:30:03 +00:00
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
2006-07-06 09:55:10 +00:00
|
|
|
class Matrix;
|
|
|
|
|
2006-07-05 13:26:08 +00:00
|
|
|
class SceneXrender
|
|
|
|
: public Scene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SceneXrender( Workspace* ws );
|
|
|
|
virtual ~SceneXrender();
|
2006-09-30 15:40:03 +00:00
|
|
|
virtual void paint( QRegion damage, ToplevelList windows );
|
2006-07-05 20:52:57 +00:00
|
|
|
virtual void windowGeometryShapeChanged( Toplevel* );
|
|
|
|
virtual void windowOpacityChanged( Toplevel* );
|
2006-09-29 19:05:36 +00:00
|
|
|
virtual void windowAdded( Toplevel* );
|
2006-07-05 20:52:57 +00:00
|
|
|
virtual void windowDeleted( Toplevel* );
|
2006-07-05 13:26:08 +00:00
|
|
|
private:
|
|
|
|
void createBuffer();
|
2006-10-14 22:08:51 +00:00
|
|
|
void paintGenericScreen( ToplevelList windows );
|
|
|
|
void paintSimpleScreen( QRegion damage, ToplevelList windows );
|
2006-10-15 07:41:19 +00:00
|
|
|
void paintBackground( QRegion region );
|
|
|
|
static QRegion infiniteRegion();
|
|
|
|
static XserverRegion toXserverRegion( QRegion region );
|
2006-10-14 22:08:51 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PAINT_OPAQUE = 1 << 0,
|
|
|
|
PAINT_TRANSLUCENT = 1 << 1
|
|
|
|
};
|
2006-07-05 13:26:08 +00:00
|
|
|
XRenderPictFormat* format;
|
|
|
|
Picture front;
|
2006-10-14 22:08:51 +00:00
|
|
|
static Picture buffer;
|
|
|
|
class Window;
|
|
|
|
QMap< Toplevel*, Window > windows;
|
|
|
|
struct Phase2Data
|
2006-07-05 20:52:57 +00:00
|
|
|
{
|
2006-10-15 07:41:19 +00:00
|
|
|
Phase2Data( Window* w, QRegion r ) : window( w ), region( r ) {}
|
2006-10-14 22:08:51 +00:00
|
|
|
Window* window;
|
2006-10-15 07:41:19 +00:00
|
|
|
QRegion region;
|
2006-07-05 20:52:57 +00:00
|
|
|
};
|
2006-10-14 22:08:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SceneXrender::Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window( Toplevel* c );
|
|
|
|
void free(); // is often copied by value, use manually instead of dtor
|
2006-10-15 07:41:19 +00:00
|
|
|
int x() const;
|
|
|
|
int y() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
void paint( QRegion region, int mask );
|
2006-10-14 22:08:51 +00:00
|
|
|
bool isOpaque() const;
|
|
|
|
void geometryShapeChanged();
|
|
|
|
void opacityChanged();
|
|
|
|
bool isVisible() const;
|
2006-10-15 07:41:19 +00:00
|
|
|
QRegion shape() const;
|
2006-10-14 22:08:51 +00:00
|
|
|
void discardPicture();
|
|
|
|
void discardShape();
|
|
|
|
void discardAlpha();
|
|
|
|
Window() {} // QMap sucks even in Qt4
|
|
|
|
private:
|
|
|
|
Picture picture();
|
|
|
|
Picture alphaMask();
|
|
|
|
Toplevel* toplevel;
|
|
|
|
Picture _picture;
|
|
|
|
XRenderPictFormat* format;
|
|
|
|
Picture alpha;
|
|
|
|
double alpha_cached_opacity;
|
2006-10-15 07:41:19 +00:00
|
|
|
mutable QRegion shape_region;
|
|
|
|
mutable bool shape_valid;
|
2006-07-05 13:26:08 +00:00
|
|
|
};
|
|
|
|
|
2006-10-15 07:41:19 +00:00
|
|
|
inline
|
|
|
|
QRegion SceneXrender::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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneXrender::Window::x() const
|
|
|
|
{
|
|
|
|
return toplevel->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneXrender::Window::y() const
|
|
|
|
{
|
|
|
|
return toplevel->y();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneXrender::Window::width() const
|
|
|
|
{
|
|
|
|
return toplevel->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
int SceneXrender::Window::height() const
|
|
|
|
{
|
|
|
|
return toplevel->height();
|
|
|
|
}
|
|
|
|
|
2006-07-05 12:30:03 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|
2006-07-05 13:26:08 +00:00
|
|
|
|
|
|
|
#endif
|