summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp')
-rw-r--r--tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp38
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);