ceef5ad12194527df5753aa133deedf85a06007d
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / shader-effects / motion-stretch-effect.h
1 #ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
2 #define __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24 #include <dali/dali.h>
25
26 namespace Dali DALI_IMPORT_API
27 {
28
29 namespace Toolkit
30 {
31
32 /**
33  *
34  * 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
35  * to ImageActor or TextActor only.
36  *
37  * Usage example:-
38  *
39  * // Create shader used for doing motion stretch\n
40  * MotionStretchEffect MotionStretchEffect = MotionStretchEffect::New();
41  *
42  * // set actor shader to the stretch one\n
43  * Actor Actor = Actor::New( ... );\n
44  * Actor.SetShaderEffect( MotionStretchEffect );
45  *
46  */
47 class MotionStretchEffect : public ShaderEffect
48 {
49
50 public:
51
52   /**
53    * Create an uninitialized MotionStretchEffect; this can be initialized with MotionStretchEffect::New()
54    * Calling member functions with an uninitialized Dali::Object is not allowed.
55    */
56   MotionStretchEffect();
57
58   /**
59    * @brief Destructor
60    *
61    * This is non-virtual since derived Handle types must not contain data or virtual methods.
62    */
63   ~MotionStretchEffect();
64
65   /**
66    * Create an initialized MotionStretchEffect
67    * @return A handle to a newly allocated Dali resource.
68    */
69   static MotionStretchEffect New();
70
71   /**
72    * Create a  MotionStretchEffect and attach it to the specified actor
73    * @param renderable actor to apply the effect to
74    * @return A handle to a newly allocated Dali resource.
75    */
76   static MotionStretchEffect Apply( RenderableActor renderable );
77
78   /**
79    * Set geometry stretch factor property. This scales the amount the geometry
80    * stretches along the motion velocity vector. A smaller value means the geometry
81    * stretches less, larger it stretches more. Default 0.5.
82    * @param scalingFactor The scaling factor that extrudes the geometry forwards along the motion velocity vector.
83    */
84   void SetGeometryStretchFactor( float scalingFactor );
85
86   /**
87    * Set speed scaling factor property. This value is used to control how much
88    * to fade the actor near the edges, based on the speed the actor is moving.
89    * When the actor is at rest this is not applied. Default 0.5.
90    * @param scalingFactor The scaling factor that controls the edge fade of the actor.
91    */
92   void SetSpeedScalingFactor( float scalingFactor );
93
94   /**
95    * Set the displacement from the centre of the actor that the actor will start to
96    * fade towards its edges. This is used to prevent an unsightly hard edge
97    * between the stretched actor and the scene. Depends on the values of the
98    * vertices in the vertex stream. When the actor is at rest this is not applied.
99    * Default Vector2(0.25, 0.25), which is half way towards the edge for an ImageRenderer::QUAD.
100    * @param displacement The displacement from the centre of the actor that the actor will start to edge fade.
101    */
102   void SetObjectFadeStart( Vector2 displacement );
103
104   /**
105    * Set the displacement from the centre of the actor that the actor will
106    * finish fading towards its edges. This is used to prevent an unsightly hard
107    * edge between the stretched actor and the scene. Depends on the values of
108    * the vertices in the vertex stream. When the actor is at rest this is not applied.
109    * Default 0.5, which is all the way towards the edge for an ImageRenderer::QUAD.
110    * @param displacement The displacement from the centre of the actor that the actor will finish edge fading.
111    */
112   void SetObjectFadeEnd( Vector2 displacement );
113
114   /**
115    * Set a global scaler applied to the alpha of the actor. Used to make the
116    * stretched actor a bit more subtle and reveal a bit of the background behind
117    * it as it moves. When the actor is at rest this is not applied. Default 0.75.
118    * @param alphaScale The scaling factor which multiplies the alpha of each pixel of the actor.
119    */
120   void SetAlphaScale( float alphaScale );
121
122
123   /**
124    * Get the name for the texcoord scale property. Useful for animation.
125    * @return A std::string containing the property name
126    */
127   const std::string& GetTexcoordScalePropertyName() const;
128
129   /**
130    * Get the name for the geometry stretching property. Useful for animation.
131    * @return A std::string containing the property name
132    */
133   const std::string& GetGeometryStretchFactorPropertyName() const;
134
135   /**
136    * Get the name for the speed scaling property. Useful for animation.
137    * @return A std::string containing the property name
138    */
139   const std::string& GetSpeedScalingFactorPropertyName() const;
140
141   /**
142    * Get the name for the fade start X property. Useful for animation.
143    * @return A std::string containing the property name
144    */
145   const std::string& GetObjectFadeStartPropertyName() const;
146
147   /**
148    * Get the name for the fade end X property. Useful for animation.
149    * @return A std::string containing the property name
150    */
151   const std::string& GetObjectFadeEndPropertyName() const;
152
153   /**
154    * Get the name for the alpha scale property. Useful for animation.
155    * @return A std::string containing the property name
156    */
157   const std::string& GetAlphaScalePropertyName() const;
158
159 private:
160   // Not intended for application developers
161   MotionStretchEffect( ShaderEffect handle );
162 };
163
164 }
165
166 }
167
168 #endif //#ifndef __DALI_TOOLKIT_SHADER_EFFECT_MOTION_STRETCH_H__
169