summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-29 23:34:46 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-29 23:37:59 (GMT)
commit420356570670dfccd3c03a778e8490717f4675ab (patch)
treee7cba769ca280c42d91990edcd9f0ba78631d1e7
parentf8a0a013243011b8ff107d1967d9befcc3689f15 (diff)
downloadQt-420356570670dfccd3c03a778e8490717f4675ab.zip
Qt-420356570670dfccd3c03a778e8490717f4675ab.tar.gz
Qt-420356570670dfccd3c03a778e8490717f4675ab.tar.bz2
A few QGraphicsEffect optimizations.
First of all we shouldn't pass pixmap.rect() into the filter, we always want to draw the entire pixmap (without making a copy). We can also skip the filter entirely if the filter is effectively not doing anything.
-rw-r--r--src/gui/graphicsview/qgraphicseffect.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicseffect.cpp b/src/gui/graphicsview/qgraphicseffect.cpp
index 45955f2..f9a99fc 100644
--- a/src/gui/graphicsview/qgraphicseffect.cpp
+++ b/src/gui/graphicsview/qgraphicseffect.cpp
@@ -218,7 +218,7 @@ void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *so
if (source->isPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
- d->filter->draw(painter, offset, pixmap, pixmap.rect());
+ d->filter->draw(painter, offset, pixmap);
return;
}
@@ -226,7 +226,7 @@ void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *so
const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
- d->filter->draw(painter, offset, pixmap, pixmap.rect());
+ d->filter->draw(painter, offset, pixmap);
painter->setWorldTransform(restoreTransform);
}
@@ -257,7 +257,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou
if (source->isPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
- d->filter->draw(painter, offset, pixmap, pixmap.rect());
+ d->filter->draw(painter, offset, pixmap);
return;
}
@@ -265,7 +265,7 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou
const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
- d->filter->draw(painter, offset, pixmap, pixmap.rect());
+ d->filter->draw(painter, offset, pixmap);
painter->setWorldTransform(restoreTransform);
}
@@ -418,7 +418,7 @@ static QImage blurred(const QImage& image, const QRect& rect, int radius)
int QGraphicsBlurEffect::blurRadius() const
{
Q_D(const QGraphicsBlurEffect);
- return int(d->filter->radius());
+ return d->filter->radius();
}
void QGraphicsBlurEffect::setBlurRadius(int radius)
@@ -437,12 +437,16 @@ QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const
void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsBlurEffect);
+ if (d->filter->radius() <= 0) {
+ source->draw(painter);
+ return;
+ }
QPoint offset;
if (source->isPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
- d->filter->draw(painter, offset, pixmap, pixmap.rect());
+ d->filter->draw(painter, offset, pixmap);
return;
}
@@ -450,7 +454,7 @@ void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
QTransform restoreTransform = painter->worldTransform();
painter->setWorldTransform(QTransform());
- d->filter->draw(painter, offset, pixmap, pixmap.rect());
+ d->filter->draw(painter, offset, pixmap);
painter->setWorldTransform(restoreTransform);
}
@@ -529,6 +533,10 @@ static QImage composited(const QImage& img1, const QImage& img2, qreal opacity,
void QGraphicsBloomEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsBloomEffect);
+ if (d->blurRadius <= 0) {
+ source->draw(painter);
+ return;
+ }
QPoint offset;
const int radius = d->blurRadius;
@@ -690,6 +698,11 @@ QRectF QGraphicsShadowEffect::boundingRectFor(const QRectF &rect) const
void QGraphicsShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsShadowEffect);
+ if (d->radius <= 0 && d->offset.isNull()) {
+ source->draw(painter);
+ return;
+ }
+
const QRectF sourceRect = source->boundingRect(Qt::DeviceCoordinates);
const QRectF shadowRect = sourceRect.translated(d->offset);
QRectF blurRect = shadowRect;