×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    34

    QGraphicsItem animation and cache mode problem on N8

    I added some fancy transitions to my app. Just animating position and rotation for QGraphicsTextItem and QGraphicsWidgetProxy that are in QGraphicsSCene in QGraphicsView.

    On desktop version (win32) everything works as excepted. Items rotate and there is no artifacts and everything looks great.

    But on N8 only a small part of the item, or not even that, is visible during animation. QGraphicsView background is rendered correctly and so is foreground. I debugged this by rendering item bounds manually to foreground. Bounds are rendered correctly, but only a small portion is visible inside bounds. It's like it's rendering is stopped to some random horizontal line. Somebody might call it flickering, but an item is not rendered fully even once.

    I tried few things. First I thought that animation framework was messing something up, because I used QPropertyAnimation. So I did animation manually. Same result.
    I tried without background or foreground. I tested with different z-values. I tried QGraphicsView optimization flags and viewport update modes. Different sort of update timers etc. No effect.

    I tried without rotation and now it worked. This made me think that behaviour has something to do with incorrect bounds. Somehow bounding box is messed up when item is rotated (and perhaps this happens with scale too.) If I understood right, Qt uses axis-aligned bounding boxes, so naturally when object is rotated bounding box should change it's geometry. However when I tried to force rendering of everything, there was no difference what so ever. (I am not sure if I did that right though.)

    Animated Tiles example uses DeviceCoordinateCache mode for items. I tried that and in fact it worked, but for some reason it causes recursive paint events leading to warnings and out of memory errors. Animated Tiles example works perfectly on N8, but it doesn't rotate items.

    Then I tried ItemCoordinateCache mode. Now animation works without errors or warnings. Downside is that as this mode uses separate buffer, visual quality is a bit bad. That's not a big problem since I can just set this mode on when animation starts and disable cache after transition.

    However, I think rotation should work without changing cache mode. And it does work, when object is not animated.

    What I didn't try, is to manually calculate bounds, because it's a bit too much work for just testing. I didn't found a way to easily take existing item instance and just overload bound functions. I mean, like in decorator-pattern.

    I'm using Qt 4.6.x. On N8 I use version supplied with device/os.
    Last edited by virne; 2010-12-21 at 14:01.

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    34

    Re: QGraphicsItem animation and cache mode problem on N8

    It turned out that using ItemCoordinateCache wasn't bullet proof solution either. It sometimes caused use of QPainter outside paint event (happened also on Windows) and in some cases bounds were yet again broken causing broken rendering.

    With simple objects, like QGraphicsPixmapItem, there were no problems. Problematic items were complex items like QGraphicsWidgetProxy and QGraphicsTextItem.

    I decided to make my "main" widget QGraphicsWidget instead of QWidget. To my surprise it worked! There was no need to fiddle with cache mode either. Now I need to "manually" control clipping, but that's ok since it seems that my widgets doesn't want to stay in it's box anyway.
    For text item I use DeviceCoordinateCache-mode now. It seems to work with it without warnings or errors.

    So my conclusion is that there might be a bug in bound calculations that only appears when rotating some complex items on QGraphicsScene. I haven't tried if this is case also with software rendering Symbian devices. There might be also some other platforms that are affected. Windows and OS X versions work fine. I won't spend time now checking if this behaviour still exist with Qt 4.7 on N8.

Similar Threads

  1. Replies: 2
    Last Post: 2010-11-26, 09:04
  2. Is the Cache Problem?
    By fanstar in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2003-07-21, 09:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×