1 #ifndef __DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_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/dali.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/effects-view/effects-view.h>
27 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
38 class GaussianBlurView;
42 * EffectsView implementation class
43 * @copydoc Dali::Toolkit::EffectsView
45 class EffectsView : public ControlImpl
48 /// @copydoc Dali::Toolkit::EffectsView New()
49 static Toolkit::EffectsView New();
52 * Construct a new EffectsView.
53 * @copydoc Toolkit::EffectsView New()
59 * @copydoc Toolkit::EffectsView New(const unsigned int,const float,const Pixel::Format,const float,const float)
61 EffectsView(const unsigned int numSamples, const float blurBellCurveWidth, const int spread,
62 const Pixel::Format pixelFormat,
63 const float downsampleWidthScale, const float downsampleHeightScale,
64 FrameBufferImage image);
67 * A reference counted object may only be deleted by calling Unreference()
69 virtual ~EffectsView();
73 /// @copydoc Dali::Toolkit::EffectsView::SetType
74 void SetType( Toolkit::EffectsView::EffectType type );
76 /// @copydoc Dali::Toolkit::EffectsView::GetType
77 Toolkit::EffectsView::EffectType GetType() const;
79 /// @copydoc Dali::Toolkit::EffectsView::Enable
82 /// @copydoc Dali::Toolkit::EffectsView::Disable
85 /// @copydoc Dali::Toolkit::EffectsView::Refresh
88 /// @copydoc Dali::Toolkit::EffectsView::SetRefreshOnDemand
89 void SetRefreshOnDemand( bool onDemand );
91 /// @copydoc Dali::Toolkit::EffectsView::SetPixelFormat
92 void SetPixelFormat( Pixel::Format pixelFormat );
94 /// @copydoc Dali::Toolkit::EffectsView::SetOutputImage
95 void SetOutputImage( FrameBufferImage image );
97 /// @copydoc Dali::Toolkit::EffectsView::GetOutputImage
98 FrameBufferImage GetOutputImage();
100 /// @copydoc Dali::Toolkit::EffectsView::GetEffectSizePropertyIndex
101 Property::Index GetEffectSizePropertyIndex() const;
103 /// @copydoc Dali::Toolkit::EffectsView::GetEffectStrengthPropertyIndex
104 Property::Index GetEffectStrengthPropertyIndex() const;
106 /// @copydoc Dali::Toolkit::EffectsView::GetEffectOffsetPropertyIndex
107 Property::Index GetEffectOffsetPropertyIndex() const;
109 /// @copydoc Dali::Toolkit::EffectsView::GetEffectColorPropertyIndex
110 Property::Index GetEffectColorPropertyIndex() const;
112 /// @copydoc Dali::Toolkit::EffectsView::SetBackgroundColor(const Vector4&)
113 void SetBackgroundColor( const Vector4& color );
115 /// @copydoc Dali::Toolkit::GaussianBlurView::GetBackgroundColor
116 Vector4 GetBackgroundColor() const;
120 * Register and setup indices for EffectsView properties
122 void SetupProperties();
124 private: // From ControlImpl
127 * @copydoc Toolkit::Control::OnInitialize()
129 virtual void OnInitialize();
132 * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
134 virtual void OnControlSizeSet( const Vector3& targetSize );
139 * Callback received when the control is disconnected from the stage.
141 void OnStageDisconnection();
144 * Setup image filters
151 void AllocateResources();
159 * Create render tasks for internal jobs
161 void CreateRenderTasks();
164 * Remove render tasks
166 void RemoveRenderTasks();
169 * Refresh render tasks
171 void RefreshRenderTasks();
174 * Remove ImageFilters
176 void RemoveFilters();
181 EffectsView( const EffectsView& );
184 EffectsView& operator = ( const EffectsView& );
186 private: // attributes/properties
187 Toolkit::EffectsView::EffectType mEffectType;
189 /////////////////////////////////////////////////////////////
190 // for rendering all user added children to offscreen target
191 FrameBufferImage mImageForChildren;
192 ImageActor mActorForChildren;
193 RenderTask mRenderTaskForChildren;
194 CameraActor mCameraForChildren;
196 /////////////////////////////////////////////////////////////
197 Pixel::Format mPixelFormat; ///< pixel format used by render targets
199 /////////////////////////////////////////////////////////////
200 // downsampling is used for the separated blur passes to get increased blur with the same number of samples and also to make rendering quicker
203 /////////////////////////////////////////////////////////////
204 // background fill color
205 Vector4 mBackgroundColor;
207 /////////////////////////////////////////////////////////////
208 // for checking if we need to reallocate render targets
212 bool mRefreshOnDemand;
214 /////////////////////////////////////////////////////////////
215 // horizontal spread objects
216 FrameBufferImage mImageForHorzSpread;
217 ImageActor mActorForHorzSpread;
218 RenderTask mRenderTaskForHorzSpread;
220 /////////////////////////////////////////////////////////////
221 // vertical spread objects
222 FrameBufferImage mImageForVertSpread;
223 ImageActor mActorForVertSpread;
224 RenderTask mRenderTaskForVertSpread;
226 CameraActor mCameraForSpread;
228 /////////////////////////////////////////////////////////////
230 FrameBufferImage mImagePostFilter;
231 ImageActor mActorPostFilter;
233 /////////////////////////////////////////////////////////////
235 FrameBufferImage mImageForResult;
236 Actor mActorForResult;
237 RenderTask mRenderTaskForResult;
239 Property::Index mEffectSizePropertyIndex;
240 Property::Index mEffectStrengthPropertyIndex;
241 Property::Index mEffectOffsetPropertyIndex;
242 Property::Index mEffectColorPropertyIndex;
244 std::vector<ImageFilter*> mFilters;
245 }; // class EffectsView
247 } // namespace Internal
250 // Helpers for public-api forwarding methods
252 inline Toolkit::Internal::EffectsView& GetImpl( Toolkit::EffectsView& effectsView )
254 DALI_ASSERT_ALWAYS( effectsView );
256 Dali::RefObject& handle = effectsView.GetImplementation();
258 return static_cast<Toolkit::Internal::EffectsView&>( handle );
261 inline const Toolkit::Internal::EffectsView& GetImpl( const Toolkit::EffectsView& effectsView )
263 DALI_ASSERT_ALWAYS( effectsView );
265 const Dali::RefObject& handle = effectsView.GetImplementation();
267 return static_cast<const Toolkit::Internal::EffectsView&>( handle );
270 } // namespace Toolkit
274 #endif // __DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H__