diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-10-05 00:01:43 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-10-05 00:01:43 (GMT) |
commit | 956f3baa661ec846d64793c2241718bfb311c452 (patch) | |
tree | 6fc8eb19c043638aed1469d0ef97ba8ca2dfc637 | |
parent | d193b7d5e56e940de64e597c832a0bd8c75ad590 (diff) | |
download | Qt-956f3baa661ec846d64793c2241718bfb311c452.zip Qt-956f3baa661ec846d64793c2241718bfb311c452.tar.gz Qt-956f3baa661ec846d64793c2241718bfb311c452.tar.bz2 |
Use qDrawPixmaps for particles.
-rw-r--r-- | src/declarative/extra/qfxparticles.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 15e257e..b4a04a9 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -57,6 +57,8 @@ #include "qfxparticles.h" #include <QPainter> +#include <QtGui/qdrawutil.h> +#include <QVarLengthArray> QT_BEGIN_NAMESPACE #define PI_SQR 9.8696044 @@ -356,6 +358,7 @@ public: qreal minX; qreal maxY; qreal minY; + QVarLengthArray<QDrawPixmaps::Data, 50> pixmapData; QFxParticlesPrivate* d; }; @@ -380,6 +383,7 @@ public: { Q_Q(QFxParticles); paintItem = new QFxParticlesPainter(this, q); + paintItem->pixmapData.resize(count); } void tick(int time); @@ -697,6 +701,8 @@ void QFxParticles::setCount(int cnt) int oldCount = d->count; d->count = cnt; + if (cnt > oldCount) + d->paintItem->pixmapData.resize(d->count); d->addParticleTime = 0; d->addParticleCount = d->particles.count(); if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count) { @@ -1097,11 +1103,19 @@ void QFxParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, Q const int myX = x() + parentItem()->x(); const int myY = y() + parentItem()->y(); + const QRectF sourceRect = d->image.rect(); for (int i = 0; i < d->particles.count(); ++i) { const QFxParticle &particle = d->particles.at(i); - p->setOpacity(particle.opacity); - p->drawPixmap(particle.x - myX, particle.y - myY, d->image); + pixmapData[i].point = QPointF(particle.x - myX, particle.y - myY); + pixmapData[i].opacity = particle.opacity; + + //these never change + pixmapData[i].rotation = 0; + pixmapData[i].scaleX = 1; + pixmapData[i].scaleY = 1; + pixmapData[i].source = sourceRect; } + qDrawPixmaps(p, pixmapData.data(), d->particles.count(), d->image); } void QFxParticles::componentComplete() |