X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-geometry.h;h=2f04c973133649a9ca9019ba24804ed03fef1eda;hb=a513234144a775134eff3a24144983a5e374d1d5;hp=f4c7a1999a142cf1ce73f59cfcf83e092cbd7952;hpb=93460e870dcbb949193f2e790aba4f4e0defd2e2;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-geometry.h b/dali/internal/render/renderers/render-geometry.h index f4c7a19..2f04c97 100644 --- a/dali/internal/render/renderers/render-geometry.h +++ b/dali/internal/render/renderers/render-geometry.h @@ -1,8 +1,8 @@ -#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_GEOMETRY_H -#define DALI_INTERNAL_SCENE_GRAPH_RENDER_GEOMETRY_H +#ifndef DALI_INTERNAL_RENDER_GEOMETRY_H +#define DALI_INTERNAL_RENDER_GEOMETRY_H /* - * Copyright (c) 2015 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. @@ -17,146 +17,149 @@ * limitations under the License. */ -#include -#include +// INTERNAL INCLUDES +#include +#include +#include #include -#include #include -#include -#include +#include +#include namespace Dali { namespace Internal { -class Context; class Program; class GpuBuffer; -namespace SceneGraph +namespace Render { -class RenderDataProvider; -class GeometryDataProvider; +class VertexBuffer; /** * This class encapsulates the GPU buffers. It is used to upload vertex data * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute * bindings */ -class RenderGeometry +class Geometry { public: + using Type = Dali::Geometry::Type; + using IndexType = Dali::Graphics::Format; + + using Uint16ContainerType = Dali::Vector; + using Uint32ContainerType = Dali::Vector; + + Geometry(); /** - * Constructor. Creates a render geometry object with no GPU buffers. + * Destructor */ - RenderGeometry( ); + ~Geometry(); /** - * Destructor + * Adds a property buffer to the geometry + * @param[in] dataProvider The VertexBuffer data provider */ - ~RenderGeometry(); + void AddVertexBuffer(Render::VertexBuffer* vertexBuffer); /** - * Called on Gl Context created + * Set the data for the index buffer to be used by the geometry + * @param[in] indices A vector containing the indices */ - void GlContextCreated( Context& context ); + void SetIndexBuffer(Uint16ContainerType& indices); /** - * Called on Gl Context destroyed. + * Set the data for the index buffer to be used by the geometry + * @param[in] indices A vector containing the indices */ - void GlContextDestroyed(); + void SetIndexBuffer(Uint32ContainerType& indices); /** - * Upload the geometry if it has changed, set up the attributes and perform - * the Draw call corresponding to the geometry type - * @param[in] context The GL context - * @param[in] program The shader program to query for attribute locations - * @param[in] bufferIndex The current buffer index - * @param[in] dataProviders The data providers (to fetch geometry from) + * Removes a VertexBuffer from the geometry + * @param[in] vertexBuffer The property buffer to be removed */ - void UploadAndDraw(Context& context, - Program& program, - BufferIndex bufferIndex, - const RenderDataProvider* dataProviders ); + void RemoveVertexBuffer(const Render::VertexBuffer* vertexBuffer); /** - * Tell the object that the geometry has been updated. - * It will be uploaded on the next UploadAndDraw call. + * Get the vertex buffers + * @return the list of vertex buffers */ - void GeometryUpdated(); + [[nodiscard]] const Vector& GetVertexBuffers() const; /** - * Upload the vertex data if it needs uploading. - * @param[in] context The GL context - * @param[in] bufferIndex The current buffer index - * @param[in] geometryDataProvider The geometry data provider (to fetch geometry from) + * Called from RenderManager to notify the geometry that current rendering pass has finished. */ - void UploadVertexData( Context& context, - BufferIndex bufferIndex, - const RenderDataProvider* dataProviders ); + void OnRenderFinished(); -private: /** - * Perform the upload of the geometry - * @param[in] context The GL context - * @param[in] bufferIndex The current buffer index - * @param[in] dataProviders The data providers (to fetch geometry from) + * Check if the attributes for the geometry have changed + * @return True if vertex buffers have been added or removed since last frame, false otherwise */ - void DoUpload( Context& context, - BufferIndex bufferIndex, - const RenderDataProvider* dataProviders ); + [[maybe_unused]] [[nodiscard]] bool AttributesChanged() const + { + return mAttributesChanged; + } /** - * Bind the geometry buffers - * @param[in] context The GL context - * @param[in] bufferIndex The current buffer index - * @param[in] program The shader program to query for attribute locations + * Sets the geometry type + * @param[in] type The new geometry type */ - void BindBuffers( Context& context, - BufferIndex bufferIndex, - Program& program ); + void SetType(Type type) + { + mGeometryType = type; + } /** - * Enable the vertex attributes for each vertex buffer from the corresponding - * shader program. - * @param[in] context The GL context - * @param[in] bufferIndex The current buffer index - * @param[in] program The shader program to query for attribute locations + * @return the topology of this geometry */ - void EnableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& progam ); + [[nodiscard]] Graphics::PrimitiveTopology GetTopology() const; /** - * Disable the vertex attributes for each vertex buffer from the corresponding - * shader program. - * @param[in] context The GL context - * @param[in] bufferIndex The current buffer index - * @param[in] program The shader program to query for attribute locations + * Upload the geometry if it has changed */ - void DisableVertexAttributes( Context& context, BufferIndex bufferIndex, Program& program ); + void Upload(Graphics::Controller& graphicsController); /** - * Perform the correct draw call corresponding to the geometry type - * @param[in] context The GL context - * @param[in] bufferIndex The current buffer index - * @param[in] dataProviders The data providers (to fetch geometry from) + * Set up the attributes and perform the Draw call corresponding to the geometry type. + * + * @param[in] graphicsController The graphics controller + * @param[in,out] commandBuffer The current command buffer queue + * @param[in] elementBufferOffset The index of first element to draw if index buffer bound + * @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0 + * @return true if the draw command was issued, false otherwise */ - void Draw( Context& context, - BufferIndex bufferIndex, - const RenderDataProvider* dataProviders ); + bool Draw(Graphics::Controller& graphicsController, + Graphics::CommandBuffer& commandBuffer, + uint32_t elementBufferOffset, + uint32_t elementBufferCount); + + /** + * @brief Set up the attributes bind commaneds + * + * @param[in,out] commandBuffer The current command buffer queue + * @return true if the bind command was issued, false otherwise + */ + bool BindVertexAttributes(Graphics::CommandBuffer& commandBuffer); private: - // PropertyBuffers - OwnerPointer< RenderPropertyBuffer > mIndexBuffer; - OwnerContainer< RenderPropertyBuffer* > mVertexBuffers; + // VertexBuffers + Vector mVertexBuffers; + + Uint16ContainerType mIndices; + OwnerPointer mIndexBuffer; + IndexType mIndexType; + Type mGeometryType; // Booleans - bool mDataNeedsUploading; - bool mShaderChanged; + bool mIndicesChanged : 1; + bool mHasBeenUpdated : 1; + bool mAttributesChanged : 1; }; -} // namespace SceneGraph +} // namespace Render } // namespace Internal } // namespace Dali -#endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H +#endif // DALI_INTERNAL_RENDER_GEOMETRY_H