[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/libs/plasma
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2008-09-02 23:29:54
Message-ID: 1220398194.678413.17729.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 856476 by aseigo:
don't repaint the entire item *every time* if the exposed area is just a small \
section. this saves huge numbers of whole screen repaints.
M +20 -12 applet.cpp
--- trunk/KDE/kdebase/workspace/libs/plasma/applet.cpp #856475:856476
@@ -851,7 +851,7 @@
{
QPainter *p;
//FIXME: we should probably set the pixmap to screenSize(), but that breaks \
stuff atm.
- QPixmap pixmap(boundingRect().size().toSize());
+ QPixmap *pixmap = 0;
QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget ? widget->parent() : \
0); bool ghost = (qgv && (qgv == d->ghostView));
@@ -861,11 +861,11 @@
// that pixmap where the applet can draw on so we can draw the result \
transparently // at the end.
kDebug() << "Painting ghosted...";
+ pixmap = new QPixmap(boundingRect().size().toSize());
+ pixmap->fill(Qt::transparent);
- pixmap.fill(Qt::transparent);
-
p = new QPainter();
- p->begin(&pixmap);
+ p->begin(pixmap);
} else {
p = painter;
}
@@ -887,8 +887,16 @@
if (!d->failed) {
qreal left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
- const QRect contentsRect = QRectF(QPointF(0,0), boundingRect().size())
- .adjusted(left, top, -right, -bottom).toAlignedRect();
+ QRectF contentsRect = QRectF(QPointF(0,0), boundingRect().size())
+ .adjusted(left, top, -right, -bottom);
+
+ if (!ghost) {
+ // only paint the bare minimum when not ghosting
+ contentsRect = option->exposedRect.intersected(contentsRect);
+ }
+
+ QRect exposed = contentsRect.toAlignedRect();
+
if (widget && isContainment()) {
// note that the widget we get is actually the viewport of the view, not \
the view itself View* v = qobject_cast<Plasma::View*>(widget->parent());
@@ -896,12 +904,12 @@
if (!v || v->isWallpaperEnabled()) {
Containment* c = qobject_cast<Plasma::Containment*>(this);
if (c && c->drawWallpaper() && c->wallpaper()) {
- c->wallpaper()->paint(p, contentsRect);
+ c->wallpaper()->paint(p, exposed);
}
Containment::StyleOption coption(*option);
coption.view = v;
- paintInterface(p, &coption, contentsRect);
+ paintInterface(p, &coption, exposed);
}
p->restore();
@@ -909,19 +917,19 @@
}
//kDebug() << "paint interface of" << (QObject*) this;
- paintInterface(p, option, contentsRect);
+ paintInterface(p, option, exposed);
}
p->restore();
if (ghost) {
// Lets display the pixmap that we've just drawn... transparently.
p->setCompositionMode(QPainter::CompositionMode_DestinationIn);
- p->fillRect(pixmap.rect(), QColor(0, 0, 0, (0.3 * 255)));
+ p->fillRect(pixmap->rect(), QColor(0, 0, 0, (0.3 * 255)));
p->end();
-
delete p;
- painter->drawPixmap(0, 0, pixmap);
+ painter->drawPixmap(0, 0, *pixmap);
+ delete pixmap;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic