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