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/internal/event/common/event-thread-services.h>
23 #include <dali/internal/render/renderers/render-vertex-buffer.h>
24 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
25 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
26 #include <dali/public-api/object/base-object.h>
27 #include <dali/public-api/object/property-map.h> // Dali::Property::Map
34 using VertexBufferPtr = IntrusivePtr<VertexBuffer>;
37 * VertexBuffer is an object that contains an array of structures of values that
38 * can be accessed as properties.
40 class VertexBuffer : public BaseObject
44 * @copydoc PropertBuffer::New()
46 static VertexBufferPtr New(Dali::Property::Map& format);
49 * @copydoc PropertBuffer::SetData()
51 void SetData(const void* data, uint32_t size);
54 * @copydoc PropertBuffer::GetSize()
56 uint32_t GetSize() const;
58 public: // Default property extensions from Object
60 * @brief Get the render thread side of the VertexBuffer
62 * @return The render thread side of this VertexBuffer
64 const Render::VertexBuffer* GetRenderObject() const;
70 ~VertexBuffer() override;
72 private: // implementation
74 * @brief Default constructor
79 * Second stage initialization
81 void Initialize(Dali::Property::Map& format);
83 private: // unimplemented methods
84 VertexBuffer(const VertexBuffer&);
85 VertexBuffer& operator=(const VertexBuffer&);
88 EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
89 Render::VertexBuffer* mRenderObject; ///<Render side object
90 uint32_t mBufferFormatSize;
91 uint32_t mSize; ///< Number of elements in the buffer
95 * Get the implementation type from a Property::Type
97 template<Property::Type type>
98 struct PropertyImplementationType
100 // typedef ... Type; not defined, only support types declared below
103 struct PropertyImplementationType<Property::BOOLEAN>
108 struct PropertyImplementationType<Property::FLOAT>
113 struct PropertyImplementationType<Property::INTEGER>
118 struct PropertyImplementationType<Property::VECTOR2>
120 using Type = Vector2;
123 struct PropertyImplementationType<Property::VECTOR3>
125 using Type = Vector3;
128 struct PropertyImplementationType<Property::VECTOR4>
130 using Type = Vector4;
133 struct PropertyImplementationType<Property::MATRIX3>
135 using Type = Matrix3;
138 struct PropertyImplementationType<Property::MATRIX>
143 struct PropertyImplementationType<Property::RECTANGLE>
145 using Type = Rect<int>;
148 struct PropertyImplementationType<Property::ROTATION>
150 using Type = Quaternion;
153 uint32_t GetPropertyImplementationSize(Property::Type& propertyType);
155 } // namespace Internal
157 // Helpers for public-api forwarding methods
158 inline Internal::VertexBuffer& GetImplementation(Dali::VertexBuffer& handle)
160 DALI_ASSERT_ALWAYS(handle && "VertexBuffer handle is empty");
162 BaseObject& object = handle.GetBaseObject();
164 return static_cast<Internal::VertexBuffer&>(object);
167 inline const Internal::VertexBuffer& GetImplementation(const Dali::VertexBuffer& handle)
169 DALI_ASSERT_ALWAYS(handle && "VertexBuffer handle is empty");
171 const BaseObject& object = handle.GetBaseObject();
173 return static_cast<const Internal::VertexBuffer&>(object);
178 #endif // DALI_INTERNAL_VERTEX_BUFFER_H