#define DALI_INTERNAL_SCENE_GRAPH_RENDER_LIST_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <cstdint>
// INTERNAL INCLUDES
-#include <dali/public-api/math/rect.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/public-api/math/rect.h>
+
+#include <dali/graphics-api/graphics-controller.h>
+#include <dali/internal/common/owner-key-container.h>
#include <dali/internal/render/common/render-item.h>
namespace Dali
namespace Internal
{
-
namespace Render
{
class Renderer;
namespace SceneGraph
{
-
class Layer;
-using RenderItemContainer = OwnerContainer<RenderItem*>;
+using RenderItemContainer = OwnerKeyContainer<RenderItem>;
struct RenderList;
using RenderListContainer = OwnerContainer<RenderList*>;
/**
- * The RenderList structure provides the renderer with a list of renderers.
+ * The RenderList structure provides the renderer manager with a list of renderers.
*/
struct RenderList
{
public:
-
/**
* Constructor
*/
RenderList()
- : mNextFree( 0 ),
- mClippingBox( NULL ),
- mSourceLayer( NULL ),
- mHasColorRenderItems( false )
+ : mNextFree(0),
+ mClippingBox(nullptr),
+ mSourceLayer(nullptr),
+ mHasColorRenderItems(false)
{
}
delete mClippingBox;
}
+ /*
+ * Copy constructor and assignment operator not defined
+ */
+ RenderList(const RenderList& rhs) = delete;
+ const RenderList& operator=(const RenderList& rhs) = delete;
+
/**
* Reset the render list for next frame
*/
mNextFree = 0;
delete mClippingBox;
- mClippingBox = NULL;
+ mClippingBox = nullptr;
}
/**
* Reserve space in the render list
* @param size to reserve
*/
- void Reserve( RenderItemContainer::SizeType size )
+ void Reserve(RenderItemContainer::SizeType size)
{
mNextFree = 0;
- mItems.Reserve( size );
+ mItems.Reserve(size);
}
/**
RenderItem& GetNextFreeItem()
{
// check if we have enough items, we can only be one behind at worst
- if( mItems.Count() <= mNextFree )
+ if(mItems.Count() <= mNextFree)
{
- mItems.PushBack( RenderItem::New() ); // Push a new empty render item
+ mItems.PushBack(RenderItem::NewKey()); // Push a new empty render item
}
// get the item mNextFree points to and increase by one
- RenderItem& item = *mItems[ mNextFree++ ];
- return item;
+ RenderItem* item = mItems[mNextFree++].Get();
+ return *item;
}
/**
* Get item at a given position in the list
*/
- RenderItem& GetItem( uint32_t index ) const
+ RenderItem& GetItem(uint32_t index) const
+ {
+ DALI_ASSERT_DEBUG(index < GetCachedItemCount());
+ RenderItem* item = mItems[index].Get();
+ return *item;
+ }
+
+ RenderItemKey GetItemKey(uint32_t index) const
{
- DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
- return *mItems[ index ];
+ DALI_ASSERT_DEBUG(index < GetCachedItemCount());
+ return mItems[index];
}
/**
* Get renderer from an item in the list
*/
- const Render::Renderer& GetRenderer( uint32_t index ) const
+ const Render::Renderer& GetRenderer(uint32_t index) const
{
- DALI_ASSERT_DEBUG( index < GetCachedItemCount() );
- return *mItems[ index ]->mRenderer;
+ DALI_ASSERT_DEBUG(index < GetCachedItemCount());
+ return *mItems[index]->mRenderer;
}
/**
*/
uint32_t GetCachedItemCount() const
{
- return static_cast<uint32_t>( mItems.Count() );
+ return static_cast<uint32_t>(mItems.Count());
}
/**
*/
void ReuseCachedItems()
{
- mNextFree = static_cast<uint32_t>( mItems.Count() );
+ mNextFree = static_cast<uint32_t>(mItems.Count());
}
/**
*/
bool IsEmpty() const
{
- return ( mNextFree == 0 );
+ return (mNextFree == 0);
}
/**
* @param clipping on/off
* @param box for clipping
*/
- void SetClipping( bool clipping, const ClippingBox& box )
+ void SetClipping(bool clipping, const ClippingBox& box)
{
- if( clipping )
+ if(clipping)
{
delete mClippingBox;
- mClippingBox = new ClippingBox( box );;
+ mClippingBox = new ClippingBox(box);
}
}
*/
bool IsClipping() const
{
- return ( NULL != mClippingBox );
+ return (nullptr != mClippingBox);
}
/**
void ReleaseUnusedItems()
{
// release any non-used RenderItems
- if( mItems.Count() > mNextFree )
+ if(mItems.Count() > mNextFree)
{
- mItems.Resize( mNextFree );
+ mItems.Resize(mNextFree);
}
}
/**
* @param layer The layer these RenderItems originate from
*/
- void SetSourceLayer( Layer* layer )
+ void SetSourceLayer(Layer* layer)
{
mSourceLayer = layer;
}
* Set if the RenderList contains color RenderItems
* @param[in] hasColorRenderItems True if it contains color RenderItems, false otherwise
*/
- void SetHasColorRenderItems( bool hasColorRenderItems )
+ void SetHasColorRenderItems(bool hasColorRenderItems)
{
mHasColorRenderItems = hasColorRenderItems;
}
return mHasColorRenderItems;
}
-private:
+ Graphics::CommandBuffer& GetCommandBuffer(Graphics::Controller& controller)
+ {
+ if(!mGraphicsCommandBuffer)
+ {
+ mGraphicsCommandBuffer = controller.CreateCommandBuffer(
+ Graphics::CommandBufferCreateInfo().SetLevel(Graphics::CommandBufferLevel::SECONDARY), nullptr);
+ }
+ return *mGraphicsCommandBuffer.get();
+ }
- /*
- * Copy constructor and assignment operator not defined
- */
- RenderList( const RenderList& rhs );
- const RenderList& operator=( const RenderList& rhs );
+ const Graphics::CommandBuffer* GetCommandBuffer() const
+ {
+ return mGraphicsCommandBuffer.get();
+ }
- RenderItemContainer mItems; ///< Each item is a renderer and matrix pair
- uint32_t mNextFree; ///< index for the next free item to use
+private:
+ RenderItemContainer mItems; ///< Container of render items
+ uint32_t mNextFree; ///< index for the next free item to use
- ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
- Layer* mSourceLayer; ///< The originating layer where the renderers are from
- bool mHasColorRenderItems : 1; ///< True if list contains color render items
+ mutable Graphics::UniquePtr<Graphics::CommandBuffer> mGraphicsCommandBuffer{nullptr};
+ ClippingBox* mClippingBox; ///< The clipping box, in window coordinates, when clipping is enabled
+ Layer* mSourceLayer; ///< The originating layer where the renderers are from
+ bool mHasColorRenderItems : 1; ///< True if list contains color render items
};
-
} // namespace SceneGraph
} // namespace Internal