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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include <dali-toolkit/public-api/controls/control.h>
26 namespace Dali DALI_IMPORT_API
32 namespace Internal DALI_INTERNAL
37 } // namespace Internal
40 * EffectsView: Applies an effect to a tree of actors
42 * Example usage: Applying an emboss effect
44 * EffectsView effectsView = EffectsView::New();
46 * // set position and format
47 * effectsView.SetParentOrigin( ParentOrigin::CENTER );
48 * effectsView.SetSize( Vector2( width, height) );
49 * effectsView.SetPixelFormat( Pixel::RGBA8888 );
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 );
57 * // Render result to an offscreen
58 * effectsView.SetOutputImage( image );
61 * effectsView.SetRefreshOnDemand( true );
63 * // optionally set a clear color
64 * effectsView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) );
66 * // start effect processing
67 * effectsView.Enable();
69 class EffectsView : public Control
83 * Create an EffectsView object with default configuration
85 static EffectsView New();
88 * Create an uninitialized EffectsView. Only derived versions can be instantiated.
89 * Calling member functions with an uninitialized Dali::Object is not allowed.
96 EffectsView( const EffectsView& handle );
99 * Assignment operator.
101 EffectsView& operator=( const EffectsView& rhs );
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
109 static EffectsView DownCast( BaseHandle handle );
112 * Virtual destructor.
113 * Dali::Object derived classes typically do not contain member data.
115 virtual ~EffectsView();
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.
124 void SetType( EffectType type );
127 * Get the effect type
128 * @return The type of effect performed by the EffectView. A member of the EffectType enumeration.
130 EffectType GetType() const;
143 * Refresh/Redraw the effect
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).
152 void SetRefreshOnDemand( bool onDemand );
155 * Set the pixel format for the output
156 * @param[in] pixelFormat The pixel format for the output
158 void SetPixelFormat( Pixel::Format pixelFormat );
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.
164 void SetOutputImage( FrameBufferImage image );
167 * Get the FrameBufferImage that holds the final output of the EffectsView.
168 * @return The FrameBufferImage that holds the final output of the EffectsView.
170 FrameBufferImage GetOutputImage();
173 * Get the property index to the effect size
174 * @return The property index to the effect size
176 Property::Index GetEffectSizePropertyIndex() const;
179 * Get the property index to the effect strength
180 * @return The property index to the effect strength
182 Property::Index GetEffectStrengthPropertyIndex() const;
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
188 Property::Index GetEffectOffsetPropertyIndex() const;
191 * Get the property index to the effect color (eg shadow color)
192 * @return The property index to the effect color
194 Property::Index GetEffectColorPropertyIndex() const;
197 * Set background color for the view. The background will be filled with this color.
198 * @param[in] color The background color.
200 void SetBackgroundColor( const Vector4& color );
203 * Get the background color.
204 * @return The background color.
206 Vector4 GetBackgroundColor() const;
208 public: // Not intended for application developers
211 * Creates a handle using the Toolkit::Internal implementation.
212 * @param[in] implementation The Control implementation.
214 EffectsView( Internal::EffectsView& implementation );
217 * Allows the creation of this Control from an Internal::CustomActor pointer.
218 * @param[in] internal A pointer to the internal CustomActor.
220 EffectsView( Dali::Internal::CustomActor* internal );
222 }; // class EffectsView
224 } // namespace Toolkit
228 #endif // __DALI_TOOLKIT_EFFECTS_VIEW_H__