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.
25 #include <dali/public-api/math/rect.h>
26 #include <dali/devel-api/common/owner-container.h>
27 #include <dali/internal/render/common/render-item.h>
32 typedef Rect<int> ClippingBox;
47 typedef OwnerContainer< RenderItem* > RenderItemContainer;
50 typedef OwnerContainer< RenderList* > RenderListContainer;
53 * The RenderList structure provides the renderer with a list of renderers.
66 mHasColorRenderItems( false ),
67 mPartialUpdateEnabled( false )
76 // Pointer container deletes the render items
81 * Reset the render list for next frame
85 // We don't want to delete and re-create the render items every frame
93 * Reserve space in the render list
94 * @param size to reserve
96 void Reserve( RenderItemContainer::SizeType size )
99 mItems.Reserve( size );
103 * @return the capacity of the render list
105 RenderItemContainer::SizeType Capacity()
107 return mItems.Capacity();
111 * Get next free render item
112 * @return reference to the next available RenderItem
114 RenderItem& GetNextFreeItem()
116 // check if we have enough items, we can only be one behind at worst
117 if( mItems.Count() <= mNextFree )
119 mItems.PushBack( RenderItem::New() ); // Push a new empty render item
121 // get the item mNextFree points to and increase by one
122 RenderItem& item = *mItems[ mNextFree++ ];
127 * Get item at a given position in the list
129 RenderItem& GetItem( uint32_t index ) const
131 DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
132 return *mItems[ index ];
136 * Get renderer from an item in the list
138 const Render::Renderer& GetRenderer( uint32_t index ) const
140 DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
141 return *mItems[ index ]->mRenderer;
145 * Get the number of real items
146 * Because of caching, the actual size may be bit more
147 * @return The number of items
149 uint32_t Count() const
155 * @return the number of items cached by the list
157 uint32_t GetCachedItemCount() const
159 return static_cast<uint32_t>( mItems.Count() );
163 * Tells the render list to reuse the items from the cache
165 void ReuseCachedItems()
167 mNextFree = static_cast<uint32_t>( mItems.Count() );
171 * Predicate to inform if the list is empty
175 return ( mNextFree == 0 );
180 * @param clipping on/off
181 * @param box for clipping
183 void SetClipping( bool clipping, const ClippingBox& box )
188 mClippingBox = new ClippingBox( box );;
193 * @return true if clipping is on
195 bool IsClipping() const
197 return ( NULL != mClippingBox );
201 * @return the clipping box
203 const ClippingBox& GetClippingBox() const
205 return *mClippingBox;
209 * @return the container (for sorting)
211 RenderItemContainer& GetContainer()
217 * Do some housekeeping to keep memory consumption low
219 void ReleaseUnusedItems()
221 // release any non-used RenderItems
222 if( mItems.Count() > mNextFree )
224 mItems.Resize( mNextFree );
229 * @return the source layer these renderitems originate from
231 Layer* GetSourceLayer() const
237 * @param layer The layer these RenderItems originate from
239 void SetSourceLayer( Layer* layer )
241 mSourceLayer = layer;
245 * Set if the RenderList contains color RenderItems
246 * @param[in] hasColorRenderItems True if it contains color RenderItems, false otherwise
248 void SetHasColorRenderItems( bool hasColorRenderItems )
250 mHasColorRenderItems = hasColorRenderItems;
254 * Check if the RenderList contains color RenderItems
255 * @return true if the RenderList contains color RenderItems, false otherwise
257 bool HasColorRenderItems() const
259 return mHasColorRenderItems;
263 * Enable/Disable Partial update dirty flag
264 * @param[in] true to mark dirty else false
266 void SetPartialUpdateEnabled( bool value )
268 mPartialUpdateEnabled = value;
272 * Get Partial update dirty flag
273 * @return true if dirty else false
275 bool IsPartialUpdateEnabled() const
277 return mPartialUpdateEnabled;
283 * Copy constructor and assignment operator not defined
285 RenderList( const RenderList& rhs );
286 const RenderList& operator=( const RenderList& rhs );
288 RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
289 uint32_t mNextFree; ///< index for the next free item to use
291 ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
292 Layer* mSourceLayer; ///< The originating layer where the renderers are from
293 bool mHasColorRenderItems : 1; ///< True if list contains color render items
294 bool mPartialUpdateEnabled : 1; //< True if partial update is needed.
299 } // namespace SceneGraph
301 } // namespace Internal
305 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H