diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2010-05-12 10:37:47 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2010-05-12 10:53:52 (GMT) |
commit | 9b6041bf62cfd2b0be62134ff6ee0fd488ce5921 (patch) | |
tree | 7c5616127b0bb2a7a94837f85457674af4f06fdf /tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp | |
parent | ad7988629c47a5fc1a671d36d9cdaed630f5e7f2 (diff) | |
download | Qt-9b6041bf62cfd2b0be62134ff6ee0fd488ce5921.zip Qt-9b6041bf62cfd2b0be62134ff6ee0fd488ce5921.tar.gz Qt-9b6041bf62cfd2b0be62134ff6ee0fd488ce5921.tar.bz2 |
Modified QPainter and QPixmap benchmarks to use raster pixmaps.
These benchmarks are not written in a way that supports robust
benchmarking of asynchronous pixmap backends.
Reviewed-by: Bjørn Erik Nilsen
Diffstat (limited to 'tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp')
-rw-r--r-- | tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp index 9ffbefb..8e9de4a 100644 --- a/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp @@ -43,6 +43,7 @@ #include <QPixmap> #include <QBitmap> #include <QPainter> +#include <private/qpixmap_raster_p.h> class tst_QPixmap : public QObject { @@ -67,6 +68,31 @@ Q_DECLARE_METATYPE(QImage::Format) Q_DECLARE_METATYPE(Qt::AspectRatioMode) Q_DECLARE_METATYPE(Qt::TransformationMode) +QPixmap rasterPixmap(int width, int height) +{ + QPixmapData *data = + new QRasterPixmapData(QPixmapData::PixmapType); + + data->resize(width, height); + + return QPixmap(data); +} + +QPixmap rasterPixmap(const QSize &size) +{ + return rasterPixmap(size.width(), size.height()); +} + +QPixmap rasterPixmap(const QImage &image) +{ + QPixmapData *data = + new QRasterPixmapData(QPixmapData::PixmapType); + + data->fromImage(image, Qt::AutoColor); + + return QPixmap(data); +} + tst_QPixmap::tst_QPixmap() { } @@ -90,7 +116,7 @@ void tst_QPixmap::fill() QFETCH(int, height); const QColor color = opaque ? QColor(255, 0, 0) : QColor(255, 0, 0, 200); - QPixmap pixmap(width, height); + QPixmap pixmap = rasterPixmap(width, height); QBENCHMARK { pixmap.fill(color); @@ -126,8 +152,8 @@ void tst_QPixmap::scaled() QFETCH(Qt::AspectRatioMode, ratioMode); QFETCH(Qt::TransformationMode, transformMode); - QPixmap opaque(size); - QPixmap transparent(size); + QPixmap opaque = rasterPixmap(size); + QPixmap transparent = rasterPixmap(size); opaque.fill(QColor(255, 0, 0)); transparent.fill(QColor(255, 0, 0, 200)); @@ -180,8 +206,8 @@ void tst_QPixmap::transformed() QFETCH(QTransform, transform); QFETCH(Qt::TransformationMode, transformMode); - QPixmap opaque(size); - QPixmap transparent(size); + QPixmap opaque = rasterPixmap(size); + QPixmap transparent = rasterPixmap(size); opaque.fill(QColor(255, 0, 0)); transparent.fill(QColor(255, 0, 0, 200)); @@ -209,7 +235,7 @@ void tst_QPixmap::mask() { QFETCH(QSize, size); - QPixmap src(size); + QPixmap src = rasterPixmap(size); src.fill(Qt::transparent); { QPainter p(&src); |