2008-05-07 14:43:13 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2008 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_XRENDERUTILS_H
|
|
|
|
#define KWIN_XRENDERUTILS_H
|
|
|
|
|
|
|
|
#include <kwinconfig.h>
|
|
|
|
|
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
|
|
|
|
|
|
#include <QtCore/QSharedData>
|
2008-06-06 09:11:52 +00:00
|
|
|
#include <QtGui/QColor>
|
2008-05-07 14:43:13 +00:00
|
|
|
#include <ksharedptr.h>
|
|
|
|
|
|
|
|
#include <kwinglobals.h>
|
|
|
|
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
|
|
|
|
/** @addtogroup kwineffects */
|
|
|
|
/** @{ */
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert QRegion to XserverRegion.
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EXPORT XserverRegion toXserverRegion(QRegion region);
|
2008-06-06 09:11:52 +00:00
|
|
|
/**
|
|
|
|
* draws a round box on the renderscene
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EXPORT void xRenderRoundBox(Picture pict, const QRect &rect, int round, const QColor &c);
|
2008-06-06 09:11:52 +00:00
|
|
|
/**
|
|
|
|
* dumps a QColor into a XRenderColor
|
|
|
|
*/
|
|
|
|
KWIN_EXPORT XRenderColor preMultiply(const QColor &c, float opacity = 1.0);
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
/** @internal */
|
|
|
|
class KWIN_EXPORT XRenderPictureData
|
|
|
|
: public QSharedData
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
XRenderPictureData(Picture pic = None);
|
|
|
|
~XRenderPictureData();
|
|
|
|
Picture value();
|
|
|
|
private:
|
|
|
|
Picture picture;
|
|
|
|
Q_DISABLE_COPY(XRenderPictureData)
|
|
|
|
};
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short Wrapper around XRender Picture.
|
|
|
|
*
|
2008-05-08 10:08:10 +00:00
|
|
|
* This class wraps XRender's Picture, providing proper initialization,
|
|
|
|
* convenience constructors and freeing of resources.
|
|
|
|
* It should otherwise act exactly like the Picture type.
|
2008-05-07 14:43:13 +00:00
|
|
|
*/
|
|
|
|
class KWIN_EXPORT XRenderPicture
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
XRenderPicture(Picture pic = None);
|
|
|
|
XRenderPicture(QPixmap pix);
|
|
|
|
XRenderPicture(Pixmap pix, int depth);
|
|
|
|
operator Picture();
|
|
|
|
private:
|
|
|
|
KSharedPtr< XRenderPictureData > d;
|
|
|
|
};
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
inline
|
2011-01-30 14:34:42 +00:00
|
|
|
XRenderPictureData::XRenderPictureData(Picture pic)
|
|
|
|
: picture(pic)
|
|
|
|
{
|
|
|
|
}
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
XRenderPictureData::~XRenderPictureData()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (picture != None)
|
|
|
|
XRenderFreePicture(display(), picture);
|
|
|
|
}
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
Picture XRenderPictureData::value()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-05-07 14:43:13 +00:00
|
|
|
return picture;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
inline
|
2011-01-30 14:34:42 +00:00
|
|
|
XRenderPicture::XRenderPicture(Picture pic)
|
|
|
|
: d(new XRenderPictureData(pic))
|
|
|
|
{
|
|
|
|
}
|
2008-05-07 14:43:13 +00:00
|
|
|
|
|
|
|
inline
|
|
|
|
XRenderPicture::operator Picture()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-05-07 14:43:13 +00:00
|
|
|
return d->value();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-05-07 14:43:13 +00:00
|
|
|
|
2009-05-12 14:12:46 +00:00
|
|
|
/**
|
|
|
|
* Static 1x1 picture used to deliver a black pixel with given opacity (for blending performance)
|
|
|
|
* Call and Use, the PixelPicture will stay, but may change it's opacity meanwhile. It's NOT threadsafe either
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EXPORT XRenderPicture xRenderBlendPicture(double opacity);
|
2008-06-06 09:11:52 +00:00
|
|
|
/**
|
|
|
|
* Creates a 1x1 Picture filled with c
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EXPORT XRenderPicture xRenderFill(const XRenderColor *c);
|
|
|
|
KWIN_EXPORT XRenderPicture xRenderFill(const QColor &c);
|
2008-06-06 09:11:52 +00:00
|
|
|
|
2008-05-07 14:43:13 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#endif
|