Removed Meshes and Model loading
[platform/core/uifw/dali-core.git] / dali / internal / update / common / discard-queue.h
1 #ifndef __DALI_INTERNAL_DISCARD_QUEUE_H__
2 #define __DALI_INTERNAL_DISCARD_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/public-api/object/ref-object.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/common/owner-container.h>
25 #include <dali/internal/update/nodes/node-declarations.h>
26 #include <dali/internal/update/node-attachments/node-attachment-declarations.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 class Texture;
35
36 namespace SceneGraph
37 {
38
39 class Node;
40 class RenderQueue;
41 class Shader;
42
43 /**
44  * DiscardQueue is used to cleanup nodes & resources when no longer in use.
45  * Unwanted objects are added here during UpdateManager::Update().
46  * When added, messages will be sent to clean-up GL resources in the next Render.
47  * The Update for frame N+1 may occur in parallel with the rendering of frame N.
48  * Therefore objects queued for destruction in frame N, are destroyed frame N+2.
49  */
50 class DiscardQueue
51 {
52 public:
53
54   typedef OwnerContainer< Shader* > ShaderQueue;
55
56   /**
57    * Create a new DiscardQueue.
58    * @param[in] renderQueue Used to send GL clean-up messages for the next Render.
59    */
60   DiscardQueue( RenderQueue& renderQueue );
61
62   /**
63    * Non-virtual destructor; DiscardQueue is not suitable as a base class.
64    */
65   ~DiscardQueue();
66
67   /**
68    * Adds an unwanted Node and its children to the discard queue.
69    * If necessary, a message will be sent to clean-up GL resources in the next Render.
70    * @pre This method is not thread-safe, and should only be called from the update-thread.
71    * @param[in] updateBufferIndex The current update buffer index.
72    * @param[in] node The discarded node; DiscardQueue takes ownership.
73    */
74   void Add( BufferIndex updateBufferIndex, Node* node );
75
76   /**
77    * Adds an unwanted NodeAttachment to the discard queue.
78    * If necessary, a message will be sent to clean-up GL resources in the next Render.
79    * @pre This method is not thread-safe, and should only be called from the update-thread.
80    * @param[in] updateBufferIndex The current update buffer index.
81    * @param[in] attachment The discarded attachment; DiscardQueue takes ownership.
82    */
83   void Add( BufferIndex updateBufferIndex, NodeAttachment* attachment );
84
85   /**
86    * Adds an unwanted shader to the discard queue.
87    * A message will be sent to clean-up GL resources in the next Render.
88    * @pre This method is not thread-safe, and should only be called from the update-thread.
89    * @param[in] bufferIndex The current update buffer index.
90    * @param[in] shader The shader to queue; DiscardQueue takes ownership.
91    */
92   void Add( BufferIndex bufferIndex, Shader* shader );
93
94   /**
95    * Release the nodes which were queued in the frame N-2.
96    * @pre This method should be called (once) at the beginning of every Update.
97    * @param[in] updateBufferIndex The current update buffer index.
98    */
99   void Clear( BufferIndex updateBufferIndex );
100
101 private:
102
103   // Undefined
104   DiscardQueue( const DiscardQueue& );
105
106   // Undefined
107   DiscardQueue& operator=( const DiscardQueue& rhs );
108
109 private:
110
111   RenderQueue& mRenderQueue; ///< Used to send GL clean-up messages for the next Render.
112
113   // Messages are queued here when the update buffer index == 0
114   NodeOwnerContainer           mNodeQueue0;
115   NodeAttachmentOwnerContainer mAttachmentQueue0;
116   ShaderQueue                  mShaderQueue0;
117
118   // Messages are queued here when the update buffer index == 1
119   NodeOwnerContainer           mNodeQueue1;
120   NodeAttachmentOwnerContainer mAttachmentQueue1;
121   ShaderQueue                  mShaderQueue1;
122 };
123
124 } // namespace SceneGraph
125
126 } // namespace Internal
127
128 } // namespace Dali
129
130 #endif // __DALI_INTERNAL_RESOURCE_DISCARD_QUEUE_H__