diff options
author | Peter Penz <ppenz@openismus.com> | 2010-07-27 13:48:15 +0200 |
---|---|---|
committer | Sergiy Dubovik <sergiy.dubovik@nokia.com> | 2010-07-30 13:56:48 +0300 |
commit | 861c0f61b371311800268c1cd3f99c169430c78c (patch) | |
tree | 47db3cf781ca0d9103d103d8e73c7e5917af4825 /benchmarks | |
parent | 95361b708022b050b6da810654dfb3a0b1db6a5d (diff) |
Changes: Use QStaticText instead of doing a custom text caching in MLabel
Fixes: NB#179282 - No anti-alias available for the clock symbol in lock window
Fixes: NB#179142 - MLabel is not word wrapping correctly with the QTextOption::WrapAtWordBoundaryOrAnywhere option
RevBy: Armin Berres, John Tapsell, Jörgen Scheibengruber
Details: Using QStaticText improves the painting performance, when the the text is changed rarely. The performance benchmark pt_mlabel, which has been disabled a while ago and did work anymore with the latest source, has been adjusted and enabled again. Beside the performance improvement NB#179282 had been fixed by providing a render hint to QPainter. NB#179142 has been fixed automatically by using QStaticText, which internally uses QTextOption and hence respects QTextOption::WrapAtWordBoundaryOrAnywhere.
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/benchmarks.pro | 1 | ||||
-rw-r--r-- | benchmarks/pt_mlabel/pt_mlabel.cpp | 85 | ||||
-rw-r--r-- | benchmarks/pt_mlabel/pt_mlabel.h | 12 | ||||
-rw-r--r-- | benchmarks/pt_mlabel/pt_mlabel.pro | 2 |
4 files changed, 48 insertions, 52 deletions
diff --git a/benchmarks/benchmarks.pro b/benchmarks/benchmarks.pro index ba8b0dd0..740a7ade 100644 --- a/benchmarks/benchmarks.pro +++ b/benchmarks/benchmarks.pro @@ -19,6 +19,7 @@ SUBDIRS = \ pt_minimalqtapplication \ pt_mprogressindicator \ pt_qapplication \ + pt_mlabel \ pt_mslider \ pt_mtheme \ pt_mtoolbar \ diff --git a/benchmarks/pt_mlabel/pt_mlabel.cpp b/benchmarks/pt_mlabel/pt_mlabel.cpp index edf5396b..7b6f93ce 100644 --- a/benchmarks/pt_mlabel/pt_mlabel.cpp +++ b/benchmarks/pt_mlabel/pt_mlabel.cpp @@ -31,12 +31,9 @@ void Pt_MLabel::initTestCase() { int argc = 1; const char *argv[argc]; - char appName[] = "./eternia"; + char appName[] = "./pt_mlabel"; argv[0] = appName; app = new MApplication(argc, (char **)argv); - MTheme::instance()->changeTheme("common"); - - currentViewIndex = 0; } void Pt_MLabel::cleanupTestCase() @@ -46,36 +43,22 @@ void Pt_MLabel::cleanupTestCase() void Pt_MLabel::init() { - // get size dimensions for test QFETCH(QString, text); - QFETCH(qint32, viewIndex); - - this->currentViewIndex = viewIndex; // create widget, set size - m_subject = new MLabel(text); - - m_subject->setMaximumWidth(864); - - switch (this->currentViewIndex) { - case View: - this->currentView = new MLabelView(m_subject); - break; + subject = new MLabel(text); + subject->resize(864, 480); + currentView = new MLabelView(subject); + subject->setView(currentView); // transfers ownership to controller + + // wait for the resource loading to finish + while (MTheme::instance()->hasPendingRequests()) { + usleep(100); + QCoreApplication::processEvents(); } - this->currentView->updateStyle(); - //this->currentView->styleUpdated(); - - // There is no MLabel::setView() so this is the one from - // MWidgetController, which is private, so need to be friends - m_subject->setView(this->currentView); // transfers ownership to controller - - // wait for the image loading - usleep(1000000); - QCoreApplication::processEvents(); - // create pixmap paintdevice - pixmap = new QPixmap(846, 480); + pixmap = new QPixmap(864, 480); pixmap->fill(QColor(0, 0, 0, 0)); painter = new QPainter(pixmap); } @@ -88,11 +71,6 @@ void Pt_MLabel::cleanup() QString kuva; QTextStream(&kuva) << "view_" - << this->currentViewIndex - << "_" - << m_subject->size().width() - << "x" - << m_subject->size().height() << ".png"; if (!written.contains(kuva)) { pixmap->save(kuva, "png", -1); @@ -100,35 +78,50 @@ void Pt_MLabel::cleanup() } #endif - delete m_subject; - m_subject = 0; - + delete subject; + subject = 0; delete painter; painter = 0; delete pixmap; pixmap = 0; - } void Pt_MLabel::paintPerformance() { - // actual benchmark QBENCHMARK { - this->currentView->paint(painter, NULL); + currentView->paint(painter, NULL); } } void Pt_MLabel::paintPerformance_data() { - QTest::addColumn<QString>("text"); - QTest::addColumn<qint32>("viewIndex"); + data(); +} - for (qint32 viewIndex = 0; viewIndex < NoViews; viewIndex++) { - // typical icon sizes - QTest::newRow("plaintext") << "Silence!" << viewIndex; - QTest::newRow("richtext") << "<span>Silence! I <b>kill</b> you!</span>" << viewIndex; - QTest::newRow("veryrich") << "<h5>Very rich text, multi line label</h5><p>The phrase \"<b>to be, or not to be</b>\" comes from <font color=\"white\">William Shakespeare's <i>Hamlet</i></font> (written about 1600), act three, scene one. It is one of the most famous quotations in <small>world literature</small> and the <u>best-known of this particular play</u>...<h6>And tables...</h6><table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table></p>" << viewIndex; +void Pt_MLabel::multiplePaintPerformance() +{ + QBENCHMARK { + // To verify whether the internal usage of QStaticText improves the performance, + // several painting operations without init() and cleanup() must be done + for (int i = 0; i < 1000; ++i) { + currentView->paint(painter, NULL); + } } } +void Pt_MLabel::multiplePaintPerformance_data() +{ + data(); +} + +void Pt_MLabel::data() +{ + QTest::addColumn<QString>("text"); + + QTest::newRow("plaintext") << "Silence!"; + QTest::newRow("multilength-strings") << "Very very long text" + QLatin1Char(0x9c) + "Very long text" + QLatin1Char(0x9c) + "Long text" + QLatin1Char(0x9c) + "text"; + QTest::newRow("richtext") << "<span>Silence! I <b>kill</b> you!</span>"; + QTest::newRow("veryrich") << "<h5>Very rich text, multi line label</h5><p>The phrase \"<b>to be, or not to be</b>\" comes from <font color=\"white\">William Shakespeare's <i>Hamlet</i></font> (written about 1600), act three, scene one. It is one of the most famous quotations in <small>world literature</small> and the <u>best-known of this particular play</u>...<h6>And tables...</h6><table border=1><tr><td>Cell 1</td><td>Cell 2</td></tr></table></p>"; +} + QTEST_APPLESS_MAIN(Pt_MLabel) diff --git a/benchmarks/pt_mlabel/pt_mlabel.h b/benchmarks/pt_mlabel/pt_mlabel.h index 556c29a7..3f5d056d 100644 --- a/benchmarks/pt_mlabel/pt_mlabel.h +++ b/benchmarks/pt_mlabel/pt_mlabel.h @@ -41,15 +41,15 @@ private slots: void paintPerformance(); void paintPerformance_data(); + void multiplePaintPerformance(); + void multiplePaintPerformance_data(); + private: - MLabel *m_subject; - enum ViewName { - View = 0, - NoViews - }; + void data(); + + MLabel *subject; MWidgetView *currentView; - qint32 currentViewIndex; QPixmap *pixmap; QPainter *painter; qint32 width; diff --git a/benchmarks/pt_mlabel/pt_mlabel.pro b/benchmarks/pt_mlabel/pt_mlabel.pro index ea2631e3..908aaf0e 100644 --- a/benchmarks/pt_mlabel/pt_mlabel.pro +++ b/benchmarks/pt_mlabel/pt_mlabel.pro @@ -5,3 +5,5 @@ TARGET = pt_mlabel SOURCES += pt_mlabel.cpp HEADERS += pt_mlabel.h + +LIBS += -lmeegotouchviews |