1 #ifndef DALI_INTERNAL_RENDER_PROPERTY_BUFFER_H
2 #define DALI_INTERNAL_RENDER_PROPERTY_BUFFER_H
5 * Copyright (c) 2015 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.
19 #include <dali/internal/common/owner-pointer.h>
20 #include <dali/public-api/actors/sampling.h>
21 #include <dali/devel-api/rendering/sampler.h>
22 #include <dali/internal/render/renderers/render-sampler.h>
23 #include <dali/internal/render/gl-resources/gpu-buffer.h>
45 * Structure that holds the meta-data of the format of PropertyBuffer.
49 std::vector<Component> components;
54 * @brief Default constructor
64 * @brief Set the format of the buffer
66 * This function takes ownership of the pointer
68 * @param[in] format The format for the PropertyBuffer
70 void SetFormat( PropertyBuffer::Format* format );
73 * @brief Set the data of the PropertyBuffer
75 * This function takes ownership of the pointer
76 * @param[in] data The new data of the PropertyBuffer
77 * @param[in] size The new size of the buffer
79 void SetData( Dali::Vector<char>* data, size_t size );
82 * @brief Set the number of elements
83 * @param[in] size The number of elements
85 void SetSize( unsigned int size );
88 * @brief Bind the property buffer
89 * @param[in] target The binding point
91 void BindBuffer(GpuBuffer::Target target);
94 * Perform the upload of the buffer only when requiered
95 * @param[in] context The GL context
96 * @param[in] isIndexBuffer True if the buffer is used as an index buffer
98 bool Update( Context& context, bool isIndexBuffer );
101 * Enable the vertex attributes for each vertex buffer from the corresponding
103 * @param[in] context The GL context
104 * @param[in] vAttributeLocation Vector containing attributes location for current program
105 * @param[in] locationBase Index in vAttributeLocation corresponding to the first attribute defined by this buffer
107 unsigned int EnableVertexAttributes( Context& context, Vector<GLint>& vAttributeLocation, unsigned int locationBase );
110 * Get the number of attributes present in the buffer
111 * @return The number of attributes stored in this buffer
113 inline unsigned int GetAttributeCount() const
115 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
116 return mFormat->components.size();
120 * Retrieve the i-essim attribute name
121 * @param[in] index The index of the attribute
122 * @return The name of the attribute
124 inline const std::string& GetAttributeName(unsigned int index ) const
126 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
127 return mFormat->components[index].name;
131 * Retrieve the size of the buffer in bytes
132 * @return The total size of the buffer
134 inline std::size_t GetDataSize() const
136 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
137 return mFormat->size * mSize;
141 * Retrieve the size of one element of the buffer
142 * @return The size of one element
144 inline std::size_t GetElementSize() const
146 DALI_ASSERT_DEBUG( mFormat && "Format should be set ");
147 return mFormat->size;
151 * Retrieve the number of elements in the buffer
152 * @return The total number of elements
154 inline unsigned int GetElementCount() const
160 OwnerPointer< PropertyBuffer::Format > mFormat; ///< Format of the buffer
161 OwnerPointer< Dali::Vector< char > > mData; ///< Data
162 OwnerPointer<GpuBuffer> mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderPropertyBuffer
164 size_t mSize; ///< Number of Elements in the buffer
165 bool mDataChanged; ///< Flag to know if data has changed in a frame
169 } // namespace Render
173 } // namespace Internal
177 #endif // DALI_INTERNAL_RENDER_PROPERTY_BUFFER_H