/*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
// check that the default value is set for the derived instance as well
DALI_TEST_EQUALS(derived.GetProperty(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX).Get<float>(), 10.f, TEST_LOCATION);
+ // add a property in base class
+ AnimatablePropertyRegistration(typeRegistration, "Foobar2", ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX, 30.f);
+
+ // should be one more property now
+ DALI_TEST_EQUALS(derived.GetPropertyCount(), actorHandle.GetPropertyCount() + 2, TEST_LOCATION);
+ // check that the default value is set for base class
+ DALI_TEST_EQUALS(UnregisteredCustomActor::New().GetProperty(ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX).Get<float>(), 30.f, TEST_LOCATION);
+ // check that the default value is set for the derived instance as well
+ DALI_TEST_EQUALS(derived.GetProperty(ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX).Get<float>(), 30.f, TEST_LOCATION);
+
END_TEST;
}
DALI_TEST_EQUALS(derived.GetCurrentProperty(vec3PropIndex).Get<Vector3>(), Vector3(i * 2.0f, i * 4.0f, i * 8.0f), 0.0001f, TEST_LOCATION);
}
+ // Add a Vector4 property and its components for completeness
+ const Property::Index vec4PropIndex = ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX + 1;
+ const Property::Index vec4xPropIndex = vec4PropIndex + 1;
+ const Property::Index vec4yPropIndex = vec4PropIndex + 2;
+ const Property::Index vec4zPropIndex = vec4PropIndex + 3;
+ const Property::Index vec4wPropIndex = vec4PropIndex + 4;
+
+ AnimatablePropertyRegistration(typeRegistration, "vec4Prop", vec4PropIndex, Vector4(10.0f, 20.0f, 30.0f, 40.0f));
+ AnimatablePropertyComponentRegistration(typeRegistration, "vec4Prop.x", vec4xPropIndex, vec4PropIndex, 0);
+ AnimatablePropertyComponentRegistration(typeRegistration, "vec4Prop.y", vec4yPropIndex, vec4PropIndex, 1);
+ AnimatablePropertyComponentRegistration(typeRegistration, "vec4Prop.z", vec4zPropIndex, vec4PropIndex, 2);
+ AnimatablePropertyComponentRegistration(typeRegistration, "vec4Prop.w", vec4wPropIndex, vec4PropIndex, 3);
+
+ tet_infoline("Test the default values of the registered vec4 property");
+ // should be more properties now
+ DALI_TEST_EQUALS(derived.GetPropertyCount(), actorHandle.GetPropertyCount() + 12, TEST_LOCATION);
+ // check that the default value is set for base class
+ DALI_TEST_EQUALS(UnregisteredCustomActor::New().GetProperty(vec4PropIndex).Get<Vector4>(), Vector4(10.f, 20.0f, 30.0f, 40.0f), 0.0001f, TEST_LOCATION);
+ // check that the default value is set for the derived instance as well
+ DALI_TEST_EQUALS(derived.GetProperty(vec4PropIndex).Get<Vector4>(), Vector4(10.f, 20.0f, 30.0f, 40.0f), 0.0001f, TEST_LOCATION);
+
+ tet_infoline("Test that the components of the registered property can be constrained");
+
+ // Try constraining the properties
+ Constraint vec4xConstraint = Constraint::New<float>(derived, vec4xPropIndex, &Test::Doubler);
+ vec4xConstraint.AddSource(LocalSource(Actor::Property::POSITION_X));
+ vec4xConstraint.Apply();
+ Constraint vec4yConstraint = Constraint::New<float>(derived, vec4yPropIndex, &Test::Doubler);
+ vec4yConstraint.AddSource(LocalSource(vec4xPropIndex));
+ vec4yConstraint.Apply();
+ Constraint vec4zConstraint = Constraint::New<float>(derived, vec4zPropIndex, &Test::Doubler);
+ vec4zConstraint.AddSource(LocalSource(vec4yPropIndex));
+ vec4zConstraint.Apply();
+ Constraint vec4wConstraint = Constraint::New<float>(derived, vec4wPropIndex, &Test::Doubler);
+ vec4wConstraint.AddSource(LocalSource(vec4zPropIndex));
+ vec4wConstraint.Apply();
+
+ for(int i = 1; i < 10; ++i)
+ {
+ derived[Actor::Property::POSITION_X] = i * 1.0f;
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(derived.GetCurrentProperty(vec4PropIndex).Get<Vector4>(), Vector4(i * 2.0f, i * 4.0f, i * 8.0f, i * 16.0f), 0.0001f, TEST_LOCATION);
+ }
+
END_TEST;
}
END_TEST;
}
+int UtcDaliTypeRegistryAnimatablePropertyWithoutUniformRegistrationP(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ auto& graphics = application.GetGraphicsController();
+ std::string animatablePropertyName("animatableProp1");
+ std::string animatablePropertyWithoutUniformName("animatableProp2");
+
+ auto uniforms = std::vector<UniformData>{
+ {animatablePropertyName.c_str(), Dali::Property::Type::FLOAT},
+ {animatablePropertyWithoutUniformName.c_str(), Dali::Property::Type::FLOAT}};
+ graphics.AddCustomUniforms(uniforms);
+
+ // Check property count before property registration
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo(typeid(MyTestCustomActor));
+ DALI_TEST_CHECK(typeInfo);
+ BaseHandle handle = typeInfo.CreateInstance();
+ DALI_TEST_CHECK(handle);
+ Actor customActor = Actor::DownCast(handle);
+ DALI_TEST_CHECK(customActor);
+ application.GetScene().Add(customActor);
+
+ unsigned int customPropertyCount(customActor.GetPropertyCount());
+
+ // Register animatable property
+ int animatablePropertyIndex(ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX);
+ Property::Type animatablePropertyType(Property::FLOAT);
+ AnimatablePropertyRegistration animatableProperty(customType1, animatablePropertyName, animatablePropertyIndex, animatablePropertyType, &SetProperty, &GetPropertyWithEmptyValueReturn);
+
+ // Register animatable property without uniform mapping
+ int animatablePropertyWithoutUniformIndex(ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX);
+ Property::Type animatablePropertyWithoutUniformType(Property::FLOAT);
+ AnimatablePropertyRegistration animatablePropertyWithoutUniform(customType1, animatablePropertyWithoutUniformName, animatablePropertyWithoutUniformIndex, animatablePropertyWithoutUniformType, &SetProperty, &GetPropertyWithEmptyValueReturn);
+
+ // Check property count after registration
+ DALI_TEST_EQUALS(customPropertyCount + 2u, customActor.GetPropertyCount(), TEST_LOCATION);
+
+ // Set the animatable property value
+ DALI_TEST_CHECK(!setPropertyCalled);
+ customActor.SetProperty(animatablePropertyIndex, 25.0f);
+ DALI_TEST_CHECK(setPropertyCalled);
+ setPropertyCalled = false;
+ customActor.SetProperty(animatablePropertyWithoutUniformIndex, 45.0f);
+ DALI_TEST_CHECK(setPropertyCalled);
+ setPropertyCalled = false;
+
+ // Add dummy renderer to check uniform call.
+ Actor renderableActor = CreateRenderableActor();
+ Renderer renderer = renderableActor.GetRendererAt(0u);
+ customActor.AddRenderer(renderer);
+
+ renderer.RegisterProperty(animatablePropertyName, 65.0f);
+ renderer.RegisterProperty(animatablePropertyWithoutUniformName, 85.0f);
+
+ customActor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
+
+ // Render and notify
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ application.SendNotification();
+ application.Render();
+
+ // Check animatable property without uniform doesn't write uniform value.
+ float uniformValue = 0.0f;
+ bool uniformValueExist;
+
+ // Check uniform use custom actor's value.
+ uniformValueExist = gl.GetUniformValue<float>(animatablePropertyName.c_str(), uniformValue);
+ DALI_TEST_EQUALS(uniformValueExist, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(uniformValue, 25.0f, TEST_LOCATION);
+
+ // Check non-uniform use renderer's value.
+ uniformValueExist = gl.GetUniformValue<float>(animatablePropertyWithoutUniformName.c_str(), uniformValue);
+ DALI_TEST_EQUALS(uniformValueExist, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(uniformValue, 85.0f, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliTypeRegistryChildPropertyRegistrationP(void)
{
TestApplication application;
}
}
RegisterSceneGraphProperty(propertyName, Property::INVALID_KEY, index, initialValue);
- AddUniformMapping(index, propertyName);
+
+ // Add uniform mapping automatically only if index is not rage of WITHOUT_UNIFORM.
+ if(!(ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX <= index && index <= ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_MAX_INDEX))
+ {
+ AddUniformMapping(index, propertyName);
+ }
}
AnimatablePropertyMetadata* Object::GetSceneAnimatableProperty(Property::Index index, const Property::Value* value) const
#define DALI_PROPERTY_INDEX_RANGES_H
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
// clang-format off
enum PropertyRanges
{
- DEFAULT_OBJECT_PROPERTY_START_INDEX = 0, ///< For all objects deriving from Handle (including Actors). @SINCE_1_0.0
- DEFAULT_ACTOR_PROPERTY_START_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< Start index for Actor. @SINCE_1_0.0
- DEFAULT_ACTOR_PROPERTY_MAX_COUNT = 10000, ///< Actor range: 0 to 9999 @SINCE_1_0.0
+ DEFAULT_OBJECT_PROPERTY_START_INDEX = 0, ///< For all objects deriving from Handle (including Actors). @SINCE_1_0.0
+ DEFAULT_ACTOR_PROPERTY_START_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< Start index for Actor. @SINCE_1_0.0
+ DEFAULT_ACTOR_PROPERTY_MAX_COUNT = 10000, ///< Actor range: 0 to 9999 @SINCE_1_0.0
- DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX = DEFAULT_ACTOR_PROPERTY_START_INDEX + DEFAULT_ACTOR_PROPERTY_MAX_COUNT, ///< Property start index for classes deriving directly from Actor. @SINCE_1_0.0
- DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION = 10000, ///< Second-level and onwards derived objects should increment their start index by this. @SINCE_1_0.0
+ DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX = DEFAULT_ACTOR_PROPERTY_START_INDEX + DEFAULT_ACTOR_PROPERTY_MAX_COUNT, ///< Property start index for classes deriving directly from Actor. @SINCE_1_0.0
+ DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION = 10000, ///< Second-level and onwards derived objects should increment their start index by this. @SINCE_1_0.0
- DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< Used by PanGestureDetector. @SINCE_1_0.0
+ DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< Used by PanGestureDetector. @SINCE_1_0.0
- DEFAULT_RENDERER_PROPERTY_START_INDEX = 9000000, ///< Start index for Renderer. @SINCE_1_1.44
- DEFAULT_RENDERER_PROPERTY_MAX_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION-1,///< Renderer range: 9,000,000 to 9,009,999 @SINCE_2_1.13
+ DEFAULT_RENDERER_PROPERTY_START_INDEX = 9000000, ///< Start index for Renderer. @SINCE_1_1.44
+ DEFAULT_RENDERER_PROPERTY_MAX_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX + DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION-1,///< Renderer range: 9,000,000 to 9,009,999 @SINCE_2_1.13
- PROPERTY_REGISTRATION_START_INDEX = 10000000, ///< The index when registering a property should start from this number. @SINCE_1_0.0
- DEFAULT_PROPERTY_MAX_COUNT = PROPERTY_REGISTRATION_START_INDEX, ///< Default Property Range: 0 to 9999999 @SINCE_1_0.0
+ PROPERTY_REGISTRATION_START_INDEX = 10000000, ///< The index when registering a property should start from this number. @SINCE_1_0.0
+ DEFAULT_PROPERTY_MAX_COUNT = PROPERTY_REGISTRATION_START_INDEX, ///< Default Property Range: 0 to 9999999 @SINCE_1_0.0
- PROPERTY_REGISTRATION_MAX_INDEX = 19999999, ///< The maximum index supported when registering a property @SINCE_1_0.0
+ PROPERTY_REGISTRATION_MAX_INDEX = 19999999, ///< The maximum index supported when registering a property @SINCE_1_0.0
- ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX = 20000000, ///< The index when registering an animatable property should start from this number. (SceneGraph properties per type) @SINCE_1_0.0
- ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX = 29999999, ///< The maximum index supported when registering an animatable property @SINCE_1_0.0
+ ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX = 20000000, ///< The index when registering an animatable property should start from this number. (SceneGraph properties per type) @SINCE_1_0.0
+ ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_START_INDEX = 25000000, ///< The index when registering an animatable property without uniform mapping should start from this number. (SceneGraph properties per type) @SINCE_2_4.15
+ ANIMATABLE_PROPERTY_WITHOUT_UNIFORM_REGISTRATION_MAX_INDEX = 25999999, ///< The maximum index supported when registering an animatable property without uniform mapping @SINCE_2_4.15
+ ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX = 29999999, ///< The maximum index supported when registering an animatable property @SINCE_1_0.0
- CHILD_PROPERTY_REGISTRATION_START_INDEX = 45000000, ///< The index when registering a child property should start from this number. (Event side properties per instance) @SINCE_1_1.35
- CHILD_PROPERTY_REGISTRATION_MAX_INDEX = 49999999, ///< The maximum index supported when registering a child property @SINCE_1_1.35
+ CHILD_PROPERTY_REGISTRATION_START_INDEX = 45000000, ///< The index when registering a child property should start from this number. (Event side properties per instance) @SINCE_1_1.35
+ CHILD_PROPERTY_REGISTRATION_MAX_INDEX = 49999999, ///< The maximum index supported when registering a child property @SINCE_1_1.35
- PROPERTY_CUSTOM_START_INDEX = 50000000, ///< The index at which custom properties start (SceneGraph and Event side properties per instance) @SINCE_1_0.0
- PROPERTY_CUSTOM_MAX_INDEX = 59999999, ///< The maximum index supported for custom properties @SINCE_1_1.45
+ PROPERTY_CUSTOM_START_INDEX = 50000000, ///< The index at which custom properties start (SceneGraph and Event side properties per instance) @SINCE_1_0.0
+ PROPERTY_CUSTOM_MAX_INDEX = 59999999, ///< The maximum index supported for custom properties @SINCE_1_1.45
- CORE_PROPERTY_MAX_INDEX = PROPERTY_CUSTOM_MAX_INDEX, ///< The maximum index that Core properties can go up to @SINCE_1_1.45
+ CORE_PROPERTY_MAX_INDEX = PROPERTY_CUSTOM_MAX_INDEX, ///< The maximum index that Core properties can go up to @SINCE_1_1.45
};
// clang-format on