-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// CLASS HEADER
#include <dali/internal/update/queue/update-message-queue.h>
-// EXTERNAL INCLUDES
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wall"
-#include <boost/thread/mutex.hpp>
-#pragma clang diagnostic pop
-#else
-#include <boost/thread/mutex.hpp>
-#endif // ifdef __clang
-
// INTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.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>
#include <dali/internal/render/common/performance-monitor.h>
typedef vector< MessageBuffer* > MessageBufferQueue;
typedef MessageBufferQueue::iterator MessageBufferIter;
-typedef boost::mutex MessageQueueMutex;
+typedef Dali::Mutex MessageQueueMutex;
} // unnamed namespace
~Impl()
{
// Delete the current buffer
- delete currentMessageBuffer;
+ if( currentMessageBuffer )
+ {
+ DeleteBufferContents( currentMessageBuffer );
+ delete currentMessageBuffer;
+ }
// Delete the unprocessed buffers
const MessageBufferIter processQueueEndIter = processQueue.end();
MessageBufferQueue freeQueue; ///< buffers from the recycleQueue; can be used without locking
};
-MessageQueue::MessageQueue( RenderController& controller, const SceneGraphBuffers& buffers )
+MessageQueue::MessageQueue( Integration::RenderController& controller, const SceneGraph::SceneGraphBuffers& buffers )
: mImpl(NULL)
{
mImpl = new Impl( controller, buffers );
void MessageQueue::EventProcessingStarted()
{
- mImpl->processingEvents = true;
+ mImpl->processingEvents = true; // called from event thread
}
-unsigned int* MessageQueue::ReserveMessageSlot( std::size_t requestedSize, bool updateScene )
+// Called from event thread
+unsigned int* MessageQueue::ReserveMessageSlot( unsigned int requestedSize, bool updateScene )
{
DALI_ASSERT_DEBUG( 0 != requestedSize );
// 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 );
}
-BufferIndex MessageQueue::GetEventBufferIndex() const
-{
- return mImpl->sceneGraphBuffers.GetEventBufferIndex();
-}
-
+// Called from event thread
bool MessageQueue::FlushQueue()
{
const bool messagesToProcess = ( NULL != mImpl->currentMessageBuffer );
if ( messagesToProcess )
{
// queueMutex must be locked whilst accessing processQueue or recycleQueue
- MessageQueueMutex::scoped_lock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
mImpl->processQueue.push_back( mImpl->currentMessageBuffer );
mImpl->currentMessageBuffer = NULL;
return messagesToProcess;
}
-void MessageQueue::ProcessMessages()
+bool MessageQueue::ProcessMessages( BufferIndex updateBufferIndex )
{
PERF_MONITOR_START(PerformanceMonitor::PROCESS_MESSAGES);
// queueMutex must be locked whilst accessing queue
- MessageQueueMutex::scoped_lock lock( mImpl->queueMutex );
+ MessageQueueMutex::ScopedLock lock( mImpl->queueMutex );
const MessageBufferIter processQueueEndIter = mImpl->processQueue.end();
for ( MessageBufferIter iter = mImpl->processQueue.begin(); iter != processQueueEndIter ; ++iter )
{
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();
// Pass back for use in the event-thread
mImpl->recycleQueue.push_back( buffer );
-
- mImpl->sceneUpdate >>= 1;
}
+ mImpl->sceneUpdate >>= 1;
+
mImpl->queueWasEmpty = mImpl->processQueue.empty(); // Flag whether we processed anything
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