add more spacing
[personal-kdebase.git] / workspace / kwin / effects / shadow.h
blobeafa1cdb454e1f7b6549448fbb7f418427aa0e5e
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
6 Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
7 Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************/
23 #ifndef KWIN_SHADOW_H
24 #define KWIN_SHADOW_H
26 #include <kwineffects.h>
27 #include <kwinxrenderutils.h>
29 namespace KWin
32 class GLTexture;
34 class ShadowEffect
35 : public QObject, public Effect
37 Q_OBJECT
38 public:
39 ShadowEffect();
40 virtual ~ShadowEffect();
41 virtual void reconfigure( ReconfigureFlags );
42 virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
43 virtual void drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
44 virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
45 virtual void windowClosed( EffectWindow* c );
46 virtual void buildQuads( EffectWindow* w, WindowQuadList& quadList );
47 virtual QRect transformWindowDamage( EffectWindow* w, const QRect& r );
49 private slots:
50 void updateShadowColor();
52 private:
53 void prepareRenderStates( GLTexture *texture, double opacity, double brightness, double saturation );
54 void restoreRenderStates( GLTexture *texture, double opacity, double brightness, double saturation );
56 void drawShadowQuadOpenGL( GLTexture *texture, QVector<float> verts, QVector<float> texCoords,
57 QColor color, QRegion region, float opacity, float brightness, float saturation );
58 void drawShadowQuadXRender( XRenderPicture *picture, QRect rect, float xScale, float yScale,
59 QColor color, float opacity, float brightness, float saturation );
61 void drawShadow( EffectWindow* w, int mask, QRegion region, const WindowPaintData& data );
62 void addQuadVertices(QVector<float>& verts, float x1, float y1, float x2, float y2) const;
63 // transforms window rect -> shadow rect
64 QRect shadowRectangle( EffectWindow* w, const QRect& windowRectangle ) const;
65 bool useShadow( EffectWindow* w ) const;
66 void drawQueuedShadows( EffectWindow* behindWindow );
68 int shadowXOffset, shadowYOffset;
69 double shadowOpacity;
70 int shadowFuzzyness;
71 int shadowSize;
72 bool intensifyActiveShadow;
73 QColor shadowColor;
74 bool forceDecorated;
75 bool forceUndecorated;
76 bool forceOther;
77 #ifdef KWIN_HAVE_OPENGL_COMPOSITING
78 QList< QList<GLTexture*> > mShadowTextures;
79 QList<GLTexture*> mDefaultShadowTextures;
80 #endif
81 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
82 QList< QList<XRenderPicture*> > mShadowPics;
83 QList<XRenderPicture*> mDefaultShadowPics;
84 #endif
86 QList<WindowQuadType> mShadowQuadTypes;
87 WindowQuadType mDefaultShadowQuadType;
89 struct ShadowData
91 ShadowData(EffectWindow* _w, WindowPaintData& _data) : w(_w), data(_data) {}
92 EffectWindow* w;
93 QRegion clip;
94 int mask;
95 QRegion region;
96 WindowPaintData data;
99 QList<ShadowData> shadowDatas;
102 } // namespace
104 #endif