[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / shader-effects / motion-stretch-effect.h
index 5cc7bcf..8ad7c67 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
-#define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
+#ifndef DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H
+#define DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/actors/renderable-actor.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
+/**
+ * @brief Set the properties for the motion stretch
+ */
+DALI_TOOLKIT_API void SetMotionStretchProperties(Actor& actor);
 
 /**
+ * @brief Creates a new MotionStretchEffect
  *
- * Class for motion stretch shader that works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves. Can be applied
- * to ImageActor or TextActor only.
+ * Motion stretch shader works on a per object basis. Objects will stretch in the direction of motion when they move, or if the camera moves.
  *
- * Usage example:-
- *
- * // Create shader used for doing motion stretch\n
- * MotionStretchEffect MotionStretchEffect = MotionStretchEffect::New();
- *
- * // set actor shader to the stretch one\n
- * Actor Actor = Actor::New( ... );\n
- * Actor.SetShaderEffect( MotionStretchEffect );
+ * Animatable/Constrainable uniforms:
+ *  "uGeometryStretchFactor"  - This scales the amount the geometry stretches along the motion velocity vector.
+ *                              A smaller value means the geometry stretches less, larger it stretches more. Default 0.5.
+ *  "uSpeedScalingFactor"     - This value is used to control how much to fade the actor near the edges, based on the
+ *                              speed the actor is moving. When the actor is at rest this is not applied. Default 0.5.
+ *  "uObjectFadeStart"        - The displacement from the centre of the actor that the actor will start to fade towards
+ *                              its edges. This is used to prevent an unsightly hard edge between the stretched actor and
+ *                              the scene. Depends on the values of the vertices in the vertex stream. When the actor is at
+ *                              rest this is not applied. Default Vector2(0.25, 0.25), which is half way towards the edge for
+ *                              an ImageVisual::QUAD.
+ *  "uObjectFadeEnd"          - The displacement from the centre of the actor that the actor will finish fading towards its edges.
+ *                              This is used to prevent an unsightly hard edge between the stretched actor and the scene. Depends
+ *                              on the values of the vertices in the vertex stream. When the actor is at rest this is not applied.
+ *                              Default 0.5, which is all the way towards the edge for an ImageVisual::QUAD.
+ *  "uAlphaScale"             - Global scaler applied to the alpha of the actor. Used to make the stretched actor a bit more subtle
+ *                              and reveal a bit of the background behind it as it moves. When the actor is at rest this is not
+ *                              applied. Default 0.75.
+ *  "uModelLastFrame"         - The model to world space transformation matrix of the actor in the previous frame.
  *
+ * @return The newly created Property::Map with the motion stretch effect
  */
-class DALI_IMPORT_API MotionStretchEffect : public ShaderEffect
-{
-
-public:
-
-  /**
-   * Create an uninitialized MotionStretchEffect; this can be initialized with MotionStretchEffect::New()
-   * Calling member functions with an uninitialized Dali::Object is not allowed.
-   */
-  MotionStretchEffect();
-
-  /**
-   * @brief Destructor
-   *
-   * This is non-virtual since derived Handle types must not contain data or virtual methods.
-   */
-  ~MotionStretchEffect();
-
-  /**
-   * Create an initialized MotionStretchEffect
-   * @return A handle to a newly allocated Dali resource.
-   */
-  static MotionStretchEffect New();
-
-  /**
-   * Create a  MotionStretchEffect and attach it to the specified actor
-   * @param renderable actor to apply the effect to
-   * @return A handle to a newly allocated Dali resource.
-   */
-  static MotionStretchEffect Apply( RenderableActor renderable );
-
-  /**
-   * Set geometry stretch factor property. This scales the amount the geometry
-   * stretches along the motion velocity vector. A smaller value means the geometry
-   * stretches less, larger it stretches more. Default 0.5.
-   * @param scalingFactor The scaling factor that extrudes the geometry forwards along the motion velocity vector.
-   */
-  void SetGeometryStretchFactor( float scalingFactor );
-
-  /**
-   * Set speed scaling factor property. This value is used to control how much
-   * to fade the actor near the edges, based on the speed the actor is moving.
-   * When the actor is at rest this is not applied. Default 0.5.
-   * @param scalingFactor The scaling factor that controls the edge fade of the actor.
-   */
-  void SetSpeedScalingFactor( float scalingFactor );
-
-  /**
-   * Set the displacement from the centre of the actor that the actor will start to
-   * fade towards its edges. This is used to prevent an unsightly hard edge
-   * between the stretched actor and the scene. Depends on the values of the
-   * vertices in the vertex stream. When the actor is at rest this is not applied.
-   * Default Vector2(0.25, 0.25), which is half way towards the edge for an ImageRenderer::QUAD.
-   * @param displacement The displacement from the centre of the actor that the actor will start to edge fade.
-   */
-  void SetObjectFadeStart( Vector2 displacement );
-
-  /**
-   * Set the displacement from the centre of the actor that the actor will
-   * finish fading towards its edges. This is used to prevent an unsightly hard
-   * edge between the stretched actor and the scene. Depends on the values of
-   * the vertices in the vertex stream. When the actor is at rest this is not applied.
-   * Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
-   * @param displacement The displacement from the centre of the actor that the actor will finish edge fading.
-   */
-  void SetObjectFadeEnd( Vector2 displacement );
-
-  /**
-   * Set a global scaler applied to the alpha of the actor. Used to make the
-   * stretched actor a bit more subtle and reveal a bit of the background behind
-   * it as it moves. When the actor is at rest this is not applied. Default 0.75.
-   * @param alphaScale The scaling factor which multiplies the alpha of each pixel of the actor.
-   */
-  void SetAlphaScale( float alphaScale );
-
-
-  /**
-   * Get the name for the texcoord scale property. Useful for animation.
-   * @return A std::string containing the property name
-   */
-  const std::string& GetTexcoordScalePropertyName() const;
-
-  /**
-   * Get the name for the geometry stretching property. Useful for animation.
-   * @return A std::string containing the property name
-   */
-  const std::string& GetGeometryStretchFactorPropertyName() const;
-
-  /**
-   * Get the name for the speed scaling property. Useful for animation.
-   * @return A std::string containing the property name
-   */
-  const std::string& GetSpeedScalingFactorPropertyName() const;
-
-  /**
-   * Get the name for the fade start X property. Useful for animation.
-   * @return A std::string containing the property name
-   */
-  const std::string& GetObjectFadeStartPropertyName() const;
-
-  /**
-   * Get the name for the fade end X property. Useful for animation.
-   * @return A std::string containing the property name
-   */
-  const std::string& GetObjectFadeEndPropertyName() const;
-
-  /**
-   * Get the name for the alpha scale property. Useful for animation.
-   * @return A std::string containing the property name
-   */
-  const std::string& GetAlphaScalePropertyName() const;
-
-private:
-  // Not intended for application developers
-  DALI_INTERNAL MotionStretchEffect( ShaderEffect handle );
-};
+DALI_TOOLKIT_API Property::Map CreateMotionStretchEffect();
 
-}
+} // namespace Toolkit
 
-}
+} // namespace Dali
 
-#endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
+#endif // DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H