diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-13 07:21:52 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-13 07:21:52 (GMT) |
commit | 7180ccf653af6370fedc43debcfbf2386f0a4b3d (patch) | |
tree | a8364c746c9cd9045ac711b6ba05d33aa39a23fc /tests/benchmarks | |
parent | 50711dd7aa22052eff58431d9f4e95e1a688047e (diff) | |
parent | 2555221bbcb33e0d12e786eb0b3d08bd9260eeb7 (diff) | |
download | Qt-7180ccf653af6370fedc43debcfbf2386f0a4b3d.zip Qt-7180ccf653af6370fedc43debcfbf2386f0a4b3d.tar.gz Qt-7180ccf653af6370fedc43debcfbf2386f0a4b3d.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (35 commits)
Avoid running animation when loopCount == 0
Set the pictures for the examples of multitouch
Compile fix on Windows.
Remove an unnecessary assert.
Documentation for the Pad Navigator Example.
New Pad Nagivator example implementation.
Skip definition of wintab functions in case of QT_NO_TABLETEVENT.
Made curve tesselation be dynamically adjusted based on transform.
Modified QPainter and QPixmap benchmarks to use raster pixmaps.
Stabilize tst_QWidgetAction::visibilityUpdate
Fix compiler warning in QT_REQUIRE_VERSION
Stabilize tst_QColumnView::parentCurrentIndex
Really fix tst_QDockWidget::taskQTBUG_9758_undockedGeometry on Linux
Fix typos in Elastic Nodes example documentation.
Made paint engine texture drawing work in GL ES 2 and updated docs.
Opt out of visual-config size checks with extension
Fix off-by-one in text layouts and widget size hints on Mac
Stabilize tst_QDockWidget::taskQTBUG_9758_undockedGeometry
Mark QFileDialog::Options as a Q_FLAGS
fix tst_QDockWidget::taskQTBUG_9758_undockedGeometry on Linux
...
Diffstat (limited to 'tests/benchmarks')
-rw-r--r-- | tests/benchmarks/gui/image/qpixmap/tst_qpixmap.cpp | 38 | ||||
-rw-r--r-- | tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp | 79 |
2 files changed, 88 insertions, 29 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); diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index d570bb3..318b671 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp @@ -50,6 +50,8 @@ #define M_PI 3.14159265358979323846 #endif +#include <private/qpixmap_raster_p.h> + Q_DECLARE_METATYPE(QLine) Q_DECLARE_METATYPE(QRect) Q_DECLARE_METATYPE(QSize) @@ -125,6 +127,32 @@ struct PrimitiveSet { }; +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); +} + + class tst_QPainter : public QObject { Q_OBJECT @@ -222,7 +250,8 @@ private: QPaintDevice *surface() { - return new QPixmap(1024, 1024); + m_pixmap = rasterPixmap(1024, 1024); + return &m_pixmap; } @@ -233,6 +262,7 @@ private: PrimitiveSet m_primitives_100; PrimitiveSet m_primitives_1000; + QPixmap m_pixmap; QPaintDevice *m_surface; QPainter m_painter; @@ -490,7 +520,7 @@ void tst_QPainter::setupBrushes() void tst_QPainter::beginAndEnd() { - QPixmap pixmap(100, 100); + QPixmap pixmap = rasterPixmap(100, 100); QBENCHMARK { QPainter p; @@ -505,10 +535,11 @@ void tst_QPainter::drawLine() QFETCH(QPen, pen); const int offset = 5; - QPixmap pixmapUnclipped(qMin(line.x1(), line.x2()) - + 2*offset + qAbs(line.dx()), - qMin(line.y1(), line.y2()) - + 2*offset + qAbs(line.dy())); + QPixmap pixmapUnclipped = + rasterPixmap(qMin(line.x1(), line.x2()) + + 2*offset + qAbs(line.dx()), + qMin(line.y1(), line.y2()) + + 2*offset + qAbs(line.dy())); pixmapUnclipped.fill(Qt::white); QPainter p(&pixmapUnclipped); @@ -535,10 +566,11 @@ void tst_QPainter::drawLine_clipped() QFETCH(QPen, pen); const int offset = 5; - QPixmap pixmapClipped(qMin(line.x1(), line.x2()) - + 2*offset + qAbs(line.dx()), - qMin(line.y1(), line.y2()) - + 2*offset + qAbs(line.dy())); + QPixmap pixmapClipped + = rasterPixmap(qMin(line.x1(), line.x2()) + + 2*offset + qAbs(line.dx()), + qMin(line.y1(), line.y2()) + + 2*offset + qAbs(line.dy())); const QRect clip = QRect(line.p1(), line.p2()).normalized(); @@ -569,10 +601,11 @@ void tst_QPainter::drawLine_antialiased_clipped() QFETCH(QPen, pen); const int offset = 5; - QPixmap pixmapClipped(qMin(line.x1(), line.x2()) - + 2*offset + qAbs(line.dx()), - qMin(line.y1(), line.y2()) - + 2*offset + qAbs(line.dy())); + QPixmap pixmapClipped + = rasterPixmap(qMin(line.x1(), line.x2()) + + 2*offset + qAbs(line.dx()), + qMin(line.y1(), line.y2()) + + 2*offset + qAbs(line.dy())); const QRect clip = QRect(line.p1(), line.p2()).normalized(); @@ -696,8 +729,8 @@ void tst_QPainter::drawPixmap() QImage sourceImage = createImage(type, size).convertToFormat(sourceFormat); QImage targetImage(size, targetFormat); - QPixmap sourcePixmap = QPixmap::fromImage(sourceImage); - QPixmap targetPixmap = QPixmap::fromImage(targetImage); + QPixmap sourcePixmap = rasterPixmap(sourceImage); + QPixmap targetPixmap = rasterPixmap(targetImage); QPainter p(&targetPixmap); @@ -759,10 +792,10 @@ void tst_QPainter::compositionModes() QFETCH(QSize, size); QFETCH(QColor, color); - QPixmap src(size); + QPixmap src = rasterPixmap(size); src.fill(color); - QPixmap dest(size); + QPixmap dest = rasterPixmap(size); if (mode < QPainter::RasterOp_SourceOrDestination) color.setAlpha(127); // porter-duff needs an alpha channel dest.fill(color); @@ -844,11 +877,11 @@ void tst_QPainter::drawTiledPixmap() QFETCH(QColor, color); QFETCH(QPainter::RenderHint, renderHint); - QPixmap src(srcSize); + QPixmap src = rasterPixmap(srcSize); src.fill(color); const QRect dstRect = transform.mapRect(QRect(QPoint(), dstSize)); - QPixmap dst(dstRect.right() + 5, dstRect.bottom() + 5); + QPixmap dst = rasterPixmap(dstRect.right() + 5, dstRect.bottom() + 5); QPainter p(&dst); p.setTransform(transform); p.setRenderHint(renderHint); @@ -1411,7 +1444,7 @@ void tst_QPainter::drawBorderPixmapRoundedRect() rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); else rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); + QPixmap rectPixmap = rasterPixmap(rectImage); //setup surface QImage surface(100, 100, QImage::Format_RGB16); @@ -1466,7 +1499,7 @@ void tst_QPainter::drawScaledBorderPixmapRoundedRect() else rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); + QPixmap rectPixmap = rasterPixmap(rectImage); //setup surface QImage surface(400, 400, QImage::Format_RGB16); @@ -1522,7 +1555,7 @@ void tst_QPainter::drawTransformedBorderPixmapRoundedRect() else rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); - QPixmap rectPixmap = QPixmap::fromImage(rectImage); + QPixmap rectPixmap = rasterPixmap(rectImage); //setup surface QImage surface(400, 400, QImage::Format_RGB16); |