VertexBuffer can now be created from Property::Map by initializer list
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / vertex-buffer-impl.cpp
index 462fc9c..b6bbf32 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -155,7 +155,7 @@ void VertexBuffer::SetData(const void* data, uint32_t size)
   // create a new DALi vector to store the buffer data
   // the heap allocated vector will end up being owned by Render::VertexBuffer
   OwnerPointer<Vector<uint8_t> > bufferCopy = new Dali::Vector<uint8_t>();
-  bufferCopy->Resize(bufferSize);
+  bufferCopy->ResizeUninitialized(bufferSize);
 
   // copy the data
   const uint8_t* source      = static_cast<const uint8_t*>(data);
@@ -222,6 +222,15 @@ void VertexBuffer::Initialize(Dali::Property::Map& formatMap)
     Property::Type type = Property::Type(component.second.Get<int>());
 
     // Get the size and alignment
+    if(type == Property::NONE)
+    {
+      /* Note, Property::Value() has an explicit constructor using Property::Type enum,
+       * which will generate a property value of that type. This constructor is used when
+       * using C++ initializer lists.
+       */
+      type = component.second.GetType();
+    }
+
     if((type == Property::NONE) ||
        (type == Property::STRING) ||
        (type == Property::ARRAY) ||
@@ -229,6 +238,7 @@ void VertexBuffer::Initialize(Dali::Property::Map& formatMap)
     {
       DALI_ABORT("Property::Type not supported in VertexBuffer");
     }
+
     uint32_t elementSize      = GetPropertyImplementationSize(type);
     uint32_t elementAlignment = GetPropertyImplementationAlignment(type);