Results 1 to 4 of 4

Thread: Why doesn't QT cache the bounding rect for QPainterPaths?

  1. #1

    Default 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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why doesn't QT cache the bounding rect for QPainterPaths?

    It seems that Qt 4.4.0 does cache it:
    Qt Code:
    1. QRectF QPainterPath::boundingRect() const
    2. {
    3. if (!d_ptr)
    4. return QRectF();
    5. QPainterPathData *d = d_func();
    6.  
    7. if (d->dirtyBounds)
    8. computeBoundingRect();
    9. return d->bounds;
    10. }
    To copy to clipboard, switch view to plain text mode 
    Which Qt version do you use?

  3. #3

    Default 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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why doesn't QT cache the bounding rect for QPainterPaths?

    Quote Originally Posted by mooreaa View Post
    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?

Similar Threads

  1. QGraphicsSvgItem, problem with scaling (invalid bounding rect)
    By Józef Paczenko in forum Qt Programming
    Replies: 3
    Last Post: 8th June 2010, 08:58
  2. hide bounding rect
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2008, 09:40
  3. Image format without bounding rect
    By dreamer in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2008, 22:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.