1 #ifndef __DALI_INTERNAL_DISCARD_QUEUE_H__
2 #define __DALI_INTERNAL_DISCARD_QUEUE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/devel-api/common/owner-container.h>
24 #include <dali/internal/common/buffer-index.h>
25 #include <dali/internal/update/nodes/node-declarations.h>
26 #include <dali/internal/update/rendering/scene-graph-texture-set.h>
27 #include <dali/internal/update/rendering/scene-graph-renderer.h>
46 * DiscardQueue is used to cleanup nodes & resources when no longer in use.
47 * Unwanted objects are added here during UpdateManager::Update().
48 * When added, messages will be sent to clean-up GL resources in the next Render.
49 * The Update for frame N+1 may occur in parallel with the rendering of frame N.
50 * Therefore objects queued for destruction in frame N, are destroyed frame N+2.
56 typedef OwnerContainer< Shader* > ShaderQueue;
57 typedef OwnerContainer< Renderer* > RendererQueue;
60 * Create a new DiscardQueue.
61 * @param[in] renderQueue Used to send GL clean-up messages for the next Render.
63 DiscardQueue( RenderQueue& renderQueue );
66 * Non-virtual destructor; DiscardQueue is not suitable as a base class.
71 * Adds an unwanted Node and its children to the discard queue.
72 * If necessary, a message will be sent to clean-up GL resources in the next Render.
73 * @pre This method is not thread-safe, and should only be called from the update-thread.
74 * @param[in] updateBufferIndex The current update buffer index.
75 * @param[in] node The discarded node; DiscardQueue takes ownership.
77 void Add( BufferIndex updateBufferIndex, Node* node );
80 * Adds an unwanted shader to the discard queue.
81 * A message will be sent to clean-up GL resources in the next Render.
82 * @pre This method is not thread-safe, and should only be called from the update-thread.
83 * @param[in] bufferIndex The current update buffer index.
84 * @param[in] shader The shader to queue; DiscardQueue takes ownership.
86 void Add( BufferIndex bufferIndex, Shader* shader );
89 * Adds an unwanted Renderer to the discard queue.
90 * A message will be sent to clean up GL resources in the next Render.
91 * @param[in] updateBufferIndex The current update buffer index.
92 * @param[in] renderer The discarded renderer; DiscardQueue takes ownership.
94 void Add( BufferIndex updateBufferIndex, Renderer* renderer );
97 * Release the nodes which were queued in the frame N-2.
98 * @pre This method should be called (once) at the beginning of every Update.
99 * @param[in] updateBufferIndex The current update buffer index.
101 void Clear( BufferIndex updateBufferIndex );
106 DiscardQueue( const DiscardQueue& );
109 DiscardQueue& operator=( const DiscardQueue& rhs );
113 RenderQueue& mRenderQueue; ///< Used to send GL clean-up messages for the next Render.
115 // Messages are queued here when the update buffer index == 0
116 NodeOwnerContainer mNodeQueue0;
117 ShaderQueue mShaderQueue0;
118 RendererQueue mRendererQueue0;
120 // Messages are queued here when the update buffer index == 1
121 NodeOwnerContainer mNodeQueue1;
122 ShaderQueue mShaderQueue1;
123 RendererQueue mRendererQueue1;
126 } // namespace SceneGraph
128 } // namespace Internal
132 #endif // __DALI_INTERNAL_RESOURCE_DISCARD_QUEUE_H__