Moved OwnerContainer from internal to devel-api.
[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) 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/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 class CompleteStatusManager;
32 class CompleteNotificationInterface;
33
34 namespace SceneGraph
35 {
36
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    */
51   RenderTaskList( CompleteStatusManager& completeStatusManager );
52
53   /**
54    * Destructor
55    */
56   ~RenderTaskList();
57
58   /**
59    * Add a new RenderTask to the list.
60    * @param[in] newTask The RenderTaskList takes ownership of this task.
61    */
62   void AddTask( RenderTask* newTask );
63
64   /**
65    * Remove a RenderTask from the list.
66    * @param[in] task The RenderTaskList will destroy this task.
67    */
68   void RemoveTask( RenderTask* task );
69
70   /**
71    * Retrieve the container of RenderTasks.
72    * @return The container.
73    */
74   RenderTaskContainer& GetTasks();
75
76   /**
77    * Retrieve the container of RenderTasks.
78    * @return The container.
79    */
80   const RenderTaskContainer& GetTasks() const;
81
82   /**
83    * Set the notification method to package in the NotifyFinishedMessage
84    * @param object to store in notification managers queue
85    */
86   void SetCompleteNotificationInterface( CompleteNotificationInterface* object );
87
88   /**
89    * Get the Notification interface for when 1+ render tasks have finished
90    */
91   CompleteNotificationInterface* GetCompleteNotificationInterface();
92
93 private:
94
95   // Undefined
96   RenderTaskList(const RenderTaskList&);
97
98   // Undefined
99   RenderTaskList& operator=(const RenderTaskList&);
100
101 private:
102
103   CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification
104   RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
105   CompleteStatusManager& mCompleteStatusManager; ///< The complete status tracker (render tasks need this)
106
107 };
108
109 // Messages for RenderTaskList
110
111 inline void AddTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, RenderTask& task )
112 {
113   typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
114
115   // Reserve some memory inside the message queue
116   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
117
118   // Construct message in the message queue memory; note that delete should not be called on the return value
119   new (slot) LocalType( &list, &RenderTaskList::AddTask, &task );
120 }
121
122 inline void RemoveTaskMessage( EventThreadServices& eventThreadServices, RenderTaskList& list, const RenderTask& constTask )
123 {
124   // Scene graph thread can destroy this object.
125   RenderTask& task = const_cast< RenderTask& >( constTask );
126
127   typedef MessageValue1< RenderTaskList, RenderTask* > LocalType;
128
129   // Reserve some memory inside the message queue
130   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
131
132   // Construct message in the message queue memory; note that delete should not be called on the return value
133   new (slot) LocalType( &list, &RenderTaskList::RemoveTask, &task );
134 }
135
136 } // namespace SceneGraph
137
138 } // namespace Internal
139
140 } // namespace Dali
141
142 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_LIST_H__