Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / render / queue / render-queue.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_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/message-buffer.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 class MessageBase;
31
32 namespace SceneGraph
33 {
34
35 /**
36  * Allows messages to be queued for RenderManager, during the scene-graph Update.
37  */
38 class RenderQueue
39 {
40 public:
41
42   /**
43    * Create a new RenderQueue.
44    */
45   RenderQueue();
46
47   /**
48    * Non-virtual destructor; RenderQueue is not suitable as a base class.
49    */
50   ~RenderQueue();
51
52   /**
53    * Reserve space for another message in the queue; this must then be initialized by the caller.
54    * The message will be read from the next render-thread tick.
55    * @post Calling this method may invalidate any previously returned slots.
56    * @param[in] updateBufferIndex The current update buffer index.
57    * @param[in] size The message size with respect to the size of type "char".
58    * @return A pointer to the first char allocated for the message.
59    */
60   unsigned int* ReserveMessageSlot( BufferIndex updateBufferIndex, std::size_t size );
61
62   /**
63    * Process the batch of messages, which were queued in the previous update.
64    * @pre This message should only be called by RenderManager from within the render-thread.
65    * @param[in] bufferIndex The previous update buffer index.
66    */
67   void ProcessMessages( BufferIndex bufferIndex );
68
69 private:
70
71   /**
72    * Helper to retrieve the current container.
73    * The update-thread queues messages with one container, whilst the render-thread is processing the other.
74    * @param[in] bufferIndex The current buffer index.
75    * @return The container.
76    */
77   MessageBuffer* GetCurrentContainer( BufferIndex bufferIndex );
78
79   /**
80    * Helper to limit the buffer capacity i.e. after a frame when an extreme number of messages have been sent.
81    * @param[in] bufferIndex The current buffer index.
82    */
83   void LimitBufferCapacity( BufferIndex bufferIndex );
84
85   // Undefined
86   RenderQueue( const RenderQueue& );
87
88   // Undefined
89   RenderQueue& operator=( const RenderQueue& rhs );
90
91 private:
92
93   MessageBuffer* container0; ///< Messages are queued here when the update buffer index == 0
94   MessageBuffer* container1; ///< Messages are queued here when the update buffer index == 1
95 };
96
97 } // namespace SceneGraph
98
99 } // namespace Internal
100
101 } // namespace Dali
102
103 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_QUEUE_H__