From: Eunki, Hong Date: Wed, 12 Jun 2024 09:11:58 +0000 (+0900) Subject: Make Transform Component dirty as 2 frames, not for true/false X-Git-Tag: dali_2.3.29~7^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=616b896b696a77b7c0dc544b812959df14c93ab0;p=platform%2Fcore%2Fuifw%2Fdali-core.git Make Transform Component dirty as 2 frames, not for true/false Since ResetToBaseValue for TransfromProperty doesn't use basic AnimatableProperty logic, the dirty flag is not match with common sence. To match it as frame-by-frame, let we make component dirty as 2 bit, and age-down every frame. And after we allow to use dirty flag feature for transform, we can determine whether we need to re-calculate matrix or not. If that flag be used, we can 'skip' heavy matrix multiply operation. Change-Id: Icf51e0be37962bee5147c08bb0cd3302bf203f89 Signed-off-by: Eunki, Hong --- diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index a5471ed..f9bd877 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -81,7 +81,7 @@ protected: // for derived classes */ virtual void OnSet() { - mDirtyFlags |= SET_FLAG; + mDirtyFlags = SET_FLAG; } /** @@ -89,7 +89,7 @@ protected: // for derived classes */ virtual void OnBake() { - mDirtyFlags |= BAKED_FLAG; + mDirtyFlags = BAKED_FLAG; } public: @@ -98,7 +98,7 @@ public: */ void MarkAsDirty() { - mDirtyFlags |= RESET_FLAG; + mDirtyFlags = RESET_FLAG; } public: // From PropertyBase diff --git a/dali/internal/update/manager/transform-manager.cpp b/dali/internal/update/manager/transform-manager.cpp index f5e3bac..2683f41 100644 --- a/dali/internal/update/manager/transform-manager.cpp +++ b/dali/internal/update/manager/transform-manager.cpp @@ -26,6 +26,7 @@ //INTERNAL INCLUDES #include #include +#include ///< for SET_FLAG and BAKE_FLAG #include #include @@ -45,6 +46,8 @@ static const float gDefaultTransformComponentAnimatableData[] = {1.0f, 1.0f, 1.0 //Default values for anchor point (CENTER) and parent origin (TOP_LEFT) static const float gDefaultTransformComponentStaticData[] = {0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true}; +static const uint32_t STATIC_COMPONENT_FLAG = 0x01; ///< Indicates that the value when we change static transform components, so need to update at least 1 frame. + static_assert(sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable"); static_assert(sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic"); @@ -110,7 +113,7 @@ TransformId TransformManager::CreateTransform() mBoundingSpheres.PushBack(Vector4(0.0f, 0.0f, 0.0f, 0.0f)); mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable()); mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f)); - mComponentDirty.PushBack(false); + mComponentDirty.PushBack(CLEAN_FLAG); mLocalMatrixDirty.PushBack(false); } else @@ -127,7 +130,7 @@ TransformId TransformManager::CreateTransform() mWorld[mComponentCount].SetIdentity(); mBoundingSpheres[mComponentCount] = Vector4(0.0f, 0.0f, 0.0f, 0.0f); mSizeBase[mComponentCount] = Vector3(0.0f, 0.0f, 0.0f); - mComponentDirty[mComponentCount] = false; + mComponentDirty[mComponentCount] = CLEAN_FLAG; mLocalMatrixDirty[mComponentCount] = false; } @@ -164,10 +167,12 @@ void TransformManager::RemoveTransform(TransformId id) void TransformManager::SetParent(TransformId id, TransformId parentId) { DALI_ASSERT_ALWAYS(id != parentId); - TransformId index = mIds[id]; - mParent[index] = parentId; - mComponentDirty[index] = true; - mReorder = true; + + TransformId index = mIds[id]; + mParent[index] = parentId; + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; ///< Need to calculate local matrix, at least 1 frame. + + mReorder = true; } const Matrix& TransformManager::GetWorldMatrix(TransformId id) const @@ -192,7 +197,7 @@ void TransformManager::SetInheritPosition(TransformId id, bool inherit) mInheritanceMode[index] &= ~INHERIT_POSITION; } - mComponentDirty[index] = true; + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; } void TransformManager::SetInheritScale(TransformId id, bool inherit) @@ -207,7 +212,7 @@ void TransformManager::SetInheritScale(TransformId id, bool inherit) mInheritanceMode[index] &= ~INHERIT_SCALE; } - mComponentDirty[index] = true; + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; } void TransformManager::SetInheritOrientation(TransformId id, bool inherit) @@ -222,7 +227,7 @@ void TransformManager::SetInheritOrientation(TransformId id, bool inherit) mInheritanceMode[index] &= ~INHERIT_ORIENTATION; } - mComponentDirty[index] = true; + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; } void TransformManager::ResetToBaseValue() @@ -362,8 +367,8 @@ bool TransformManager::Update() mBoundingSpheres[i] = mWorld[i].GetTranslation(); mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace); - componentsChanged = componentsChanged || mComponentDirty[i]; - mComponentDirty[i] = false; + componentsChanged = componentsChanged || mComponentDirty[i]; + mComponentDirty[i] >>= 1u; ///< age down. } DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_TRANSFORM_UPDATE", [&](std::ostringstream& oss) { @@ -592,33 +597,37 @@ const float& TransformManager::GetVector3PropertyComponentValue(TransformId id, void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; switch(property) { case TRANSFORM_PROPERTY_POSITION: { + mComponentDirty[index] = SET_FLAG; mTxComponentAnimatable[index].mPosition = value; break; } case TRANSFORM_PROPERTY_SCALE: { + mComponentDirty[index] = SET_FLAG; mTxComponentAnimatable[index].mScale = value; break; } case TRANSFORM_PROPERTY_PARENT_ORIGIN: { + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; mTxComponentStatic[index].mParentOrigin = value; break; } case TRANSFORM_PROPERTY_ANCHOR_POINT: { + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; mTxComponentStatic[index].mAnchorPoint = value; break; } case TRANSFORM_PROPERTY_SIZE: { - mSize[index] = value; + mComponentDirty[index] = SET_FLAG; + mSize[index] = value; break; } default: @@ -631,32 +640,36 @@ void TransformManager::SetVector3PropertyValue(TransformId id, TransformManagerP void TransformManager::SetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component) { TransformId index(mIds[id]); - mComponentDirty[index] = true; switch(property) { case TRANSFORM_PROPERTY_POSITION: { + mComponentDirty[index] = SET_FLAG; mTxComponentAnimatable[index].mPosition[component] = value; break; } case TRANSFORM_PROPERTY_SCALE: { + mComponentDirty[index] = SET_FLAG; mTxComponentAnimatable[index].mScale[component] = value; break; } case TRANSFORM_PROPERTY_PARENT_ORIGIN: { + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; mTxComponentStatic[index].mParentOrigin[component] = value; break; } case TRANSFORM_PROPERTY_ANCHOR_POINT: { + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; mTxComponentStatic[index].mAnchorPoint[component] = value; break; } case TRANSFORM_PROPERTY_SIZE: { + mComponentDirty[index] = SET_FLAG; mSize[index][component] = value; break; } @@ -670,7 +683,7 @@ void TransformManager::SetVector3PropertyComponentValue(TransformId id, Transfor void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -709,7 +722,7 @@ void TransformManager::BakeVector3PropertyValue(TransformId id, TransformManager void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -748,7 +761,7 @@ void TransformManager::BakeRelativeVector3PropertyValue(TransformId id, Transfor void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, TransformManagerProperty property, const Vector3& value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -787,7 +800,7 @@ void TransformManager::BakeMultiplyVector3PropertyValue(TransformId id, Transfor void TransformManager::BakeVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, float value, unsigned int component) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -826,7 +839,7 @@ void TransformManager::BakeVector3PropertyComponentValue(TransformId id, Transfo void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManagerProperty property, float value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -865,7 +878,7 @@ void TransformManager::BakeXVector3PropertyValue(TransformId id, TransformManage void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManagerProperty property, float value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -904,7 +917,7 @@ void TransformManager::BakeYVector3PropertyValue(TransformId id, TransformManage void TransformManager::BakeZVector3PropertyValue(TransformId id, TransformManagerProperty property, float value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= BAKED_FLAG; switch(property) { @@ -954,22 +967,25 @@ const Quaternion& TransformManager::GetQuaternionPropertyValue(TransformId id) c void TransformManager::SetQuaternionPropertyValue(TransformId id, const Quaternion& q) { TransformId index(mIds[id]); + mComponentDirty[index] = SET_FLAG; + mTxComponentAnimatable[index].mOrientation = q; - mComponentDirty[index] = true; } void TransformManager::BakeQuaternionPropertyValue(TransformId id, const Quaternion& q) { TransformId index(mIds[id]); + mComponentDirty[index] |= BAKED_FLAG; + mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = q; - mComponentDirty[index] = true; } void TransformManager::BakeRelativeQuaternionPropertyValue(TransformId id, const Quaternion& q) { TransformId index(mIds[id]); + mComponentDirty[index] |= BAKED_FLAG; + mTxComponentAnimatable[index].mOrientation = mTxComponentAnimatableBaseValue[index].mOrientation = mTxComponentAnimatable[index].mOrientation * q; - mComponentDirty[index] = true; } const Vector4& TransformManager::GetBoundingSphere(TransformId id) const @@ -987,7 +1003,8 @@ void TransformManager::GetWorldMatrixAndSize(TransformId id, Matrix& worldMatrix void TransformManager::SetPositionUsesAnchorPoint(TransformId id, bool value) { TransformId index(mIds[id]); - mComponentDirty[index] = true; + mComponentDirty[index] |= STATIC_COMPONENT_FLAG; + mTxComponentStatic[index].mPositionUsesAnchorPoint = value; } diff --git a/dali/internal/update/manager/transform-manager.h b/dali/internal/update/manager/transform-manager.h index 97294e2..8f28273 100644 --- a/dali/internal/update/manager/transform-manager.h +++ b/dali/internal/update/manager/transform-manager.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_TRANSFORM_MANAGER_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -418,10 +418,14 @@ private: Vector mBoundingSpheres; ///< Bounding spheres. xyz is the center and w is the radius Vector mTxComponentAnimatableBaseValue; ///< Base values for the animatable part of the components Vector mSizeBase; ///< Base value for the size of the components - Vector mComponentDirty; ///< 1u if some of the parts of the component has changed in this frame, 0 otherwise - Vector mLocalMatrixDirty; ///< 1u if the local matrix has been updated in this frame, 0 otherwise - Vector mOrderedComponents; ///< Used to reorder components when hierarchy changes - bool mReorder; ///< Flag to determine if the components have to reordered in the next Update + Vector mComponentDirty; ///< Dirty flags for each component. Follow as animatable property's dirty flag. + ///< Or If we change static component changed, flag become non-zero. Age down at Update time. + ///< Note that we don't replace dirty flag as BAKE even if we call Bake operation. + ///< (Since single dirty flag controls multiple animatable properties ; Position, Size, Scale, Orientation.) + Vector mLocalMatrixDirty; ///< 1u if the local matrix has been updated in this frame, 0 otherwise + Vector mOrderedComponents; ///< Used to reorder components when hierarchy changes + + bool mReorder : 1; ///< Flag to determine if the components have to reordered in the next Update }; } //namespace SceneGraph