Ensured consistency of scene graph and render items 68/125068/2
authorDavid Steele <david.steele@samsung.com>
Thu, 13 Apr 2017 13:21:22 +0000 (14:21 +0100)
committerDavid Steele <david.steele@samsung.com>
Thu, 13 Apr 2017 17:04:43 +0000 (18:04 +0100)
There was a timing issue where UpdateManager's updateScene could be
false, but the messageQueue flushed messages to the process queue just
prior to ProcessSMessages being called which updated the scene graph.

Have ensured that ProcessMessages returns true if there were updates
to the scene graph, and changed UpdateManager to process the scene
appropriately.

Change-Id: I773f5eae2820ad1d93a78d0f3c784a7592ea320a
Signed-off-by: David Steele <david.steele@samsung.com>
dali/internal/update/manager/update-manager.cpp
dali/internal/update/queue/update-message-queue.cpp
dali/internal/update/queue/update-message-queue.h

index dae7194..39e8a31 100644 (file)
@@ -895,7 +895,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
   //Process Touches & Gestures
   const bool gestureUpdated = ProcessGestures( bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
 
-  const bool updateScene =                                  // The scene-graph requires an update if..
+  bool updateScene = // The scene-graph requires an update if..
       (mImpl->nodeDirtyFlags & RenderableUpdateFlags) ||    // ..nodes were dirty in previous frame OR
       IsAnimationRunning()                            ||    // ..at least one animation is running OR
       mImpl->messageQueue.IsSceneUpdateRequired()     ||    // ..a message that modifies the scene graph node tree is queued OR
@@ -911,8 +911,10 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
     mImpl->transformManager.ResetToBaseValue();
   }
 
-  //Process the queued scene messages
-  mImpl->messageQueue.ProcessMessages( bufferIndex );
+  // Process the queued scene messages. Note, MessageQueue::FlushQueue may be called
+  // between calling IsSceneUpdateRequired() above and here, so updateScene should
+  // be set again
+  updateScene |= mImpl->messageQueue.ProcessMessages( bufferIndex );
 
   //Forward compiled shader programs to event thread for saving
   ForwardCompiledShadersToEventThread();
index f6f7193..29b32ba 100644 (file)
@@ -149,9 +149,10 @@ MessageQueue::~MessageQueue()
 
 void MessageQueue::EventProcessingStarted()
 {
-  mImpl->processingEvents = true;
+  mImpl->processingEvents = true; // called from event thread
 }
 
+// Called from event thread
 unsigned int* MessageQueue::ReserveMessageSlot( unsigned int requestedSize, bool updateScene )
 {
   DALI_ASSERT_DEBUG( 0 != requestedSize );
@@ -198,6 +199,7 @@ unsigned int* MessageQueue::ReserveMessageSlot( unsigned int requestedSize, bool
   return mImpl->currentMessageBuffer->ReserveMessageSlot( requestedSize );
 }
 
+// Called from event thread
 bool MessageQueue::FlushQueue()
 {
   const bool messagesToProcess = ( NULL != mImpl->currentMessageBuffer );
@@ -241,7 +243,7 @@ bool MessageQueue::FlushQueue()
   return messagesToProcess;
 }
 
-void MessageQueue::ProcessMessages( BufferIndex updateBufferIndex )
+bool MessageQueue::ProcessMessages( BufferIndex updateBufferIndex )
 {
   PERF_MONITOR_START(PerformanceMonitor::PROCESS_MESSAGES);
 
@@ -275,6 +277,8 @@ void MessageQueue::ProcessMessages( BufferIndex updateBufferIndex )
   mImpl->processQueue.clear();
 
   PERF_MONITOR_END(PerformanceMonitor::PROCESS_MESSAGES);
+
+  return ( mImpl->sceneUpdate & 0x01 ); // if it was previously 2, scene graph was updated.
 }
 
 bool MessageQueue::WasEmpty() const
index c873967..e03d3f2 100644 (file)
@@ -87,8 +87,9 @@ public:
   /**
    * Called once per update; process the previously flushed messages.
    * @param updateBufferIndex to use
+   * @return true if the scene graph node tree is updated
    */
-  void ProcessMessages( BufferIndex updateBufferIndex );
+  bool ProcessMessages( BufferIndex updateBufferIndex );
 
   /**
    * Query whether the queue was empty this frame.