[dali_1.0.25] Merge branch 'tizen'
[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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
21 // INTERNAL INCLUDES
22 #include <dali/internal/common/buffer-index.h>
23 #include <dali/internal/common/event-to-update.h>
24 #include <dali/internal/update/common/scene-graph-buffers.h>
25
26 namespace Dali
27 {
28
29 namespace Integration
30 {
31 class RenderController;
32 }
33
34 namespace Internal
35 {
36
37 class MessageBase;
38
39 namespace Update
40 {
41
42 /**
43  * Used by UpdateManager to receive messages from the event-thread.
44  * The event-thread uses the EventToUpdate interface to queue messages for the next update.
45  */
46 class MessageQueue: public EventToUpdate
47 {
48 public:
49
50   /**
51    * Create a new UpdateMessageQueue.
52    * @param[in] renderController After messages are flushed, we request a render from the RenderController.
53    * @param[in] sceneGraphBuffers Used to keep track of which buffers are being written or read.
54    */
55   MessageQueue( Integration::RenderController& renderController,
56                 const SceneGraph::SceneGraphBuffers& sceneGraphBuffers );
57
58   /**
59    * Virtual destructor
60    */
61   virtual ~MessageQueue();
62
63   // From EventToUpdate interface
64
65   /**
66    * @copydoc Dali::Internal::EventToUpdate::EventProcessingStarted()
67    */
68   virtual void EventProcessingStarted();
69
70   /**
71    * @copydoc Dali::Internal::EventToUpdate::ReserveMessageSlot()
72    */
73   virtual unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene );
74
75   /**
76    * @copydoc Dali::Internal::EventToUpdate::GetEventBufferIndex()
77    */
78   virtual BufferIndex GetEventBufferIndex() const;
79
80   /**
81    * @copydoc Dali::Internal::EventToUpdate::FlushQueue()
82    */
83   virtual bool FlushQueue();
84
85   // Exclusive to UpdateManager
86
87   /**
88    * Called once per update; process the previously flushed messages.
89    */
90   void ProcessMessages();
91
92   /**
93    * Query whether the queue was empty this frame.
94    */
95   bool WasEmpty() const;
96
97   /**
98    * Query whether the queue contains at least one message that requires that the scene-graph
99    * node tree be updated.
100    * @return A flag, true if the scene graph needs an update
101    */
102   bool IsSceneUpdateRequired() const;
103
104 private:
105
106   /**
107    * Helper to call Process and destructor on each queued message
108    * @param[in] minorQueue The queue to process.
109    */
110   void ProcessMinorQueue( char* minorQueue );
111
112 private:
113
114   struct Impl;
115   Impl* mImpl;
116 };
117
118 } // namespace Update
119
120 } // namespace Internal
121
122 } // namespace Dali
123
124 #endif // __DALI_INTERNAL_UPDATE_MESSAGE_QUEUE_H__