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