Calculate VisualRenderer coefficient only if updated.
[platform/core/uifw/dali-core.git] / dali / internal / update / common / animatable-property.h
index d1f97d6..612af3f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
 #include <limits>
 
 // INTERNAL INCLUDES
-#include <dali/internal/common/message.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/event/common/property-input-impl.h>
+#include <dali/internal/common/matrix-utils.h>
+
 #include <dali/internal/update/common/double-buffered.h>
 #include <dali/internal/update/common/property-base.h>
-#include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/object/property-input.h>
 #include <dali/public-api/object/property-types.h>
@@ -52,6 +50,7 @@ namespace SceneGraph
 static const uint32_t CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame
 static const uint32_t BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame
 static const uint32_t SET_FLAG   = 0x02; ///< Indicates that the value was Set during the previous frame
+static const uint32_t RESET_FLAG = 0x02; ///< Indicates that the value should be reset to the base value in the next two frames
 
 template<class T>
 class AnimatableProperty;
@@ -80,7 +79,7 @@ protected: // for derived classes
   /**
    * Flag that the property has been Set during the current frame.
    */
-  void OnSet()
+  virtual void OnSet()
   {
     mDirtyFlags = SET_FLAG;
   }
@@ -88,11 +87,20 @@ protected: // for derived classes
   /**
    * Flag that the property has been Baked during the current frame.
    */
-  void OnBake()
+  virtual void OnBake()
   {
     mDirtyFlags = BAKED_FLAG;
   }
 
+public:
+  /**
+   * Mark the property as dirty so that it will be reset to the base value in the next two frames.
+   */
+  void MarkAsDirty()
+  {
+    mDirtyFlags = RESET_FLAG;
+  }
+
 public: // From PropertyBase
   /**
    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
@@ -1821,7 +1829,7 @@ public:
   void SetRelative(BufferIndex bufferIndex, const Matrix& delta)
   {
     Matrix temp;
-    Matrix::Multiply(temp, mValue[bufferIndex], delta);
+    MatrixUtils::Multiply(temp, mValue[bufferIndex], delta);
     mValue[bufferIndex] = temp;
 
     OnSet();
@@ -1887,7 +1895,7 @@ public:
   void BakeRelative(BufferIndex bufferIndex, const Matrix& delta)
   {
     Matrix temp;
-    Matrix::Multiply(temp, mValue[bufferIndex], delta);
+    MatrixUtils::Multiply(temp, mValue[bufferIndex], delta);
     mValue[bufferIndex] = temp;
     mBaseValue          = temp;
 
@@ -1977,7 +1985,7 @@ public:
   void SetRelative(BufferIndex bufferIndex, const Matrix3& delta)
   {
     Matrix3 temp;
-    Matrix3::Multiply(temp, mValue[bufferIndex], delta);
+    MatrixUtils::Multiply(temp, mValue[bufferIndex], delta);
     mValue[bufferIndex] = temp;
     OnSet();
   }
@@ -2042,7 +2050,7 @@ public:
   void BakeRelative(BufferIndex bufferIndex, const Matrix3& delta)
   {
     Matrix3 temp;
-    Matrix3::Multiply(temp, mValue[bufferIndex], delta);
+    MatrixUtils::Multiply(temp, mValue[bufferIndex], delta);
     mValue[bufferIndex] = temp;
     mBaseValue          = temp;
 
@@ -2063,104 +2071,6 @@ private:
 
 } // namespace SceneGraph
 
-// Messages for AnimatableProperty<T>
-
-template<class T>
-void BakeMessage(EventThreadServices&                     eventThreadServices,
-                 const SceneGraph::AnimatableProperty<T>& property,
-                 typename ParameterType<T>::PassingType   newValue)
-{
-  using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, T>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&property,
-                      &SceneGraph::AnimatableProperty<T>::Bake,
-                      newValue);
-}
-
-template<class T>
-void BakeRelativeMessage(EventThreadServices&                     eventThreadServices,
-                         const SceneGraph::AnimatableProperty<T>& property,
-                         const T&                                 delta)
-{
-  using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, const T&>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&property,
-                      &SceneGraph::AnimatableProperty<T>::BakeRelative,
-                      delta);
-}
-
-template<class T>
-void SetXComponentMessage(EventThreadServices&                       eventThreadServices,
-                          const SceneGraph::AnimatableProperty<T>&   property,
-                          typename ParameterType<float>::PassingType newValue)
-{
-  using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&property,
-                      &SceneGraph::AnimatableProperty<T>::BakeX,
-                      newValue);
-}
-
-template<class T>
-void SetYComponentMessage(EventThreadServices&                       eventThreadServices,
-                          const SceneGraph::AnimatableProperty<T>&   property,
-                          typename ParameterType<float>::PassingType newValue)
-{
-  using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&property,
-                      &SceneGraph::AnimatableProperty<T>::BakeY,
-                      newValue);
-}
-
-template<class T>
-void SetZComponentMessage(EventThreadServices&                       eventThreadServices,
-                          const SceneGraph::AnimatableProperty<T>&   property,
-                          typename ParameterType<float>::PassingType newValue)
-{
-  using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&property,
-                      &SceneGraph::AnimatableProperty<T>::BakeZ,
-                      newValue);
-}
-
-template<class T>
-void SetWComponentMessage(EventThreadServices&                       eventThreadServices,
-                          const SceneGraph::AnimatableProperty<T>&   property,
-                          typename ParameterType<float>::PassingType newValue)
-{
-  using LocalType = MessageDoubleBuffered1<SceneGraph::AnimatableProperty<T>, float>;
-
-  // Reserve some memory inside the message queue
-  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new(slot) LocalType(&property,
-                      &SceneGraph::AnimatableProperty<T>::BakeW,
-                      newValue);
-}
-
 } // namespace Internal
 
 } // namespace Dali