[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / transform-manager.h
old mode 100644 (file)
new mode 100755 (executable)
index 45bc00d..30b253b
@@ -1,9 +1,8 @@
-
-#ifndef TRANSFORM_MANAGER_H_
-#define TRANSFORM_MANAGER_H_
+#ifndef DALI_INTERNAL_TRANSFORM_MANAGER_H
+#define DALI_INTERNAL_TRANSFORM_MANAGER_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -24,6 +23,7 @@
 #include <dali/public-api/math/matrix.h>
 #include <dali/public-api/math/quaternion.h>
 #include <dali/public-api/math/vector3.h>
+#include <dali/public-api/common/constants.h>
 #include <dali/internal/update/manager/free-list.h>
 
 namespace Dali
@@ -41,10 +41,11 @@ namespace SceneGraph
 struct TransformComponentAnimatable
 {
   TransformComponentAnimatable()
-  :mScale(1.0f,1.0f,1.0f),
-   mOrientation(1.0f,0.0f,0.0f,0.0f),
-   mPosition(0.0f,0.0f,0.0f)
-  {}
+  : mScale( Vector3::ONE ),
+    mOrientation( Quaternion::IDENTITY ),
+    mPosition( Vector3::ZERO )
+  {
+  }
 
   Vector3 mScale;
   Quaternion mOrientation;
@@ -57,12 +58,15 @@ struct TransformComponentAnimatable
 struct TransformComponentStatic
 {
   TransformComponentStatic()
-  :mAnchorPoint(0.5f,0.5f,0.5f),
-   mParentOrigin(0.0f,0.0f,0.5f)
-  {}
+  : mAnchorPoint( AnchorPoint::DEFAULT ),
+    mParentOrigin( ParentOrigin::DEFAULT ),
+    mPositionUsesAnchorPoint( true )
+  {
+  }
 
   Vector3 mAnchorPoint;
   Vector3 mParentOrigin;
+  bool mPositionUsesAnchorPoint;
 };
 
 enum InheritanceMode
@@ -85,10 +89,11 @@ enum TransformManagerProperty
   TRANSFORM_PROPERTY_WORLD_SCALE,
   TRANSFORM_PROPERTY_WORLD_ORIENTATION,
   TRANSFORM_PROPERTY_WORLD_MATRIX,
+  TRANSFORM_PROPERTY_UPDATE_SIZE_HINT,
   TRANSFORM_PROPERTY_COUNT,
 };
 
-typedef unsigned int TransformId;
+typedef uint32_t TransformId; // 4,294,967,295 transforms supported
 static const TransformId INVALID_TRANSFORM_ID = -1;
 
 } //SceneGraph
@@ -216,7 +221,7 @@ public:
    * @param[in] property The property
    * param[in] component The component (0,1,2)
    */
-  const float& GetVector3PropertyComponentValue(TransformId id, TransformManagerProperty property, unsigned int component ) const;
+  const float& GetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, uint32_t component ) const;
 
   /**
    * Set the value of a Vector3 property
@@ -233,7 +238,7 @@ public:
    * @param[in] value The new value
    * param[in] component The component (0,1,2)
    */
-  void SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component );
+  void SetVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, uint32_t component );
 
   /**
    * Bakes the value of a Vector3 property
@@ -265,7 +270,7 @@ public:
    * @param[in] property The property
    * @param[in] value The new value
    */
-  void BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, unsigned int component );
+  void BakeVector3PropertyComponentValue( TransformId id, TransformManagerProperty property, float value, uint32_t component );
 
   /**
    * Bakes the value of the x component of Vector3 property
@@ -332,12 +337,34 @@ public:
   const Vector4& GetBoundingSphere( TransformId id ) const;
 
   /**
+   * Component of node is changed or not
+   * @param[in] id Id of the transform component
+   * @return true if Component box is changed else false.
+   */
+  bool IsComponentChanged( TransformId id );
+
+  /**
    * Get the world matrix and size of a given component
    * @param[in] id Id of the transform component
+   * @param[out] The world matrix of the component
    * @param[out] size size of the component
-   * @return The world matrix of the component
    */
-  const Matrix& GetWorldMatrixAndSize( TransformId id, Vector3& size ) const;
+  void GetWorldMatrixAndSize( TransformId id, Matrix& worldMatrix, Vector3& size ) const;
+
+  /**
+   * Get the update size hint,
+   * @param[in] id Id of the transform component
+   * @return The update size hint of the component
+   */
+  const Vector3& GetUpdateSizeHint( TransformId id ) const;
+
+
+  /**
+   * @brief Sets the boolean which states whether the position should use the anchor-point on the given transform component.
+   * @param[in] id Id of the transform component
+   * @param[in] value True if the position should use the anchor-point
+   */
+  void SetPositionUsesAnchorPoint( TransformId id, bool value );
 
 private:
 
@@ -347,7 +374,7 @@ private:
     bool operator<(const SOrderItem& item) const {return level < item.level;}
 
     TransformId  id;
-    unsigned int level;
+    uint32_t level;
   };
 
   /**
@@ -355,7 +382,7 @@ private:
    * @param[in] i Index of a component
    * @param[in] j Index of a component
    */
-  void SwapComponents( unsigned int i, unsigned int j );
+  void SwapComponents( uint32_t i, uint32_t j );
 
   /**
    * Reorders components in hierarchical order so update can iterate sequentially
@@ -363,23 +390,27 @@ private:
    */
   void ReorderComponents();
 
-  unsigned int mComponentCount;                                ///< Total number of components
-  FreeList mIds;                                               ///< FreeList of Ids
-  Vector<TransformComponentAnimatable> mTxComponentAnimatable; ///< Animatable part of the components
-  Vector<TransformComponentStatic> mTxComponentStatic;         ///< Static part of the components
-  Vector<unsigned int> mInheritanceMode;                       ///< Inheritance mode of the components
-  Vector<TransformId> mComponentId;                            ///< Ids of the components
-  Vector<Vector3> mSize;                                       ///< Size of the components
-  Vector<TransformId> mParent;                                 ///< Parent of the components
-  Vector<Matrix> mWorld;                                       ///< Local to world transform of the components
-  Vector<Matrix> mLocal;                                       ///< Local to parent space transform of the components
-  Vector<Vector4> mBoundingSpheres;                            ///< Bounding spheres. xyz is the center and w is the radius
-  Vector<TransformComponentAnimatable> mTxComponentAnimatableBaseValue;  ///< Base values for the animatable part of the components
-  Vector<Vector3> mSizeBase;                                             ///< Base value for the size of the components
-  Vector<bool> mComponentDirty;    ///< 1u if some of the parts of the component has changed in this frame, 0 otherwise
-  Vector<bool> mLocalMatrixDirty;  ///< 1u if the local matrix has been updated in this frame, 0 otherwise
-  Vector<SOrderItem> mOrderedComponents;   ///< Used to reorder components when hierarchy changes
-  bool mReorder;                           ///< Flag to determine if the components have to reordered in the next Update
+  uint32_t mComponentCount;                                               ///< Total number of components
+  FreeList mIds;                                                          ///< FreeList of Ids
+  Vector< TransformComponentAnimatable > mTxComponentAnimatable;          ///< Animatable part of the components
+  Vector< TransformComponentStatic > mTxComponentStatic;                  ///< Static part of the components
+  Vector< uint32_t > mInheritanceMode;                                    ///< Inheritance mode of the components
+  Vector< TransformId > mComponentId;                                     ///< Ids of the components
+  Vector< Vector3 > mSize;                                                ///< Size of the components
+  Vector< TransformId > mParent;                                          ///< Parent of the components
+  Vector< Matrix > mWorld;                                                ///< Local to world transform of the components
+  Vector< Matrix > mPrevWorld;                                            ///< Local to world transform of the components in last frame
+  Vector< Matrix > mLocal;                                                ///< Local to parent space transform of the components
+  Vector< Vector4 > mBoundingSpheres;                                     ///< Bounding spheres. xyz is the center and w is the radius
+  Vector< TransformComponentAnimatable > mTxComponentAnimatableBaseValue; ///< Base values for the animatable part of the components
+  Vector< Vector3 > mSizeBase;                                            ///< Base value for the size of the components
+  Vector< bool > mComponentDirty;                                         ///< 1u if some of the parts of the component has changed in this frame, 0 otherwise
+  Vector< bool > mLocalMatrixDirty;                                       ///< 1u if the local matrix has been updated in this frame, 0 otherwise
+  Vector< SOrderItem > mOrderedComponents;                                ///< Used to reorder components when hierarchy changes
+  Vector< bool> mComponentChanged;                                        ///< Component is changed or not
+  Vector< Vector3 > mUpdateSizeHint;                                      ///< BoundingBox of the components
+  Vector< Vector3 > mUpdateSizeHintBase;                                     ///< Base value for the boundingBox of the components
+  bool mReorder;                                                          ///< Flag to determine if the components have to reordered in the next Update
 };
 
 } //namespace SceneGraph
@@ -390,4 +421,4 @@ private:
 } //namespace Dali
 
 
-#endif /* TRANSFORM_MANAGER_H_ */
+#endif // DALI_INTERNAL_TRANSFORM_MANAGER_H