[Tizen] Make TransformManager check WorldMatrix dirty, instead local matrix dirty 21/315521/1 accepted/tizen/unified/20240802.160159 accepted/tizen/unified/dev/20240805.054539 accepted/tizen/unified/toolchain/20240812.133418 accepted/tizen/unified/x/20240805.012925
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 2 Aug 2024 03:53:05 +0000 (12:53 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 2 Aug 2024 04:12:54 +0000 (13:12 +0900)
Since we only need to check parent's world matrix + parent's size
to calculate the world matrix,

Dirtyness of local matrix is not important. Instead, we'd better check
the world matrix changeness.

Change-Id: I5ef804f54300cbad355d7b265e42cd109d2b5d81
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/update/manager/transform-manager.cpp
dali/internal/update/manager/transform-manager.h
dali/internal/update/manager/update-algorithms.cpp
dali/internal/update/nodes/node.h
dali/internal/update/render-tasks/scene-graph-camera.cpp

index 5b8ffbb667fdba3fca465f90d27ef85c9d824542..879d20b8b91554c6185d4662a2073c72296ec13a 100644 (file)
@@ -116,7 +116,7 @@ TransformId TransformManager::CreateTransform()
     mTxComponentAnimatableBaseValue.PushBack(TransformComponentAnimatable());
     mSizeBase.PushBack(Vector3(0.0f, 0.0f, 0.0f));
     mComponentDirty.PushBack(CLEAN_FLAG);
-    mLocalMatrixDirty.PushBack(false);
+    mWorldMatrixDirty.PushBack(false);
   }
   else
   {
@@ -133,7 +133,7 @@ TransformId TransformManager::CreateTransform()
     mBoundingSpheres[mComponentCount]  = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
     mSizeBase[mComponentCount]         = Vector3(0.0f, 0.0f, 0.0f);
     mComponentDirty[mComponentCount]   = CLEAN_FLAG;
-    mLocalMatrixDirty[mComponentCount] = false;
+    mWorldMatrixDirty[mComponentCount] = false;
   }
 
   mComponentCount++;
@@ -155,7 +155,7 @@ void TransformManager::RemoveTransform(TransformId id)
   mTxComponentAnimatableBaseValue[index] = mTxComponentAnimatableBaseValue[mComponentCount];
   mSizeBase[index]                       = mSizeBase[mComponentCount];
   mComponentDirty[index]                 = mComponentDirty[mComponentCount];
-  mLocalMatrixDirty[index]               = mLocalMatrixDirty[mComponentCount];
+  mWorldMatrixDirty[index]               = mWorldMatrixDirty[mComponentCount];
   mBoundingSpheres[index]                = mBoundingSpheres[mComponentCount];
 
   TransformId lastItemId = mComponentId[mComponentCount];
@@ -252,7 +252,7 @@ void TransformManager::ResetToBaseValue()
 
     if(mUpdated)
     {
-      memset(&mLocalMatrixDirty[0], false, sizeof(bool) * mComponentCount);
+      memset(&mWorldMatrixDirty[0], false, sizeof(bool) * mComponentCount);
     }
   }
 }
@@ -292,9 +292,10 @@ bool TransformManager::Update()
       const TransformId& parentIndex = mIds[mParent[i]];
       if(DALI_LIKELY(mInheritanceMode[i] == INHERIT_ALL))
       {
-        if(mComponentDirty[i] || mLocalMatrixDirty[parentIndex])
+        if(mComponentDirty[i] || mWorldMatrixDirty[parentIndex])
         {
-          mLocalMatrixDirty[i] = true;
+          // TODO : Skip world matrix comparision. Is it improve performance?
+          mWorldMatrixDirty[i] = true;
 
           //Full transform inherited
           CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
@@ -307,8 +308,8 @@ bool TransformManager::Update()
       }
       else
       {
-        // Keep previous localMatrix for comparison.
-        Matrix previousLocalMatrix = mLocal[i];
+        // Keep previous worldMatrix for comparison.
+        Matrix previousWorldMatrix = mWorld[i];
 
         // Get Parent information.
         Vector3       parentPosition, parentScale;
@@ -370,14 +371,18 @@ bool TransformManager::Update()
         inverseParentMatrix.SetInverseTransformComponents(parentScale, parentOrientation, parentPosition);
         mLocal[i] = inverseParentMatrix * mWorld[i];
 
-        mLocalMatrixDirty[i] = mComponentDirty[i] || (previousLocalMatrix != mLocal[i]);
+        // TODO : We need to check mComponentDirty since we have to check the size changeness.
+        //        Could we check size changeness only?
+        mWorldMatrixDirty[i] = mComponentDirty[i] || (previousWorldMatrix != mWorld[i]);
       }
     }
     else //Component has no parent or doesn't inherit transform
     {
       if(mComponentDirty[i])
       {
-        mLocalMatrixDirty[i] = true;
+        // TODO : We need to check mComponentDirty since we have to check the size changeness.
+        //        Could we check size changeness only?
+        mWorldMatrixDirty[i] = true;
 
         CalculateCenterPosition(centerPosition, mTxComponentStatic[i], mTxComponentAnimatable[i].mScale, mTxComponentAnimatable[i].mOrientation, mSize[i], half, topLeft);
         localPosition = mTxComponentAnimatable[i].mPosition + centerPosition;
@@ -394,7 +399,7 @@ bool TransformManager::Update()
     mBoundingSpheres[i]   = mWorld[i].GetTranslation();
     mBoundingSpheres[i].w = Length(centerToEdgeWorldSpace);
 
-    mUpdated = mUpdated || mLocalMatrixDirty[i];
+    mUpdated = mUpdated || mWorldMatrixDirty[i];
 
     mComponentDirty[i] >>= 1u; ///< age down.
   }
@@ -502,7 +507,7 @@ void TransformManager::ReorderComponents()
     mTxComponentAnimatableBaseValue.Resize(mComponentCount);
     mSizeBase.Resize(mComponentCount);
     mComponentDirty.Resize(mComponentCount);
-    mLocalMatrixDirty.Resize(mComponentCount);
+    mWorldMatrixDirty.Resize(mComponentCount);
     mOrderedComponents.Resize(mComponentCount);
 
     mTxComponentAnimatable.ShrinkToFit();
@@ -517,7 +522,7 @@ void TransformManager::ReorderComponents()
     mTxComponentAnimatableBaseValue.ShrinkToFit();
     mSizeBase.ShrinkToFit();
     mComponentDirty.ShrinkToFit();
-    mLocalMatrixDirty.ShrinkToFit();
+    mWorldMatrixDirty.ShrinkToFit();
     mOrderedComponents.ShrinkToFit();
   }
 #endif
index b304ba1985e1280b6d294a9ae7c9eefef77d71b3..432399d4b354a19eeddc78844743ecdb0fd75cd2 100644 (file)
@@ -179,13 +179,13 @@ public:
   Matrix& GetWorldMatrix(TransformId id);
 
   /**
-   * Checks if the local transform was updated in the last Update
+   * Checks if the world transform was updated in the last Update
    * @param[in] id Id of the transform
-   * @return true if local matrix changed in the last update, false otherwise
+   * @return true if world matrix changed in the last update, false otherwise
    */
-  bool IsLocalMatrixDirty(TransformId id) const
+  bool IsWorldMatrixDirty(TransformId id) const
   {
-    return mLocalMatrixDirty[mIds[id]];
+    return mWorldMatrixDirty[mIds[id]];
   }
 
   /**
@@ -422,7 +422,7 @@ private:
                                                                         ///< 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<bool>       mLocalMatrixDirty;                                 ///< 1u if the local matrix has been updated in this frame, 0 otherwise
+  Vector<bool>       mWorldMatrixDirty;                                 ///< 1u if the local matrix has been updated in this frame, 0 otherwise
   Vector<SOrderItem> mOrderedComponents;                                ///< Used to reorder components when hierarchy changes
 
   uint8_t mDirtyFlags : 2; ///< Dirty flags for all transform components. Age down at Update time.
index d70bcaae52e9806d78b8a7e250ae6d7b44fc7cc2..1873e30bba38eb42c2de2f1f9d482ba1069f665a 100644 (file)
@@ -207,7 +207,7 @@ inline void UpdateLayers(Node&             node,
 {
   // Some dirty flags are inherited from parent
   NodePropertyFlags nodeDirtyFlags = node.GetDirtyFlags() | node.GetInheritedDirtyFlags(parentFlags);
-  nodeDirtyFlags |= (node.IsLocalMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
+  nodeDirtyFlags |= (node.IsWorldMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
 
   Layer* nodeIsLayer(node.GetLayer());
   Layer* layer = nodeIsLayer ? nodeIsLayer : &currentLayer;
@@ -255,7 +255,7 @@ void UpdateLayerTree(Layer&      layer,
                      BufferIndex updateBufferIndex)
 {
   NodePropertyFlags nodeDirtyFlags = layer.GetDirtyFlags();
-  nodeDirtyFlags |= (layer.IsLocalMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
+  nodeDirtyFlags |= (layer.IsWorldMatrixDirty() ? NodePropertyFlags::TRANSFORM : NodePropertyFlags::NOTHING);
 
   layer.SetReuseRenderers(updateBufferIndex, nodeDirtyFlags == NodePropertyFlags::NOTHING);
 
index 52f76bbbe5099a594676b21601dcf4be24fd9cdd..6bfecbec930e1401329d418ecd042ac93e86535d 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_NODE_H
 
 /*
- * Copyright (c) 2023 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.
@@ -740,10 +740,10 @@ public:
    * Checks if local matrix has changed since last update
    * @return true if local matrix has changed, false otherwise
    */
-  bool IsLocalMatrixDirty() const
+  bool IsWorldMatrixDirty() const
   {
     return (mTransformManagerData.Id() != INVALID_TRANSFORM_ID) &&
-           (mTransformManagerData.Manager()->IsLocalMatrixDirty(mTransformManagerData.Id()));
+           (mTransformManagerData.Manager()->IsWorldMatrixDirty(mTransformManagerData.Id()));
   }
 
   /**
index d044c6cca98f14b90cb8cb917142c815b0387aff..e5a6f25811f5a56a51a3fa273ae8c5cbd29bbc10 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 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.
@@ -551,7 +551,7 @@ const PropertyBase* Camera::GetProjectionDirection() const
 void Camera::Update(BufferIndex updateBufferIndex)
 {
   // if this has changes in world position we need to update camera for next 2 frames
-  if(IsLocalMatrixDirty())
+  if(IsWorldMatrixDirty())
   {
     mUpdateViewFlag = UPDATE_COUNT;
   }
@@ -875,7 +875,7 @@ uint32_t Camera::UpdateProjection(BufferIndex updateBufferIndex)
         {
           Matrix& projectionMatrix = mProjectionMatrix.Get(updateBufferIndex);
           Orthographic(projectionMatrix,
-                      static_cast<Dali::DevelCameraActor::ProjectionDirection>(mProjectionDirection[0]),
+                       static_cast<Dali::DevelCameraActor::ProjectionDirection>(mProjectionDirection[0]),
                        mOrthographicSize[updateBufferIndex],
                        mAspectRatio[updateBufferIndex],
                        mNearClippingPlane[updateBufferIndex],