PDA

View Full Version : Anyway to increase paint performance



cmessineo
21st December 2013, 01:46
This is just an experiment I have been doing. It takes about 7 seconds to run with 200 points. The CPU and memory on the machine are not that great 454 MHz ARM9 processor with 128MB RAM, there might not be a way to speed this up, but I thought I'd ask.



void HeatMap::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
int x = 0;
int y = 0;
qreal intensity = 0;
qDebug() << QTime::currentTime();

QImage image(m_width, m_height, QImage::Format_ARGB32_Premultiplied);
QPainter *paint = new QPainter(&image);

foreach (QVariant v, m_data)
{
QStringList tmp = v.toString().split(",");

x = tmp[0].toInt();
y = tmp[1].toInt();
intensity = tmp[2].toDouble();
QRadialGradient g(QPointF(x, y), m_radius, QPointF(x, y));
g.setColorAt(0.0, QColor::fromRgbF(0, 0, 0, intensity));
g.setColorAt(1.0, QColor::fromRgbF(0, 0, 0, 0.0));
paint->fillRect(QRectF(x - m_radius, y - m_radius, x + m_radius, y + m_radius), g);
}

painter->drawImage(QPoint(0, 0), image);
qDebug() << QTime::currentTime();
}



Thanks

wysota
21st December 2013, 08:53
Do not create the image in the paint() method. In the above method you should only have what is in your line #24.

anda_skoa
21st December 2013, 11:12
And it is currently leaking the painter "paint". Just create it on the stack.

Cheers,
_