diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-19 19:32:53 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-19 19:32:53 (GMT) |
commit | 01498eb9a44f3b15e517e81b309087fbbf1b93bf (patch) | |
tree | 24451e4bb7ccf184229499205ed5f832b0f453a9 /tests/benchmarks/declarative | |
parent | dc0ce606eb848730c1d5047eaad4ec061ffe2dde (diff) | |
parent | 6c3acdf906a678158928b76cf047b58fbb9f8969 (diff) | |
download | Qt-01498eb9a44f3b15e517e81b309087fbbf1b93bf.zip Qt-01498eb9a44f3b15e517e81b309087fbbf1b93bf.tar.gz Qt-01498eb9a44f3b15e517e81b309087fbbf1b93bf.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-qml: (81 commits)
Revert "Speed up QmlGraphicsItem::setParentItem."
Fix dynamic example
More strict type checking of ListElement properties.
Fix tst_QmlGraphicsLoader::networkRequestUrl autotest.
Fix tst_qmlgraphicstextedit::delegateLoading autotest
Delete the QmlImageRequestHandler in the correct thread.
Fix "AnimatedImage ignores Anchors setting"
Remove unused function that breaks build on AIX.
doc
Add support for startDragDistance in qmlviewer.
Add pixmap benchmarks and make cached rounded rect the same as Rectangle.
Make QmlDom API internal
Compile fix with namepaces
Doc: reformulate why we build a button
Removed incorrect Q_UNUSED() macro from QmlPropertyAnimation::transition
Doc: onExited, onEntered only work when button pressed or hoverEnabled
Ensure visibleIndex and currentIndex are updated on itemsMoved().
QmlView API review. See QmlChanges.txt for details.
Fix example after introduction of RotationAnimation.
Animation doc fix.
...
Diffstat (limited to 'tests/benchmarks/declarative')
-rw-r--r-- | tests/benchmarks/declarative/painting/data/63x63.png | bin | 0 -> 3077 bytes | |||
-rw-r--r-- | tests/benchmarks/declarative/painting/data/63x63_opaque.png | bin | 0 -> 3440 bytes | |||
-rw-r--r-- | tests/benchmarks/declarative/painting/data/64x64.png | bin | 0 -> 3101 bytes | |||
-rw-r--r-- | tests/benchmarks/declarative/painting/data/64x64_opaque.png | bin | 0 -> 3588 bytes | |||
-rw-r--r-- | tests/benchmarks/declarative/painting/paintbenchmark.cpp | 116 |
5 files changed, 102 insertions, 14 deletions
diff --git a/tests/benchmarks/declarative/painting/data/63x63.png b/tests/benchmarks/declarative/painting/data/63x63.png Binary files differnew file mode 100644 index 0000000..d9efda8 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/63x63.png diff --git a/tests/benchmarks/declarative/painting/data/63x63_opaque.png b/tests/benchmarks/declarative/painting/data/63x63_opaque.png Binary files differnew file mode 100644 index 0000000..d142908 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/63x63_opaque.png diff --git a/tests/benchmarks/declarative/painting/data/64x64.png b/tests/benchmarks/declarative/painting/data/64x64.png Binary files differnew file mode 100644 index 0000000..b149f33 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/64x64.png diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/declarative/painting/data/64x64_opaque.png Binary files differnew file mode 100644 index 0000000..94c07f3 --- /dev/null +++ b/tests/benchmarks/declarative/painting/data/64x64_opaque.png diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp index dd52740..9231b67 100644 --- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp +++ b/tests/benchmarks/declarative/painting/paintbenchmark.cpp @@ -57,6 +57,7 @@ const int spacing = 36; QSizeF size(1000, 800); const qreal lineWidth = 1000; QString strings[lines]; +QGLWidget *testWidget = 0; void paint_QTextLayout(QPainter &p, bool useCache) { @@ -158,6 +159,15 @@ void paint_QPixmapCachedText(QPainter &p) void paint_RoundedRect(QPainter &p) { + static bool first = true; + if (first) { + if (testWidget) { + QGLFormat format = testWidget->format(); + if (!format.sampleBuffers()) + qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers"; + } + first = false; + } p.setRenderHint(QPainter::Antialiasing, true); p.setPen(Qt::black); p.setBrush(Qt::red); @@ -172,27 +182,101 @@ void paint_RoundedRect(QPainter &p) void paint_QPixmapCachedRoundedRect(QPainter &p) { static bool first = true; - static QPixmap cacheRect[lines]; + static QPixmap cacheRect; if (first) { - for (int i = 0; i < lines; ++i) { - QSize size((i+1)*50, spacing-1); - cacheRect[i] = QPixmap(size); - cacheRect[i].fill(Qt::transparent); - QPainter paint(&cacheRect[i]); - paint.setRenderHint(QPainter::Antialiasing); - paint.setPen(Qt::black); - paint.setBrush(Qt::red); - paint.drawRoundedRect(QRect(QPoint(0,0), size), 8, 8); + const int pw = 0; + const int radius = 8; + cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); + cacheRect.fill(Qt::transparent); + QPainter paint(&cacheRect); + paint.setRenderHint(QPainter::Antialiasing); + paint.setPen(Qt::black); + paint.setBrush(Qt::red); + if (pw%2) + paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius); + else + paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius); + + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + QSize size((j+1)*50, spacing-1); + + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true); + + const int pw = 0; + + int xOffset = (cacheRect.width()-1)/2; + int yOffset = (cacheRect.height()-1)/2; + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects + qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules); + } + } +} + +void paint_QPixmap63x63_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} + +void paint_QPixmap64x64_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); } + } +} + +void paint_QPixmap63x63(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63.png"); first = false; } for (int i = 0; i < count; i++) { for (int j = 0; j < lines; ++j) { - p.drawPixmap(0,j*spacing,cacheRect[j]); + p.drawPixmap((i%10) * 64,j*spacing, pm); } } } +void paint_QPixmap64x64(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} typedef void(*PaintFunc)(QPainter &); struct { @@ -206,6 +290,10 @@ struct { { "CachedText", &paint_QPixmapCachedText }, { "RoundedRect", &paint_RoundedRect }, { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, + { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque }, + { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque }, + { "QPixmap63x63", &paint_QPixmap63x63 }, + { "QPixmap64x64", &paint_QPixmap64x64 }, { 0, 0 } }; @@ -293,11 +381,11 @@ int main(int argc, char *argv[]) QWidget w; QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(sampleBuffers); - MyGLWidget *glw = new MyGLWidget(format); - glw->setAutoFillBackground(false); + testWidget = new MyGLWidget(format); + testWidget->setAutoFillBackground(false); QVBoxLayout *layout = new QVBoxLayout(&w); w.setLayout(layout); - layout->addWidget(glw); + layout->addWidget(testWidget); w.showFullScreen(); app.exec(); |