Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / effects-view / effects-view.h
1 #ifndef __DALI_TOOLKIT_EFFECTS_VIEW_H__
2 #define __DALI_TOOLKIT_EFFECTS_VIEW_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 // EXTERNAL INCLUDES
21
22 // INTERNAL INCLUDES
23 #include <dali-toolkit/public-api/controls/control.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33
34 class EffectsView;
35
36 } // namespace Internal
37
38 /**
39  * EffectsView: Applies an effect to a tree of actors
40  *
41  * Example usage: Applying an emboss effect
42  * ...
43  * EffectsView effectsView = EffectsView::New();
44  *
45  * // set position and format
46  * effectsView.SetParentOrigin( ParentOrigin::CENTER );
47  * effectsView.SetSize( Vector2( width, height) );
48  * effectsView.SetPixelFormat( Pixel::RGBA8888 );
49  *
50  * // set effect type and properties
51  * effectsView.SetType( Toolkit::EffectsView::EMBOSS );
52  * effectsView.SetProperty( effectsView.GetEffectSizePropertyIndex(), static_cast< float >( shadowSize ) );
53  * effectsView.SetProperty( effectsView.GetEffectOffsetPropertyIndex(), Vector3( shadowDistance.x, shadowDistance.y, 0.0f ) );
54  * effectsView.SetProperty( effectsView.GetEffectColorPropertyIndex(), shadowColor );
55  *
56  * // Render result to an offscreen
57  * effectsView.SetOutputImage( image );
58  *
59  * // Render once
60  * effectsView.SetRefreshOnDemand( true );
61  *
62  * // optionally set a clear color
63  * effectsView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) );
64  *
65  * // start effect processing
66  * effectsView.Enable();
67  */
68 class EffectsView : public Control
69 {
70 public:
71
72   enum EffectType
73   {
74     DROP_SHADOW,
75     EMBOSS,
76     INVALID_TYPE
77   };
78
79 public:
80
81   /**
82    * Create an EffectsView object with default configuration
83    */
84   static EffectsView New();
85
86   /**
87    * Create an uninitialized EffectsView. Only derived versions can be instantiated.
88    * Calling member functions with an uninitialized Dali::Object is not allowed.
89    */
90   EffectsView();
91
92   /**
93    * Copy constructor.
94    */
95   EffectsView( const EffectsView& handle );
96
97   /**
98    * Assignment operator.
99    */
100   EffectsView& operator=( const EffectsView& rhs );
101
102   /**
103    * Downcast an Object handle to EffectsView. If handle points to a EffectsView the
104    * downcast produces a valid handle. If not the returned handle is left uninitialized.
105    * @param[in] handle Handle to an object
106    * @return handle to a EffectsView or an uninitialized handle
107    */
108   static EffectsView DownCast( BaseHandle handle );
109
110   /**
111    * Virtual destructor.
112    * Dali::Object derived classes typically do not contain member data.
113    */
114   virtual ~EffectsView();
115
116 public:
117
118   /**
119    * Set the effect type
120    * @param[in] type The type of effect to be performed by the EffectView.
121    *                 A member of the EffectType enumeration.
122    */
123   void SetType( EffectType type );
124
125   /**
126    * Get the effect type
127    * @return The type of effect performed by the EffectView. A member of the EffectType enumeration.
128    */
129   EffectType GetType() const;
130
131   /**
132    * Enable the effect
133    */
134   void Enable();
135
136   /**
137    * Disable the effect
138    */
139   void Disable();
140
141   /**
142    * Refresh/Redraw the effect
143    */
144   void Refresh();
145
146   /**
147    * Set refresh mode
148    * @param[in] onDemand Set true to enable on demand rendering, call Refresh() whenever a render is required.
149    *                     Set false to render each frame. (EffectsView refresh mode is set to continuous by default).
150    */
151   void SetRefreshOnDemand( bool onDemand );
152
153    /**
154     * Set the pixel format for the output
155     * @param[in] pixelFormat The pixel format for the output
156     */
157    void SetPixelFormat( Pixel::Format pixelFormat );
158
159    /**
160     * Set the FrameBufferImage that will receive the final output of the EffectsView.
161     * @param[in] image User supplied FrameBufferImage that will receive the final output of the EffectsView.
162     */
163    void SetOutputImage( FrameBufferImage image );
164
165    /**
166     * Get the FrameBufferImage that holds the final output of the EffectsView.
167     * @return The FrameBufferImage that holds the final output of the EffectsView.
168     */
169    FrameBufferImage GetOutputImage();
170
171    /**
172     * Get the property index to the effect size
173     * @return The property index to the effect size
174     */
175    Property::Index GetEffectSizePropertyIndex() const;
176
177    /**
178     * Get the property index to the effect strength
179     * @return The property index to the effect strength
180     */
181    Property::Index GetEffectStrengthPropertyIndex() const;
182
183    /**
184     * Get the property index to the Vector3 specifying the effect offset (eg drop shadow offset)
185     * @return The property index to the Vector3 specifying the effect offset
186     */
187    Property::Index GetEffectOffsetPropertyIndex() const;
188
189    /**
190     * Get the property index to the effect color (eg shadow color)
191     * @return The property index to the effect color
192     */
193    Property::Index GetEffectColorPropertyIndex() const;
194
195    /**
196     * Set background color for the view. The background will be filled with this color.
197     * @param[in] color The background color.
198     */
199    void SetBackgroundColor( const Vector4& color );
200
201    /**
202     * Get the background color.
203     * @return The background color.
204     */
205    Vector4 GetBackgroundColor() const;
206
207 public: // Not intended for application developers
208
209   /**
210    * Creates a handle using the Toolkit::Internal implementation.
211    * @param[in]  implementation  The Control implementation.
212    */
213   EffectsView( Internal::EffectsView& implementation );
214
215   /**
216    * Allows the creation of this Control from an Internal::CustomActor pointer.
217    * @param[in]  internal  A pointer to the internal CustomActor.
218    */
219   EffectsView( Dali::Internal::CustomActor* internal );
220
221 }; // class EffectsView
222
223 } // namespace Toolkit
224
225 } // namespace Dali
226
227 #endif // __DALI_TOOLKIT_EFFECTS_VIEW_H__