1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/public-api/math/rect.h>
22 #include <dali/internal/render/common/render-item.h>
23 #include <dali/internal/common/owner-container.h>
28 typedef Rect<int> ClippingBox;
40 typedef OwnerContainer< RenderItem* > RenderItemContainer;
43 typedef OwnerContainer< RenderList* > RenderListContainer;
46 * The RenderList structure provides the renderer with a list of renderers and
47 * a set of flags to tell it what depth buffering is required.
54 * The RenderFlags describe how the objects are rendered using the depth buffer.
58 DEPTH_TEST = 0x01, ///< If depth testing should be used
59 DEPTH_WRITE = 0x02, ///< If the depth buffer is writable
60 DEPTH_CLEAR = 0x04, ///< If the depth buffer should first be cleared
61 STENCIL_TEST = 0x08, ///< If stencil testing should be used
62 STENCIL_WRITE = 0x10, ///< If the stencil buffer is writable
63 STENCIL_CLEAR = 0x20 ///< If the stencil buffer should first be cleared
82 // pointer container deletes the render items
87 * Clear the render flags
95 * Set particular render flags
96 * @param[in] flags The set of flags to bitwise or with existing flags
98 void SetFlags( unsigned int flags )
100 mRenderFlags |= flags;
104 * Retrieve the render flags.
105 * @return the render flags.
107 unsigned int GetFlags() const
113 * Reset the render list for next frame
117 // we dont want to delete and re-create the render items every frame
126 * Reserve space in the render list
127 * @param size to reserve
129 void Reserve( RenderItemContainer::SizeType size )
132 mItems.Reserve( size );
136 * @return the capacity of the render list
138 RenderItemContainer::SizeType Capacity()
140 return mItems.Capacity();
144 * Get next free render item
145 * @return reference to the next available RenderItem
147 RenderItem& GetNextFreeItem()
149 // check if we have enough items, we can only be one behind at worst
150 if( mItems.Count() <= mNextFree )
152 mItems.PushBack( new RenderItem ); // Push a new empty render item
154 // get the item mNextFree points to and increase by one
155 RenderItem& item = *mItems[ mNextFree++ ];
161 * Get item at a given position in the list
163 RenderItem& GetItem( RenderItemContainer::SizeType index ) const
165 DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
166 return *mItems[ index ];
170 * Get renderer from an item in the list
172 const Renderer* GetRenderer( RenderItemContainer::SizeType index ) const
174 DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
175 return mItems[ index ]->GetRenderer();
179 * Get the number of real items
180 * Because of caching, the actual size may be bit more
181 * @return The number of items
183 RenderItemContainer::SizeType Count() const
189 * @return the number of items cached by the list
191 RenderItemContainer::SizeType GetCachedItemCount() const
193 return mItems.Count();
197 * Tells the render list to reuse the items from the cache
199 void ReuseCachedItems()
201 mNextFree = mItems.Count();
205 * Predicate to inform if the list is empty
209 return (mNextFree == 0);
214 * @param clipping on/off
215 * @param box for clipping
217 void SetClipping( bool clipping, const ClippingBox& box )
221 ClippingBox* newBox = new ClippingBox( box );
223 mClippingBox = newBox;
228 * @return true if clipping is on
230 bool IsClipping() const
232 return (NULL != mClippingBox);
236 * @return the clipping box
238 const ClippingBox& GetClippingBox() const
240 return *mClippingBox;
244 * @return the container (for sorting)
246 RenderItemContainer& GetContainer()
252 * Do some housekeeping to keep memory consumption low
254 void ReleaseUnusedItems()
256 // release any non-used RenderItems
257 if( mItems.Count() > mNextFree )
259 mItems.Resize( mNextFree );
264 * @return the source layer these renderitems originate from
266 Layer* GetSourceLayer()
272 * @param layer these renderitems originate from
274 void SetSourceLayer( Layer* layer )
276 mSourceLayer = layer;
282 * Copy constructor and assignment operator not defined
284 RenderList( const RenderList& rhs );
285 const RenderList& operator=( const RenderList& rhs );
287 RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
288 RenderItemContainer::SizeType mNextFree; ///< index for the next free item to use
290 unsigned int mRenderFlags; ///< The render flags
292 ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
293 Layer* mSourceLayer; ///< The originating layer where the renderers are from
297 } // namespace SceneGraph
299 } // namespace Internal
303 #endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H__