Re: [Development] Calling a function at frame-rate before rendering

2014-05-15 Thread raskolnikov
Hi!

Just for the record: I solved the problem by combining a
QAbstractAnimation and a QQuickItem. the later calls the commit state
function of my model in the updatePolish() override, and the animation
calls polish() on the first object on every updateCurrentTime(). This way
my state is updated and visible in the UI at frame-rate.

Thanks a lot for the hints Gunnar!

JP


 Thank you a lot, that is a very comprenhensive response.

 If you have GUI thread state, application logic and other stuff you can
 call QQuickItem::polish() and reimplemnt QQuickItem::updatePolish()
 which
 is called just before the QML tree is synced into the render thread.

 Indeed, this is GUI thread state and this update potentially updates QML
 properties, whose state we want visible before synching to the state
 thread. This seems reasonably the best approach, but when can I call
 polish?

 If you have continuous animations use QAbstractAnimation and use the
 time
 you get in updateCurrentTime().

 I did this, but then the state update seems to lag one frame behind. The
 problem looks like this:

  next
 Touch Input   -   Render  - updateCurrentTime  -   Render
 \  \
  \  \
   \  \ Depndent properties
  Set some property\  /  update
 \  \/
  \  \  /
   \  \/
 State update State update
 ScheduledComitted

 I wonder, if there is a way to commit the state before the first render,
 so dependent properties don't seem to lag. The problem with calling
 polish() explicitly is that the component that ticks the state and the
 ones that modify the state are unrelated. Maybe, is there a way to mark a
 component as always dirty needing polish?

 JP




___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Calling a function at frame-rate before rendering

2014-05-14 Thread Gunnar Sletta
It depends on what your update state is...

If you want to tick rendering state (OpenGL and Scene Graph stuff) then you can 
call QQuickWindow::update() and make a direct connection to 
QQuickWindow::beforeRendering() to advance the state on the render thread just 
before the scene is drawn. 

If you have a QSGNode structure you want to update, call QQuickItem::update() 
and QQuickItem::updatePaintNode() will be called to synchronise your item state 
into the scene graph before the scene graph is rendered.

If you have GUI thread state, application logic and other stuff you can call 
QQuickItem::polish() and reimplemnt QQuickItem::updatePolish() which is called 
just before the QML tree is synced into the render thread.

If you have continuous animations use QAbstractAnimation and use the time you 
get in updateCurrentTime(). 

cheers,
Gunnar


On 14 May 2014, at 16:53, raskolni...@es.gnu.org wrote:

 Hi guys!
 
 So... I am working on a project where the data model is written in a
 functional style and uses a epochal approach to move it's state
 forward... the details would probably bore you but the important thing is
 that it requires a tick() function to be called to make an updated world
 state visible.
 
 This seems to be tricky in Qt and I haven't found the best approach yet...
 and I am starting to wonder if is even possible at all.
 
 Because following some discussions in this list it seems that animations
 are ticked at frame-rate, I tried deriving from QAbstractAnimation and
 tick updateCurrentTime(), however, that made the state lag one frame
 behind rendering, something quite visible when dragging an object (the Qt
 draggable would be updated automatically, but our data-model based stuff
 would lag one frame).
 
 Then I tried making an eventFilter() in which I do something like this:
 
if (event != MyTickEvent)
postEvent(MyTickEvent)
else
tick()
 
 I expected this to remove the lagging, but while it improves the
 situation, there are cases in which I can still see some lagging.
 Furthermore, this approach involves too much ticking, while ticking one
 per frame should be enough.
 
 So, am I missing something? Is there a general way to tick my state update
 before rendering?
 
 Thanks!
 
 JP
 
 
 ___
 Development mailing list
 Development@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/development

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development