Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-39701

QPainter::drawText() slowdown

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.3.0
    • GUI: Painting
    • None
    • BeagleBoard xM, gcc 4.8.3, Linux 3.2.32

    Description

      This is a simple benchmark, compiled to run both with Qt 5.2.1 and 5.3.0:

      printf("\nwidth = %d, height = %d\n", w, h);
      if (w > 800)
      	w = 800;
      if (h > 480)
      	h = 480;
      QPainter painter;
      painter.setClipRect(0, 0, w, h, Qt::IntersectClip);
      painter.setRenderHint(QPainter::Antialiasing);
      painter.setRenderHint(QPainter::TextAntialiasing);
      
      for (alphaOn = 0; alphaOn <= 1; alphaOn++) {
      	painter.setOpacity(alphaOn ? 0.3 : 1.0);
      	painter.setPen(Qt::black);
      	startTest("2000x drawText", alphaOn);
      	for (i = 0; i < TEST_REPETITION; i++) {
      		int n = rand(64) + 1;
      		str.clear();
      		while (n--) {
      			char c = rand(26 * 2);
      			str += QChar((c >> 1) + ((c & 1) ? 'a' : 'A'));
      		}
      		painter.drawText(rand(w), rand(h), str);
      	}
      	endTest();
      

      The whole program code needs to be cleaned and can be made available on request. startTest()/endTest() just do time capturing and storing the results.

      Running with 5.2.1:

      width = 720, height = 574
      2000x drawText: 0.294s
      2000x drawText mit Alpha-Blending: 0.415s
      width = 800, height = 480
      2000x drawText: 0.280s
      2000x drawText mit Alpha-Blending: 0.439s

      Results with 5.3.0:

      width = 720, height = 574
      2000x drawText: 0.341s
      2000x drawText mit Alpha-Blending: 0.555s
      width = 800, height = 480
      2000x drawText: 0.339s
      2000x drawText mit Alpha-Blending: 0.602s

      Repeating the runs gives jitter of drawText+Alpha test in the range of 10ms, so the effect is actually there. All tests were run using linuxfb, but using minimal does not give any difference. In fact I originally observed this on a even slower ARM machine where the results look like this:

      2000x drawText: 4.919s
      2000x drawText mit Alpha-Blending: 4.617s
      2000x drawText: 23.891s
      2000x drawText mit Alpha-Blending: 6.275s

      For reference: a similar test on this machine using Qt 4.8:

      Text Solid 4,663
      Text Alpha 4,619

      Since I can't guarantee the same build environment is used for 5.2 and 5.3 on the slower device I repeated the test on the BBxM.

      Attachments

        1. PainterSlowdown.cpp
          1.0 kB
        2. PainterSlowdown.h
          0.2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            rebemlix Rolf Eike Beer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes