1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_GEOMETRY_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_GEOMETRY_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/public-api/common/dali-vector.h>
21 #include <dali/devel-api/common/owner-container.h>
22 #include <dali/integration-api/gl-defines.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/common/owner-pointer.h>
25 #include <dali/internal/render/data-providers/render-data-provider.h>
26 #include <dali/internal/render/renderers/render-renderer-property-buffer.h>
38 class RenderDataProvider;
39 class GeometryDataProvider;
41 typedef OwnerPointer< RenderPropertyBuffer > RenderPropertyBufferPtr;
42 typedef OwnerContainer< RenderPropertyBuffer* > RenderPropertyBufferContainer;
43 typedef RenderPropertyBufferContainer::Iterator RenderPropertyBufferIter;
47 * This class encapsulates the GPU buffers. It is used to upload vertex data
48 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
56 * Constructor. Creates a render geometry object with no GPU buffers.
58 RenderGeometry( const GeometryDataProvider& geometryDataProvider );
66 * Called on Gl Context created
68 void GlContextCreated( Context& context );
71 * Called on Gl Context destroyed.
73 void GlContextDestroyed();
76 * Adds a property buffer to the geometry
77 * @param[in] dataProvider The PropertyBuffer data provider
78 * @param[in] gpuBufferTarget target Specifies the type of the buffer
79 * @param[in] gpuBufferUsage usage Specifies how will the buffer be used
81 void AddPropertyBuffer( const PropertyBufferDataProvider* dataProvider, GpuBuffer::Target gpuBufferTarget, GpuBuffer::Usage gpuBufferUsage );
84 * Removes a PropertyBuffer from the geometry
85 * @param[in] dataProvider The property buffer to be removed
87 void RemovePropertyBuffer( const PropertyBufferDataProvider* dataProvider );
90 * Gets the attribute locations on the shader for the attributes defined in the geometry RenderBuffers
91 * @param[out] attributeLocation The vector where the attributes locations will be stored
92 * @param[in] program The program
93 * @param[in] bufferIndex The current buffer index
95 void GetAttributeLocationFromProgram( Vector<GLint>& attributeLocation, Program& program, BufferIndex bufferIndex ) const;
98 * Called from RenderManager to notify the geometry that current rendering pass has finished.
100 void OnRenderFinished();
103 * Chack if the attributes for the geometry have changed
104 * @return True if vertex buffers have been added or removed since last frame, false otherwise
106 bool AttributesChanged() const
108 return mAttributesChanged;
112 * Upload the geometry if it has changed, set up the attributes and perform
113 * the Draw call corresponding to the geometry type
114 * @param[in] context The GL context
115 * @param[in] bufferIndex The current buffer index
116 * @param[in] attributeLocation The location for the attributes in the shader
118 void UploadAndDraw(Context& context,
119 BufferIndex bufferIndex,
120 Vector<GLint>& attributeLocation );
124 const GeometryDataProvider& mGeometryDataProvider; //Reference to update thread object
127 RenderPropertyBufferPtr mIndexBuffer;
128 RenderPropertyBufferContainer mVertexBuffers;
131 bool mHasBeenUpdated : 1;
132 bool mAttributesChanged : 1;
135 } // namespace SceneGraph
136 } // namespace Internal
139 #endif // DALI_INTERNAL_SCENE_GRAPH_SAMPLER_DATA_PROVIDER_H