XRenderPicture, a wrapper around XRender's Picture, which
should act just like Picture, except for proper initialization and resource freeing (i.e. it's sane and easy from C++ point of view). svn path=/trunk/KDE/kdebase/workspace/; revision=805085
This commit is contained in:
parent
b840fa0792
commit
5efac21537
10 changed files with 175 additions and 54 deletions
|
@ -344,25 +344,13 @@ void BoxSwitchEffect::setInactive()
|
||||||
if( w != selected_window )
|
if( w != selected_window )
|
||||||
w->addRepaintFull();
|
w->addRepaintFull();
|
||||||
}
|
}
|
||||||
foreach( ItemInfo* i, windows )
|
qDeleteAll( windows );
|
||||||
{
|
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
||||||
if( effects->compositingType() == XRenderCompositing )
|
|
||||||
{
|
|
||||||
if( i->iconPicture != None )
|
|
||||||
XRenderFreePicture( display(), i->iconPicture );
|
|
||||||
i->iconPicture = None;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
delete i;
|
|
||||||
}
|
|
||||||
windows.clear();
|
windows.clear();
|
||||||
setSelectedWindow( 0 );
|
setSelectedWindow( 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // DesktopMode
|
{ // DesktopMode
|
||||||
foreach( ItemInfo* i, desktops )
|
qDeleteAll( windows );
|
||||||
delete i;
|
|
||||||
desktops.clear();
|
desktops.clear();
|
||||||
}
|
}
|
||||||
effects->addRepaint( frame_area );
|
effects->addRepaint( frame_area );
|
||||||
|
@ -601,8 +589,6 @@ void BoxSwitchEffect::paintWindowIcon( EffectWindow* w )
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
if( effects->compositingType() == XRenderCompositing )
|
if( effects->compositingType() == XRenderCompositing )
|
||||||
{
|
{
|
||||||
if( windows[ w ]->iconPicture != None )
|
|
||||||
XRenderFreePicture( display(), windows[ w ]->iconPicture );
|
|
||||||
windows[ w ]->iconPicture = XRenderCreatePicture( display(),
|
windows[ w ]->iconPicture = XRenderCreatePicture( display(),
|
||||||
windows[ w ]->icon.handle(), alphaFormat, 0, NULL );
|
windows[ w ]->icon.handle(), alphaFormat, 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
|
||||||
#include <kwinglutils.h>
|
#include <kwinglutils.h>
|
||||||
|
#include <kwinxrenderutils.h>
|
||||||
|
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
#include <X11/extensions/Xrender.h>
|
#include <X11/extensions/Xrender.h>
|
||||||
|
@ -112,7 +113,7 @@ class BoxSwitchEffect::ItemInfo
|
||||||
GLTexture iconTexture;
|
GLTexture iconTexture;
|
||||||
#endif
|
#endif
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
Picture iconPicture;
|
XRenderPicture iconPicture;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1046,8 +1046,6 @@ void PresentWindowsEffect::paintWindowIcon( EffectWindow* w, WindowPaintData& pa
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
if( effects->compositingType() == XRenderCompositing )
|
if( effects->compositingType() == XRenderCompositing )
|
||||||
{
|
{
|
||||||
if( data.iconPicture != None )
|
|
||||||
XRenderFreePicture( display(), data.iconPicture );
|
|
||||||
data.iconPicture = XRenderCreatePicture( display(),
|
data.iconPicture = XRenderCreatePicture( display(),
|
||||||
data.icon.handle(), alphaFormat, 0, NULL );
|
data.icon.handle(), alphaFormat, 0, NULL );
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Include with base class for effects.
|
// Include with base class for effects.
|
||||||
#include <kwineffects.h>
|
#include <kwineffects.h>
|
||||||
#include <kwinglutils.h>
|
#include <kwinglutils.h>
|
||||||
|
#include <kwinxrenderutils.h>
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ class PresentWindowsEffect
|
||||||
KSharedPtr< GLTexture > iconTexture;
|
KSharedPtr< GLTexture > iconTexture;
|
||||||
#endif
|
#endif
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
Picture iconPicture;
|
XRenderPicture iconPicture;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
typedef QHash<EffectWindow*, WindowData> DataHash;
|
typedef QHash<EffectWindow*, WindowData> DataHash;
|
||||||
|
|
|
@ -33,6 +33,7 @@ set(kwin_EFFECTSLIB_SRCS
|
||||||
kwinglutils.cpp
|
kwinglutils.cpp
|
||||||
kwinglutils_funcs.cpp
|
kwinglutils_funcs.cpp
|
||||||
kwinshadereffect.cpp
|
kwinshadereffect.cpp
|
||||||
|
kwinxrenderutils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
kde4_add_library(kwineffects SHARED ${kwin_EFFECTSLIB_SRCS})
|
kde4_add_library(kwineffects SHARED ${kwin_EFFECTSLIB_SRCS})
|
||||||
|
@ -72,5 +73,6 @@ install( FILES
|
||||||
kwinglutils.h
|
kwinglutils.h
|
||||||
kwinglutils_funcs.h
|
kwinglutils_funcs.h
|
||||||
kwinshadereffect.h
|
kwinshadereffect.h
|
||||||
|
kwinxrenderutils.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/kwinconfig.h
|
${CMAKE_CURRENT_BINARY_DIR}/kwinconfig.h
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR})
|
DESTINATION ${INCLUDE_INSTALL_DIR})
|
||||||
|
|
|
@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "kwineffects.h"
|
#include "kwineffects.h"
|
||||||
|
|
||||||
#include "kwinglutils.h"
|
#include "kwinglutils.h"
|
||||||
|
#include "kwinxrenderutils.h"
|
||||||
|
|
||||||
#include <QtDBus/QtDBus>
|
#include <QtDBus/QtDBus>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
@ -979,27 +980,4 @@ void TimeLine::setCurveShape(CurveShape curveShape)
|
||||||
m_CurveShape = curveShape;
|
m_CurveShape = curveShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
||||||
// Convert QRegion to XserverRegion. All code uses XserverRegion
|
|
||||||
// only when really necessary as the shared implementation uses
|
|
||||||
// QRegion.
|
|
||||||
XserverRegion toXserverRegion( QRegion region )
|
|
||||||
{
|
|
||||||
QVector< QRect > rects = region.rects();
|
|
||||||
XRectangle* xr = new XRectangle[ rects.count() ];
|
|
||||||
for( int i = 0;
|
|
||||||
i < rects.count();
|
|
||||||
++i )
|
|
||||||
{
|
|
||||||
xr[ i ].x = rects[ i ].x();
|
|
||||||
xr[ i ].y = rects[ i ].y();
|
|
||||||
xr[ i ].width = rects[ i ].width();
|
|
||||||
xr[ i ].height = rects[ i ].height();
|
|
||||||
}
|
|
||||||
XserverRegion ret = XFixesCreateRegion( display(), xr, rects.count());
|
|
||||||
delete[] xr;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -41,10 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
||||||
#include <X11/extensions/Xfixes.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class KLibrary;
|
class KLibrary;
|
||||||
class KConfigGroup;
|
class KConfigGroup;
|
||||||
class KActionCollection;
|
class KActionCollection;
|
||||||
|
@ -179,13 +175,6 @@ QRect infiniteRegion()
|
||||||
return QRect( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
|
return QRect( INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
|
||||||
/**
|
|
||||||
* Convert QRegion to XserverRegion.
|
|
||||||
*/
|
|
||||||
KWIN_EXPORT XserverRegion toXserverRegion( QRegion region );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short Base class for all KWin effects
|
* @short Base class for all KWin effects
|
||||||
*
|
*
|
||||||
|
|
53
lib/kwinxrenderutils.cpp
Normal file
53
lib/kwinxrenderutils.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/********************************************************************
|
||||||
|
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/>.
|
||||||
|
*********************************************************************/
|
||||||
|
|
||||||
|
#include "kwinxrenderutils.h"
|
||||||
|
|
||||||
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||||
|
|
||||||
|
#include <qvector.h>
|
||||||
|
|
||||||
|
namespace KWin
|
||||||
|
{
|
||||||
|
|
||||||
|
// Convert QRegion to XserverRegion. All code uses XserverRegion
|
||||||
|
// only when really necessary as the shared implementation uses
|
||||||
|
// QRegion.
|
||||||
|
XserverRegion toXserverRegion( QRegion region )
|
||||||
|
{
|
||||||
|
QVector< QRect > rects = region.rects();
|
||||||
|
XRectangle* xr = new XRectangle[ rects.count() ];
|
||||||
|
for( int i = 0;
|
||||||
|
i < rects.count();
|
||||||
|
++i )
|
||||||
|
{
|
||||||
|
xr[ i ].x = rects[ i ].x();
|
||||||
|
xr[ i ].y = rects[ i ].y();
|
||||||
|
xr[ i ].width = rects[ i ].width();
|
||||||
|
xr[ i ].height = rects[ i ].height();
|
||||||
|
}
|
||||||
|
XserverRegion ret = XFixesCreateRegion( display(), xr, rects.count());
|
||||||
|
delete[] xr;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
112
lib/kwinxrenderutils.h
Normal file
112
lib/kwinxrenderutils.h
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
/********************************************************************
|
||||||
|
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>
|
||||||
|
#include <ksharedptr.h>
|
||||||
|
|
||||||
|
#include <kwinglobals.h>
|
||||||
|
|
||||||
|
#include <X11/extensions/Xfixes.h>
|
||||||
|
#include <X11/extensions/Xrender.h>
|
||||||
|
|
||||||
|
/** @addtogroup kwineffects */
|
||||||
|
/** @{ */
|
||||||
|
|
||||||
|
namespace KWin
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert QRegion to XserverRegion.
|
||||||
|
*/
|
||||||
|
KWIN_EXPORT XserverRegion toXserverRegion( QRegion region );
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
|
class KWIN_EXPORT XRenderPictureData
|
||||||
|
: public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XRenderPictureData( Picture pic = None );
|
||||||
|
~XRenderPictureData();
|
||||||
|
Picture value();
|
||||||
|
private:
|
||||||
|
Picture picture;
|
||||||
|
Q_DISABLE_COPY( XRenderPictureData )
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @short Wrapper around XRender Picture.
|
||||||
|
*
|
||||||
|
* This class wraps XRender's Picture, providing proper initialization
|
||||||
|
* and freeing of resources. It should otherwise act exactly like the Picture type.
|
||||||
|
*/
|
||||||
|
class KWIN_EXPORT XRenderPicture
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
XRenderPicture( Picture pic = None );
|
||||||
|
operator Picture();
|
||||||
|
private:
|
||||||
|
KSharedPtr< XRenderPictureData > d;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline
|
||||||
|
XRenderPictureData::XRenderPictureData( Picture pic )
|
||||||
|
: picture( pic )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
XRenderPictureData::~XRenderPictureData()
|
||||||
|
{
|
||||||
|
if( picture != None )
|
||||||
|
XRenderFreePicture( display(), picture );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
Picture XRenderPictureData::value()
|
||||||
|
{
|
||||||
|
return picture;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
XRenderPicture::XRenderPicture( Picture pic )
|
||||||
|
: d( new XRenderPictureData( pic ))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
XRenderPicture::operator Picture()
|
||||||
|
{
|
||||||
|
return d->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
#endif
|
|
@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "deleted.h"
|
#include "deleted.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
#include "kwinxrenderutils.h"
|
||||||
|
|
||||||
#include <kxerrorhandler.h>
|
#include <kxerrorhandler.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue