Removed Meshes and Model loading
[platform/core/uifw/dali-core.git] / dali / internal / update / common / discard-queue.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/update/common/discard-queue.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/render/gl-resources/gl-resource-owner.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/update/nodes/node.h>
25 #include <dali/internal/render/queue/render-queue.h>
26 #include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
27 #include <dali/internal/render/renderers/scene-graph-renderer.h>
28 #include <dali/internal/render/shaders/shader.h>
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace SceneGraph
37 {
38
39 DiscardQueue::DiscardQueue( RenderQueue& renderQueue )
40 : mRenderQueue( renderQueue )
41 {
42 }
43
44 DiscardQueue::~DiscardQueue()
45 {
46 }
47
48 void DiscardQueue::Add( BufferIndex updateBufferIndex, Node* node )
49 {
50   DALI_ASSERT_DEBUG( NULL != node );
51
52   // The GL resources will now be freed in frame N
53   // The Update for frame N+1 may occur in parallel with the rendering of frame N
54   // Queue the node for destruction in frame N+2
55   if ( 0u == updateBufferIndex )
56   {
57     mNodeQueue0.PushBack( node );
58   }
59   else
60   {
61     mNodeQueue1.PushBack( node );
62   }
63 }
64
65 void DiscardQueue::Add( BufferIndex updateBufferIndex, NodeAttachment* attachment )
66 {
67   DALI_ASSERT_DEBUG( NULL != attachment );
68
69   // The GL resources will now be freed in Render frame N
70   // The Update for frame N+1 may occur in parallel with the rendering of frame N
71   // Queue the attachment for destruction in Update frame N+2
72   if ( 0u == updateBufferIndex )
73   {
74     mAttachmentQueue0.PushBack( attachment );
75   }
76   else
77   {
78     mAttachmentQueue1.PushBack( attachment );
79   }
80 }
81
82 void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
83 {
84   DALI_ASSERT_DEBUG( NULL != shader );
85
86   // Programs are cached for the lifetime of DALi so no need for GL cleanup for shader for now.
87
88   // The GL resources will now be freed in frame N
89   // The Update for frame N+1 may occur in parallel with the rendering of frame N
90   // Queue the node for destruction in frame N+2
91   if ( 0u == updateBufferIndex )
92   {
93     mShaderQueue0.PushBack( shader );
94   }
95   else
96   {
97     mShaderQueue1.PushBack( shader );
98   }
99 }
100
101 void DiscardQueue::Clear( BufferIndex updateBufferIndex )
102 {
103   // Destroy some discarded objects; these should no longer own any GL resources
104
105   if ( 0u == updateBufferIndex )
106   {
107     mNodeQueue0.Clear();
108     mAttachmentQueue0.Clear();
109     mShaderQueue0.Clear();
110   }
111   else
112   {
113     mNodeQueue1.Clear();
114     mAttachmentQueue1.Clear();
115     mShaderQueue1.Clear();
116   }
117 }
118
119 } // namespace SceneGraph
120
121 } // namespace Internal
122
123 } // namespace Dali