1 #ifndef __DALI_TOOLKIT_EFFECTS_VIEW_H__
2 #define __DALI_TOOLKIT_EFFECTS_VIEW_H__
5 * Copyright (c) 2015 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.
22 #include <dali/public-api/images/frame-buffer-image.h>
25 #include <dali-toolkit/public-api/controls/control.h>
33 namespace Internal DALI_INTERNAL
38 } // namespace Internal
41 * EffectsView: Applies an effect to a tree of actors
43 * Example usage: Applying an emboss effect
45 * EffectsView effectsView = EffectsView::New();
47 * // set position and format
48 * effectsView.SetParentOrigin( ParentOrigin::CENTER );
49 * effectsView.SetSize( Vector2( width, height) );
50 * effectsView.SetPixelFormat( Pixel::RGBA8888 );
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 );
58 * // Render result to an offscreen
59 * effectsView.SetOutputImage( image );
62 * effectsView.SetRefreshOnDemand( true );
64 * // optionally set a clear color
65 * effectsView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) );
67 * // start effect processing
68 * effectsView.Enable();
70 class DALI_IMPORT_API EffectsView : public Control
84 * Create an EffectsView object with default configuration
86 static EffectsView New();
89 * Create an uninitialized EffectsView. Only derived versions can be instantiated.
90 * Calling member functions with an uninitialized Dali::Object is not allowed.
97 EffectsView( const EffectsView& handle );
100 * Assignment operator.
102 EffectsView& operator=( const EffectsView& rhs );
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
110 static EffectsView DownCast( BaseHandle handle );
115 * This is non-virtual since derived Handle types must not contain data or virtual methods.
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.
126 void SetType( EffectType type );
129 * Get the effect type
130 * @return The type of effect performed by the EffectView. A member of the EffectType enumeration.
132 EffectType GetType() const;
145 * Refresh/Redraw the effect
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).
154 void SetRefreshOnDemand( bool onDemand );
157 * Set the pixel format for the output
158 * @param[in] pixelFormat The pixel format for the output
160 void SetPixelFormat( Pixel::Format pixelFormat );
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.
166 void SetOutputImage( FrameBufferImage image );
169 * Get the FrameBufferImage that holds the final output of the EffectsView.
170 * @return The FrameBufferImage that holds the final output of the EffectsView.
172 FrameBufferImage GetOutputImage();
175 * Get the property index to the effect size
176 * @return The property index to the effect size
178 Dali::Property::Index GetEffectSizePropertyIndex() const;
181 * Get the property index to the effect strength
182 * @return The property index to the effect strength
184 Dali::Property::Index GetEffectStrengthPropertyIndex() const;
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
190 Dali::Property::Index GetEffectOffsetPropertyIndex() const;
193 * Get the property index to the effect color (eg shadow color)
194 * @return The property index to the effect color
196 Dali::Property::Index GetEffectColorPropertyIndex() const;
199 * Set background color for the view. The background will be filled with this color.
200 * @param[in] color The background color.
202 void SetBackgroundColor( const Vector4& color );
205 * Get the background color.
206 * @return The background color.
208 Vector4 GetBackgroundColor() const;
210 public: // Not intended for application developers
213 * Creates a handle using the Toolkit::Internal implementation.
214 * @param[in] implementation The Control implementation.
216 DALI_INTERNAL EffectsView( Internal::EffectsView& implementation );
219 * Allows the creation of this Control from an Internal::CustomActor pointer.
220 * @param[in] internal A pointer to the internal CustomActor.
222 explicit DALI_INTERNAL EffectsView( Dali::Internal::CustomActor* internal );
224 }; // class EffectsView
226 } // namespace Toolkit
230 #endif // __DALI_TOOLKIT_EFFECTS_VIEW_H__