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