END_TEST;
}
+int UtcDaliHandleReserveProperties(void)
+{
+ TestApplication application;
+ Dali::Handle instance = Handle::New();
+ DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
+
+ instance.ReserveCustomProperties(0);
+ DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
+
+ instance.ReserveCustomProperties(20);
+ DALI_TEST_EQUALS(instance.GetPropertyCount(), 0, TEST_LOCATION);
+
+ instance.RegisterProperty("testProperty", 22.0f);
+ DALI_TEST_EQUALS(instance.GetPropertyCount(), 1, TEST_LOCATION);
+
+ // Test that reserving actor properties doesn't change property count
+ Dali::Actor actor = Actor::New();
+ auto count = actor.GetPropertyCount();
+
+ actor.ReserveCustomProperties(15);
+ DALI_TEST_EQUALS(actor.GetPropertyCount(), count, TEST_LOCATION);
+
+ // Test that reserving renderer properties doesn't change property count
+ Geometry geom = Geometry::New();
+ Shader shader = Shader::New("vertex", "frag");
+ Dali::Renderer renderer = Renderer::New(geom, shader);
+ count = renderer.GetPropertyCount();
+ renderer.ReserveCustomProperties(22);
+ DALI_TEST_EQUALS(renderer.GetPropertyCount(), count, TEST_LOCATION);
+
+ count = shader.GetPropertyCount();
+ shader.ReserveCustomProperties(5);
+ DALI_TEST_EQUALS(shader.GetPropertyCount(), count, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
+
int UtcDaliHandleSetPropertyNegative(void)
{
TestApplication application;
}
}
+void Object::ReserveCustomProperties(int propertyCount)
+{
+ mCustomProperties.Reserve(propertyCount);
+ const SceneGraph::PropertyOwner& sceneObject = GetSceneObject();
+ ReservePropertiesMessage(const_cast<EventThreadServices&>(GetEventThreadServices()), sceneObject, propertyCount);
+}
+
Property::Index Object::RegisterProperty(std::string_view name, Property::Value propertyValue)
{
return RegisterProperty(name, Property::INVALID_KEY, std::move(propertyValue), Property::ANIMATABLE, true);
void GetProperties(Property::Map& properties);
/**
+ * @copydoc Dali::Handle::ReserveCustomProperties()
+ */
+ void ReserveCustomProperties(int propertyCount);
+
+ /**
* @copydoc Dali::Handle::RegisterProperty()
*/
Property::Index RegisterProperty(std::string_view name, Property::Value propertyValue);
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
new(slot) LocalType(&owner, &PropertyOwner::RemoveUniformMapping, uniformName);
}
+inline void ReservePropertiesMessage(EventThreadServices& eventThreadServices, const PropertyOwner& owner, int propertyCount)
+{
+ using LocalType = MessageValue1<PropertyOwner, int>;
+
+ // Reserve some memory inside the message queue
+ uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+
+ new(slot) LocalType(&owner, &PropertyOwner::ReserveProperties, propertyCount);
+}
+
} // namespace SceneGraph
} // namespace Internal
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
mConstraints.Clear();
}
+void PropertyOwner::ReserveProperties(int propertyCount)
+{
+ mCustomProperties.Reserve(propertyCount);
+}
+
void PropertyOwner::InstallCustomProperty(OwnerPointer<PropertyBase>& property)
{
mCustomProperties.PushBack(property.Release());
#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
void DisconnectFromSceneGraph(BufferIndex updateBufferIndex);
/**
+ * Reserve the given number of properties
+ */
+ void ReserveProperties(int propertyCount);
+
+ /**
* Install a custom property.
* @post The PropertyOwner takes ownership of the property.
* @param[in] property A pointer to a newly allocated property.
GetImplementation(*this).SetProperty(index, std::move(propertyValue));
}
+void Handle::ReserveCustomProperties(int propertyCount)
+{
+ GetImplementation(*this).ReserveCustomProperties(propertyCount);
+}
+
Property::Index Handle::RegisterProperty(std::string_view name, Property::Value propertyValue)
{
return GetImplementation(*this).RegisterProperty(name, std::move(propertyValue));
void SetProperty(Property::Index index, Property::Value propertyValue);
/**
+ * @brief Reserves a number of custom properties
+ *
+ * Saves automatic re-allocation of vectors for properties when we know in advance how many there
+ * will be.
+ *
+ * @param[in] propertyCount The total number of initial properties.
+ */
+ void ReserveCustomProperties(int propertyCount);
+
+ /**
* @brief Registers a new animatable property.
*
* @SINCE_1_0.0