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 <qevent.h>
|
||||
#include <qpainter.h>
|
||||
#include <qmath.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -43,15 +44,22 @@ PaintRedirector::PaintRedirector( QWidget* w )
|
|||
QPixmap PaintRedirector::performPendingPaint()
|
||||
{
|
||||
//qDebug() << "### performing paint, pending:" << pending.boundingRect();
|
||||
QPixmap pixmap( pending.boundingRect().size());
|
||||
pixmap.fill( Qt::transparent );
|
||||
const QSize size = pending.boundingRect().size();
|
||||
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;
|
||||
// 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;
|
||||
pending = QRegion();
|
||||
scheduled = QRegion();
|
||||
return pixmap;
|
||||
cleanupTimer.start(2000, this);
|
||||
return scratch;
|
||||
}
|
||||
|
||||
bool PaintRedirector::isToolTip( QWidget *object ) const
|
||||
|
@ -128,6 +136,15 @@ void PaintRedirector::removed( QWidget* w )
|
|||
w->installEventFilter( this );
|
||||
}
|
||||
|
||||
void PaintRedirector::timerEvent( QTimerEvent* event )
|
||||
{
|
||||
if ( event->timerId() == cleanupTimer.timerId() )
|
||||
{
|
||||
cleanupTimer.stop();
|
||||
scratch = QPixmap();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "paintredirector.moc"
|
||||
|
|
|
@ -28,6 +28,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
#include <qregion.h>
|
||||
#include <qtimer.h>
|
||||
#include <qwidget.h>
|
||||
#include <qbasictimer.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -50,11 +51,14 @@ class PaintRedirector
|
|||
void added( QWidget* widget );
|
||||
void removed( QWidget* widget );
|
||||
bool isToolTip( QWidget* widget ) const;
|
||||
void timerEvent( QTimerEvent* event );
|
||||
QWidget* widget;
|
||||
QRegion pending;
|
||||
QRegion scheduled;
|
||||
QPixmap scratch;
|
||||
bool recursionCheck;
|
||||
QTimer timer;
|
||||
QBasicTimer cleanupTimer;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue