Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, April 2007
drawText on QGraphicsView


Message 1 in thread

Hello,
I am looking for ways to speed up the drawing of small portions of text 
on my graphics items. Or alternatively, I am looking for assurance that 
text drawing on graphics views will be vastly improved in Qt 4.3.

On a graphics view with about 10 graphics items, if I remove all the 
calls to QPainter::drawText from inside the derives classes paint method 
and just leave the painting for other parts of the graphics item (lines, 
rectangles, curves) I achieve resonable performance. However, as soon as 
I turn on the drawing of small pieces of text on the graphics items, 
typically one or two latin character words on each graphics item, 
centered in a rectangle, the performance degrades beyond usable. Drawing 
text 10 or 20 times makes repainting of the entire scene take over a 
second at certain scale settings of the graphics view QMatrix.

Regards,
Andy.

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 2 in thread

Hi Andy,

You may try to draw text out of your own classes - just using 
QGraphicSimpleTextItem (with Z greater then your classes Z). May be  drawing 
in rect takes the time?

Best regards,
Igor Grivko

5 ÐÐÑÐÐÑ 2007 10:28, Andrew Ward ÐÐÐÐÑÐÐ:
> Hello,
> I am looking for ways to speed up the drawing of small portions of text
> on my graphics items. Or alternatively, I am looking for assurance that
> text drawing on graphics views will be vastly improved in Qt 4.3.
>
> On a graphics view with about 10 graphics items, if I remove all the
> calls to QPainter::drawText from inside the derives classes paint method
> and just leave the painting for other parts of the graphics item (lines,
> rectangles, curves) I achieve resonable performance. However, as soon as
> I turn on the drawing of small pieces of text on the graphics items,
> typically one or two latin character words on each graphics item,
> centered in a rectangle, the performance degrades beyond usable. Drawing
> text 10 or 20 times makes repainting of the entire scene take over a
> second at certain scale settings of the graphics view QMatrix.
>
> Regards,
> Andy.
>
> To unsubscribe - send "unsubscribe" in the subject to
> qt4-preview-feedback-request@xxxxxxxxxxxxx

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 3 in thread

Andrew Ward wrote:
> Hello,
> I am looking for ways to speed up the drawing of small portions of 
> text on my graphics items. Or alternatively, I am looking for 
> assurance that text drawing on graphics views will be vastly improved 
> in Qt 4.3.
>
> On a graphics view with about 10 graphics items, if I remove all the 
> calls to QPainter::drawText from inside the derives classes paint 
> method and just leave the painting for other parts of the graphics 
> item (lines, rectangles, curves) I achieve resonable performance. 
> However, as soon as I turn on the drawing of small pieces of text on 
> the graphics items, typically one or two latin character words on each 
> graphics item, centered in a rectangle, the performance degrades 
> beyond usable. Drawing text 10 or 20 times makes repainting of the 
> entire scene take over a second at certain scale settings of the 
> graphics view QMatrix.

Have you tried disabling anti-aliasing of text with 
graphicsView->setRenderHint( QPainter::TextAntialiasing, false );


--Dave

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 4 in thread

Thanks for your replies Igor and Dave,
Using a QGraphicsSimpleTextItem is not an option for me, however I 
checked and it uses much the same code behind the scenes as 
QPainter::drawText does anyway.
With regard to TextAntialiasing I don't even think this flag is used on 
Windows, I could not see it referenced anywhere in the Qt code while 
stepping through a call to QPainter::drawText, and the output looks the 
same whether it is set or not.
I must admit that I am surprised by the huge amounts of code run before 
the final call to the Windows function 'ExtTextOutW' to actually draw 
the text.

Here is a profile constructed using LTProf of the call trace using most 
of the CPU time in the application. Percents are the total application 
time spent in that particular function.

49.59% QPainter::drawText
    49.58% qt_format_text
        49.35% QTextLine::draw
            49.22% drawMenuText
                49.15% QPainter::drawTextItem
                    48.53% QRasterPaintEngine::drawTextItem
                         41.55% QRasterPaintEngine::drawTextInFontBuffer

I am not sure I trust this profile completely, because it says that 98% 
of the time spent in QRasterPaintEngine::drawTextInFontBuffer is spent 
in the line:
d->fontRasterBuffer->resetBuffer(255);
Which simply does a memset, which should be very quick.

Looking at the docs for QRasterPaintEngine it says this class is only 
available in Qtopia, but I am using Windows XP, maybe the docs are 
misleading?

Andy.


Dave Smith wrote:
> Andrew Ward wrote:
>> Hello,
>> I am looking for ways to speed up the drawing of small portions of 
>> text on my graphics items. Or alternatively, I am looking for 
>> assurance that text drawing on graphics views will be vastly improved 
>> in Qt 4.3.
>>
>> On a graphics view with about 10 graphics items, if I remove all the 
>> calls to QPainter::drawText from inside the derives classes paint 
>> method and just leave the painting for other parts of the graphics 
>> item (lines, rectangles, curves) I achieve resonable performance. 
>> However, as soon as I turn on the drawing of small pieces of text on 
>> the graphics items, typically one or two latin character words on 
>> each graphics item, centered in a rectangle, the performance degrades 
>> beyond usable. Drawing text 10 or 20 times makes repainting of the 
>> entire scene take over a second at certain scale settings of the 
>> graphics view QMatrix.
>
> Have you tried disabling anti-aliasing of text with 
> graphicsView->setRenderHint( QPainter::TextAntialiasing, false );
>
>
> --Dave
>
> To unsubscribe - send "unsubscribe" in the subject to 
> qt4-preview-feedback-request@xxxxxxxxxxxxx
>
>

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx