1 #ifndef DALI_INTERNAL_RENDER_GEOMETRY_H
2 #define DALI_INTERNAL_RENDER_GEOMETRY_H
5 * Copyright (c) 2021 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.
21 #include <dali/devel-api/common/owner-container.h>
22 #include <dali/graphics-api/graphics-controller.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/common/owner-pointer.h>
25 #include <dali/public-api/common/dali-vector.h>
26 #include <dali/public-api/rendering/geometry.h>
40 * This class encapsulates the GPU buffers. It is used to upload vertex data
41 * to it's GPU buffers, to bind all the buffers and to setup/teardown vertex attribute
47 using Type = Dali::Geometry::Type;
57 * Adds a property buffer to the geometry
58 * @param[in] dataProvider The VertexBuffer data provider
60 void AddVertexBuffer(Render::VertexBuffer* vertexBuffer);
63 * Set the data for the index buffer to be used by the geometry
64 * @param[in] indices A vector containing the indices
66 void SetIndexBuffer(Dali::Vector<uint16_t>& indices);
69 * Removes a VertexBuffer from the geometry
70 * @param[in] vertexBuffer The property buffer to be removed
72 void RemoveVertexBuffer(const Render::VertexBuffer* vertexBuffer);
75 * Get the vertex buffers
76 * @return the list of vertex buffers
78 [[nodiscard]] const Vector<Render::VertexBuffer*>& GetVertexBuffers() const;
81 * Called from RenderManager to notify the geometry that current rendering pass has finished.
83 void OnRenderFinished();
86 * Check if the attributes for the geometry have changed
87 * @return True if vertex buffers have been added or removed since last frame, false otherwise
89 [[nodiscard]] bool AttributesChanged() const
91 return mAttributesChanged;
95 * Sets the geometry type
96 * @param[in] type The new geometry type
98 void SetType(Type type)
100 mGeometryType = type;
104 * @return the topology of this geometry
106 [[nodiscard]] Graphics::PrimitiveTopology GetTopology() const;
109 * Upload the geometry if it has changed
111 void Upload(Graphics::Controller& graphicsController);
114 * Set up the attributes and perform the Draw call corresponding to the geometry type.
116 * @param[in] graphicsController The graphics controller
117 * @param[in] bufferIndex The current buffer index
118 * @param[in] elementBufferOffset The index of first element to draw if index buffer bound
119 * @param[in] elementBufferCount Number of elements to draw if index buffer bound, uses whole buffer when 0
120 * @return true if the draw command was issued, false otherwise
122 bool Draw(Graphics::Controller& graphicsController,
123 Graphics::CommandBuffer& commandBuffer,
124 uint32_t elementBufferOffset,
125 uint32_t elementBufferCount);
129 Vector<Render::VertexBuffer*> mVertexBuffers;
131 Dali::Vector<uint16_t> mIndices;
132 OwnerPointer<GpuBuffer> mIndexBuffer;
136 bool mIndicesChanged : 1;
137 bool mHasBeenUpdated : 1;
138 bool mAttributesChanged : 1;
141 } // namespace Render
142 } // namespace Internal
145 #endif // DALI_INTERNAL_RENDER_GEOMETRY_H