[4.0] Change to process events when the application is paused
[platform/core/uifw/dali-core.git] / dali / internal / update / queue / update-message-queue.cpp
index c11674e..330234d 100644 (file)
@@ -20,7 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/common/mutex.h>
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/integration-api/render-controller.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/common/message-buffer.h>
@@ -76,7 +76,11 @@ struct MessageQueue::Impl
   ~Impl()
   {
     // Delete the current buffer
-    delete currentMessageBuffer;
+    if( currentMessageBuffer )
+    {
+      DeleteBufferContents( currentMessageBuffer );
+      delete currentMessageBuffer;
+    }
 
     // Delete the unprocessed buffers
     const MessageBufferIter processQueueEndIter = processQueue.end();
@@ -145,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 );
@@ -188,12 +193,13 @@ unsigned int* MessageQueue::ReserveMessageSlot( unsigned int requestedSize, bool
   // If we are outside, then we have to request a call to Core::ProcessEvents() on idle.
   if ( false == mImpl->processingEvents )
   {
-    mImpl->renderController.RequestProcessEventsOnIdle();
+    mImpl->renderController.RequestProcessEventsOnIdle( false );
   }
 
   return mImpl->currentMessageBuffer->ReserveMessageSlot( requestedSize );
 }
 
+// Called from event thread
 bool MessageQueue::FlushQueue()
 {
   const bool messagesToProcess = ( NULL != mImpl->currentMessageBuffer );
@@ -237,7 +243,7 @@ bool MessageQueue::FlushQueue()
   return messagesToProcess;
 }
 
-void MessageQueue::ProcessMessages()
+bool MessageQueue::ProcessMessages( BufferIndex updateBufferIndex )
 {
   PERF_MONITOR_START(PerformanceMonitor::PROCESS_MESSAGES);
 
@@ -253,7 +259,7 @@ void MessageQueue::ProcessMessages()
     {
       MessageBase* message = reinterpret_cast< MessageBase* >( iter.Get() );
 
-      message->Process( mImpl->sceneGraphBuffers.GetUpdateBufferIndex() );
+      message->Process( updateBufferIndex  );
 
       // Call virtual destructor explictly; since delete will not be called after placement new
       message->~MessageBase();
@@ -271,6 +277,8 @@ void MessageQueue::ProcessMessages()
   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