[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / internal / update / queue / update-message-queue.h
1 #ifndef __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__
2 #define __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // INTERNAL INCLUDES
21 #include <dali/internal/common/buffer-index.h>
22 #include <dali/internal/common/event-to-update.h>
23 #include <dali/internal/update/common/scene-graph-buffers.h>
24
25 namespace Dali
26 {
27
28 namespace Integration
29 {
30 class RenderController;
31 }
32
33 namespace Internal
34 {
35
36 class MessageBase;
37
38 namespace Update
39 {
40
41 /**
42  * Used by UpdateManager to receive messages from the event-thread.
43  * The event-thread uses the EventToUpdate interface to queue messages for the next update.
44  */
45 class MessageQueue: public EventToUpdate
46 {
47 public:
48
49   /**
50    * Create a new UpdateMessageQueue.
51    * @param[in] renderController After messages are flushed, we request a render from the RenderController.
52    * @param[in] sceneGraphBuffers Used to keep track of which buffers are being written or read.
53    */
54   MessageQueue( Integration::RenderController& renderController,
55                 const SceneGraph::SceneGraphBuffers& sceneGraphBuffers );
56
57   /**
58    * Virtual destructor
59    */
60   virtual ~MessageQueue();
61
62   // From EventToUpdate interface
63
64   /**
65    * @copydoc Dali::Internal::EventToUpdate::EventProcessingStarted()
66    */
67   virtual void EventProcessingStarted();
68
69   /**
70    * @copydoc Dali::Internal::EventToUpdate::ReserveMessageSlot()
71    */
72   virtual unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene );
73
74   /**
75    * @copydoc Dali::Internal::EventToUpdate::GetEventBufferIndex()
76    */
77   virtual BufferIndex GetEventBufferIndex() const;
78
79   /**
80    * @copydoc Dali::Internal::EventToUpdate::FlushQueue()
81    */
82   virtual bool FlushQueue();
83
84   // Exclusive to UpdateManager
85
86   /**
87    * Called once per update; process the previously flushed messages.
88    */
89   void ProcessMessages();
90
91   /**
92    * Query whether the queue was empty this frame.
93    */
94   bool WasEmpty() const;
95
96   /**
97    * Query whether the queue contains at least one message that requires that the scene-graph
98    * node tree be updated.
99    * @return A flag, true if the scene graph needs an update
100    */
101   bool IsSceneUpdateRequired() const;
102
103 private:
104
105   /**
106    * Helper to call Process and destructor on each queued message
107    * @param[in] minorQueue The queue to process.
108    */
109   void ProcessMinorQueue( char* minorQueue );
110
111 private:
112
113   struct Impl;
114   Impl* mImpl;
115 };
116
117 } // namespace Update
118
119 } // namespace Internal
120
121 } // namespace Dali
122
123 #endif // __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__