1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H
5 * Copyright (c) 2018 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/math/rect.h>
23 #include <dali/devel-api/common/owner-container.h>
24 #include <dali/internal/update/rendering/render-item.h>
29 typedef Rect<int> ClippingBox;
39 typedef OwnerContainer< RenderItem* > RenderItemContainer;
42 typedef OwnerContainer< RenderList* > RenderListContainer;
45 * The RenderList structure provides the renderer with a list of renderers.
58 mHasColorRenderItems( false )
67 // Pointer container deletes the render items
72 * Reset the render list for next frame
76 // We don't want to delete and re-create the render items every frame
84 * Reserve space in the render list
85 * @param size to reserve
87 void Reserve( RenderItemContainer::SizeType size )
90 mItems.Reserve( size );
94 * @return the capacity of the render list
96 RenderItemContainer::SizeType Capacity()
98 return mItems.Capacity();
102 * Get next free render item
103 * @return reference to the next available RenderItem
105 RenderItem& GetNextFreeItem()
107 // check if we have enough items, we can only be one behind at worst
108 if( mItems.Count() <= mNextFree )
110 mItems.PushBack( RenderItem::New() ); // Push a new empty render item
112 // get the item mNextFree points to and increase by one
113 RenderItem& item = *mItems[ mNextFree++ ];
118 * Get item at a given position in the list
120 RenderItem& GetItem( RenderItemContainer::SizeType index ) const
122 DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
123 return *mItems[ index ];
127 * Get the number of real items
128 * Because of caching, the actual size may be bit more
129 * @return The number of items
131 RenderItemContainer::SizeType Count() const
137 * @return the number of items cached by the list
139 RenderItemContainer::SizeType GetCachedItemCount() const
141 return mItems.Count();
145 * Tells the render list to reuse the items from the cache
147 void ReuseCachedItems()
149 mNextFree = mItems.Count();
153 * Predicate to inform if the list is empty
157 return ( mNextFree == 0 );
162 * @param clipping on/off
163 * @param box for clipping
165 void SetClipping( bool clipping, const ClippingBox& box )
170 mClippingBox = new ClippingBox( box );;
175 * @return true if clipping is on
177 bool IsClipping() const
179 return ( NULL != mClippingBox );
183 * @return the clipping box
185 const ClippingBox& GetClippingBox() const
187 return *mClippingBox;
191 * @return the container (for sorting)
193 RenderItemContainer& GetContainer()
199 * Do some housekeeping to keep memory consumption low
201 void ReleaseUnusedItems()
203 // release any non-used RenderItems
204 if( mItems.Count() > mNextFree )
206 mItems.Resize( mNextFree );
211 * @return the source layer these renderitems originate from
213 Layer* GetSourceLayer() const
219 * @param layer The layer these RenderItems originate from
221 void SetSourceLayer( Layer* layer )
223 mSourceLayer = layer;
227 * Set if the RenderList contains color RenderItems
228 * @param[in] hasColorRenderItems True if it contains color RenderItems, false otherwise
230 void SetHasColorRenderItems( bool hasColorRenderItems )
232 mHasColorRenderItems = hasColorRenderItems;
236 * Check if the RenderList contains color RenderItems
237 * @return true if the RenderList contains color RenderItems, false otherwise
239 bool HasColorRenderItems() const
241 return mHasColorRenderItems;
247 * Copy constructor and assignment operator not defined
249 RenderList( const RenderList& rhs );
250 const RenderList& operator=( const RenderList& rhs );
252 RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
253 RenderItemContainer::SizeType mNextFree; ///< index for the next free item to use
255 ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
256 Layer* mSourceLayer; ///< The originating layer where the renderers are from
257 bool mHasColorRenderItems : 1; ///< True if list contains color render items
262 } // namespace SceneGraph
264 } // namespace Internal
268 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H