Performance bugfix.

In case we use OpenGL compositing and KWin is started with the raster graphicssystem,
the decoration gets painted with the raster backend.
REVIEW: 101370
icc-effect-5.14.5
Philipp Knechtges 2011-05-15 13:22:28 +02:00 committed by Martin Gräßlin
parent da82739301
commit 2c0b0e9f18
5 changed files with 82 additions and 10 deletions

View File

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QPainter>
#include <QDateTime>
#include <QProcess>
#include <QPaintEngine>
#include <unistd.h>
#include <kstandarddirs.h>
#include <QWhatsThis>
@ -131,6 +132,7 @@ Client::Client(Workspace* ws)
, electricMaximizing(false)
, activitiesDefined(false)
, needsSessionInteract(false)
, m_responsibleForDecoPixmap(false)
{
// TODO: Do all as initialization
@ -395,6 +397,13 @@ void Client::destroyDecoration()
move(grav);
delete paintRedirector;
paintRedirector = NULL;
if (m_responsibleForDecoPixmap) {
XFreePixmap(display(), decorationPixmapTop.handle());
XFreePixmap(display(), decorationPixmapBottom.handle());
XFreePixmap(display(), decorationPixmapLeft.handle());
XFreePixmap(display(), decorationPixmapRight.handle());
m_responsibleForDecoPixmap = false;
}
decorationPixmapLeft = decorationPixmapRight = decorationPixmapTop = decorationPixmapBottom = QPixmap();
if (compositing())
discardWindowPixmap();
@ -583,23 +592,79 @@ void Client::resizeDecorationPixmaps()
layoutDecorationRects(lr, tr, rr, br, DecorationRelative);
if (decorationPixmapTop.size() != tr.size()) {
Pixmap pixmap = XCreatePixmap(display(), rootWindow(), tr.width(), tr.height(), 32);
decorationPixmapTop = QPixmap::fromX11Pixmap(pixmap, QPixmap::ExplicitlyShared);
if (m_responsibleForDecoPixmap && !decorationPixmapTop.isNull() &&
decorationPixmapTop.paintEngine()->type() == QPaintEngine::X11) {
XFreePixmap(display(), decorationPixmapTop.handle());
}
if (workspace()->compositingActive() && effects->compositingType() == OpenGLCompositing) {
decorationPixmapTop = QPixmap(tr.size());
m_responsibleForDecoPixmap = false;
} else {
Pixmap xpix = XCreatePixmap(QX11Info::display(), rootWindow(),
tr.size().width(), tr.height(),
32);
decorationPixmapTop = QPixmap::fromX11Pixmap(xpix, QPixmap::ExplicitlyShared);
decorationPixmapTop.fill(Qt::transparent);
m_responsibleForDecoPixmap= true;
}
}
if (decorationPixmapBottom.size() != br.size()) {
Pixmap pixmap = XCreatePixmap(display(), rootWindow(), br.width(), br.height(), 32);
decorationPixmapBottom = QPixmap::fromX11Pixmap(pixmap, QPixmap::ExplicitlyShared);
if (m_responsibleForDecoPixmap && !decorationPixmapBottom.isNull() &&
decorationPixmapBottom.paintEngine()->type() == QPaintEngine::X11) {
XFreePixmap(display(), decorationPixmapBottom.handle());
}
if (workspace()->compositingActive() && effects->compositingType() == OpenGLCompositing) {
decorationPixmapBottom = QPixmap(br.size());
m_responsibleForDecoPixmap = false;
} else {
Pixmap xpix = XCreatePixmap(QX11Info::display(), rootWindow(),
br.size().width(), br.height(),
32);
decorationPixmapBottom = QPixmap::fromX11Pixmap(xpix, QPixmap::ExplicitlyShared);
decorationPixmapBottom.fill(Qt::transparent);
m_responsibleForDecoPixmap = true;
}
}
if (decorationPixmapLeft.size() != lr.size()) {
Pixmap pixmap = XCreatePixmap(display(), rootWindow(), lr.width(), lr.height(), 32);
decorationPixmapLeft = QPixmap::fromX11Pixmap(pixmap, QPixmap::ExplicitlyShared);
if (m_responsibleForDecoPixmap && !decorationPixmapLeft.isNull() &&
decorationPixmapLeft.paintEngine()->type() == QPaintEngine::X11) {
XFreePixmap(display(), decorationPixmapLeft.handle());
}
if (workspace()->compositingActive() && effects->compositingType() == OpenGLCompositing) {
decorationPixmapLeft = QPixmap(lr.size());
m_responsibleForDecoPixmap = false;
} else {
Pixmap xpix = XCreatePixmap(QX11Info::display(), rootWindow(),
lr.size().width(), lr.height(),
32);
decorationPixmapLeft = QPixmap::fromX11Pixmap(xpix, QPixmap::ExplicitlyShared);
decorationPixmapLeft.fill(Qt::transparent);
m_responsibleForDecoPixmap = true;
}
}
if (decorationPixmapRight.size() != rr.size()) {
Pixmap pixmap = XCreatePixmap(display(), rootWindow(), rr.width(), rr.height(), 32);
decorationPixmapRight = QPixmap::fromX11Pixmap(pixmap, QPixmap::ExplicitlyShared);
if (m_responsibleForDecoPixmap && !decorationPixmapRight.isNull() &&
decorationPixmapRight.paintEngine()->type() == QPaintEngine::X11) {
XFreePixmap(display(), decorationPixmapRight.handle());
}
if (workspace()->compositingActive() && effects->compositingType() == OpenGLCompositing) {
decorationPixmapRight = QPixmap(rr.size());
m_responsibleForDecoPixmap = false;
} else {
Pixmap xpix = XCreatePixmap(QX11Info::display(), rootWindow(),
rr.size().width(), rr.height(),
32);
decorationPixmapRight = QPixmap::fromX11Pixmap(xpix, QPixmap::ExplicitlyShared);
decorationPixmapRight.fill(Qt::transparent);
m_responsibleForDecoPixmap = true;
}
}
#ifdef HAVE_XRENDER

View File

@ -710,6 +710,8 @@ private:
friend class GeometryUpdatesBlocker;
QTimer* demandAttentionKNotifyTimer;
QPixmap decorationPixmapLeft, decorationPixmapRight, decorationPixmapTop, decorationPixmapBottom;
// we (instead of Qt) initialize the Pixmaps, and have to free them
bool m_responsibleForDecoPixmap;
PaintRedirector* paintRedirector;
TabBox::TabBoxClientImpl* m_tabBoxClient;

View File

@ -202,6 +202,7 @@ void Workspace::finishCompositing()
#ifdef KWIN_HAVE_COMPOSITING
if (scene == NULL)
return;
m_finishingCompositing = true;
delete cm_selection;
foreach (Client * c, clients)
scene->windowClosed(c, NULL);
@ -240,6 +241,7 @@ void Workspace::finishCompositing()
// discard all Deleted windows (#152914)
while (!deleted.isEmpty())
deleted.first()->discard(Allowed);
m_finishingCompositing = false;
#endif
}
@ -639,7 +641,7 @@ void Workspace::destroyOverlay()
bool Workspace::compositingActive()
{
return compositing();
return !m_finishingCompositing && compositing();
}
// force is needed when the list of windows changes (e.g. a window goes away)
@ -951,13 +953,14 @@ void Client::setupCompositing()
{
Toplevel::setupCompositing();
updateVisibility(); // for internalKeep()
updateDecoration(true, true);
}
void Client::finishCompositing()
{
Toplevel::finishCompositing();
updateVisibility();
triggerDecorationRepaint();
updateDecoration(true, true);
}
bool Client::shouldUnredirect() const

View File

@ -160,6 +160,7 @@ Workspace::Workspace(bool restore)
, transSlider(NULL)
, transButton(NULL)
, forceUnredirectCheck(true)
, m_finishingCompositing(false)
{
(void) new KWinAdaptor(this);

View File

@ -1038,6 +1038,7 @@ private:
bool forceUnredirectCheck;
QList< int > composite_paint_times;
QTimer compositeResetTimer; // for compressing composite resets
bool m_finishingCompositing; // finishCompositing() sets this variable while shutting down
private:
friend bool performTransiencyCheck();