1 #ifndef __DALI_TOOLKIT_EFFECTS_VIEW_H__
2 #define __DALI_TOOLKIT_EFFECTS_VIEW_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
23 #include <dali-toolkit/public-api/controls/control.h>
25 namespace Dali DALI_IMPORT_API
31 namespace Internal DALI_INTERNAL
36 } // namespace Internal
39 * EffectsView: Applies an effect to a tree of actors
41 * Example usage: Applying an emboss effect
43 * EffectsView effectsView = EffectsView::New();
45 * // set position and format
46 * effectsView.SetParentOrigin( ParentOrigin::CENTER );
47 * effectsView.SetSize( Vector2( width, height) );
48 * effectsView.SetPixelFormat( Pixel::RGBA8888 );
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 );
56 * // Render result to an offscreen
57 * effectsView.SetOutputImage( image );
60 * effectsView.SetRefreshOnDemand( true );
62 * // optionally set a clear color
63 * effectsView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) );
65 * // start effect processing
66 * effectsView.Enable();
68 class EffectsView : public Control
82 * Create an EffectsView object with default configuration
84 static EffectsView New();
87 * Create an uninitialized EffectsView. Only derived versions can be instantiated.
88 * Calling member functions with an uninitialized Dali::Object is not allowed.
95 EffectsView( const EffectsView& handle );
98 * Assignment operator.
100 EffectsView& operator=( const EffectsView& rhs );
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
108 static EffectsView DownCast( BaseHandle handle );
111 * Virtual destructor.
112 * Dali::Object derived classes typically do not contain member data.
114 virtual ~EffectsView();
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.
123 void SetType( EffectType type );
126 * Get the effect type
127 * @return The type of effect performed by the EffectView. A member of the EffectType enumeration.
129 EffectType GetType() const;
142 * Refresh/Redraw the effect
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).
151 void SetRefreshOnDemand( bool onDemand );
154 * Set the pixel format for the output
155 * @param[in] pixelFormat The pixel format for the output
157 void SetPixelFormat( Pixel::Format pixelFormat );
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.
163 void SetOutputImage( FrameBufferImage image );
166 * Get the FrameBufferImage that holds the final output of the EffectsView.
167 * @return The FrameBufferImage that holds the final output of the EffectsView.
169 FrameBufferImage GetOutputImage();
172 * Get the property index to the effect size
173 * @return The property index to the effect size
175 Property::Index GetEffectSizePropertyIndex() const;
178 * Get the property index to the effect strength
179 * @return The property index to the effect strength
181 Property::Index GetEffectStrengthPropertyIndex() const;
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
187 Property::Index GetEffectOffsetPropertyIndex() const;
190 * Get the property index to the effect color (eg shadow color)
191 * @return The property index to the effect color
193 Property::Index GetEffectColorPropertyIndex() const;
196 * Set background color for the view. The background will be filled with this color.
197 * @param[in] color The background color.
199 void SetBackgroundColor( const Vector4& color );
202 * Get the background color.
203 * @return The background color.
205 Vector4 GetBackgroundColor() const;
207 public: // Not intended for application developers
210 * Creates a handle using the Toolkit::Internal implementation.
211 * @param[in] implementation The Control implementation.
213 EffectsView( Internal::EffectsView& implementation );
216 * Allows the creation of this Control from an Internal::CustomActor pointer.
217 * @param[in] internal A pointer to the internal CustomActor.
219 EffectsView( Dali::Internal::CustomActor* internal );
221 }; // class EffectsView
223 } // namespace Toolkit
227 #endif // __DALI_TOOLKIT_EFFECTS_VIEW_H__