2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/update/common/discard-queue.h>
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>
39 DiscardQueue::DiscardQueue( RenderQueue& renderQueue )
40 : mRenderQueue( renderQueue )
44 DiscardQueue::~DiscardQueue()
48 void DiscardQueue::Add( BufferIndex updateBufferIndex, Node* node )
50 DALI_ASSERT_DEBUG( NULL != node );
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 )
57 mNodeQueue0.PushBack( node );
61 mNodeQueue1.PushBack( node );
65 void DiscardQueue::Add( BufferIndex updateBufferIndex, NodeAttachment* attachment )
67 DALI_ASSERT_DEBUG( NULL != attachment );
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 )
74 mAttachmentQueue0.PushBack( attachment );
78 mAttachmentQueue1.PushBack( attachment );
82 void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
84 DALI_ASSERT_DEBUG( NULL != shader );
86 // Programs are cached for the lifetime of DALi so no need for GL cleanup for shader for now.
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 )
93 mShaderQueue0.PushBack( shader );
97 mShaderQueue1.PushBack( shader );
101 void DiscardQueue::Clear( BufferIndex updateBufferIndex )
103 // Destroy some discarded objects; these should no longer own any GL resources
105 if ( 0u == updateBufferIndex )
108 mAttachmentQueue0.Clear();
109 mShaderQueue0.Clear();
114 mAttachmentQueue1.Clear();
115 mShaderQueue1.Clear();
119 } // namespace SceneGraph
121 } // namespace Internal