License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / shader-effects / water-effect.h
1 #ifndef __DALI_TOOLKIT_WATER_EFFECT_H__
2 #define __DALI_TOOLKIT_WATER_EFFECT_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 // INTERNAL INCLUDES
22 #include <dali/dali.h>
23
24 namespace Dali DALI_IMPORT_API
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32
33 /**
34  * WaterEffect implementation class
35  */
36 class WaterEffect;
37
38 } // namespace Internal
39
40 /**
41  * WaterEffect is a custom shader effect to achieve water like effects on Image actors
42  *
43  * Usage example:
44  *
45  *   WaterEffect waterEffect = WaterEffect::New( numberOfDrops );
46  *
47  *   actor.SetShaderEffect( waterEffect );
48  *
49  *   // Set initial values
50  *   waterEffect.SetCenter( 1, centerPosition );
51  *   waterEffect.SetPropagation( 1, INITIAL_RADIUS );
52  *
53  *   // Animate the wave propagation
54  *   std::string propertyName = waterEffect.GetPropagationPropertyName( 1 );
55  *   animation.AnimateTo( Property(waterEffect, propertyName), FINAL_RADIUS );
56  */
57 class WaterEffect : public ShaderEffect
58 {
59 public:
60
61   /**
62    * Create an uninitialized WaterEffect; this can be initialized with WaterEffect::New()
63    * Calling member functions with an uninitialized Dali::Object is not allowed.
64    */
65   WaterEffect();
66
67   /**
68    * Virtual destructor.
69    */
70   virtual ~WaterEffect();
71
72   /**
73    * Create an initialized WaterEffect.
74    * @param [in] numberOfWaves The number of waves.
75    * @return A handle to a newly allocated Dali resource
76    */
77   static WaterEffect New( unsigned int numberOfWaves );
78
79   /**
80    * Get the number of waves the shader supports.
81    * @return The number of waves in the shader.
82    */
83   unsigned int GetNumberOfWaves() const;
84
85   /**
86    * Set the amplitude of a wave.
87    * @param [in] index The index of the wave to change
88    * @param [in] amplitude The new amplitude of the wave
89    * @pre index has to be between 0 and GetNumberOfWaves() - 1
90    */
91   void SetAmplitude( unsigned int index, float amplitude );
92
93   /**
94    * Set the center point of a wave in texture coordinates.
95    * @param [in] index The index of the wave to change
96    * @param [in] center The center point of the wave
97    * @pre index has to be between 0 and GetNumberOfWaves() - 1
98    */
99   void SetCenter( unsigned int index, const Vector2& center );
100
101   /**
102    * Set the propagation radius of a wave.
103    * @param [in] index The index of the wave to change
104    * @param [in] radius The propagation radius
105    * @pre index has to be between 0 and GetNumberOfWaves() - 1
106    */
107   void SetPropagation( unsigned int index, float radius );
108
109   /**
110    * Get the amplitude of a wave.
111    * @param [in] index The index of the wave
112    * @return The new amplitude of the wave
113    * @pre index has to be between 0 and GetNumberOfWaves() - 1
114    */
115   float GetAmplitude( unsigned int index ) const;
116
117   /**
118    * Get the center point of a wave in texture coordinates.
119    * @param [in] index The index of the wave
120    * @return The center point of the wave
121    * @pre index has to be between 0 and GetNumberOfWaves() - 1
122    */
123   Vector2 GetCenter( unsigned int index ) const;
124
125   /**
126    * Get the propagation radius of a wave.
127    * @param [in] index The index of the wave
128    * @return The propagation radius
129    * @pre index has to be between 0 and GetNumberOfWaves() - 1
130    */
131   float GetPropagation( unsigned int index ) const;
132
133   /**
134    * Get the name for the amplitude property of a wave.
135    * @param [in] index The index of the wave
136    * @return A std::string containing the property name
137    * @pre index has to be between 0 and GetNumberOfWaves() - 1
138    */
139   std::string GetAmplitudePropertyName( unsigned int index ) const;
140
141   /**
142    * Get the name for the center property of a wave.
143    * @param [in] index The index of the wave
144    * @return A std::string containing the property name
145    * @pre index has to be between 0 and GetNumberOfWaves() - 1
146    */
147   std::string GetCenterPropertyName( unsigned int index ) const;
148
149   /**
150    * Get the name for the propagation property.
151    * @param [in] index The index of the wave
152    * @return A std::string containing the property name
153    * @pre index has to be between 0 and GetNumberOfWaves() - 1
154    */
155   std::string GetPropagationPropertyName( unsigned int index ) const;
156
157 public: // Not intended for developer use
158
159   WaterEffect( ShaderEffect handle, Internal::WaterEffect* shaderExtension );
160 };
161
162 } // namespace Toolkit
163
164 } // namespace Dali
165
166 #endif // __DALI_TOOLKIT_WATER_EFFECT_H__