1 #ifndef DALI_INTERNAL_VERTEX_BUFFER_H
2 #define DALI_INTERNAL_VERTEX_BUFFER_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.
22 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/public-api/object/property-map.h> // Dali::Property::Map
26 #include <dali/public-api/rendering/vertex-buffer.h> // Dali::VertexBuffer
28 #include <dali/internal/event/common/event-thread-services.h>
29 #include <dali/internal/render/renderers/render-vertex-buffer.h>
37 using VertexBufferPtr = IntrusivePtr<VertexBuffer>;
40 * VertexBuffer is an object that contains an array of structures of values that
41 * can be accessed as properties.
43 class VertexBuffer : public BaseObject
47 * @copydoc PropertBuffer::New()
49 static VertexBufferPtr New(Dali::Property::Map& format);
52 * @copydoc PropertBuffer::SetData()
54 void SetData(const void* data, uint32_t size);
57 * @copydoc PropertBuffer::GetSize()
59 uint32_t GetSize() const;
61 public: // Default property extensions from Object
63 * @brief Get the render thread side of the VertexBuffer
65 * @return The render thread side of this VertexBuffer
67 const Render::VertexBuffer* GetRenderObject() const;
73 ~VertexBuffer() override;
75 private: // implementation
77 * @brief Default constructor
82 * Second stage initialization
84 void Initialize(Dali::Property::Map& format);
86 private: // unimplemented methods
87 VertexBuffer(const VertexBuffer&);
88 VertexBuffer& operator=(const VertexBuffer&);
91 EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
92 Render::VertexBuffer* mRenderObject; ///<Render side object
93 uint32_t mBufferFormatSize;
94 uint32_t mSize; ///< Number of elements in the buffer
98 * Get the implementation type from a Property::Type
100 template<Property::Type type>
101 struct PropertyImplementationType
103 // typedef ... Type; not defined, only support types declared below
106 struct PropertyImplementationType<Property::BOOLEAN>
111 struct PropertyImplementationType<Property::FLOAT>
116 struct PropertyImplementationType<Property::INTEGER>
121 struct PropertyImplementationType<Property::VECTOR2>
123 using Type = Vector2;
126 struct PropertyImplementationType<Property::VECTOR3>
128 using Type = Vector3;
131 struct PropertyImplementationType<Property::VECTOR4>
133 using Type = Vector4;
136 struct PropertyImplementationType<Property::MATRIX3>
138 using Type = Matrix3;
141 struct PropertyImplementationType<Property::MATRIX>
146 struct PropertyImplementationType<Property::RECTANGLE>
148 using Type = Rect<int>;
151 struct PropertyImplementationType<Property::ROTATION>
153 using Type = Quaternion;
156 uint32_t GetPropertyImplementationSize(Property::Type& propertyType);
158 } // namespace Internal
160 // Helpers for public-api forwarding methods
161 inline Internal::VertexBuffer& GetImplementation(Dali::VertexBuffer& handle)
163 DALI_ASSERT_ALWAYS(handle && "VertexBuffer handle is empty");
165 BaseObject& object = handle.GetBaseObject();
167 return static_cast<Internal::VertexBuffer&>(object);
170 inline const Internal::VertexBuffer& GetImplementation(const Dali::VertexBuffer& handle)
172 DALI_ASSERT_ALWAYS(handle && "VertexBuffer handle is empty");
174 const BaseObject& object = handle.GetBaseObject();
176 return static_cast<const Internal::VertexBuffer&>(object);
181 #endif // DALI_INTERNAL_VERTEX_BUFFER_H