Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / shader-effects / distance-field-effect.h
1 #ifndef __DALI_TOOLKIT_SHADER_EFFECT_DISTANCEFIELD_H__
2 #define __DALI_TOOLKIT_SHADER_EFFECT_DISTANCEFIELD_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 /**
31  * DistanceFieldEffect is a custom shader effect to achieve distance field on Image actors
32  */
33 class DistanceFieldEffect : public ShaderEffect
34 {
35 public:
36
37   /**
38    * Create an uninitialized DistanceFieldEffect; this can be initialized with DistanceFieldEffect::New()
39    * Calling member functions with an uninitialized Dali::Object is not allowed.
40    */
41   DistanceFieldEffect();
42
43   /**
44    * Virtual destructor.
45    */
46   virtual ~DistanceFieldEffect();
47
48   /**
49    * Create an initialized DistanceFieldEffect.
50    * @return A handle to a newly allocated Dali resource.
51    */
52   static DistanceFieldEffect New();
53
54   /**
55    * Set the shadow state
56    * @param[in] shadowEnable value - true, enable shadow.
57    * @note Shadow cannot be used with glow/and or outline.
58    */
59   void SetShadow(bool shadowEnable);
60
61   /**
62    * Set the shadow color multiplier (e.g. output RGB)
63    * @param[in] color Shadow color value
64    */
65   void SetShadowColor(const Vector4& color);
66
67   /**
68    * Set the shadow offset
69    * @param[in] color shadow offset value
70    */
71   void SetShadowOffset(const Vector2& color);
72
73   /**
74    * Set the glow state
75    * @param[in] glowEnable value - true, enable glow.
76    */
77
78   void SetGlow(bool glowEnable);
79
80   /**
81    * Set the glow color multiplier (e.g. output RGB)
82    * @param[in] color Glow color value
83    */
84   void SetGlowColor(const Vector4& color);
85
86   /**
87    * Set the glow boundary factor
88    * @param[in] glowBoundary glow boundary
89    */
90   void SetGlowBoundary(float glowBoundary);
91
92   /**
93    * Set the outline state
94    * @param[in] outlineEnable value - true, enable outline.
95    */
96
97   void SetOutline(bool outlineEnable);
98
99   /**
100    * Set the outline color multiplier (e.g. output RGB)
101    * @param[in] color Outline color value
102    */
103   void SetOutlineColor(const Vector4& color);
104
105   /**
106    * Sets the outline parameters.
107    * @param[in] outlineParams  Thickness of outline. The outline thickness is determined by two parameters.
108    *              params[0] (0-1) Specifies the distance field value for the center of the outline.
109    *                      0 <= params[0] <= 1
110    *              params[1] (0-1) Specifies the softness/width/anti-aliasing of the outlines inner edge.
111    *                      0 <= params[0] <= 1
112    */
113   void SetOutlineParams(const Vector2& outlineParams);
114
115   /**
116    * Set soft edge smoothing
117    * @param[in] smoothing Specify the distance field value for the center of the edge.
118    *                      0 <= params <= 1
119    */
120   void SetSmoothingEdge(float smoothing);
121
122   /**
123    * Get the name for the outline-enable property
124    * @return A std::string containing the property name
125    */
126   const std::string& GetOutlineEnablePropertyName() const;
127
128   /**
129    * Get the name for the glow-enable property
130    * @return A std::string containing the property name
131    */
132   const std::string& GetGlowEnablePropertyName() const;
133
134   /**
135    * Get the name for the shadow-enable property
136    * @return A std::string containing the property name
137    */
138   const std::string& GetShadowEnablePropertyName() const;
139
140   /**
141    * Get the name for the radius property
142    * @return A std::string containing the property name
143    */
144   const std::string& GetColorPropertyName() const;
145
146   /**
147    * Get the name for the smoothing property
148    * @return A std::string containing the property name
149    */
150   const std::string& GetSmoothingPropertyName() const;
151
152   /**
153    * Get the name for the outline color property
154    * @return A std::string containing the property name
155    */
156   const std::string& GetOutlineColorPropertyName() const;
157
158   /**
159    * Get the name for the outline size property
160    * @return A std::string containing the property name
161    */
162   const std::string& GetOutlineSizePropertyName() const;
163
164   /**
165    * Get the name for the shadow color property
166    * @return A std::string containing the property name
167    */
168   const std::string& GetShadowColorPropertyName() const;
169
170   /**
171    * Get the name for the shadow offset property
172    * @return A std::string containing the property name
173    */
174   const std::string& GetShadowOffsetPropertyName() const;
175
176   /**
177    * Get the name for the glow color property
178    * @return A std::string containing the property name
179    */
180   const std::string& GetGlowColorPropertyName() const;
181
182   /**
183    * Get the name for the glow boundary property
184    * @return A std::string containing the property name
185    */
186   const std::string& GetGlowBoundaryPropertyName() const;
187
188 private:
189   DistanceFieldEffect(ShaderEffect handle);
190
191 };
192
193 } // namespace Toolkit
194
195 } // namespace Dali
196
197 #endif // __DALI_TOOLKIT_SHADER_EFFECT_SPOT_H__