1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_RENDERER_PROPERTY_BUFFER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_RENDERER_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.
20 #include <dali/integration-api/gl-abstraction.h>
21 #include <dali/internal/common/buffer-index.h>
22 #include <dali/internal/common/owner-container.h>
23 #include <dali/internal/common/owner-pointer.h>
24 #include <dali/internal/render/data-providers/property-buffer-data-provider.h>
25 #include <dali/internal/render/gl-resources/gpu-buffer.h>
43 * This class encapsulates the GPU buffers. It is used to upload vertex data
44 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
47 class RenderPropertyBuffer
50 typedef OwnerContainer< GpuBuffer* > GpuBuffers;
53 * Constructor. Creates a render geometry object with no GPU buffers.
54 * @param[in] propertyBufferDataProvider The property-buffer data provider (to fetch geometry from)
55 * @param[in] gpuBufferTarget Type of target for the gpu-buffer
56 * @param[in] gpuBufferUsage Type of target for the gpu-buffer
58 RenderPropertyBuffer( const PropertyBufferDataProvider& propertyBufferDataProvider,
59 GpuBuffer::Target gpuBufferTarget,
60 GpuBuffer::Usage gpuBufferUsage );
65 ~RenderPropertyBuffer();
68 * Perform the upload of the buffer only when requiered
69 * @param[in] context The GL context
70 * @param[in] bufferIndex The current buffer index
72 void Update( Context& context, BufferIndex bufferIndex );
75 * Bind the geometry buffers
76 * @param[in] context The GL context
78 void BindBuffer( Context& context );
81 * Enable the vertex attributes for each vertex buffer from the corresponding
83 * @param[in] context The GL context
84 * @param[in] bufferIndex The current buffer index
85 * @param[in] program The shader program to query for attribute locations
86 * @param[in] vAttributeLocation Vector containing attributes location for current program
87 * @param[in] locationBase Index in vAttributeLocation corresponding to the first attribute defined by this buffer
89 unsigned int EnableVertexAttributes( Context& context, BufferIndex bufferIndex, Vector<GLint>& vAttributeLocation, unsigned int locationBase);
92 * Get the data provider for the buffer
94 const PropertyBufferDataProvider& GetDataProvider() const
99 private: // implementation
102 * Update attribute locations
103 * @param[in] context The GL context
104 * @param[in] bufferIndex The current buffer index
105 * @param[in] program The shader program to query for attribute locations
107 void UpdateAttributeLocations( Context& context, BufferIndex bufferIndex, Program& program );
110 const PropertyBufferDataProvider& mDataProvider; ///< Data provider used by this property buffer
111 Vector<GLint> mAttributesLocation; ///< Location of the attributes for the property buffer in this renderer.
113 OwnerPointer<GpuBuffer> mGpuBuffer; ///< Pointer to the GpuBuffer associated with this RenderPropertyBuffer
114 GpuBuffer::Target mGpuBufferTarget; ///< The type of GPU buffer to create
115 GpuBuffer::Usage mGpuBufferUsage; ///< The type of usage the GPU buffer will have
118 } // namespace SceneGraph
119 } // namespace Internal
122 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_RENDERER_PROPERTY_BUFFER_H