Moved SetUpdate propagation to UpdateNodes
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-vertex-buffer.h
index 37d2aeb..b7074ef 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_RENDER_VERTEX_BUFFER_H
 
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/actors/sampling.h>
 #include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/rendering/sampler.h>
-#include <dali/internal/common/owner-pointer.h>
-#include <dali/internal/render/renderers/render-sampler.h>
-#include <dali/internal/render/gl-resources/gpu-buffer.h>
+#include <dali/public-api/object/property.h>
+
+#include <dali/graphics-api/graphics-types.h>
 #include <dali/internal/common/const-string.h>
+#include <dali/internal/common/owner-pointer.h>
+#include <dali/internal/render/renderers/gpu-buffer.h>
 
 namespace Dali
 {
@@ -32,11 +32,9 @@ namespace Internal
 {
 namespace Render
 {
-
 class VertexBuffer
 {
 public:
-
   struct Component
   {
     ConstString    name;
@@ -71,7 +69,7 @@ public:
    *
    * @param[in] format The format for the VertexBuffer
    */
-  void SetFormat( VertexBuffer::Format* format );
+  void SetFormat(VertexBuffer::Format* format);
 
   /**
    * @brief Set the data of the VertexBuffer
@@ -80,44 +78,22 @@ public:
    * @param[in] data The new data of the VertexBuffer
    * @param[in] size The new size of the buffer
    */
-  void SetData( Dali::Vector<uint8_t>* data, uint32_t size );
-
-  /**
-   * @brief Set the number of elements
-   * @param[in] size The number of elements
-   */
-  void SetSize( uint32_t size );
-
-  /**
-   * @brief Bind the property buffer
-   * @param context The context to bind the the buffer
-   * @param[in] target The binding point
-   */
-  void BindBuffer( Context& context, GpuBuffer::Target target );
-
-  /**
-   * Perform the upload of the buffer only when requiered
-   * @param[in] context The GL context
-   */
-  bool Update( Context& context );
+  void SetData(Dali::Vector<uint8_t>* data, uint32_t size);
 
   /**
-   * Enable the vertex attributes for each vertex buffer from the corresponding
-   * shader program.
-   * @param[in] context The GL context
-   * @param[in] vAttributeLocation Vector containing attributes location for current program
-   * @param[in] locationBase Index in vAttributeLocation corresponding to the first attribute defined by this buffer
+   * Perform the upload of the buffer only when required
+   * @param[in] graphicsController The controller
    */
-  uint32_t EnableVertexAttributes( Context& context, Vector<GLint>& vAttributeLocation, uint32_t locationBase );
+  bool Update(Graphics::Controller& graphicsController);
 
   /**
    * Get the number of attributes present in the buffer
    * @return The number of attributes stored in this buffer
    */
-  inline uint32_t GetAttributeCount() const
+  [[nodiscard]] inline uint32_t GetAttributeCount() const
   {
-    DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
-    return static_cast<uint32_t>( mFormat->components.size() );
+    DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
+    return static_cast<uint32_t>(mFormat->components.size());
   }
 
   /**
@@ -125,9 +101,9 @@ public:
    * @param[in] index The index of the attribute
    * @return The name of the attribute
    */
-  inline ConstString GetAttributeName( uint32_t index ) const
+  [[nodiscard]] inline ConstString GetAttributeName(uint32_t index) const
   {
-    DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
+    DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
     return mFormat->components[index].name;
   }
 
@@ -135,9 +111,9 @@ public:
    * Retrieve the size of the buffer in bytes
    * @return The total size of the buffer
    */
-  inline uint32_t GetDataSize() const
+  [[nodiscard]] inline uint32_t GetDataSize() const
   {
-    DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
+    DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
     return mFormat->size * mSize;
   }
 
@@ -145,9 +121,9 @@ public:
    * Retrieve the size of one element of the buffer
    * @return The size of one element
    */
-  inline uint32_t GetElementSize() const
+  [[nodiscard]] inline uint32_t GetElementSize() const
   {
-    DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
+    DALI_ASSERT_DEBUG(mFormat && "Format should be set ");
     return mFormat->size;
   }
 
@@ -155,44 +131,28 @@ public:
    * Retrieve the number of elements in the buffer
    * @return The total number of elements
    */
-  inline uint32_t GetElementCount() const
+  [[nodiscard]] inline uint32_t GetElementCount() const
   {
     return mSize;
   }
 
-  /**
-   * Retrieve reference to the data storage vector
-   * @return Reference to the data storage
-   */
-  inline const Dali::Vector< uint8_t >& GetData() const
-  {
-    return *mData.Get();
-  }
-
-  /**
-   * Retrieve data writeable pointer ( direct access to the buffer data )
-   * @return Pointer to data converted to requested type
-   */
-  template <typename T>
-  inline T* GetDataTypedPtr()
+  [[nodiscard]] inline const VertexBuffer::Format* GetFormat() const
   {
-    Dali::Vector< uint8_t >* data = mData.Release();
-    mData = data;
-    return reinterpret_cast<T*>( &data->operator[]( 0 ) );
+    return mFormat.Get();
   }
 
-  inline const VertexBuffer::Format* GetFormat() const
+  [[nodiscard]] inline const GpuBuffer* GetGpuBuffer() const
   {
-    return mFormat.Get();
+    return mGpuBuffer.Get();
   }
 
 private:
-  OwnerPointer< VertexBuffer::Format >  mFormat;    ///< Format of the buffer
-  OwnerPointer< Dali::Vector< uint8_t > > mData;      ///< Data
-  OwnerPointer< GpuBuffer >               mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderVertexBuffer
+  OwnerPointer<VertexBuffer::Format>   mFormat;    ///< Format of the buffer
+  OwnerPointer<Dali::Vector<uint8_t> > mData;      ///< Data
+  OwnerPointer<GpuBuffer>              mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderVertexBuffer
 
-  uint32_t mSize;       ///< Number of Elements in the buffer
-  bool mDataChanged;  ///< Flag to know if data has changed in a frame
+  uint32_t mSize;        ///< Number of Elements in the buffer
+  bool     mDataChanged; ///< Flag to know if data has changed in a frame
 };
 
 } // namespace Render
@@ -201,5 +161,4 @@ private:
 
 } // namespace Dali
 
-
 #endif //  DALI_INTERNAL_RENDER_VERTEX_BUFFER_H