Wait two seconds before deleting the scratch pixmap in the paint redirector
in case we need it again. This should improve performance with drivers where creating pixmaps is expensive. svn path=/trunk/KDE/kdebase/workspace/; revision=1104069
This commit is contained in:
parent
c83c168c16
commit
e969813b4a
2 changed files with 25 additions and 4 deletions
|
@ -27,6 +27,7 @@ DEALINGS IN THE SOFTWARE.
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <qevent.h>
|
#include <qevent.h>
|
||||||
#include <qpainter.h>
|
#include <qpainter.h>
|
||||||
|
#include <qmath.h>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -43,15 +44,22 @@ PaintRedirector::PaintRedirector( QWidget* w )
|
||||||
QPixmap PaintRedirector::performPendingPaint()
|
QPixmap PaintRedirector::performPendingPaint()
|
||||||
{
|
{
|
||||||
//qDebug() << "### performing paint, pending:" << pending.boundingRect();
|
//qDebug() << "### performing paint, pending:" << pending.boundingRect();
|
||||||
QPixmap pixmap( pending.boundingRect().size());
|
const QSize size = pending.boundingRect().size();
|
||||||
pixmap.fill( Qt::transparent );
|
if ( scratch.width() < size.width() || scratch.height() < size.height() )
|
||||||
|
{
|
||||||
|
int w = qCeil( size.width() / 128. ) * 128;
|
||||||
|
int h = qCeil( size.height() / 128. ) * 128;
|
||||||
|
scratch = QPixmap( qMax( scratch.width(), w ), qMax( scratch.height(), h ) );
|
||||||
|
}
|
||||||
|
scratch.fill( Qt::transparent );
|
||||||
recursionCheck = true;
|
recursionCheck = true;
|
||||||
// do not use DrawWindowBackground, it's ok to be transparent
|
// do not use DrawWindowBackground, it's ok to be transparent
|
||||||
widget->render( &pixmap, QPoint(), pending.boundingRect(), QWidget::DrawChildren );
|
widget->render( &scratch, QPoint(), pending.boundingRect(), QWidget::DrawChildren );
|
||||||
recursionCheck = false;
|
recursionCheck = false;
|
||||||
pending = QRegion();
|
pending = QRegion();
|
||||||
scheduled = QRegion();
|
scheduled = QRegion();
|
||||||
return pixmap;
|
cleanupTimer.start(2000, this);
|
||||||
|
return scratch;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PaintRedirector::isToolTip( QWidget *object ) const
|
bool PaintRedirector::isToolTip( QWidget *object ) const
|
||||||
|
@ -128,6 +136,15 @@ void PaintRedirector::removed( QWidget* w )
|
||||||
w->installEventFilter( this );
|
w->installEventFilter( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintRedirector::timerEvent( QTimerEvent* event )
|
||||||
|
{
|
||||||
|
if ( event->timerId() == cleanupTimer.timerId() )
|
||||||
|
{
|
||||||
|
cleanupTimer.stop();
|
||||||
|
scratch = QPixmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "paintredirector.moc"
|
#include "paintredirector.moc"
|
||||||
|
|
|
@ -28,6 +28,7 @@ DEALINGS IN THE SOFTWARE.
|
||||||
#include <qregion.h>
|
#include <qregion.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
#include <qwidget.h>
|
#include <qwidget.h>
|
||||||
|
#include <qbasictimer.h>
|
||||||
|
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
|
@ -50,11 +51,14 @@ class PaintRedirector
|
||||||
void added( QWidget* widget );
|
void added( QWidget* widget );
|
||||||
void removed( QWidget* widget );
|
void removed( QWidget* widget );
|
||||||
bool isToolTip( QWidget* widget ) const;
|
bool isToolTip( QWidget* widget ) const;
|
||||||
|
void timerEvent( QTimerEvent* event );
|
||||||
QWidget* widget;
|
QWidget* widget;
|
||||||
QRegion pending;
|
QRegion pending;
|
||||||
QRegion scheduled;
|
QRegion scheduled;
|
||||||
|
QPixmap scratch;
|
||||||
bool recursionCheck;
|
bool recursionCheck;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
|
QBasicTimer cleanupTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in a new issue