not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kwin / lib / kwinxrenderutils.h
blob5caafa78d40711372e2909bdf9332d299a687f10
1 /********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
21 #ifndef KWIN_XRENDERUTILS_H
22 #define KWIN_XRENDERUTILS_H
24 #include <kwinconfig.h>
26 #ifdef KWIN_HAVE_XRENDER_COMPOSITING
28 #include <QtCore/QSharedData>
29 #include <QtGui/QColor>
30 #include <ksharedptr.h>
32 #include <kwinglobals.h>
34 #include <X11/extensions/Xfixes.h>
35 #include <X11/extensions/Xrender.h>
37 /** @addtogroup kwineffects */
38 /** @{ */
40 namespace KWin
43 /**
44 * Convert QRegion to XserverRegion.
46 KWIN_EXPORT XserverRegion toXserverRegion( QRegion region );
47 /**
48 * draws a round box on the renderscene
50 KWIN_EXPORT void xRenderRoundBox( Picture pict, const QRect &rect, int round, const QColor &c );
51 /**
52 * dumps a QColor into a XRenderColor
54 KWIN_EXPORT XRenderColor preMultiply(const QColor &c, float opacity = 1.0);
56 /** @internal */
57 class KWIN_EXPORT XRenderPictureData
58 : public QSharedData
60 public:
61 XRenderPictureData( Picture pic = None );
62 ~XRenderPictureData();
63 Picture value();
64 private:
65 Picture picture;
66 Q_DISABLE_COPY( XRenderPictureData )
69 /**
70 * @short Wrapper around XRender Picture.
72 * This class wraps XRender's Picture, providing proper initialization,
73 * convenience constructors and freeing of resources.
74 * It should otherwise act exactly like the Picture type.
76 class KWIN_EXPORT XRenderPicture
78 public:
79 XRenderPicture( Picture pic = None );
80 XRenderPicture( QPixmap pix );
81 XRenderPicture( Pixmap pix, int depth );
82 operator Picture();
83 private:
84 KSharedPtr< XRenderPictureData > d;
87 inline
88 XRenderPictureData::XRenderPictureData( Picture pic )
89 : picture( pic )
93 inline
94 XRenderPictureData::~XRenderPictureData()
96 if( picture != None )
97 XRenderFreePicture( display(), picture );
100 inline
101 Picture XRenderPictureData::value()
103 return picture;
106 inline
107 XRenderPicture::XRenderPicture( Picture pic )
108 : d( new XRenderPictureData( pic ))
112 inline
113 XRenderPicture::operator Picture()
115 return d->value();
119 * Creates a 1x1 Picture filled with c
121 KWIN_EXPORT XRenderPicture xRenderFill( const XRenderColor *c );
122 KWIN_EXPORT XRenderPicture xRenderFill( const QColor &c );
124 } // namespace
126 #endif
128 /** @} */
130 #endif