(Gestures) Ensure an update is done if gesture properties are updated. 90/20290/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 25 Apr 2014 14:36:06 +0000 (15:36 +0100)
committerDavid Steele <david.steele@partner.samsung.com>
Thu, 1 May 2014 14:29:50 +0000 (15:29 +0100)
[Problem]  If gesture properties are updated and if there are no queued messaged from the event
           thread, then update is still not run.
[Cause]    Gesture properties are updated directly rather than via a message.
[Solution] Process gestures whenever we have an update, if the properties are updated, then we
           should update the scene as well.

Change-Id: Ief1ee545fb7a3af289623cf100fe24e18f296569
Signed-off-by: David Steele <david.steele@partner.samsung.com>
dali/internal/update/gestures/scene-graph-pan-gesture.cpp
dali/internal/update/gestures/scene-graph-pan-gesture.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h

index 1b9c71f..a891fe2 100644 (file)
@@ -195,8 +195,10 @@ void PanGesture::PredictiveAlgorithm2(int eventsThisFrame, PanInfo& gestureOut,
   gestureOut.time += interpolationTime;
 }
 
-void PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
+bool PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
 {
+  bool propertiesUpdated( false );
+
   if( !mInGesture )
   {
     // clear current pan history
@@ -322,6 +324,8 @@ void PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int next
       mScreenDisplacement.Set( nextGesture.screen.displacement );
       mLocalPosition.Set( nextGesture.local.position );
       mLocalDisplacement.Set( nextGesture.local.displacement );
+
+      propertiesUpdated = true;
     }
 
     if( mProfiling )
@@ -339,6 +343,8 @@ void PanGesture::UpdateProperties( unsigned int lastVSyncTime, unsigned int next
     mProfiling->ClearData();
     UPDATE_COUNT = 0u;
   }
+
+  return propertiesUpdated;
 }
 
 const GesturePropertyVector2& PanGesture::GetScreenPositionProperty() const
index 1d0d6a0..25ea13b 100644 (file)
@@ -217,8 +217,9 @@ public:
   /**
    * Called by the update manager so that we can update the value of our properties.
    * @param[in]  nextRenderTime  The estimated time of the next render (in milliseconds).
+   * @return true, if properties were updated.
    */
-  virtual void UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
+  virtual bool UpdateProperties( unsigned int lastRenderTime, unsigned int nextRenderTime );
 
   /**
    * Retrieves a reference to the screen position property.
index 61502af..fe75dda 100644 (file)
@@ -791,25 +791,24 @@ void UpdateManager::ResetProperties()
     (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
   }
 
-  // Reset gesture properties to base values
-  for ( GestureIter iter = mImpl->gestures.Begin(); iter != mImpl->gestures.End(); ++iter )
-  {
-    (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
-  }
-
   PERF_MONITOR_END(PerformanceMonitor::RESET_PROPERTIES);
 }
 
-void UpdateManager::ProcessGestures( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
+bool UpdateManager::ProcessGestures( unsigned int lastVSyncTime, unsigned int nextVSyncTime )
 {
+  bool gestureUpdated( false );
+
   // constrain gestures... (in construction order)
   GestureContainer& gestures = mImpl->gestures;
 
   for ( GestureIter iter = gestures.Begin(), endIter = gestures.End(); iter != endIter; ++iter )
   {
     PanGesture& gesture = **iter;
-    gesture.UpdateProperties( lastVSyncTime, nextVSyncTime );
+    gesture.ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() ); // Needs to be done every time as gesture data is written directly to an update-buffer rather than via a message
+    gestureUpdated |= gesture.UpdateProperties( lastVSyncTime, nextVSyncTime );
   }
+
+  return gestureUpdated;
 }
 
 void UpdateManager::Animate( float elapsedSeconds )
@@ -1019,26 +1018,31 @@ unsigned int UpdateManager::Update( float elapsedSeconds, unsigned int lastVSync
   // 2) Grab any loaded resources
   bool resourceChanged = mImpl->resourceManager.UpdateCache( mSceneGraphBuffers.GetUpdateBufferIndex() );
 
+  // 3) Process Touches & Gestures
+  mImpl->touchResampler.Update();
+  const bool gestureUpdated = ProcessGestures( lastVSyncTime, nextVSyncTime );
+
   const bool updateScene =                                            // The scene-graph requires an update if..
       mImpl->activeConstraints != 0 ||                                // ..constraints were active in previous frame OR
       (mImpl->nodeDirtyFlags & RenderableUpdateFlags) ||              // ..nodes were dirty in previous frame OR
       IsAnimationRunning() ||                                         // ..at least one animation is running OR
       mImpl->dynamicsChanged ||                                       // ..there was a change in the dynamics simulation OR
-      mImpl->messageQueue.IsSceneUpdateRequired() ||                  // ..a message that modifies the scene graph node tree is queued
-      resourceChanged;                                                // one or more resources were updated/changed
+      mImpl->messageQueue.IsSceneUpdateRequired() ||                  // ..a message that modifies the scene graph node tree is queued OR
+      resourceChanged ||                                              // ..one or more resources were updated/changed OR
+      gestureUpdated;                                                // ..a gesture property was updated
 
   // Although the scene-graph may not require an update, we still need to synchronize double-buffered
   // values if the scene was updated in the previous frame.
   if( updateScene || mImpl->previousUpdateScene )
   {
-    // 3) Reset properties from the previous update
+    // 4) Reset properties from the previous update
     ResetProperties();
   }
 
-  // 4) Process the queued scene messages
+  // 5) Process the queued scene messages
   mImpl->messageQueue.ProcessMessages();
 
-  // 5) Post Process Ids of resources updated by renderer
+  // 6) Post Process Ids of resources updated by renderer
   mImpl->resourceManager.PostProcessResources( mSceneGraphBuffers.GetUpdateBufferIndex() );
 
   // Although the scene-graph may not require an update, we still need to synchronize double-buffered
@@ -1046,10 +1050,6 @@ unsigned int UpdateManager::Update( float elapsedSeconds, unsigned int lastVSync
   // We should not start skipping update steps or reusing lists until there has been two frames where nothing changes
   if( updateScene || mImpl->previousUpdateScene )
   {
-    // 6) Process Touches & Gestures
-    mImpl->touchResampler.Update();
-    ProcessGestures( lastVSyncTime, nextVSyncTime );
-
     // 7) Animate
     Animate( elapsedSeconds );
 
index 50ea6c2..fd475bc 100644 (file)
@@ -428,8 +428,9 @@ private:
    * Perform gesture updates.
    * @param[in]  lastVSyncTime  The last VSync time.
    * @param[in]  nextVSyncTime  The estimated time of the next VSync.
+   * @return true, if any properties were updated.
    */
-  void ProcessGestures( unsigned int lastVSyncTime, unsigned int nextVSyncTime );
+  bool ProcessGestures( unsigned int lastVSyncTime, unsigned int nextVSyncTime );
 
   /**
    * Perform animation updates