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

Bad Performance of QPainter::drawText on Linux

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • 4.8.5
    • None
    • Open Suse 13.1, Ubuntu

    Description

      I have noticed that QPainter::drawText is horribly slow on Linux when using it with a scaled window mapping. Is there anything I can do about this? I already checked whether disabling anti-aliasing or enabled the raster-renderer makes a difference, but it doesn't. People on StackOverflow suggested to post it here since it seems to be a Qt bug.

      Example: When using a viewport size of (450px, 200px), a window size of factor 100 (45000, 20000) and thus font sizes scaled up by factor 100 as well (1400pt), rendering 30 times the text "hello" takes about 4 seconds on Linux - both on OpenSuse and Ubuntu.

      The same sample renders in a snap on Windows and Mac.

      Just for clarification: although the font size is scaled up, the text appears in "normal" size on screen due to the described window<->viewport mapping.

      Here is the simple sample code I am using:

      void Widget::paintEvent(QPaintEvent *event)
      {
      const int scaleFactor = 100;

      QPainter painter(this);

      // Setup font
      QFont font;
      font.setPointSize(14*scaleFactor);
      painter.setFont(font);

      // Setup mapping
      painter.setWindow(0, 0, width() * scaleFactor, height() * scaleFactor);

      // Render the text
      for (int i = 0; i < 30; i++)
      painter.drawText(qrand() % (width() * scaleFactor), qrand() % (height() * scaleFactor), "Hello");
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            zottel78 Fabian Roeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes