Why doesn't QT cache the bounding rect for QPainterPaths?
I had a HUGE performance issue and wasn't sure what was causing it, I eventually narrowed it down to a QPainterPath boundingRect() issue.
I had a QGraphicsItem subclasses line which drew its line with a QPainterPath. So in the subclassed class's boundingRect() function I called mypath.boundingRect(). Turns out that thats a really slow call!.
Saving the results to a QRectF had a drastic impact on performance.
Why doesn't it internally cache the bounding rect if its computation is complex?
Re: Why doesn't QT cache the bounding rect for QPainterPaths?
It seems that Qt 4.4.0 does cache it:
Code:
{
if (!d_ptr)
QPainterPathData *d = d_func();
if (d->dirtyBounds)
computeBoundingRect();
return d->bounds;
}
Which Qt version do you use?
Re: Why doesn't QT cache the bounding rect for QPainterPaths?
Hmm then I must be doing something that is causing it to think it needs to recaculate all the time. :(
Is there a good way to identify this kind of a bug?
Re: Why doesn't QT cache the bounding rect for QPainterPaths?
Quote:
Originally Posted by
mooreaa
Hmm then I must be doing something that is causing it to think it needs to recaculate all the time.
Maybe you create a new path every time?