~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/libkwineffects/kwinxrenderutils.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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
*********************************************************************/
 
20
 
 
21
#ifndef KWIN_XRENDERUTILS_H
 
22
#define KWIN_XRENDERUTILS_H
 
23
 
 
24
#include <kwinconfig.h>
 
25
 
 
26
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
 
27
 
 
28
#include <QtCore/QSharedData>
 
29
#include <QtGui/QColor>
 
30
#include <ksharedptr.h>
 
31
 
 
32
#include <kwinglobals.h>
 
33
 
 
34
#include <X11/extensions/Xfixes.h>
 
35
#include <X11/extensions/Xrender.h>
 
36
 
 
37
/** @addtogroup kwineffects */
 
38
/** @{ */
 
39
 
 
40
namespace KWin
 
41
{
 
42
 
 
43
/**
 
44
 * Convert QRegion to XserverRegion.
 
45
 */
 
46
KWIN_EXPORT XserverRegion toXserverRegion(QRegion region);
 
47
/**
 
48
 * draws a round box on the renderscene
 
49
 */
 
50
KWIN_EXPORT void xRenderRoundBox(Picture pict, const QRect &rect, int round, const QColor &c);
 
51
/**
 
52
 * dumps a QColor into a XRenderColor
 
53
 */
 
54
KWIN_EXPORT XRenderColor preMultiply(const QColor &c, float opacity = 1.0);
 
55
 
 
56
/** @internal */
 
57
class KWIN_EXPORT XRenderPictureData
 
58
    : public QSharedData
 
59
{
 
60
public:
 
61
    XRenderPictureData(Picture pic = None);
 
62
    ~XRenderPictureData();
 
63
    Picture value();
 
64
private:
 
65
    Picture picture;
 
66
    Q_DISABLE_COPY(XRenderPictureData)
 
67
};
 
68
 
 
69
/**
 
70
 * @short Wrapper around XRender Picture.
 
71
 *
 
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.
 
75
 */
 
76
class KWIN_EXPORT XRenderPicture
 
77
{
 
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;
 
85
};
 
86
 
 
87
inline
 
88
XRenderPictureData::XRenderPictureData(Picture pic)
 
89
    : picture(pic)
 
90
{
 
91
}
 
92
 
 
93
inline
 
94
XRenderPictureData::~XRenderPictureData()
 
95
{
 
96
    if (picture != None)
 
97
        XRenderFreePicture(display(), picture);
 
98
}
 
99
 
 
100
inline
 
101
Picture XRenderPictureData::value()
 
102
{
 
103
    return picture;
 
104
}
 
105
 
 
106
inline
 
107
XRenderPicture::XRenderPicture(Picture pic)
 
108
    : d(new XRenderPictureData(pic))
 
109
{
 
110
}
 
111
 
 
112
inline
 
113
XRenderPicture::operator Picture()
 
114
{
 
115
    return d->value();
 
116
}
 
117
 
 
118
/**
 
119
 * Static 1x1 picture used to deliver a black pixel with given opacity (for blending performance)
 
120
 * Call and Use, the PixelPicture will stay, but may change it's opacity meanwhile. It's NOT threadsafe either
 
121
 */
 
122
KWIN_EXPORT XRenderPicture xRenderBlendPicture(double opacity);
 
123
/**
 
124
 * Creates a 1x1 Picture filled with c
 
125
 */
 
126
KWIN_EXPORT XRenderPicture xRenderFill(const XRenderColor *c);
 
127
KWIN_EXPORT XRenderPicture xRenderFill(const QColor &c);
 
128
 
 
129
} // namespace
 
130
 
 
131
#endif
 
132
 
 
133
/** @} */
 
134
 
 
135
#endif