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