90b84cf2340c30ca87961c46e2f1fde7eb4ec805
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-render-task-list.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__
3
4 /*
5  * Copyright (c) 2015 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/devel-api/common/owner-container.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class CompleteNotificationInterface;
33
34 namespace SceneGraph
35 {
36 class RenderMessageDispatcher;
37 class RenderTask;
38
39 /**
40  * An ordered list of render-tasks.
41  */
42 class RenderTaskList
43 {
44 public:
45
46   typedef OwnerContainer< RenderTask* > RenderTaskContainer;
47
48   /**
49    * Constructor
50    * @param renderMessageDispatcher to send messages
51    */
52   RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher );
53
54   /**
55    * Destructor
56    */
57   ~RenderTaskList();
58
59   /**
60    * Add a new RenderTask to the list.
61    * @param[in] newTask The RenderTaskList takes ownership of this task.
62    */
63   void AddTask( RenderTask* newTask );
64
65   /**
66    * Remove a RenderTask from the list.
67    * @param[in] task The RenderTaskList will destroy this task.
68    */
69   void RemoveTask( RenderTask* task );
70
71   /**
72    * Retrieve the container of RenderTasks.
73    * @return The container.
74    */
75   RenderTaskContainer& GetTasks();
76
77   /**
78    * Retrieve the container of RenderTasks.
79    * @return The container.
80    */
81   const RenderTaskContainer& GetTasks() const;
82
83   /**
84    * Set the notification method to package in the NotifyFinishedMessage
85    * @param object to store in notification managers queue
86    */
87   void SetCompleteNotificationInterface( CompleteNotificationInterface* object );
88
89   /**
90    * Get the Notification interface for when 1+ render tasks have finished
91    */
92   CompleteNotificationInterface* GetCompleteNotificationInterface();
93
94 private:
95
96   // Undefined
97   RenderTaskList(const RenderTaskList&);
98
99   // Undefined
100   RenderTaskList& operator=(const RenderTaskList&);
101
102 private:
103
104   CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification
105   RenderMessageDispatcher& mRenderMessageDispatcher; ///< for sending messages to render thread
106   RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
107
108 };
109
110 // Messages for RenderTaskList
111
112 inline void AddTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, RenderTask& task )
113 {
114   typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
115
116   // Reserve some memory inside the message queue
117   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
118
119   // Construct message in the message queue memory; note that delete should not be called on the return value
120   new (slot) LocalType( &list, &RenderTaskList::AddTask, &task );
121 }
122
123 inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, const RenderTask& constTask )
124 {
125   // Scene graph thread can destroy this object.
126   RenderTask& task = const_cast< RenderTask& >( constTask );
127
128   typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
129
130   // Reserve some memory inside the message queue
131   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
132
133   // Construct message in the message queue memory; note that delete should not be called on the return value
134   new (slot) LocalType( &list, &RenderTaskList::RemoveTask, &task );
135 }
136
137 } // namespace SceneGraph
138
139 } // namespace Internal
140
141 } // namespace Dali
142
143 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__